View Single Post
Old 05-21-2009, 12:29 AM   #14
rogue_ronin
Banned
rogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-books
 
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
========================================
  • What it does: Finds generic chapter headings, and converts them to your chosen format.
    Before-Text:
    Code:
    <h4 id="Chapter 01">Chapter 01</h4>
    <p>  chaPtertWo  </p>
    Chapter III
    After-Text:
    Code:
    <h3 class="chapter">Chapter 01</h3>
    
    <h3 class="chapter">Chapter tWo</h3>
    
    Chapter III
  • Best used on: HTML
  • Regex Find:
    Code:
    ^\<(p.*|h\d.*)\>\s*[Cc][Hh][Aa][Pp][Tt][Ee][Rr]\s*(.*)\</(p|h\d)\>\s*
  • Find Translation: Find any single line that starts with a paragraph or header, followed immediately by any number of spaces or tabs and the word "chapter" in upper or lower (or mixed) case, and may have some spaces and characters following it, then a close of the paragraph/header, and any number of spaces, tabs or hard-returns.
  • Regex Replace:
    Code:
    <h3 class="chapter">Chapter $2</h3>\n\n
  • Replace Translation: Whatever follows the word "cHapTer" (and any number of spaces) in the original line is placed into an <h3 class="chapter"> header, and preceded with the word "Chapter".
  • Variants/Comments: Change the Replace header/wrap to suit yourself (the $2 is whatever the name of the chapter is.) Leave the \n\n in your Replace; the \s* grabs the hard returns. If you want to use this with plain text lines, remove \<(p.*|h\d.*)\> and \</(p|h\d)\> Changing (.*) to (.*?) (un-greedy) causes selection to miss the closing tag on my machine. Anyone know why?
========================================

Last edited by rogue_ronin; 05-21-2009 at 12:34 AM. Reason: Forgot to let you have paragraphs with attributes...
rogue_ronin is offline   Reply With Quote