Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 07-22-2023, 05:54 AM   #1
repilo
Enthusiast
repilo began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Apr 2021
Location: Spain
Device: Kobo Libra 2
Nested span, clean

Please, how can I, using regex, select the text between an opening tag of a div or span and its corresponding closing tag, without confusing it with the closing of another element nested inside it?
I would like to remove "span" tags without causing errors, i.e. taking into account other "span" tags nested inside them, for example in:
Code:
<span class="txt">Lorem <span class="italic">ipsum</span> dolor</span>
Can this be done via regex with Sigil?
The best I know how to do so far is:
Search: <span class="txt">([^<]+)</span>
Replace: \1
Thanks for your help.
repilo is offline   Reply With Quote
Old 07-22-2023, 08:04 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Use the TagMechanic plugin that is set up to handle just that.

https://www.mobileread.com/forums/sh...d.php?t=270639

You can find a set of useful free plugins here:

https://www.mobileread.com/forums/sh...d.php?t=247431

Last edited by KevinH; 07-22-2023 at 10:08 AM.
KevinH is offline   Reply With Quote
Advert
Old 07-22-2023, 05:22 PM   #3
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Yes, TagMechanic is the best way to clean up all that HTML + <span> cruft.

I wrote multiple TagMechanic tutorials and linked to many more helpful topics of mine a few months ago in:
Tex2002ans is offline   Reply With Quote
Old 07-24-2023, 02:31 PM   #4
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
Quote:
Originally Posted by Tex2002ans View Post
Yes, TagMechanic is the best way to clean up all that HTML + <span> cruft.
I use the last release of Microsoft Expression Web to do all the tag-related stuff...nothing else comes close to its power.

Being able to find a tag by one or more of:
  • attribute existence or value (including regex search)
  • contained/not contained inside another tag
  • containing text (including regex)
with all of this infinitely nested when "contained inside tag" is used, and then doing one of:
  • Remove the tag
  • Change the tag
  • Remove an attribute
  • Set an attribute value
  • Remove the tag and contents
  • Replace the tag and contents
  • Replace contents only
  • Add before/after beginning/ending tag
The only thing that isn't really covered is changing the outermost tag where you only want to change it when it contains another tag with specific details.
nabsltd is offline   Reply With Quote
Old 07-24-2023, 04:10 PM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
I think the op was looking for a Sigil based solution according his/her query. Can you use Microsoft Expression Web with Sigil's OpenWith or does it need access to all files in the epub at the same time?
KevinH is offline   Reply With Quote
Advert
Old 07-24-2023, 05:05 PM   #6
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,498
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
For what it may be worth, Microsoft Expression Web was discontinued over a decade ago. I vaguely remember some of the web devs using it for web page development before they moved on to better tools with fewer oddities.
DNSB is offline   Reply With Quote
Old 07-25-2023, 10:39 AM   #7
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
Quote:
Originally Posted by KevinH View Post
Can you use Microsoft Expression Web with Sigil's OpenWith or does it need access to all files in the epub at the same time?
It works fine with Open With, since Sigil passes the file from the "workspace" directory, which allows it to see all the files. This means the CSS file is available, which allows Expression to show a preview if you need it.

Quote:
Originally Posted by DNSB View Post
For what it may be worth, Microsoft Expression Web was discontinued over a decade ago. I vaguely remember some of the web devs using it for web page development before they moved on to better tools with fewer oddities.
It is not good for building a whole website, and editing in the WYSIWYG "Design" view can lead to bad formatting. PHP is the most "modern" server-side language it understands.

But, as a standalone HTML and CSS editor, it has better features than the more recent MS releases (Visual Studio and Visual Studio Code). In particular, it is much better at not needing a "project" to have features like HTML/CSS linking. This makes it much better for touch-ups of ePub.

I use the Calibre editor, Microsoft Expression Web ("Unpack Book" from within Calibre), and Sigil. All have their strengths and weaknesses, but if I had to stop using any one of them, it would be a pain for my editing chain.
nabsltd is offline   Reply With Quote
Old 07-25-2023, 11:24 AM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Actually, If you are changing files via OpenWith outside of the current file, to guarantee it to work properly, Sigil must install a filewatcher on each file. Right now Sigil only does that for the target file. That is why a separate interface for PageEdit (External XHTML Editor) was developed.

If you do not need or use PageEdit, you may want to use that method to better/safer run Microsoft Expression from Sigil.
KevinH is offline   Reply With Quote
Old 07-26-2023, 10:31 AM   #9
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
Quote:
Originally Posted by KevinH View Post
Actually, If you are changing files via OpenWith outside of the current file, to guarantee it to work properly, Sigil must install a filewatcher on each file.
I was talking more about Expression being able to see the CSS and image files and display its preview correctly.

If someone wanted to use the power of Expression's search and replace on all files in an ePub, I'd always recommend using "Unpack Book" from Calibre.
nabsltd is offline   Reply With Quote
Old 07-26-2023, 11:40 AM   #10
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
Or you could just use the external XEditor interface in Sigil that PageEdit uses.
KevinH is offline   Reply With Quote
Old 07-26-2023, 11:47 AM   #11
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by nabsltd View Post
If someone wanted to use the power of Expression's search and replace on all files in an ePub, I'd always recommend using "Unpack Book" from Calibre.
Or the FolderIn/FolderOut Sigil plugins.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Span Span Span Sigil cleaning up indesign blackest Sigil 31 12-06-2017 10:16 AM
KT3: nested (or even un-nested) document collections? milo1984 Amazon Kindle 1 12-24-2016 02:09 PM
Nested Span? Turtle91 ePub 4 05-20-2013 02:47 PM
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 BrianMartinez Kindle Books 0 12-13-2010 09:25 PM
Short Fiction Martinez, Brian: A Good Clean, A Harsh Clean. v1. 13th Dec 2010 BrianMartinez ePub Books 0 12-13-2010 09:23 PM


All times are GMT -4. The time now is 12:59 PM.


MobileRead.com is a privately owned, operated and funded community.