### Image/Link Placement: Image Links at Start Option (Markdown) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This snippet demonstrates the `image-links-at-start` option, which forces image links to be rendered on a new line if they appear at the start of a logical line in the Markdown source. ```Markdown text with [link](/url) followed by  ``` -------------------------------- ### Image/Link Placement: Image and Explicit Links at Start Options (Markdown) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This snippet combines `image-links-at-start` and `explicit-links-at-start` options, causing both image and explicit links to be rendered on new lines if they appear at the start of a logical line in the Markdown source. ```Markdown text with [link](/url) followed by  ``` -------------------------------- ### Image/Link Placement: Explicit Links at Start Option (Markdown) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This snippet illustrates the `explicit-links-at-start` option, which forces explicit links (like `[link](/url)`) to be rendered on a new line if they appear at the start of a logical line in the Markdown source. ```Markdown text with [link](/url) followed by  ``` -------------------------------- ### Setting Ordered List Start Number (Markdown) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_pegdown_compatibility_spec.md This example illustrates that an ordered list can start with a number other than '1'. The parser correctly identifies '2.' as the starting point for the ordered list, and the generated HTML reflects this custom starting number. ```Markdown 2. Non One Start Item ``` ```HTML
abc
`, and the detailed Abstract Syntax Tree (AST) representation, highlighting nested emphasis nodes and their character ranges. ```flexmark-java Spec Example example GFM Emphasis: 7 **a*b*c** .abc
. Document[0, 11] Paragraph[0, 10] isTrailingBlankLine StrongEmphasis[0, 9] textOpen:[0, 2, "**"] text:[2, 7, "a*b*c"] textClose:[7, 9, "**"] Text[2, 3] chars:[2, 3, "a"] Emphasis[3, 6] textOpen:[3, 4, "*"] text:[4, 5, "b"] textClose:[5, 6, "*"] Text[4, 5] chars:[4, 5, "b"] Text[6, 7] chars:[6, 7, "c"] ``` -------------------------------- ### Wrap Functionality Example 1 - Basic Margin Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_paragraph_formatter_spec.md This example demonstrates the 'Wrap' functionality with a margin of 66. It illustrates how repeated prefixes in items are automatically copied when adding or splitting an item, treating them as equivalent to a task item marker prefix. ```Text Add: configuration for repeated prefixes in items, which would `be #2` copied when adding/splitting an item. In other words they would be treated equivalent to task item marker prefix. That way standard: `Add: `, `Fix: `, `Break: ` and `Deprecate: ` prefixes would be automatically copied. ``` -------------------------------- ### Markdown List Example 27 with Link and Newline Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This snippet demonstrates a Markdown list item containing an inline link, followed by a blank line and additional text. Similar to Example 26, it further illustrates how such content is parsed and rendered within a list context, confirming the behavior of continued list item content. ```Markdown - [link](link.txt) next line ``` -------------------------------- ### Markdown Spec Example: Empty Sections 1 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-spec-example/src/test/resources/ext_spec_example_formatter_spec.md This example demonstrates how the flexmark-java formatter handles an empty section, showing that the input Markdown with a minimal content block (…) is preserved in the output, including its YAML front matter and example fences. ```Markdown --- title: Intentions Spec author: version: date: '2019-10-14' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' ... ```````````````` example … ```````````````` ``` ```Markdown --- title: Intentions Spec author: version: date: '2019-10-14' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' ... ```````````````` example : 1 … ```````````````` ``` -------------------------------- ### Installing and Linking TypeScript Globally (Shell) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/issue_mn_236_exception_spec.md These shell commands install the TypeScript compiler globally on your system and then link it to your project. Installing globally allows 'tsc' to be run from any directory, while 'npm link' ensures that local projects can still resolve the globally installed package. ```shell npm install typescript -g npm link typescript ``` -------------------------------- ### Markdown List: Nested Unordered List with Asterisks Example 1 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md Demonstrates a standard nested unordered list using asterisk (*) as the bullet marker. The example includes both the input Markdown and its expected rendering output, showcasing basic list structure and indentation. ```Markdown * list item 1 * list item 1.1 * list item 1.2 * list item 1.2.1 * list item 1.2.2 * list item 1.2.3 * list item 2 * list item 2.1 * list item 2.2 * list item 2.2.1 * list item 2.2.2 * list item 2.2.3 . * LiISt iIteEm 1 * LiISt iIteEm 1.1 * LiISt iIteEm 1.2 * LiISt iIteEm 1.2.1 * LiISt iIteEm 1.2.2 * LiISt iIteEm 1.2.3 * LiISt iIteEm 2 * LiISt iIteEm 2.1 * LiISt iIteEm 2.2 * LiISt iIteEm 2.2.1 * LiISt iIteEm 2.2.2 * LiISt iIteEm 2.2.3 ``` -------------------------------- ### Markdown Spec Example: Empty Sections 2 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-spec-example/src/test/resources/ext_spec_example_formatter_spec.md This example further illustrates the formatter's preservation of empty sections, showing how two minimal content blocks (… …) within Markdown are maintained in the output, including their YAML front matter and example fences. ```Markdown --- title: Intentions Spec author: version: date: '2019-10-14' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' ... ```````````````` example … … ```````````````` ``` ```Markdown --- title: Intentions Spec author: version: date: '2019-10-14' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' ... ```````````````` example : 1 … … ```````````````` ``` -------------------------------- ### Adding Space and Equalizing Trailing Hashes for ATX Headings (Example 6) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This snippet uses `atx-space-add` and `atx-trailing-equalize` on a heading without initial space. It adds a space after the leading hash and equalizes the trailing hashes, adding a space before them. ```Markdown #Heading#### ``` -------------------------------- ### Demonstrating Item Prefix Copying with Flexmark (Wrap 9) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_paragraph_formatter_spec.md This snippet illustrates how configured repeated prefixes like 'Add:', 'Fix:', 'Break:', and 'Deprecate:' are automatically copied when an item is added or split, treating them similarly to task item markers. The example shows the input text and the resulting processed text with the prefixes preserved. ```Flexmark Example Text Add: configuration for repeated prefixes in items, which would `be #2` copied when adding/splitting an item. In other words they ⟦ ⟧⦙would be treated equivalent to task item marker prefix. That way ⟦ ⟧standard: `Add: `, `Fix: `, `Break: ` and `Deprecate: ` prefixes would be automatically copied. ⦙ ⦙ . ``` -------------------------------- ### Markdown List: Unordered List After Blank Line Example 8 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md Demonstrates an unordered list separated from a preceding paragraph by a blank line. This is the standard Markdown practice for distinct block elements, ensuring proper rendering. ```Markdown paragraph * item 1 * item 2 * item 2.1 * item 2.2 . paARaAGRaAph * iIteEm 1 * iIteEm 2 * iIteEm 2.1 * iIteEm 2.2 ``` -------------------------------- ### Markdown Reference Link and Image Formatting Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md Demonstrates various forms of Markdown reference links and images, including shorthand, full reference, and image syntax. It shows how these are processed, including case-insensitivity for references. ```Markdown Work with [Markdown] Work with [Markdown][] Work with [Markdown Text][Markdown] Work with ![Markdown][] Work with ![Markdown Image][Markdown] [Markdown]: https://test.com/doc.png ``` ```Markdown woRK WiIth [maARKDoWN] woRK WiIth [maARKDoWN][] woRK WiIth [maARKDoWN teEXt][maARKDoWN] woRK WiIth ![maARKDoWN][] woRK WiIth ![maARKDoWN imaAGeE][maARKDoWN] [maARKDoWN]: https://test.com/doc.png ``` -------------------------------- ### Markdown List: Unordered List Following Paragraph Example 7 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md Shows an unordered list immediately following a paragraph without an intervening blank line. This example tests how a Markdown parser handles the transition from block-level text to a list without explicit separation. ```Markdown paragraph * item 1 * item 2 * item 2.1 * item 2.2 . paARaAGRaAph * iIteEm 1 * iIteEm 2 * iIteEm 2.1 * iIteEm 2.2 ``` -------------------------------- ### Non-Definition: Leading Colon Paragraph - Example 1 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-definition/src/test/resources/ext_definition_ast_spec.md Illustrates that a line starting with a colon but not preceded by a definition term is treated as a regular paragraph, not a definition list item. The HTML output confirms it's wrapped in atag. ```markdown : definition item ``` ```html
: definition item
``` ```ast Document[0, 18] Paragraph[0, 18] Text[0, 17] chars:[0, 17, ": def … item"] ``` -------------------------------- ### Markdown Section Example with Options Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-spec-example/src/test/resources/ext_spec_example_formatter_spec.md This snippet demonstrates a basic Markdown section with specific options 'test' and 'option2'. It shows how a section might be defined or parsed within a larger document structure. ```Markdown Markdown only … ``` -------------------------------- ### Setting Ordered List Start with Non-One Index in Markdown Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_spec.md This snippet illustrates how an ordered list item, even if it starts with an index other than '1' (e.g., '2.'), correctly initializes an ordered list. The parser recognizes the starting number and renders the item within an `~~foo
`, and the AST, confirming the `~~` are treated as literal text due to the unclosed tag. ```CommonMark ~~foo ``` ```HTML~~foo
``` ```AST Document[0, 5] Paragraph[0, 5] Text[0, 5] chars:[0, 5, "~~foo"] ``` -------------------------------- ### Definition List Example 1 - Markdown Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-definition/src/test/resources/ext_definition_formatter_spec.md An example showing a definition item without a preceding term, which might not render as a standard definition list or could be part of a larger context. ```Markdown : definition item . : definition item ``` -------------------------------- ### Wrap Functionality Example 2 - Margin with Tracked Offset Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_paragraph_formatter_spec.md This example demonstrates the 'Wrap' functionality with a margin of 66, showing the effect of a tracked offset (indicated by ⦙) on the wrapping behavior. It illustrates how repeated prefixes in items are automatically copied when adding or splitting an item. ```Text Add: configuration for repeated prefixes in items, which would `be #2` ⦙copied when adding/splitting an item. In other words they would be treated equivalent to task item marker prefix. That way standard: `Add: `, `Fix: `, `Break: ` and `Deprecate: ` prefixes would be automatically copied. ``` -------------------------------- ### GFM Task List Markdown Input - Example 19 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-gfm-tasklist/src/test/resources/ext_gfm_tasklist_ast_spec.md Demonstrates basic GitHub Flavored Markdown (GFM) task list syntax, including both standard list items and task list items, with consistent indentation. This input is processed by flexmark-java to generate HTML and an AST. ```Markdown - task - [ ] task 1. task 1. [ ] task ``` -------------------------------- ### Escaping Pipe Characters in Markdown with Flexmark-Java Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-formatter-test-suite/src/test/resources/formatter_issue_test_suite_spec.md This snippet demonstrates how a pipe character ('|') needs to be escaped when it appears at the start of a wrapped line in Markdown, especially when 'aside' is enabled, to prevent misinterpretation during parsing. ```Markdown Text wrapping pipe `|` should be escaped when | is wrapped to start of line. ``` -------------------------------- ### Autolink WWW URLs (Issue #178) - Markdown Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-autolink/src/test/resources/ext_autolink_ast_spec.md This example addresses Issue #178, demonstrating that the AutolinkExtension correctly adds the `http://` prefix to simple URLs starting with `www.` when converting them into hyperlinks. ```Markdown auto link www.example.com ``` -------------------------------- ### Separating Aside Blocks with a Blank Line (Markdown) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-aside/src/test/resources/ext_aside_ast_spec.md This example demonstrates that a blank line between two lines starting with the Aside marker `|` will cause them to be parsed as two distinct Aside blocks, each containing its own paragraph. ```Markdown | foo\n\n| bar\n ``` -------------------------------- ### Basic Markdown Parsing and HTML Rendering in Java Source: https://github.com/vsch/flexmark-java/blob/master/README.md This Java code demonstrates the fundamental usage of flexmark-java to parse a Markdown string and render it as HTML. It initializes a `Parser` and `HtmlRenderer` with default options, parses the input, and prints the resulting HTML. Optional extensions and soft-break handling are commented out as examples. ```Java package com.vladsch.flexmark.samples; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataSet; public class BasicSample { public static void main(String[] args) { MutableDataSet options = new MutableDataSet(); // uncomment to set optional extensions //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); // uncomment to convert soft-breaks to hard breaks //options.set(HtmlRenderer.SOFT_BREAK, "This is Sparta
\n" System.out.println(html); } } ``` -------------------------------- ### Markdown Syntax Demonstration with HTML Output Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_profile_compatibility_spec.md This example showcases a comprehensive set of Markdown features, including headings, thematic breaks, paragraphs with lazy continuation, nested lists (bullet and numbered), blockquotes, and both fenced and indented code blocks. It provides the original Markdown input and its corresponding HTML rendering, demonstrating how flexmark-java processes these elements. ```Markdown #Heading ----- paragraph text lazy continuation * list item > block quote lazy continuation ~~~info with uneven indent with uneven indent indented code ~~~ with uneven indent with uneven indent indented code 1. numbered item 1 1. numbered item 2 1. numbered item 3 - bullet item 1 - bullet item 2 - bullet item 3 1. numbered sub-item 1 1. numbered sub-item 2 1. numbered sub-item 3 ~~~info with uneven indent with uneven indent indented code ~~~ with uneven indent with uneven indent indented code ``` ```HTMLparagraph text lazy continuation
block quote lazy continuation
with uneven indent
with uneven indent
indented code
with uneven indent
with uneven indent
indented code
with uneven indent
with uneven indent
indented code
with uneven indent
with uneven indent
indented code
Block Quote Contents
Nested Block Quote Contents
``` -------------------------------- ### Handling HTML Blocks in Formatter Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md This example illustrates how the formatter processes HTML block elements. It shows that the content within the HTML tags is translated, but the HTML tags themselves are preserved, demonstrating partial translation within HTML structures. ```HTML this is a test ``` -------------------------------- ### Markdown Loose Item Handling: Example 9 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_profile_compatibility_spec.md This example demonstrates Markdown list rendering, focusing on how blank lines between list items affect their 'tightness' or 'looseness' in the generated HTML. It provides the Markdown input and the corresponding HTML output. ```Markdown - item 1 - item 1.1 - item 2 - item 2.1 - item 3 - item 3.1 - item 4 - item 4.1 ``` ```HTML
tags within
Loose Definition of above term
Another loose definition term
block quoted text lazy continuation
another paragraph
``` ```AST Document[0, 56] BlockQuote[0, 38] marker:[0, 1, ">"] Paragraph[2, 38] isTrailingBlankLine Text[2, 19] chars:[2, 19, "block … text"] SoftLineBreak[19, 20] Text[20, 37] chars:[20, 37, "lazy … ation"] Paragraph[39, 56] Text[39, 56] chars:[39, 56, "anoth … graph"] ``` -------------------------------- ### Enabling Source Position Attributes in HTML Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-typographic/src/test/resources/ext_typographic_ast_spec.md This example shows how to enable the `src-pos` option to include source position attributes in the generated HTML. The `md-pos` attribute on HTML elements indicates the start and end character offsets from the original Markdown source, useful for debugging or linking back to source. ```Markdown Sample with l'existence, from 1...2 and so on. . . en--dash and em---dash ``` ```HTMLSample with l’existence, from 1…2 and so on…
en–dash and em—dash
``` -------------------------------- ### Rendering Task List with Heading (Issue #136, Example 2) Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_extension_compatibility_spec.md This example demonstrates the rendering of a Markdown task list preceded by a heading. It verifies that flexmark-java correctly processes the task list syntax into an HTML unordered list with interactive checkboxes, maintaining the heading structure. ```Markdown # Task List - [x] Task 1 - [ ] Task 2 - [x] Task 3 ``` ```HTMLNested Quote
Bullet item can interrupt paragraph
Empty bullet item with space can interrupt paragraph *
Empty bullet item without space can interrupt paragraph *
Numbered one item can interrupt paragraph
Empty Numbered one item with space can interrupt paragraph 1.
Empty Numbered one item without space can interrupt paragraph 1.
Numbered non-one item can interrupt paragraph 2. non-one item
Empty Numbered non-one item with space can interrupt paragraph 2.
Empty Numbered non-one item without space can interrupt paragraph 2.
``` -------------------------------- ### Nesting List Items with Two-Space Indentation - Example 3 Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_spec.md This snippet tests list item indentation where each item's content starts with two spaces after the list marker. It confirms that the parser correctly interprets the nesting based on the overall indentation level, similar to single-space indentation, maintaining the nested list structure. ```Markdown * item 1 * item 2 * item 3 * item 4 * item 5 * item 6 * item 7 * item 8 * item 9 ``` ```HTMLOrdered
```
--------------------------------
### Text Wrapping Example - Restore Spaces: 43
Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_wrapping_spec.md
This snippet is another example of the text wrapping and space restoration feature, similar to example 42 but potentially with different margin or space handling parameters. It illustrates how the formatter processes and wraps text while preserving or restoring spaces.
```Plain Text
⟦### Next 2.9.0.227/2.9.7.227 - Dev Build
* [ ] ⟧Fix: remove formatter and use flexmark formatter for document format to eliminate the need
⟦ ⟧ ⦙to keep duplicate code.
.
* [ ] Fix: remove formatter and use flexmark formatter for document format to eliminate the need
⦙to keep duplicate code.
```
--------------------------------
### Handling Empty Markdown List Items (Default Unordered)
Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-core-test/src/test/resources/core_translation_formatter_spec.md
Demonstrates the default rendering behavior of unordered Markdown lists containing empty list items. Empty items, including those separated by blank lines, are preserved in the output.
```markdown
* list item 1
*
* list item 2
*
not a list item
```
--------------------------------
### Markdown Loose Item Handling: Example 7 (IGNORE option)
Source: https://github.com/vsch/flexmark-java/blob/master/flexmark-profile-pegdown/src/test/resources/pegdown_profile_compatibility_spec.md
This example demonstrates Markdown list rendering with the `IGNORE` option, which might affect how blank lines within list items are handled, potentially leading to different HTML output compared to default rendering. It shows the Markdown input and the expected HTML output.
```Markdown
- item 1
- item 1.1
- item 2
- item 2.1
- item 3
- item 3.1
- item 4
- item 4.1
```
```HTML
item 1.1