Thursday, January 7, 2016

[SIGIL] - Replace link with regex

Add anchor value after link URL

Working with Sigil [ePUB editor] and need to add anchor and value after link URL. The value is the same is this same inside title attribute for element "a".
Have this:
<dt id="note_758" class="calibre23">[<a title="758" href="../META-INF/page.xhtml" class="calibre24">←758</a>]</dt>

And need that:
<dt id="note_758" class="calibre23">[<a title="758" href="../META-INF/page.xhtml#758" class="calibre24">←758</a>]</dt>

Using regex to find and replace
find: title=\"(\d+)\" href=\"..\/META-INF\/titlepage.xhtml\"

replace with: title="\1" href="../META-INF/titlepage.xhtml#\1"

No comments :

Post a Comment