06-26-2018, 07:30 AM | #1 |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
inserting sequential text
Is there any method, plugin, etc that will insert sequential text?
Specifically, I'd like to insert <h2>Chapter 1</h2> in file chap01.html <h2>Chapter 2</h2> in file chap02.html etc., at the top of each file. Or is there a way to refer to the name of the html file in the S&R regex? Then it would be simple to build the text. Last edited by AlanHK; 06-26-2018 at 08:48 AM. |
06-26-2018, 06:02 PM | #2 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I've used creative regex before to do this, but Doitsu made a plugin called "AddIDs - Generates incremental ids" that can easily add an incremental ID to some tag, like <h2>. Then it's really easy to regex those into Text between the tags.
Although, being able to reference the filename would be awesome too. |
Advert | |
|
06-26-2018, 10:03 PM | #3 |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
|
06-30-2018, 07:50 AM | #4 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
AlanHK...I had some spare time today so I wrote a quick and dirty plugin to try and solve your sequential chapter heading problem. It's a small plugin and please be aware that I haven't tested it that thoroughly. But it seems to work without any major problems.
The plugin does the following: * It inserts chapter headings in the relevant epub xhtml files according to your mark up.(See Plugin Run for details) * It inserts the chapter headings and chapter numbering(consecutively) per xhtml file in Sigil's Book Browser. * This plugin should work on both epubs and imported html docs. * The dialog allows the user to type in and add the "chapter" part of the heading either in title case, lower case or upper case i.e. whatever you type into the "Type heading suffix" dialog textbox will be used as the main heading throughout. * The dialog also allows the user to select either numeric chapter headings or chapter headings that use roman numerals. You are only allowed to have a maximum of 50 chapters in your epub if you use chapter headings with roman numerals, otherwise there will be errors. * Depending on whether you use h1 or h2 heading styles, be sure that the styles for these headings are already properly defined by you in the css otherwise their default styling will be used. This plugin does not add or change any styling in the css. Plugin run Before you run this plugin you must first use a marker that you can insert in Sigil's Book View to denote the required locations of your chapter headings in each of the xhtml files. The following two symbols must be used together as the marker for the chapter heading locations -- @#(at + hash symbols). Use the latter symbols to mark where you want your consecutively numbered chapter headings to be placed. After you do this just run the plugin and the headings will be automatically added and formatted according to your mark-up and dialog choices. Lastly, I'm not intending to release this plugin properly unless more people ask me to do so on this thread. I say this because I honestly can't see many other Sigil users being that interested in this plugin. Last edited by slowsmile; 07-01-2018 at 07:46 PM. |
06-30-2018, 12:39 PM | #5 | |
Well trained by Cats
Posts: 29,768
Karma: 54401244
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Request: allow a class= value to be assigned (and saved) the the Header type. Default is as it is. |
|
Advert | |
|
06-30-2018, 07:03 PM | #6 | ||
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
@theducks
Quote:
Quote:
Last edited by slowsmile; 06-30-2018 at 07:16 PM. |
||
06-30-2018, 07:28 PM | #7 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
I've had a quick rethink about the AddChapterHeadings plugin. I've realized that, apart from it's other features, it is the only plugin that can automatically change and consecutively add chapter headings either numerically or using roman numerals to your epub. So I probably will put it out as a proper release eventually because the plugin appears to be more useful than I'd previously realized.
Last edited by slowsmile; 06-30-2018 at 09:11 PM. |
07-01-2018, 12:04 AM | #8 |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Thanks for this.
If you're going to make it a "real" release, there should be an option for numbers as words, and that in different upper/lower/mixed cases (ONE / One /one). |
07-01-2018, 12:37 AM | #9 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
@AlanHK...I must admit that I only ever envisaged creating a plugin for just your problem which was limited to a plugin that only provided consecutive chapter numerics. That was your original proposal for a new plugin. Hopefully that has been satisfied.
Regarding your new suggestions, I'll have a look and see what I can do. And if I can't implement your suggested changes -- to make it a "real " release -- I think I will also take your advice and defer releasing the above plugin as a proper release. I think that's fair. This also means that there will be no further updates to the current plugin because it is not, as you have already said, a "real" release. Last edited by slowsmile; 07-01-2018 at 12:59 AM. |
07-01-2018, 01:02 AM | #10 | |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
Personally, I had already solved my problem. As above though, others would have more use for it, those who create books from scratch more than converting or editing as I mostly do. My post was just prompted by a book that was just one long text file that I thought really needed to be broken up, for aesthetic as well as practical reasons. Certainly many books do number chapters in words. There are python libraries, e.g. https://pypi.org/project/num2words/ Otherwise, I notice the zip file includes the readme for "AddKindleMediaQueries" which is no doubt a relic from another project. |
|
07-01-2018, 02:23 AM | #11 | |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
@AlanHK...
Quote:
And no, I'm not going to change the plugin because, as you've said, it's not a "real" release. Last edited by slowsmile; 07-01-2018 at 04:30 AM. |
|
07-01-2018, 02:03 PM | #12 | |
Bibliophagist
Posts: 35,270
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Last edited by DNSB; 07-01-2018 at 04:58 PM. |
|
07-01-2018, 07:18 PM | #13 |
Witchman
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
|
@DNSB...I'm currently cleaning up the plugin before general release. I also need to finish it off properly(with proper error checks added etc) and test it properly because I coded it so quickly. So this plugin will be properly released soon.
The plugin now allows the user to add or replace and separately reformat the 'chapter' header part and consecutive chapter number part in any style they prefer i.e. numeric string(chapter 1, Chapter 10, CHAPTER 23 etc), number as text(chapter one , Chapter Fifteen or CHAPTER TWENTY-THREE) or roman numerals(chapter II, Chapter XXIX, CHAPTER XXXIV). Last edited by slowsmile; 07-01-2018 at 08:42 PM. |
07-02-2018, 11:42 PM | #14 | ||||
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
Try not to take a critique of your code as a mortal insult. Quote:
"AddIDs" had already solved my problem, as I acknowledged 3 days before you posted. Since several others have said your plugin could have a wider application, my remarks were in the context of making something for general use, not a bespoke application. Quote:
I was polite in every post. I thanked you. Yet you find a way to take offence at everything I say. Again, a critique is not a "complaint". Quote:
But I'm an ungrateful **** for making the suggestion. Last edited by AlanHK; 07-03-2018 at 12:14 AM. |
||||
07-03-2018, 02:31 AM | #15 |
Hedge Wizard
Posts: 800
Karma: 19999999
Join Date: May 2011
Location: UK/Philippines
Device: Kobo Touch, Nook Simple
|
Nice plugin. I will certainly download it. I do not think I will have to use it often nut it will be a godsend for those books that need it.
Last edited by Thasaidon; 07-03-2018 at 02:31 AM. Reason: typo |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to Assign Sequential Numbers to Series Index | American_Desi | Calibre | 3 | 04-19-2018 07:47 PM |
Sequential Posting | issybird | Feedback | 12 | 03-03-2015 05:49 PM |
Inserting a jpeg into a PM | Lynx-lynx | Feedback | 11 | 12-24-2014 06:17 AM |
Sequential entries in Title field | rlh3 | Library Management | 5 | 03-10-2013 11:12 PM |
Sequential numbers regex? | soparch | Sigil | 7 | 10-10-2011 05:51 AM |