Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions doc/_stdlib_gen/stdlib-content.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,44 @@ local html = import 'html.libsonnet';
},
],
},
{
name: 'parseXmlJsonml',
params: ['str', 'preserveWhitespace=false'],
availableSince: 'upcoming',
description: [
html.p({}, |||
Parses a XML string to <a href="http://www.jsonml.org/">JsonML</a>-encoded value. The XML should only contain
one root node.
|||),
html.p({}, |||
By default, all the boundary whitespace would be trimmed. It could be preserved using <code>preserveWhitespace</code>
argument of the function.
|||),
],
examples: [
{
input: "std.parseXmlJsonml('<svg height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"50\" fill=\"red\" r=\"40\" stroke=\"black\" stroke-width=\"3\"></circle></svg>')",
output: [
"svg",
{
"height": "100",
"width": "100"
},
[
"circle",
{
"cx": "50",
"cy": "50",
"fill": "red",
"r": "40",
"stroke": "black",
"stroke-width": "3"
}
]
],
},
],
},
{
name: 'encodeUTF8',
params: ['str'],
Expand Down
2 changes: 2 additions & 0 deletions stdlib/std.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -1785,4 +1785,6 @@ limitations under the License.
sha3(str):: go_only_function,

trim(str):: std.stripChars(str, ' \t\n\f\r\u0085\u00A0'),

parseXmlJsonml(str):: go_only_function,
}