View Single Post
Old 07-09-2018, 09:42 PM   #32
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@BeckyEBook...

prefs['add_chapter_template'] = 'Chapter'

In the plugin, the Add heading name template textbox is initially initialized to 'Chapter' in the dialog itself and is re-populated later if there is an appropriate existing value in prefs. After the OK button is pressed the user-entered dialog value is then saved to prefs. The main reason I initialize this option to either 'Chapter' for file group selections or 'Preface' for single file selections is to give the plugin user a helpful indication of what should be put into the textbox. Perhaps I should've initialized it to "e.g. Chapter" or "e.g. Preface" but I think that looks a bit ugly.

Quote:
2. Ignore template if "Use numbered headings only" is enabled
(Perhaps I do not understand this option, but if ... numbered ... only – ignoring is a good idea.)
File: cutils.py (approx. 250 line, before the first use of SUFFIX_CHOICE).

Code:
Code:
                if options.NUM_HEADINGS_CHOICE  == 'Yes':
                    options.SUFFIX_CHOICE = ''
There are two similar python functions found in cutils.py in the plugin code that you can have a look at. One is called AddSelectedHeading()(handler for single file selections) and the other is called AddSelectedHeadings()(handler for multi-file group selections). Both these functions basically build the new heading text line on the fly according to dialog user inputs and then it just inserts the heading line at the top of the file(after the body tag).

When Use numbered headings only is selected, the numbering part of the heading is normally generated and added separately to the heading line from a straightforward ascending count(according to the selected file count) and then styled accordingly. And in the code in AddSelectedHeadings(), the new heading line is progressively built and, in the numbered-headings-only handler, you'll see that the heading text name is removed before the numbered heading line is rebuilt -- so the heading name is removed anyway. And don't forget that the Use numbered heading ony option also works together with the Select chapter number style option to determine what numbering style is used for numbered headings only. If you have a look at that function I've mentioned, that should more clearly help your understanding of how numbered headings are added and progressively formatted and styled.

Last edited by slowsmile; 07-09-2018 at 11:22 PM.
slowsmile is offline   Reply With Quote