@@ -356,9 +356,9 @@ \subsection{DOM modifications}
356
356
\end {framed }
357
357
358
358
359
- \subsubsection {Setting raw XML and HTML using \texttt { DOM \_ Object:innerHTML } }
359
+ \subsubsection {Adding raw XML and HTML string }
360
360
361
- You can also set XML or HTML markup from a string to an element using the \texttt {DOM\_ Object:innerHTML } function.
361
+ You can also set XML or HTML markup from a string to an element using the \texttt {DOM\_ Object:inner \_ html } function.
362
362
Pass true as the second argument to parse string as XML, it is parsed as HTML otherwise.
363
363
364
364
@@ -369,8 +369,8 @@ \subsubsection{Setting raw XML and HTML using \texttt{DOM\_Object:innerHTML}}
369
369
]]
370
370
local tree = dom.html_parse(document)
371
371
local p = tree:query_selector("p")[1]
372
- -- insert innerHTML as XML
373
- p:innerHTML ("hello <b>this</b> should be the new content")
372
+ -- insert inner_html as XML
373
+ p:inner_html ("hello <b>this</b> should be the new content")
374
374
print(tree:serialize())
375
375
\end {verbatim }
376
376
@@ -385,12 +385,21 @@ \subsubsection{Setting raw XML and HTML using \texttt{DOM\_Object:innerHTML}}
385
385
]]
386
386
local tree = dom.html_parse(document)
387
387
local p = tree:query_selector("p")[1]
388
- -- insert innerHTML as XML
389
- p:innerHTML ("hello <b>this</b> should be the new content")
388
+ -- insert inner_html as XML
389
+ p:inner_html ("hello <b>this</b> should be the new content")
390
390
tex.print(tree:serialize())
391
391
\end {luacode* }
392
392
\end {framed }
393
393
394
+ There are more variants of raw string methods that add the new content at specific places in the element instead of replacing contents
395
+ of the element:
396
+
397
+ \begin {description }
398
+ \item [\texttt {DOM\_ Object:insert\_ before\_ begin }] -- before element.
399
+ \item [\texttt {DOM\_ Object:insert\_ after\_ begin }] -- just inside the element, before its first child.
400
+ \item [\texttt {DOM\_ Object:insert\_ before\_ end }] -- just inside the element, after its last child.
401
+ \item [\texttt {DOM\_ Object:insert\_ after\_ end }] -- after the element.
402
+ \end {description }
394
403
395
404
396
405
\section {The \texttt {CssQuery } library }
0 commit comments