///|
test "basic parsing" {
let input =
#|# Hello World
#|
#|This is a paragraph.
let doc = @cmark.Doc::from_string(input)
// Should contain a heading and a paragraph
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: Blocks(
#| {
#| v: Seq(
#| [
#| Heading(
#| {
#| v: {
#| layout: Atx({ indent: 0, after_opening: "", closing: "" }),
#| level: 1,
#| inline: Text(
#| {
#| v: "Hello World",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| id: None,
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| BlankLine(
#| {
#| v: "",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| Paragraph(
#| {
#| v: {
#| leading_indent: 0,
#| inline: Text(
#| {
#| v: "This is a paragraph.",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "emphasis and strong emphasis" {
let input =
#|_Emphasis_ and **strong emphasis**
let doc = @cmark.Doc::from_string(input)
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: Paragraph(
#| {
#| v: {
#| leading_indent: 0,
#| inline: Inlines(
#| {
#| v: Seq(
#| [
#| Emphasis(
#| {
#| v: {
#| delim: '_',
#| inline: Text(
#| {
#| v: "Emphasis",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| Text(
#| {
#| v: " and ",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| StrongEmphasis(
#| {
#| v: {
#| delim: '*',
#| inline: Text(
#| {
#| v: "strong emphasis",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "inline code and math" {
let input =
$|$E = mc^2$ in Python: `E = m * (c ** 2)`
let doc = @cmark.Doc::from_string(input, strict=false)
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: Paragraph(
#| {
#| v: {
#| leading_indent: 0,
#| inline: Inlines(
#| {
#| v: Seq(
#| [
#| ExtMathSpan(
#| {
#| v: {
#| display: false,
#| tex_layout: Seq(
#| [
#| {
#| blanks: "",
#| node: { v: "E = mc^2", meta: { id: 0, loc: ..., extra: None } },
#| },
#| ],
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| Text(
#| {
#| v: " in Python: ",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| CodeSpan(
#| {
#| v: {
#| backticks: 1,
#| code_layout: Seq(
#| [
#| {
#| blanks: "",
#| node: { v: "E = m * (c ** 2)", meta: { id: 0, loc: ..., extra: None } },
#| },
#| ],
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "headings" {
let input =
#|# Level 1
let doc = @cmark.Doc::from_string(input)
// Should contain a heading and a paragraph
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: Heading(
#| {
#| v: {
#| layout: Atx({ indent: 0, after_opening: "", closing: "" }),
#| level: 1,
#| inline: Text(
#| {
#| v: "Level 1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| id: None,
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "lists" {
let input =
#|- First item
#|- Second item
#| 1. Nested item
let doc = @cmark.Doc::from_string(input)
// Should find an ordered list within an unordered one.
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: List(
#| {
#| v: {
#| ty: Unordered('-'),
#| tight: true,
#| items: Seq(
#| [
#| {
#| v: {
#| before_marker: 0,
#| marker: {
#| v: "-",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| after_marker: 1,
#| block: Paragraph(
#| {
#| v: {
#| leading_indent: 0,
#| inline: Text(
#| {
#| v: "First item",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ext_task_marker: None,
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| {
#| v: {
#| before_marker: 0,
#| marker: {
#| v: "-",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| after_marker: 1,
#| block: Blocks(
#| {
#| v: Seq(
#| [
#| Paragraph(
#| {
#| v: { leading_indent: 0, inline: Text(...), trailing_blanks: "" },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| List(
#| {
#| v: { ty: Ordered(1, '.'), tight: true, items: Seq(...) },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ext_task_marker: None,
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ],
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "code blocks" {
let tick3 = "`".repeat(3)
let input =
$|\{tick3}moonbit
$|fn main {
$| println("Hello")
$|}
$|\{tick3}
let doc = @cmark.Doc::from_string(input)
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: CodeBlock(
#| {
#| v: {
#| layout: Fenced(
#| {
#| indent: 0,
#| opening_fence: {
#| v: "",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| closing_fence: Some(
#| {
#| v: "",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#| ),
#| info_string: Some(
#| {
#| v: "moonbit",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| code: Seq(
#| [
#| {
#| v: "fn main {",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| {
#| v: " println(\"Hello\")",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| {
#| v: "}",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ],
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "tables" {
let input =
#|| Header 1 | Header 2 |
#||----------|----------|
#|| Cell 1 | Cell 2 |
let doc = @cmark.Doc::from_string(input, strict=false)
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: ExtTable(
#| {
#| v: {
#| indent: 0,
#| col_count: 2,
#| rows: Seq(
#| [
#| (
#| {
#| v: Header(
#| Seq(
#| [
#| (
#| Text(
#| {
#| v: "Header 1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| TableCellLayout(("", "")),
#| ),
#| (
#| Text(
#| {
#| v: "Header 2",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| TableCellLayout(("", "")),
#| ),
#| ],
#| ),
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| "",
#| ),
#| (
#| {
#| v: Sep(
#| Seq(
#| [
#| {
#| v: TableSep((None, 10)),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| {
#| v: TableSep((None, 10)),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ],
#| ),
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| "",
#| ),
#| (
#| {
#| v: Data(
#| Seq(
#| [
#| (
#| Text(
#| {
#| v: "Cell 1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| TableCellLayout(("", "")),
#| ),
#| (
#| Text(
#| {
#| v: "Cell 2",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| TableCellLayout(("", "")),
#| ),
#| ],
#| ),
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| "",
#| ),
#| ],
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {},
#|}
),
)
}///|
test "footnotes" {
let input =
#|Text[^1]
#|
#|[^1]: Footnote content
let doc = @cmark.Doc::from_string(input, strict=false)
debug_inspect(
doc,
content=(
#|{
#| nl: "\n",
#| block: Blocks(
#| {
#| v: Seq(
#| [
#| Paragraph(
#| {
#| v: {
#| leading_indent: 0,
#| inline: Inlines(
#| {
#| v: Seq(
#| [
#| Text(
#| {
#| v: "Text",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| Link(
#| {
#| v: { text: Text(...), reference: Ref(Shortcut, ..., ...) },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| BlankLine(
#| {
#| v: "",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ExtFootnoteDefinition(
#| {
#| v: {
#| indent: 0,
#| label: {
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| key: "^1",
#| text: Seq(
#| [
#| {
#| blanks: "",
#| node: {
#| v: "^1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| },
#| ],
#| ),
#| },
#| defined_label: Some(
#| {
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| key: "^1",
#| text: Seq(
#| [
#| {
#| blanks: "",
#| node: {
#| v: "^1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: ...,
#| last_line: ...,
#| },
#| extra: None,
#| },
#| },
#| },
#| ],
#| ),
#| },
#| ),
#| block: Paragraph(
#| {
#| v: {
#| leading_indent: 1,
#| inline: Text(
#| {
#| v: "Footnote content",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| ],
#| ),
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| defs: {
#| "^1": FootnoteDef(
#| {
#| v: {
#| indent: 0,
#| label: {
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| key: "^1",
#| text: Seq(
#| [
#| {
#| blanks: "",
#| node: {
#| v: "^1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| },
#| ],
#| ),
#| },
#| defined_label: Some(
#| {
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| key: "^1",
#| text: Seq(
#| [
#| {
#| blanks: "",
#| node: {
#| v: "^1",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| },
#| ],
#| ),
#| },
#| ),
#| block: Paragraph(
#| {
#| v: {
#| leading_indent: 1,
#| inline: Text(
#| {
#| v: "Footnote content",
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| trailing_blanks: "",
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#| meta: {
#| id: 0,
#| loc: {
#| file: "-",
#| first_ccode: -1,
#| last_ccode: -1,
#| first_line: LinePos(-1, -1),
#| last_line: LinePos(-1, -1),
#| },
#| extra: None,
#| },
#| },
#| ),
#| },
#|}
),
)
}type BlockBlankLine = Stringtype InlineText = Stringtest {
let map = { 3: "three", 8: "eight", 1: "one" }
@test.assert_eq(map.get(2), None)
@test.assert_eq(map.get(3), Some("three"))
map.set(3, "updated")
@test.assert_eq(map.get(3), Some("updated"))
}type LabelKey = Stringpub(all) enum Block {
BlankLine(Node[String])
BlockQuote(Node[BlockQuote])
Blocks(Node[Seq[Block]])
CodeBlock(Node[CodeBlock])
Heading(Node[BlockHeading])
HtmlBlock(Node[HtmlBlock])
LinkRefDefinition(Node[LinkDefinition])
List(Node[BlockList])
Paragraph(Node[BlockParagraph])
ThematicBreak(Node[BlockThematicBreak])
ExtMathBlock(Node[CodeBlock])
ExtTable(Node[Table])
ExtFootnoteDefinition(Node[Footnote])
} derive(Debug)pub(all) struct BlockHeading {
layout : BlockHeadingLayout
level : Int
inline : Inline
id : BlockHeadingId?
} derive(Debug)fn BlockHeading::new(id? : BlockHeadingId?, layout? : BlockHeadingLayout, level~ : Int, inline : Inline) -> BlockHeadingpub(all) enum BlockHeadingLayout {
Atx(BlockHeadingAtxLayout)
Setext(BlockHeadingSetextLayout)
} derive(Debug)fn BlockParagraph::new(leading_indent? : Int, trailing_blanks? : String, inline : Inline) -> BlockParagraphpub(all) struct CodeBlock {
layout : CodeBlockLayout
info_string : Node[String]?
code : Seq[Node[String]]
} derive(Debug)fn Doc::from_string(defs? : Map[String, LabelDef], resolver? : LabelResolverFn, nested_links? : Bool, heading_auto_ids? : Bool, layout? : Bool, locs? : Bool, file? : String, strict? : Bool, s : String) -> Docimpl Default for FolderResult[A]pub(all) enum Inline {
Autolink(Node[InlineAutolink])
Break(Node[InlineBreak])
CodeSpan(Node[InlineCodeSpan])
Emphasis(Node[InlineEmphasis])
Image(Node[InlineLink])
Inlines(Node[Seq[Inline]])
Link(Node[InlineLink])
RawHtml(Node[InlineRawHtml])
StrongEmphasis(Node[InlineEmphasis])
Text(Node[String])
ExtStrikethrough(Node[InlineStrikethrough])
ExtMathSpan(Node[InlineMathSpan])
} derive(Eq, Debug)pub(all) struct InlineBreak {
layout_before : Node[String]
ty : InlineBreakType
layout_after : Node[String]
} derive(Eq, Debug)fn InlineBreak::new(layout_before? : Node[String], layout_after? : Node[String], ty : InlineBreakType) -> InlineBreakfn LinkDefinition::new(layout? : LinkDefinitionLayout, label? : Label?, defined_label? : Label?, dest? : Node[String]?, title? : Seq[Tight]?) -> LinkDefinitionpub(all) enum ListTaskStatus {
Cancelled
Checked
Unchecked
Other(Char)
}impl Default for MapperResult[A]pub(all) enum ReferenceKind {
Inline(Node[LinkDefinition])
Ref(ReferenceLayout, Label, Label)
} derive(Eq, Debug)pub(all) enum TableRow {
Header(Seq[(Inline, TableCellLayout)])
Sep(Seq[Node[TableSep]])
Data(Seq[(Inline, TableCellLayout)])
} derive(Debug)fn is_punctuation(c : Char) -> Boolfn is_whitespace(c : Char) -> Bool