diff --git a/src/fmt/track_config.nim b/src/fmt/track_config.nim index 4c3bfe50..23721b35 100644 --- a/src/fmt/track_config.nim +++ b/src/fmt/track_config.nim @@ -121,6 +121,20 @@ func addKeyFeatures(result: var string; val: KeyFeatures; indentLevel = 1) = result.addNewlineAndIndent(indentLevel) result.add "]," +func addConceptTags(result: var string; val: ConceptTags; indentLevel = 2) = + result.addNewlineAndIndent(indentLevel) + escapeJson("tags", result) + result.add ": {" + if val.all.len > 0: + result.addArray("all", val.all, indentLevel + 1) + if val.`any`.len > 0: + result.addArray("any", val.`any`, indentLevel + 1) + if val.`not`.len > 0: + result.addArray("not", val.`not`, indentLevel + 1) + result.removeComma() + result.addNewlineAndIndent(indentLevel) + result.add "}," + func addConcept(result: var string; val: Concept; indentLevel = 1) = ## Appends the pretty-printed JSON for a `concept` object with value `val` to ## `result`. @@ -129,6 +143,10 @@ func addConcept(result: var string; val: Concept; indentLevel = 1) = result.addString("uuid", val.uuid, indentLevel + 1) result.addString("slug", val.slug, indentLevel + 1) result.addString("name", val.name, indentLevel + 1) + if val.tags.isSome(): + let tags = val.tags.get() + if tags.all.len + tags.`any`.len + tags.`not`.len > 0: + result.addConceptTags(tags, indentLevel + 1) result.removeComma() result.addNewlineAndIndent(indentLevel) result.add "}," diff --git a/src/types_track_config.nim b/src/types_track_config.nim index 0011373e..9eb92f4b 100644 --- a/src/types_track_config.nim +++ b/src/types_track_config.nim @@ -78,10 +78,16 @@ type indentSize*: int highlightjsLanguage*: string + ConceptTags* = object + all*: seq[string] + `any`*: seq[string] + `not`*: seq[string] + Concept* = object name*: string slug*: string uuid*: string + tags*: Option[ConceptTags] Concepts* = seq[Concept]