I have a parse rules that returns true but it doesn't insert my text as expected : the html is unchanged whereas it should have inserted at the end of the main closing div. I tried to use a counter like How to parse inside HTML tags with REBOL?
Update: I also don't know how to break out of the parsing as soon as counter = 0 so as not to insert text before last closing div after main.
content: {<div class="main">
<h1>
Big TITLE
</h1>
<div>
<section>
<p>a paragraph</p>
</section>
<section>
<p>a paragraph</p>
</section>
<section>
<p>a paragraph</p>
</section>
</div>
<div>
<p>Blah Blah</p>
</div>
</div>
<div>
Another Div
</div>
}
rules: [
thru <div class="main">
(div-count: 1)
some [
to "<div" (++ div-count) thru "<div" thru ">"
|
to </div> mark: (-- div-count if div-count = 0 [insert mark "closing main div"]) thru </div>
]
to end
]
parse content rules