# As Markdown

> Extract markdown document structure and content from mixed/embedded text (NOT for converting plain text TO markdown)

- Skill: `bdambrosio/as-markdown` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add bdambrosio/as-markdown`
- Raw SKILL.md: https://api.skillmd.com/api/skills/bdambrosio/as-markdown/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: bdambrosio (https://skillmd.com/u/bdambrosio)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/bdambrosio/as-markdown

---


# As Markdown

Interpret note content as markdown, automatically identifying markdown within mixed content and extracting structural elements.

## Purpose

- Extract markdown from LLM responses with noise
- Parse document structure (headers, lists, links, code)
- Extract content under specific sections
- Strip surrounding non-markdown text
- Validate markdown present

## Input Format

Accepts a Note containing markdown (clean or embedded):
- Clean markdown
- Markdown with surrounding text
- Code-fenced markdown blocks
- Mixed format responses

## Parameters

**Optional:**
- **element** - Element type: "headers", "lists", "links", "code", "section", or "all" (default)
- **section** - When element="section", specify header name to extract content under
- **all** - If true, returns array of all matching elements; if false/omitted, returns first match (default: false)

## Output Format

Returns extracted elements:
- **headers**: List of headers with levels
- **lists**: All list items (ordered and unordered)
- **links (all=false)**: First link found; (all=true): All links
- **code (all=false)**: First code block; (all=true): All code blocks
- **section**: Content under specified header
- **all**: Structured breakdown of all elements
- **Element not found**: note-null
- **Markdown not identified**: FAIL (hard error)

## Usage Examples

**Extract all structure:**
```json
{"type":"as-markdown","target":"$llm_response","out":"$structure"}
```

**Extract headers for TOC:**
```json
{"type":"as-markdown","target":"$doc","element":"headers","out":"$toc"}
```

**Extract specific section:**
```json
{"type":"as-markdown","target":"$doc","element":"section","section":"Usage","out":"$usage"}
```

**Extract first code block:**
```json
{"type":"as-markdown","target":"$response","element":"code","out":"$code"}
```

**Extract all code blocks:**
```json
{"type":"as-markdown","target":"$response","element":"code","all":true,"out":"$all_code"}
```

## Guidelines

- Strips leading/trailing non-markdown text automatically
- Element not found returns note-null (soft failure)
- No markdown identified triggers FAIL (hard failure)
- Preserves nesting for lists
- Code blocks include language identifier if present
- Default extracts first match; use `all: true` for all matches (applies to links, code)


