![]() |
#1 |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
![]()
I need some help with my problem. I don't have any knowledge of programming and I want to put many id in a epub file.
in my file i have this: <p class="calibre2"><sup class="calibre3">45</sup> and i want to put this <a name= "#v15004045"></a>45 i have to make 45 id. <p class="calibre2"><sup class="calibre3">4</sup> will be <p class="calibre2"><sup class="calibre3"><a name= "#v15004045"></a>4</sup> Is that right? How can i do it? Is there an automatic way to do this? |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
ids should be unique -- how are you distinguishing them!
![]() If the targets already contain the number, use a regex that captures the number, and replaces it in the id. Can you show examples that indicate how the ids should be constructed. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Jul 2015
Device: none
|
are you trying to make internal links to a different part of the document?
idk what function name="" has but according to this its not a supported function of 'a' Taking a guess at what your asking, if you want 4 to link to 45, then 4 needs a url that points to the 45 id, like <p class="calibre2"><sup class="calibre3" id="v15004045">45</sup></p> <p class="calibre2"><a href="part0000.html#v15004045">4</a></p> just swap part0000.html with whatever file 45 is located in with your doc Last edited by ni_c; 09-14-2015 at 05:01 AM. |
![]() |
![]() |
![]() |
#4 |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
My epub file has 17 chapters:
v3001.html v3002.html ....... v30017.html Every chapter has almost 24 paragraph with this html: <p class="calibre2"><sup class="calibre3">1</sup> <p class="calibre2"><sup class="calibre3">2</sup> ..... <p class="calibre2"><sup class="calibre3">24</sup> Is there a way to add in every paragraph a bookmark or id like this: id="id v3001001" id="id v3001002" ...... id="id v3001024" The final string it should be: <p id="id v3001001" class="calibre1"><sup class="calibre2">1</sup> <p id="id v3001002" class="calibre1"><sup class="calibre2">2</sup> .... <p id="id v3001024" class="calibre1"><sup class="calibre2">24</sup> In other word the string should read chapter name (v3001, v3002... v3014) and add paragraph number (001, 002... 024) and the final result (v3001001, v3001002... v3001024) and all this in every chapter (v3017001, v3017002... v3017024). Any suggestion? Can anyone tell me que regular expression or is there another way? Thank you. Last edited by geniale; 09-14-2015 at 06:02 AM. |
![]() |
![]() |
![]() |
#5 |
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Jul 2015
Device: none
|
really does sound like a huge task, and the toc.ncx alone would freak me out, id tackle it if it were my job, but for personal use not my style. Would suggest waiting for Kovid for his opinion.
btw pretty sure id's dont work with blank spaces added, would wanto add an underscore or dash to join them like "id_v..." good luck |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
![]() Quote:
Thanks for your answer!! I imagine that it looks like a huge task but if you look from another angle i think you have the solution. You know regular expression formulas but i don't. Could you answer me 3 questions? 1. how can i extract the v3001.html with a regular expresion? 2. how can i extract the 1, 2, 3 or 4 of a paragraph and put it in a 000 format 3. how can i put this two in <p class="calibre2"><sup class="calibre3">1</sup> I need something like this: <p id="v3001001" class="calibre1"><sup class="calibre2">1</sup> <p id="v3001002" class="calibre1"><sup class="calibre2">2</sup> ....... <p id="v3001024" class="calibre1"><sup class="calibre2">24</sup> or <p class="calibre1"><sup class="calibre2" id="v3001001">1</sup> <p class="calibre1"><sup class="calibre2" id="v3001002">2</sup> ......... <p class="calibre1"><sup class="calibre2" id="v3001024">24</sup> Which formulas i have to use? |
|
![]() |
![]() |
![]() |
#7 |
The Fumbler
![]() Posts: 66
Karma: 10
Join Date: Jun 2015
Device: android 4.2/fbreader
|
If I understand correctly, you could try this.
In the search window, make sure that "regex" and "current file" are selected. Search for: <p class="calibre2"><sup class="calibre3">(.*?)</sup> Replace with: <p id="id_v300100\1" class="calibre1"><sup class="calibre2">\1</sup> Run this for chapter 1. Change id_v3001 to "id_v3002" in the replace string. Run this for chapter 2. etc. With the info you provided I don't see any alternative but to run this once for each chapter. I haven't tested this, but it should work. |
![]() |
![]() |
![]() |
#8 | |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
![]() Quote:
Thanks for your answer. Only that there is a problem. from 1 to 9 the result is: <p id="v3001001" class="calibre1"><sup class="calibre2">\1</sup> from 10 to 99 the result is: <p id="v30010099" class="calibre1"><sup class="calibre2">\1</sup> from 100 to 999 the result is: <p id="v300100999" class="calibre1"><sup class="calibre2">\1</sup> I need an id of only 7 numbers. There are 8 numbers in case of 99, and there are 9 numbers in case of 999. Has anyone else another idea to change ALL the chapters with ONE regular expression? |
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
It's possible that the Function Mode can do something. There is an example to allow automatic numbering within the matches. Adapting that might work. |
|
![]() |
![]() |
![]() |
#10 | |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
![]() Quote:
![]() |
|
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
Why is it essential to have an Id that is always exactly seven numbers.
Why are you complaining about case 999 when you have said that 24 is your largest value. Why does all have to be done in one single expression and not in multiple passes. It seems you turn each offered help into a Not Good Enough gripe. Buy a regex programming book. Or...Convert back to Word doc and fix it there. Or, convert to Kepub which adds Id to every paragraph anyway.... Or continue to try people's patience... |
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
PS. A 2nd regex shrinking all eight number Id back to seven is simple to write. Please explain why, if that is not acceptable.
no sense in bothering giving you that code if it does not meet your ridiculous one pass criteria |
![]() |
![]() |
![]() |
#13 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Did you look at the link? It is the help for the function mode and has examples. Including, as I said, an example for automatically numbering. Beyond that, I can't say much as I haven't used it much myself.
|
![]() |
![]() |
![]() |
#14 | |
Member
![]() Posts: 14
Karma: 10
Join Date: Sep 2015
Device: none
|
![]() Quote:
I only asked if there is the posibility to insert an id of 7 numbers with this format v0000000 (1 book, 3 chapter, 3 paragraf) and where the las 3 numbers are for the paragraph. I need this id for an android program that uses that format. The HTML files after making that changes i will copy-paste to the folder of this APP. I have more than 550 parragraphs. Once again sorry!!!!!! |
|
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
Ok , I would do it in stages. Generate the para numbers, then add the chapter numbers. Something like MS Word has extensive numbering tools, for creating scientific papers, so do most of the work before making the e pub, maybe.
And ask the folks who sold you the app for tools to assist. What is the app? |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
More than 3 regular expression? | james968 | Conversion | 1 | 04-04-2012 05:39 AM |
Regular Expression Help | iKarampa | Calibre | 13 | 12-15-2010 07:17 AM |
Regular expression help | krendk | Calibre | 4 | 12-04-2010 04:32 PM |
Regular Expression Help | smartmart | Calibre | 5 | 10-17-2010 05:19 AM |
Help with the regular expression | Dysonco | Calibre | 9 | 03-22-2010 10:45 PM |