~dmbaturin/soupault

3 2

How do we apply a widget to multiple instances of the same element.

Details
Message ID
<0f8a85798c5fd9d4270314a320423999@aoirthoir.com>
DKIM signature
pass
Download raw message
I have several H2s that I would like to add HRs after. It works for the 
first one when using the insert_html widget but i dont know how to get 
it to work for all H2s.
Details
Message ID
<039ba58f-22cd-cfbe-3056-5ffe13445a89@baturin.org>
In-Reply-To
<0f8a85798c5fd9d4270314a320423999@aoirthoir.com> (view parent)
DKIM signature
pass
Download raw message
On 4/6/20 2:15 PM, aoirthoir@aoirthoir.com wrote:
> I have several H2s that I would like to add HRs after. It works for
> the first one when using the insert_html widget but i dont know how to
> get it to work for all H2s.
>
There is no simple answer. I can be done with a custom plugin, like:

```

h2s = HTML.select(page, "h2")
count = size(h2s)
index = 1

while (index <= count) do
  HTML.insert_after(h2s[index],  HTML.create_element("hr"))
  index = index + 1
end

```

However, I think it may be a good idea to add an option to insert
something after every element in the next version. After all, the
delete_element widget does have an option to delete all elements or only
the first.
Details
Message ID
<2292c2f3-e5af-e839-e2ed-2e5af3709c76@aoirthoir.com>
In-Reply-To
<039ba58f-22cd-cfbe-3056-5ffe13445a89@baturin.org> (view parent)
DKIM signature
pass
Download raw message
I will experiment with this. I think I will create a plugin that is a 
replacement for insert_html in the way that you mention in the 
documentation on plugins.

Your comment also got me thinking that maybe all the widgets that you 
have that are even inbuilt should just be plugins. This will allow more 
rapid changes to those. Since you are about to work on a new rewrite of 
the code this might be something to consider.

If I get the plugin done I will submit it to you. Right now i dont use 
git or even know how so i will just send the plugin to the list.
Details
Message ID
<49926f53-21d0-c1cb-39ae-026dd0b0a9ba@aoirthoir.com>
In-Reply-To
<039ba58f-22cd-cfbe-3056-5ffe13445a89@baturin.org> (view parent)
DKIM signature
pass
Download raw message
I have implemented this as a new plugin. it is called insert-all-html, 
but it can be restricted with the widget settings selectors_apply and 
elements_apply...it also uses the selectors widget setting so it can be 
applied to multiple selectors at once...

http://soupault.add1tocobol.com/add1tocobol-lua/#insert-all-html-lua