| 
			
			 | 
		#1 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
			
			 
				
				Suggestion: Book level variables
			 
			
			
			Potential automation capability would be to allow book level variables and some simple math to change them. 
		
	
		
		
			Keep them disguised as html comments until the resolved values are inserted with a special save, but leave the comments in the epub I'd like to see them work at the book level, across all files CSS allows intra-file numbering, but not between files. Meta-data about the epub could also be exposed. VERY simple picture attached to show 3 files (or what would be) with a ##chapnum and a ##endnotenum variable being defined on the fly and initialized Code: 
	<!--##person = "Fred"--> <!--##chapnum = 1--> <!--##endnotenum = 1--> <h1>Chapter Number <!--##chapnum--></h1> <!--##chapnum=##chapnum + 1 --> I envision the comments remaining, but only the 'inserts' actually having their values inserted after the placeholder comment Some thoughts  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			You will be able to do this (and much more powerful things) using the upcoming function mode for search and replace which will allow you to write arbitrary functions that will be called for each match during search and replace. So you would insert 
		
	
		
		
		
		
		
		
		
		
		
		
	
	<!-- chapter # --> in the text and then use <!-- chapter # --> as the search expression and the following simple function as the replace expression. Code: 
	class ChapterNumbering(object):
  def __init__(self):
     self.number = 0
  def __call__(self, match):
     self.number += 1
     return str(self.number)
function = ChapterNumbering()
And if you want to insert the chapter number after the comment instead of replacing the comment, you can do that as well, with a slight modification to the function. Note that I haven't finished designing the function mode, so some details int he above may change.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Much more powerful and flexible for sure 
		
	
		
		
		
		
		
		
		
		
		
		
	
	But ... is it too programmer-oriented to be used by the non-programmers?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Color me gone 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089 
				Karma: 1445295 
				Join Date: Apr 2008 
				Location: Central Oregon Coast 
				
				
				Device: PRS-300 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			For common functions, we will need an MR library to archive useful ones. I am not a programmer, but I can copy and paste! (grin) 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Maybe there can be some included either in help or the program itself, somehow.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#5 | |
| 
			
			
			
			 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) 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			I dont really see a way of implementing this without programming. The original proposal is also using programming, just with a special purpose programming language designed for a single use case. As time passes more such use cases will be discovered and more special purpose programming languages will have to be invented for them. At which point the user will have to learn multiple, different programming languages to perform different automated tasks. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Much better to use a single, well designed, general purpose programming language. Python (the language in question) has a very easy to learn and newbie friendly syntax. Certainly, the first few times someone uses it may be a little daunting, but providing simple examples/templates is a good way to get around that.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#7 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Can't disagree with any of the comments. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I was modeling my idea based on the very simple (and not very flexible) way the CSS content property, and the counter-increment and counter-reset properties work (except using HTML comments in-line instead of CSS.) For general-purpose-ness, will you expose book and file metadata to the function language, such as {tags} and {title} and {comments} and {filename} and {create_date}?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Yes, metadata will be available.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 Bookish 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,049 
				Karma: 2006208 
				Join Date: Jun 2011 
				
				
				
				Device: PC, t1, t2, t3, Clara BW, Clara HD, Libra 2, Libra Color, Nxtpaper 11 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Perhaps some basic functions (like the one in the code example for just incrementing chapter numbering and such) can just be included. Then only users with very specific requirements need to program their own wishes. Perhaps those users can publish their solutions as "recipes" for the benefit of others in the future.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#10 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,686 
				Karma: 12595249 
				Join Date: Jun 2009 
				Location: Madrid, Spain 
				
				
				Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			This is very similar to program mode for custom columns. There are some basic necessities, a library (quite useful as reference) and then you create your own functions (much easier to define a function than trying the "mixed" mode in my case).
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			@kovidgoyal --  
		
	
		
		
		
		
		
		
		
		
		
		
		
			A thought occurs (sometimes I get lucky) If I have an epub with inline comments, and I use the planned F&R capablity to apply changes (leaving the original comment but inserting its calculated value) would I be able to re-edit the original document? For example if I use the F&R to insert chapter numbers and then rearrange the html files (invalidating the chapter numbering) would I be able to edit the original epub and re-replace and get an updated chapter numbering? It might be worthwhile to consider allowing some very simple inline comments that are resolved into actual values Last edited by phossler; 02-17-2014 at 10:03 AM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#12 | |
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Sure you can, simply insert the number after the comment instead of replacing it. Quoting my previous post 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#13 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Understood that part, but I was asking about re-running the F&R a second time ver 1 -- Chapter <!-- chapter # --> apply F&R makes a ver 2 ... ver 2 -- Chapter <!-- chapter # -->10 So far, so good. Now if I edit ver 2 to say re-arrange files such that chap 10 should now be chap 5 (but many changes would affect the resolved value) it seems like I'd end up with ... ver 3 -- Chapter <!-- chapter # -->510 since the "10" now looks like just some text to the second F&R So I guess a workaround would be to always work in a 'baseline' copy and do the F&R and then Save with new name? Last edited by phossler; 02-17-2014 at 11:46 AM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#14 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			No, you need to change the function to replace both the comment and the following number (if any), like this: 
		
	
		
		
		
		
		
		
		
		
		
		
	
	search expression <!-- comment# -->(\d*) function Code: 
	def __call__(self, match): self.number += 1 return '<!-- comment# -->' + str(self.number)  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#15 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,090 
				Karma: 447222 
				Join Date: Jan 2009 
				Location: Valley Forge, PA, USA 
				
				
				Device: Kindle Paperwhite 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 (ver1) epub text with tags = Fiction, Adventure, Escapist, PubDomain "and the tags in my book are <!-- tags -->" Find: Code: 
	<!-- tags --> Code: 
	Tag function () Result #1: "and the tags in my book are <!-- tags --> Fiction, Adventure, Escapist, PubDomain" (ver 2) If I were to revise the tags to "Fiction, Adventure, Public Domain", then is it possible to replace the original "Fiction, Adventure, Escapist, PubDomain" with the updated tags?  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| [Suggestion] Change indentation to one letter per indentation level. | John Peterson | Development | 1 | 10-22-2012 03:05 PM | 
| taking book sharing to the next level... | paola | General Discussions | 35 | 09-30-2012 09:32 PM | 
| Question: find and replace with variables? | veezh | Recipes | 4 | 12-21-2010 06:23 AM | 
| Regex capturing variables | Lonas | Sigil | 9 | 08-14-2010 04:05 PM | 
| Noob: just getting my head around all the variables | KAM | Sony Reader | 16 | 02-04-2009 07:16 PM |