Add content pretty printer
This commit is contained in:
@@ -66,6 +66,8 @@ proc `$`*(x: orgInlineBlockKind): string =
|
||||
# Links
|
||||
of orgLink: "Link"
|
||||
|
||||
const PPRINT_INDENT_SIZE* = 2
|
||||
|
||||
func pprint*(x: OrgInlineBlock, indent = 0): string =
|
||||
let specialFields = case x.kind:
|
||||
of orgLink:
|
||||
@@ -110,7 +112,7 @@ type
|
||||
level*: int
|
||||
todo*: Option[string]
|
||||
headlineContent*: seq[OrgInlineBlock]
|
||||
content*: string
|
||||
content*: seq[OrgBlock]
|
||||
of orgParagraph:
|
||||
paragraphContent: seq[OrgInlineBlock]
|
||||
of orgNewline: discard
|
||||
@@ -126,7 +128,14 @@ func pprint*(x: OrgBlock, indent = 0): string =
|
||||
("todo", $x.todo, x.todo.isSome()),
|
||||
("headlineContent", $x.headlineContent, x.headlineContent.len != 0),
|
||||
("children", $x.children, x.children.len != 0),
|
||||
("content", $x.content, x.content != ""),
|
||||
(
|
||||
"content",
|
||||
("@[\n" &
|
||||
x.content.map((x) => pprint(x)).join(",\n").indent(PPRINT_INDENT_SIZE) &
|
||||
",\n],"
|
||||
).indent(indent),
|
||||
x.content.len != 0
|
||||
),
|
||||
]
|
||||
of orgParagraph:
|
||||
@[
|
||||
@@ -186,6 +195,14 @@ when isMainModule:
|
||||
linkDescription: "Placeholder".some(),
|
||||
),
|
||||
],
|
||||
content: @[
|
||||
OrgBlock(
|
||||
kind: orgNewline,
|
||||
),
|
||||
OrgBlock(
|
||||
kind: orgNewline,
|
||||
)
|
||||
],
|
||||
),
|
||||
OrgBlock(kind: orgHeading, level: 1),
|
||||
OrgBlock(kind: orgHeading),
|
||||
|
||||
Reference in New Issue
Block a user