Background: I used quill.js to get some rich text input. The result I want is quite similar to HTML so I went with the quill.container.firstChild.innerHTML
approach instead of actually serializing the data. But when it comes to anchor, instead of
<a href="test.html">Anchor</a>
I actually want
Anchor{{link:test.html}}
With .replace() method I easily got {{link:test.html}}Anchor</a>
but I need to put the link description after the Anchor text. Is there a way to swap {{link:test.html}}
with the next </a>
so I can get the desired result? There can be multiple anchors in the string, like:
str = 'This is a <a href="test1.html">test</a>. And <a href="test2.html">another one</a> here.'
I would like it to become:
str = 'This is a test{{link:test1.html}}. And another one{{link:test2.html}} here.'