James
01/17/2021, 10:44 PMtext
handler in my post at https://jross.me/using-cloudflare-workers-htmlrewriter-to-extend-ghost-pro/#cloudflare-workers, and how I do the lastInTextNode
stuff to get the full text of the entire element before doing my replacements.Greg Brimble | Cloudflare Pages
01/17/2021, 10:47 PMhtml
<div>abc<p>middle</p>xyz</div>
I can't figure out a way to see that abc
and xyz
are siblings.Greg Brimble | Cloudflare Pages
01/17/2021, 10:49 PMelement
gets called whenever we go up into a node, but text.lastInTextNode
isn't exclusively going down a node. In the example above, abc
is also lastInTextNode
.James
01/17/2021, 10:56 PMGreg Brimble | Cloudflare Pages
01/17/2021, 10:59 PMJames
01/17/2021, 11:04 PMGreg Brimble | Cloudflare Pages
01/17/2021, 11:08 PMbody
exists and will definitely follow the head
?Greg Brimble | Cloudflare Pages
01/17/2021, 11:09 PMJames
01/17/2021, 11:09 PMJames
01/17/2021, 11:10 PMGreg Brimble | Cloudflare Pages
01/17/2021, 11:11 PMGreg Brimble | Cloudflare Pages
01/17/2021, 11:12 PMJames
01/17/2021, 11:13 PMGreg Brimble | Cloudflare Pages
01/17/2021, 11:18 PMhttps://i.imgur.com/g24X9RI.pngâ–¾
Greg Brimble | Cloudflare Pages
01/17/2021, 11:18 PMElectroid
01/17/2021, 11:20 PMlastInTextNode
also shows up before <p>
so it makes it hard to get the whole text?Greg Brimble | Cloudflare Pages
01/17/2021, 11:24 PMhtml
<div>abc</div><div>xyz</div>
and
html
<div>abc<div>xyz</div></div>
with HTMLRewriter, because they all come out as
element: div
text: abc (lastInTextNode)
element: div
text: xyz (lastInTextNode)
once you combine any text chunks (as you're supposed to)Xenthys
01/18/2021, 12:00 AMadvaith
01/18/2021, 12:02 AMXenthys
01/18/2021, 12:04 AMjoe
01/18/2021, 12:07 AMXenthys
01/18/2021, 12:08 AMjoe
01/18/2021, 12:11 AM+------------+
| |
| Aggregator |
| |
+-----+------+
^
|
+--------------+ +-----+------+ +--------------+
| | | | | |
| Client +------>+ Worker +------>+ Origin |
| | | | | |
+--------------+ +------------+ +--------------+
joe
01/18/2021, 12:11 AMjoe
01/18/2021, 12:11 AMjoe
01/18/2021, 12:12 AMjoe
01/18/2021, 12:12 AMXenthys
01/18/2021, 12:13 AMjoe
01/18/2021, 12:13 AMXenthys
01/18/2021, 12:14 AM