From e75482d98a586db56747bbe309573644304ccf76 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Wed, 4 May 2022 17:00:00 +0200 Subject: [PATCH] Simplify function --- src/org/org_types.nim | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/org/org_types.nim b/src/org/org_types.nim index 510280c..ec9f47d 100644 --- a/src/org/org_types.nim +++ b/src/org/org_types.nim @@ -100,10 +100,9 @@ type headlineContent*: seq[OrgInlineBlock] headlineChildrenText*: string -const INDENT_SIZE = 2; - -func stringifySpecialFields(x: OrgBlock, indent = 0): string = - @[ +proc `$`*(x: OrgBlock, indent = 0): string = + let fieldIndent = indent + INDENT_SIZE + let fields = @[ ("kind", $x.kind, true), ("level", $x.level, true), ("todo", $x.todo, x.todo.isSome()), @@ -113,12 +112,9 @@ func stringifySpecialFields(x: OrgBlock, indent = 0): string = ] .stringifyFields() -proc `$`*(x: OrgBlock, indent = 0): string = - let fieldIndent = indent + INDENT_SIZE - @[ "OrgBlock(", - stringifySpecialFields(x).indent(fieldIndent), + fields.indent(fieldIndent), ")", ] .join("\n")