diff --git a/src/org/org_types.nim b/src/org/org_types.nim index 5dd4bf4..793d668 100644 --- a/src/org/org_types.nim +++ b/src/org/org_types.nim @@ -100,7 +100,8 @@ func `$`*(xs: seq[OrgInlineBlock]): string = pprint(xs) type orgBlockKind* = enum orgHeading - # orgParagraph + orgParagraph + orgNewline OrgBlock* = ref object children*: seq[OrgInlineBlock] @@ -110,24 +111,37 @@ type todo*: Option[string] headlineContent*: seq[OrgInlineBlock] content*: string + of orgParagraph: + paragraphContent: seq[OrgInlineBlock] + of orgNewline: discard ## OrgBlock.PrettyPrinters func pprint*(x: OrgBlock, indent = 0): string = - let fields = @[ - ("kind", $x.kind, true), - ("level", $x.level, true), - ("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 != ""), - ] - .stringifyFields() + let fields = case x.kind: + of orgHeading: + @[ + ("kind", $x.kind, true), + ("level", $x.level, true), + ("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 != ""), + ] + of orgParagraph: + @[ + ("kind", $x.kind, true), + ("paragraphContent", $x.paragraphContent, x.paragraphContent.len != 0), + ] + else: + @[ + ("kind", $x.kind, true), + ] stringifyBlock( "OrgBlock", indent, - fields, + fields.stringifyFields(), ) func `$`*(x: OrgBlock): string = pprint(x)