![]() |
#1 |
Enjoy Life
![]() Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
|
Structure detection on simple chapters
Hi,
i'm very confortable with regexps, but I can't make the structure detection work with these very simple chapters headers: Code:
Chapter 1.<br> Code:
//*[re:test(., "(Chapter|Book|Section|Part|Prologue|Epilogue)\s", "")] |
![]() |
![]() |
![]() |
#2 |
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
It doesn't look like Chapter is in a tag. It needs to be in a tag to be work properly.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enjoy Life
![]() Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
|
OK, thanks. I thought that by indicating a pattern, Calibre could parse the chapter. Like /Chapter \d+\.\<br\>/
|
![]() |
![]() |
![]() |
#4 |
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
It can match a pattern but once it finds the match it references it to the current tag. Since it's XHTML references for links must point to a tag. So if your chapters are not in separate tags every one will match the same tag (duplicates are removed) and if I remember correctly it won't reference the body tag. So you get nothing.
|
![]() |
![]() |
![]() |
#5 |
Enjoy Life
![]() Posts: 26
Karma: 10
Join Date: Jun 2011
Location: Portugal
Device: Kindle
|
I found a great solution and I would like to share. Fortunately the search/replace is done before the chapter detection, so all you have to do is search eg.
Code:
Chapter\s*(\d+) Code:
<h2>Chapter \1</h2> |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Structure Detection Problems | Jonnster | Conversion | 21 | 05-12-2011 02:12 PM |
structure detection - documentation ? | cybmole | Calibre | 27 | 01-12-2011 02:14 AM |
Trouble w structure detection | jeff47 | Calibre | 1 | 10-13-2010 12:51 AM |
Structure Detection Ceased To Exist? | radiofred | Calibre | 3 | 10-01-2010 12:33 AM |
Structure detection v5.5 and v6.2 | AlexBell | Calibre | 2 | 07-29-2009 10:11 PM |