Quote:
Originally Posted by carmenchu
Well: so far, in 'non greedy' mode,
(?<=\>)\b([^<]+)(?=\</) selects between tags, not nested
(?<=\>)\b([^<]+)(?=\<) skips tags.
Useful when the mouse gets temperamental, and one wishes to manually extract/move some text.
 for the Sigil User Guide and the links to regex references
|
If you have basic programming skills, you could also write an ad-hoc Sigil plugin using the
BeautifulSoup library, which is bundled with Sigil, to manipulate tags. (The Sigil API documentation is
here.)
This will save you the hassle of coming up with complex regular expressions.
For example the following minimal plugin code:
will look for span tags with a Calibre13 class and replace them with <b> tags. (All other <span> tags will be deleted.)
Before:
Code:
<p>This should be <span class="Calibre6 Calibre13 Calibre2">bolded</span>. <span class="Calibre2">This span is redundant</span> <span>and this span should also be deleted.</span></p>
After:
Code:
<p>This should be <b>bolded</b>. This span is redundant and this span should also be deleted.</p>
If you want to test the plugin code:
- Create a MyPlugin folder in the Sigil plugins folder
- Save the plugin code as plugin.py in that folder.
- Create a plugin.xml file with the following contents:
and also save it in the MyPlugin folder.
(To run the plugin, select Plugins > Edit > MyPlugin.)