Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 06-02-2012, 03:08 PM   #16
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,199
Karma: 4800739
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Calibre does some flattening to the CSS which, I believe, means it turns every selector into a class... Of course I'm not suggesting this should be done in Sigil, but maybe the "logic" behind that can be used to check the styles?
Jellby is offline   Reply With Quote
Old 06-04-2012, 02:11 AM   #17
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
I use Linux primarily; this is what I use sometimes; it's hackish, not so elegant and it doesn't take into account css rules for HTML tags, e.g.:
h2 {font-size: xx-large;}

so only css rules for .foo in e.g. <h2 class="foo">.

Code:
$ cd OEBPS/Text
$ pcregrep -o -h 'class=".+?"' * | sort -u | perl -p -e 's/class="//' | perl -p -e 's/("\n| )/|/' | perl -p -e 's/\|$//g'
this should produce a list of the css styles used in the html/xhtml files, something like:
Code:
ach1|acl|bmh|byline|cn|cotx|crt|crt1|crt2|custom1|da|ded|ded1|di|dia|dropcap|dt|dt1|dt3|dt4
then cd to the Styles dir and:
Code:
$ cd ../Styles
$ STRING="(ach1|acl|bmh|byline|cn|cotx|crt|crt1|crt2|custom1|da|ded|ded1|di|dia|dropcap|dt|dt1|dt3|dt4)"
$ pcregrep -N ANY -M '\.'$STRING'\s*?\{(\s*.+?)+?\s*\}' *.css
this should print all the css rules that are actually used in the book.
Ahmad Samir is offline   Reply With Quote
Old 06-07-2012, 05:47 AM   #18
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
@Ahmad Samir

Thanks for providing a very nice code.

Your first command, the list of used styles in the text, represents a good part of the answer. Would it be possible to add, for each of the listed styles, the occurrences of each of them?

I mean, to get a list of this kind: |Italdroite 25|Header 12| and so on...
We could focus later on the least used items.

Spoiler:

Code:
roger@lmde64 ~/Bureau/Coups/OEBPS/Text $ pcregrep -o -h 'class=".+?"' * | sort -u | perl -p -e 's/class="//' | perl -p -e 's/("\n| )/|/' | perl -p -e 's/\|$//g'
Centrage|Chanson|frameFrame|Header|Heading|Italdroite|let|let1|let2|smcpCentrage|smcpChanson|smcpDroite|smcpIncise|smcpTypeA|smcpTypeV|Standard|Subtitleroger@lmde64 ~/Bureau/Coups/OEBPS/Text $

I did not find the second one so useful: it somewhat replicates the style sheet and is a little too verbose, or, more probably, I missed something...

Last edited by roger64; 06-07-2012 at 05:50 AM.
roger64 is offline   Reply With Quote
Old 06-07-2012, 08:48 AM   #19
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
The second command is supposed to print only the css rules that appeared in the output of the first command... that's how it usually works here.

To get a count of the occurrences of each class, you can use something like:
Code:
for i in $(pcregrep -o -h 'class=".+?"' * | sort -u); do echo "$i $(grep -r $i | wc -l)"; done | sort -t ' ' -k2 -nr
this should print a list sorted in a descending order based on the occurrences count, something like:
Code:
class="di" 54
class="body" 52
class="toccn" 50
class="dropcap" 44
class="cotx" 44
class="cn" 44
class="acl" 14
class="p3" 6
class="crt1" 5
class="ull" 4
class="crt" 4
class="pt" 3
Ahmad Samir is offline   Reply With Quote
Old 06-07-2012, 10:13 AM   #20
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo


This is exactly what I had been wishing for! The only problem... I cannot get it working this time. After half a minute, the terminal freezes and I get no result.
roger64 is offline   Reply With Quote
Old 06-07-2012, 10:55 AM   #21
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
Quote:
Originally Posted by roger64 View Post


This is exactly what I had been wishing for! The only problem... I cannot get it working this time. After half a minute, the terminal freezes and I get no result.
Freeze or just not giving any output? i.e. if you press Ctrl+C does the prompt return?
Ahmad Samir is offline   Reply With Quote
Old 06-07-2012, 11:11 AM   #22
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
Quote:
Originally Posted by Ahmad Samir View Post
Freeze or just not giving any output? i.e. if you press Ctrl+C does the prompt return?
More exactly, after ten seconds the cursor stops blinking and nothing seems to happen anymore, even if I wait 2, 3 minutes.

I can return to the prompt with Ctrl+C at any time.
roger64 is offline   Reply With Quote
Old 06-07-2012, 11:22 AM   #23
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
Quote:
Originally Posted by roger64 View Post
More exactly, after ten seconds the cursor stops blinking and nothing seems to happen anymore, even if I wait 2, 3 minutes.

I can return to the prompt with Ctrl+C at any time.
Does this give any output:
pcregrep -o -h 'class=".+?"' * | sort -u
Ahmad Samir is offline   Reply With Quote
Old 06-07-2012, 11:24 AM   #24
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 37,713
Karma: 18475602
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Quote:
Originally Posted by Jabby View Post
Doing an epub to epub conversion in Calibre you will clean the style sheet of unused stuff and put it in alphabetical order to boot. I have been surprised, more than a few times, that Calibre will catch some of my typos and create new labels for me that I can then clean up.

Regards - John
Very bad idea to do ePub > ePub. Not only can it change your styles so you no longer know what's what, it can introduce other things you may not want. Don't do it. Use Sigil to clean up the code. But don't convert.
JSWolf is offline   Reply With Quote
Old 06-07-2012, 11:44 AM   #25
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
Immediate result:

roger@lmde64 ~/Bureau/Coups/OEBPS/Text $ pcregrep -o -h 'class=".+?"' * | sort -u
class="Centrage"
class="Chanson"
class="frameFrame"
class="Header"
class="Heading"
class="Italdroite"
class="let"
class="let1"
class="let2"
class="smcpCentrage"
class="smcpChanson"
class="smcpDroite"
class="smcpIncise"
class="smcpTypeA"
class="smcpTypeV"
class="Standard"
class="Subtitle"
roger@lmde64 ~/Bureau/Coups/OEBPS/Text $
roger64 is offline   Reply With Quote
Old 06-08-2012, 01:51 AM   #26
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
Here is a solution for the above post coming straight from a Linux forum.
I have been told that problem was that grep was reading on stdin (for whatever it means...)

Spoiler:

Code:
pcregrep -o -h 'class=".+?"' * >fic_tmp.$$
for i in $(sort -u fic_tmp.$$); do echo "$i $(grep -rc $i fic_tmp.$$)"; done | sort -t ' ' -k2 -nr
Tried on one EPUB of mine.

Code:
roger@lmde64 ~/Bureau/Coups/OEBPS/Text $ pcregrep -o -h 'class=".+?"' * >fic_tmp.$$
roger@lmde64 ~/Bureau/Coups/OEBPS/Text $ for i in $(sort -u fic_tmp.$$); do echo "$i $(grep -rc $i fic_tmp.$$)"; done | sort -t ' ' -k2 -nr
class="smcpIncise" 225
class="smcpCentrage" 57
class="Header" 54
class="let" 35
class="let2" 35
class="let1" 35
class="Standard" 28
class="Centrage" 24
class="smcpTypeA" 17
class="smcpTypeV" 16
class="smcpDroite" 16
class="Subtitle" 5
class="Italdroite" 5
class="Heading" 2
class="smcpChanson" 1
class="frameFrame" 1
class="Chanson" 1
roger@lmde64 ~/Bureau/Coups/OEBPS/Text $

The result provides needed information (classes only).

Last edited by roger64; 06-08-2012 at 01:59 AM.
roger64 is offline   Reply With Quote
Old 06-08-2012, 03:35 AM   #27
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
Quote:
Originally Posted by roger64 View Post
Here is a solution for the above post coming straight from a Linux forum.
I have been told that problem was that grep was reading on stdin (for whatever it means...)
Glad it's working for you now. 'grep -r' seems to work here, but of course 'grep -rc $i' is a better/more elegant solution than 'grep -r $i | wc -l'.
Ahmad Samir is offline   Reply With Quote
Old 06-08-2012, 05:40 AM   #28
mmat1
Det
mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.
 
mmat1's Avatar
 
Posts: 980
Karma: 1300318
Join Date: Jan 2012
Location: Zischebattem
Device: Acer Lumiread
I made a small Excel-Tool wich reads the files in Sigil's "scratchpad" and covers most of the requested features.

Do you Work with Linux only ?

Maybe somebody find's it useful ...

-------------------------------
edit 12.10.2012: Attachment removed. Sigil has now some great new features, making this one obsolete.

Last edited by mmat1; 10-12-2012 at 01:06 PM. Reason: Update to version 3.1
mmat1 is offline   Reply With Quote
Old 06-08-2012, 07:35 AM   #29
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 1,450
Karma: 846401
Join Date: Jan 2009
Device: KoboGlo
Quote:
Originally Posted by mmat1 View Post
I made a small Excel-Tool wich reads the files in Sigil's "scratchpad" and covers most of the requested features.

Do you Work with Linux only ?

Maybe somebody find's it useful ...
Looks very nice. For sure, Ahmad will get it working...

On Linux, scratchpad Sigil temp files are here: /tmp/Sigil/scratchpad. Nothing too confusing about it.
I did authorize your macros on OpenOffice, but nothing happened when I clicked on Analyze.
Maybe it's coming from OpenOffice, maybe from permissions, probably from me... Anyway, I'm used to see things never working at first try.

Which string did you use to search for the tags?

Last edited by roger64; 06-08-2012 at 07:37 AM.
roger64 is offline   Reply With Quote
Old 06-08-2012, 10:14 AM   #30
mmat1
Det
mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.
 
mmat1's Avatar
 
Posts: 980
Karma: 1300318
Join Date: Jan 2012
Location: Zischebattem
Device: Acer Lumiread
Quote:
Originally Posted by roger64 View Post
On Linux, scratchpad Sigil temp files are here: /tmp/Sigil/scratchpad. Nothing too confusing about it.
I did authorize your macros on OpenOffice, but nothing happened when I clicked on Analyze.
afaik youll have to create a new button in OO, since buttons are converted to pictures without function.

I wonder if this thing will work under LO/OO in Linux ...

Quote:
Originally Posted by roger64 View Post
Which string did you use to search for the tags?
This is not understood.
Maybe this is a correct answer: It searches for everything which follows a < and is not preceeded by a /. Must-have tags ("html", "body") are omitted in most cases. And it searches for the contents of class=".*?"
mmat1 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Buy Broken or unused readers for the Museum eBookLuke Flea Market 14 05-06-2012 11:30 AM
Free Broken or unused readers for the Museum eBookLuke Flea Market 0 05-22-2011 06:52 AM
How often should an unused Kobo be charged? Gary_M_Mugford Kobo Reader 2 10-30-2010 10:38 PM
Unutterably Silly Zelda's gallery of used and unused avatars Wetdogeared Lounge 40 05-16-2009 11:31 AM
iLiad The six unused connections design256 iRex Developer's Corner 10 09-13-2006 08:52 AM


All times are GMT -4. The time now is 06:58 AM.


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