* 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>
This commit is contained in:
parent
6c0c882509
commit
e1cc0219de
3 changed files with 12 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
## Standard library additions and changes
|
## Standard library additions and changes
|
||||||
|
- Added `xmltree.newVerbatimText` support create `style`'s,`script`'s text.
|
||||||
- `uri` adds Data URI Base64, implements RFC-2397.
|
- `uri` adds Data URI Base64, implements RFC-2397.
|
||||||
- Add [DOM Parser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser)
|
- Add [DOM Parser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser)
|
||||||
to the `dom` module for the JavaScript target.
|
to the `dom` module for the JavaScript target.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
|
|
||||||
## Standard library additions and changes
|
## Standard library additions and changes
|
||||||
|
|
||||||
- Added overloaded `strformat.fmt` macro that use specified characters as
|
- Added overloaded `strformat.fmt` macro that use specified characters as
|
||||||
delimiter instead of '{' and '}'.
|
delimiter instead of '{' and '}'.
|
||||||
- Added new procs in `tables.nim`: `OrderedTable.pop`, `CountTable.del`,
|
- Added new procs in `tables.nim`: `OrderedTable.pop`, `CountTable.del`,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
## * `htmlgen module <htmlgen.html>`_ for html code generator
|
## * `htmlgen module <htmlgen.html>`_ for html code generator
|
||||||
|
|
||||||
import macros, strtabs, strutils
|
import macros, strtabs, strutils
|
||||||
|
include "system/inclrtl"
|
||||||
|
|
||||||
type
|
type
|
||||||
XmlNode* = ref XmlNodeObj ## An XML tree consisting of XML nodes.
|
XmlNode* = ref XmlNodeObj ## An XML tree consisting of XML nodes.
|
||||||
|
|
@ -44,6 +45,7 @@ type
|
||||||
|
|
||||||
XmlNodeKind* = enum ## Different kinds of XML nodes.
|
XmlNodeKind* = enum ## Different kinds of XML nodes.
|
||||||
xnText, ## a text element
|
xnText, ## a text element
|
||||||
|
xnVerbatimText, ##
|
||||||
xnElement, ## an element with 0 or more children
|
xnElement, ## an element with 0 or more children
|
||||||
xnCData, ## a CDATA node
|
xnCData, ## a CDATA node
|
||||||
xnEntity, ## an entity (like ``&thing;``)
|
xnEntity, ## an entity (like ``&thing;``)
|
||||||
|
|
@ -56,7 +58,7 @@ type
|
||||||
|
|
||||||
XmlNodeObj {.acyclic.} = object
|
XmlNodeObj {.acyclic.} = object
|
||||||
case k: XmlNodeKind # private, use the kind() proc to read this field.
|
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
|
fText: string
|
||||||
of xnElement:
|
of xnElement:
|
||||||
fTag: string
|
fTag: string
|
||||||
|
|
@ -101,6 +103,12 @@ proc newText*(text: string): XmlNode =
|
||||||
result = newXmlNode(xnText)
|
result = newXmlNode(xnText)
|
||||||
result.fText = text
|
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 =
|
proc newComment*(comment: string): XmlNode =
|
||||||
## Creates a new ``XmlNode`` of kind ``xnComment`` with the text `comment`.
|
## Creates a new ``XmlNode`` of kind ``xnComment`` with the text `comment`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
|
|
@ -646,6 +654,8 @@ proc add*(result: var string, n: XmlNode, indent = 0, indWidth = 2,
|
||||||
result.add(">")
|
result.add(">")
|
||||||
of xnText:
|
of xnText:
|
||||||
result.addEscaped(n.fText)
|
result.addEscaped(n.fText)
|
||||||
|
of xnVerbatimText:
|
||||||
|
result.add(n.fText)
|
||||||
of xnComment:
|
of xnComment:
|
||||||
result.add("<!-- ")
|
result.add("<!-- ")
|
||||||
result.addEscaped(n.fText)
|
result.addEscaped(n.fText)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue