mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 04:14:19 +00:00
* 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:
@@ -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.
|
||||
|
||||
@@ -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`,
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user