@robinpath/markdown
0.1.2Node.jsPublicMarkdown processing: convert to HTML, extract headings, links, images, code blocks, frontmatter, and tables
Markdown
Markdown processing: convert to HTML, extract headings, links, images, code blocks, frontmatter, and tables
Package: @robinpath/markdown | Category: Utility | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the markdown module when you need to:
- Convert markdown to basic HTML -- Use
markdown.toHtmlto perform this operation - Extract all headings with their levels -- Use
markdown.extractHeadingsto perform this operation - Extract all links -- Use
markdown.extractLinksto perform this operation - Extract all images -- Use
markdown.extractImagesto perform this operation - Extract fenced code blocks -- Use
markdown.extractCodeBlocksto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
toHtml | Convert markdown to basic HTML | HTML string |
extractHeadings | Extract all headings with their levels | Array of {level, text} |
extractLinks | Extract all links | Array of {text, url} |
extractImages | Extract all images | Array of {alt, src} |
extractCodeBlocks | Extract fenced code blocks | Array of {language, code} |
stripMarkdown | Strip all markdown formatting to plain text | Plain text |
extractFrontmatter | Parse YAML frontmatter from markdown | Key-value object or null |
extractTodos | Extract task list items | Array of {text, checked} |
tableToArray | Parse a markdown table into array of objects | Array of row objects |
wordCount | Count words in markdown (stripping formatting) | Word count |
Functions
toHtml
Convert markdown to basic HTML
Module: markdown | Returns: string -- HTML string
markdown.toHtml "# Hello"
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
extractHeadings
Extract all headings with their levels
Module: markdown | Returns: array -- Array of {level, text}
markdown.extractHeadings $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
extractLinks
Extract all links
Module: markdown | Returns: array -- Array of {text, url}
markdown.extractLinks $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
extractImages
Extract all images
Module: markdown | Returns: array -- Array of {alt, src}
markdown.extractImages $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
extractCodeBlocks
Extract fenced code blocks
Module: markdown | Returns: array -- Array of {language, code}
markdown.extractCodeBlocks $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
stripMarkdown
Strip all markdown formatting to plain text
Module: markdown | Returns: string -- Plain text
markdown.stripMarkdown $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
extractFrontmatter
Parse YAML frontmatter from markdown
Module: markdown | Returns: object -- Key-value object or null
markdown.extractFrontmatter $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown with frontmatter |
extractTodos
Extract task list items
Module: markdown | Returns: array -- Array of {text, checked}
markdown.extractTodos $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
tableToArray
Parse a markdown table into array of objects
Module: markdown | Returns: array -- Array of row objects
markdown.tableToArray $table
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown table |
wordCount
Count words in markdown (stripping formatting)
Module: markdown | Returns: number -- Word count
markdown.wordCount $md
| Parameter | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown string |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "To html and validate result"
do
set $result as markdown.toHtml "# Hello"
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step Markdown workflow
Chain multiple markdown operations together.
@desc "To html, extract headings, and more"
do
set $r_toHtml as markdown.toHtml "# Hello"
set $r_extractHeadings as markdown.extractHeadings $md
set $r_extractLinks as markdown.extractLinks $md
print "All operations complete"
enddo
2. Safe toHtml with validation
Check results before proceeding.
@desc "To html and validate result"
do
set $result as markdown.toHtml "# Hello"
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.2 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/markdown
