Add paragraph and newline kinds
This commit is contained in:
@@ -100,7 +100,8 @@ func `$`*(xs: seq[OrgInlineBlock]): string = pprint(xs)
|
|||||||
type
|
type
|
||||||
orgBlockKind* = enum
|
orgBlockKind* = enum
|
||||||
orgHeading
|
orgHeading
|
||||||
# orgParagraph
|
orgParagraph
|
||||||
|
orgNewline
|
||||||
OrgBlock* = ref object
|
OrgBlock* = ref object
|
||||||
children*: seq[OrgInlineBlock]
|
children*: seq[OrgInlineBlock]
|
||||||
|
|
||||||
@@ -110,24 +111,37 @@ type
|
|||||||
todo*: Option[string]
|
todo*: Option[string]
|
||||||
headlineContent*: seq[OrgInlineBlock]
|
headlineContent*: seq[OrgInlineBlock]
|
||||||
content*: string
|
content*: string
|
||||||
|
of orgParagraph:
|
||||||
|
paragraphContent: seq[OrgInlineBlock]
|
||||||
|
of orgNewline: discard
|
||||||
|
|
||||||
## OrgBlock.PrettyPrinters
|
## OrgBlock.PrettyPrinters
|
||||||
|
|
||||||
func pprint*(x: OrgBlock, indent = 0): string =
|
func pprint*(x: OrgBlock, indent = 0): string =
|
||||||
let fields = @[
|
let fields = case x.kind:
|
||||||
("kind", $x.kind, true),
|
of orgHeading:
|
||||||
("level", $x.level, true),
|
@[
|
||||||
("todo", $x.todo, x.todo.isSome()),
|
("kind", $x.kind, true),
|
||||||
("headlineContent", $x.headlineContent, x.headlineContent.len != 0),
|
("level", $x.level, true),
|
||||||
("children", $x.children, x.children.len != 0),
|
("todo", $x.todo, x.todo.isSome()),
|
||||||
("content", $x.content, x.content != ""),
|
("headlineContent", $x.headlineContent, x.headlineContent.len != 0),
|
||||||
]
|
("children", $x.children, x.children.len != 0),
|
||||||
.stringifyFields()
|
("content", $x.content, x.content != ""),
|
||||||
|
]
|
||||||
|
of orgParagraph:
|
||||||
|
@[
|
||||||
|
("kind", $x.kind, true),
|
||||||
|
("paragraphContent", $x.paragraphContent, x.paragraphContent.len != 0),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
@[
|
||||||
|
("kind", $x.kind, true),
|
||||||
|
]
|
||||||
|
|
||||||
stringifyBlock(
|
stringifyBlock(
|
||||||
"OrgBlock",
|
"OrgBlock",
|
||||||
indent,
|
indent,
|
||||||
fields,
|
fields.stringifyFields(),
|
||||||
)
|
)
|
||||||
|
|
||||||
func `$`*(x: OrgBlock): string = pprint(x)
|
func `$`*(x: OrgBlock): string = pprint(x)
|
||||||
|
|||||||
Reference in New Issue
Block a user