I try to place the line "name: *****" just after the corresponding (innermost containing) "ul" each time an "ul" appears, so that it looks like this:
Before:
<ul>
<ul>
<li href="https://www.deepl.com/translator">DeepL</li>
<li href="https://translate.google.com">Google Trad</li>
name: "Translate",
</ul>
<li href="https://www.youtube.com/feed/subscriptions">Youtube</li>
<ul>
<li href="https://www.facebook.com/">Facebook</li>
<li href="https://twitter.com/">Twitter</li>
<li href="https://www.instagram.com">Instagram</li>
<li href="https://discordapp.com">Discord</li>
name: "Network",
</ul>
name: "Fav",
</ul>
After:
<ul>
name: "Fav",
<ul>
name: "Translate",
<li href="https://www.deepl.com/translator">DeepL</li>
<li href="https://translate.google.com">Google Trad</li>
</ul>
<li href="https://www.youtube.com/feed/subscriptions">Youtube</li>
<ul>
name: "Network",
<li href="https://www.facebook.com/">Facebook</li>
<li href="https://twitter.com/">Twitter</li>
<li href="https://www.instagram.com">Instagram</li>
<li href="https://discordapp.com">Discord</li>
</ul>
</ul>
So, I already tested a lot of things, like this:
sed -i -e 'N;s/<ul>\([.\n]*\)\n\(.*\),/\2\n\1' fav.html
This and all I found to now doesn't work because the "name" following the last "ul" is not always the one to replace. If anyone has an idea, I'd be happy to hear it.