Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 12-16-2012, 08:51 AM   #1
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
Question help removing nested blockquotes please

I have not mastered how to do multi-line regex yet with the current engine.

I want to strip all but one layer of all blockquote nestings e.g,
go from 2 or more level deep like this
<blockquote class="a">
<blockquote class="a">
<blockquote class="a">
<p class="text">some text here</p>
</blockquote>
</blockquote>
</blockquote>

and reduce it to
<blockquote class="a">
<p class="text">some text here</p>
</blockquote>

i figure that the regex only needs to shrink 2 layers to 1, then if it is run multiple times it will progressively strip layers until only single layers remain.
assume also that I can by inspection insert the appropriate class names into the regex

I tried find
<blockquote class="calibre11">\s*<blockquote class="calibre11">(.*)</blockquote>\s*</blockquote>
with a suitable replace all, but it did not fully automate.( it seemed to only do one instance, evenwhen I said replace all) ; also I was not sure if I needed to tick any options e.g. Dotall
cybmole is offline   Reply With Quote
Old 12-16-2012, 10:13 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,003
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by cybmole View Post
I have not mastered how to do multi-line regex yet with the current engine.

I want to strip all but one layer of all blockquote nestings e.g,
go from 2 or more level deep like this
<blockquote class="a">
<blockquote class="a">
<blockquote class="a">
<p class="text">some text here</p>
</blockquote>
</blockquote>
</blockquote>

and reduce it to
<blockquote class="a">
<p class="text">some text here</p>
</blockquote>

i figure that the regex only needs to shrink 2 layers to 1, then if it is run multiple times it will progressively strip layers until only single layers remain.
assume also that I can by inspection insert the appropriate class names into the regex

I tried find
<blockquote class="calibre11">\s*<blockquote class="calibre11">(.*)</blockquote>\s*</blockquote>
with a suitable replace all, but it did not fully automate.( it seemed to only do one instance, evenwhen I said replace all) ; also I was not sure if I needed to tick any options e.g. Dotall
I got in the habit of starting with: (?sm)

(?sm)(?<blockquote class="a">\s+){2,}(.+?)(?</blockquote>\s+){2,}

replace is \2 <====

I only remove Nested BQ's the {2,}
theducks is offline   Reply With Quote
Advert
Old 12-16-2012, 10:18 AM   #3
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
OK - so the {2,} says to only match 2 or more occurrences.

what does the initial (?sm) do , please.

if I plan on keeping one level of block quote, that needs to be in the replace also , I assume,

just replace \2 will remove all the blockquotes & leave only the text
cybmole is offline   Reply With Quote
Old 12-16-2012, 10:42 AM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,003
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by cybmole View Post
OK - so the {2,} says to only match 2 or more occurrences.

what does the initial (?sm) do , please.

if I plan on keeping one level of block quote, that needs to be in the replace also , I assume,

just replace \2 will remove all the blockquotes & leave only the text
the (?sm) is a control
m on multilines
s treat as a single line

the \2 is the second capture (.+?), so surround it with a BQ set in the replace
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering blockquotes ghostyjack ePub 6 07-17-2014 06:07 AM
need help with nested template Jade Aislin Library Management 2 11-30-2012 02:04 AM
Content nested collections alexxx Amazon Kindle 6 06-22-2010 06:05 PM
ebook publisher & blockquotes Chauncey IMP 5 02-10-2010 10:43 AM
Are Nested TOCs Possible? VikingDave Sony Reader 11 12-28-2007 07:58 PM


All times are GMT -4. The time now is 08:03 AM.


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