summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBung <535670947@qq.com>2020-04-23 01:46:55 +0800
committerGitHub <noreply@github.com>2020-04-22 19:46:55 +0200
commite1cc0219de5a51adb68479aa8923e7151003d95d (patch)
tree0d29ce22169e4116d71b66c386aeb4b556e22046
parent6c0c8825094453af6f189bda9a7cd2f9551693a6 (diff)
downloadNim-e1cc0219de5a51adb68479aa8923e7151003d95d.tar.gz
fix #14064 xmltree should allow create text node with raw text(non-es… (#14070)
* fix #14064 xmltree should allow create text node with raw text(non-escaped) eg. html style element's text

* change xnRawText to VerbatimText,newRawText to newVerbatimText ,add since anotation

* change changelog_1_2_0.md latest date

* move change log

Co-authored-by: bung87 <crc32@qq.com>
-rw-r--r--changelog.md2
-rw-r--r--changelogs/changelog_1_2_0.md1
-rw-r--r--lib/pure/xmltree.nim12
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)
97366d441 ^
38bdf1cd7 ^
97366d441 ^
0ea4b71ee ^



7e0da3e8f ^
00a4e19e8 ^
0ea4b71ee ^
7e0da3e8f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40