Skip to content

Commit 9c2f26e

Browse files
committed
documented new insert commadns
1 parent 9a10e08 commit 9c2f26e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

luaxml.tex

+15-6
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ \subsection{DOM modifications}
356356
\end{framed}
357357

358358

359-
\subsubsection{Setting raw XML and HTML using \texttt{DOM\_Object:innerHTML}}
359+
\subsubsection{Adding raw XML and HTML string}
360360

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.
362362
Pass true as the second argument to parse string as XML, it is parsed as HTML otherwise.
363363

364364

@@ -369,8 +369,8 @@ \subsubsection{Setting raw XML and HTML using \texttt{DOM\_Object:innerHTML}}
369369
]]
370370
local tree = dom.html_parse(document)
371371
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")
374374
print(tree:serialize())
375375
\end{verbatim}
376376

@@ -385,12 +385,21 @@ \subsubsection{Setting raw XML and HTML using \texttt{DOM\_Object:innerHTML}}
385385
]]
386386
local tree = dom.html_parse(document)
387387
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")
390390
tex.print(tree:serialize())
391391
\end{luacode*}
392392
\end{framed}
393393

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}
394403

395404

396405
\section{The \texttt{CssQuery} library}

0 commit comments

Comments
 (0)