diff options
-rw-r--r-- | changelog.md | 2 | ||||
-rw-r--r-- | changelogs/changelog_1_2_0.md | 1 | ||||
-rw-r--r-- | lib/pure/xmltree.nim | 12 |
3 files changed, 12 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md index fc409c8aa..86d2e181c 100644 --- a/changelog.md +++ b/changelog.md @@ -3,7 +3,7 @@ ## Standard library additions and changes - +- Added `xmltree.newVerbatimText` support create `style`'s,`script`'s text. - `uri` adds Data URI Base64, implements RFC-2397. - Add [DOM Parser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser) to the `dom` module for the JavaScript target. diff --git a/changelogs/changelog_1_2_0.md b/changelogs/changelog_1_2_0.md index 54ead0087..1f76df0b4 100644 --- a/changelogs/changelog_1_2_0.md +++ b/changelogs/changelog_1_2_0.md @@ -2,7 +2,6 @@ ## Standard library additions and changes - - Added overloaded `strformat.fmt` macro that use specified characters as delimiter instead of '{' and '}'. - Added new procs in `tables.nim`: `OrderedTable.pop`, `CountTable.del`, diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index fbb0ab13a..35010e602 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -35,6 +35,7 @@ ## * `htmlgen module <htmlgen.html>`_ for html code generator import macros, strtabs, strutils +include "system/inclrtl" type XmlNode* = ref XmlNodeObj ## An XML tree consisting of XML nodes. @@ -44,6 +45,7 @@ type XmlNodeKind* = enum ## Different kinds of XML nodes. xnText, ## a text element + xnVerbatimText, ## xnElement, ## an element with 0 or more children xnCData, ## a CDATA node xnEntity, ## an entity (like ``&thing;``) @@ -56,7 +58,7 @@ type XmlNodeObj {.acyclic.} = object case k: XmlNodeKind # private, use the kind() proc to read this field. - of xnText, xnComment, xnCData, xnEntity: + of xnText, xnVerbatimText, xnComment, xnCData, xnEntity: fText: string of xnElement: fTag: string @@ -101,6 +103,12 @@ proc newText*(text: string): XmlNode = result = newXmlNode(xnText) result.fText = text +proc newVerbatimText*(text: string): XmlNode {.since:(1, 3).} = + ## Creates a new ``XmlNode`` of kind ``xnVerbatimText`` with the text `text`. + ## **Since**: Version 1.3. + result = newXmlNode(xnVerbatimText) + result.fText = text + proc newComment*(comment: string): XmlNode = ## Creates a new ``XmlNode`` of kind ``xnComment`` with the text `comment`. runnableExamples: @@ -646,6 +654,8 @@ proc add*(result: var string, n: XmlNode, indent = 0, indWidth = 2, result.add(">") of xnText: result.addEscaped(n.fText) + of xnVerbatimText: + result.add(n.fText) of xnComment: result.add("<!-- ") result.addEscaped(n.fText) |