User Rating 0.0
Total Usage 0 times
0 characters
Is this tool helpful?

Your feedback helps us improve.

About

LeanPub and Altpub extend standard Markdown with prefixed aside blocks: A> for asides, W> for warnings, T> for tips, E> for errors, I> for informational notes, Q> for questions, D> for discussions, and X> for exercises. Most standard Markdown parsers silently discard or mangle these blocks because they don't conform to CommonMark or GFM blockquote syntax. This tool pre-parses LeanPub section markers, converts them to semantic HTML containers with appropriate class names, and processes the inner content as inline Markdown. It handles both the single-character prefix style (A> text) and the bracketed block style ({aside}...{/aside}). Limitations: nested aside blocks are flattened. Custom LeanPub attributes like {class: "foo"} are stripped.

altpub leanpub markdown to html aside sections markdown converter leanpub markdown altpub sections

Formulas

This tool does not perform mathematical computation. The core logic is a RegExp-driven line scanner that maps LeanPub prefix markers to HTML containers. The parsing rule for prefix-style blocks follows this pattern:

match(line) regex = /^([AWTEIQDX])>\s?(.*)/

Where line is each input line, the captured group 1 identifies the block type, and group 2 captures the content. Consecutive lines sharing the same prefix are accumulated into a single block. The inner content is then processed through inline Markdown rules:

inline(text) text.replace(/\*\*(.+?)\*\*/g, <strong>$1</strong>)

For bracketed block syntax, the scanner detects opening tags like {aside} and closing tags like {/aside}. All content between them is collected and processed identically. The mapping from prefix character to HTML element and class is a static lookup table. Standard blockquotes using > are distinguished from LeanPub prefixes by the absence of an uppercase letter before the > symbol.

Reference Data

PrefixBlock TypeHTML Output ElementCSS ClassLeanPub Docs Reference
A>Aside / Sidebar<aside>asideleanpub-auto-asidessidebars
W>Warning<div>warningleanpub-auto-warning
T>Tip<div>tipleanpub-auto-tip
E>Error<div>errorleanpub-auto-error
I>Information<div>informationleanpub-auto-information
Q>Question<div>questionleanpub-auto-question
D>Discussion<div>discussionleanpub-auto-discussion
X>Exercise<div>exerciseleanpub-auto-exercise
{aside}Named Aside (block)<aside>asideleanpub-auto-asidessidebars
{warning}Named Warning (block)<div>warningleanpub-auto-warning
{tip}Named Tip (block)<div>tipleanpub-auto-tip
{icon}Icon block<div>iconleanpub-auto-icons
>Standard Blockquote<blockquote> - Standard Markdown
# ## ###Headings<h1> - <h6> - Standard Markdown
**text**Bold<strong> - Standard Markdown
*text*Italic<em> - Standard Markdown
`code`Inline Code<code> - Standard Markdown
[text](url)Link<a> - Standard Markdown
![alt](src)Image<img> - Standard Markdown
---Horizontal Rule<hr> - Standard Markdown

Frequently Asked Questions

Standard Markdown blockquotes use a bare > character followed by optional whitespace. LeanPub aside prefixes always have a single uppercase letter immediately before the > symbol (e.g., A>, W>, T>). The parser checks for the pattern /^[AWTEIQDX]>/ first. If it matches, the line is treated as a LeanPub section. If only > is found without a preceding letter, it is converted to a standard
element.
Both syntaxes are supported simultaneously and independently. The parser processes bracketed blocks first by scanning for {type}...{/type} pairs, extracting and converting their content. Then it processes the remaining lines for prefix-style blocks. This means you can freely mix both formats in one document without conflicts.
No. The LeanPub specification does not formally support nesting of aside blocks, and this tool follows that constraint. If you nest a T> block inside a W> block, the inner block will be treated as continuation content of the outer block. The prefix character of the outermost block takes precedence. For bracketed syntax, the first closing tag encountered ends the block.
No. Inline attribute annotations are stripped during parsing. The tool focuses on converting the structural block markers and inline Markdown content. If you need custom attributes, add them manually to the generated HTML output after conversion.
Fenced code blocks within prefix-style sections (e.g., A> ``` ... A> ```) are detected and wrapped in
 elements. The content inside the code fence is not processed for inline Markdown, preserving literal text. For bracketed blocks, fenced code between {aside} and {/aside} is handled identically.
The output is plain UTF-8 HTML fragment markup. It does not include , , or tags. You can paste it directly into any HTML document or CMS editor. The generated class names (aside, warning, tip, error, information, question, discussion, exercise) are intentionally generic so you can style them with your own CSS.