From 35fa14eab32baaa61555889b1228e994f4f909c5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Jan 2014 12:50:34 +0530 Subject: [PATCH] MOBI Output: Handle the value attribute on
  • tags. Fixes #1273559 [TOC numbers correct, Chapter numbers always 1](https://bugs.launchpad.net/calibre/+bug/1273559) --- src/calibre/ebooks/mobi/mobiml.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 622cca179c..97d2ce3e77 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -555,7 +555,13 @@ class MobiMLizer(object): # be added. istate.ids and tag in ('a', 'span', 'i', 'b', 'u') and len(elem)==0)): - self.mobimlize_content(tag, text, bstate, istates) + if tag == 'li' and len(istates) > 1 and 'value' in elem.attrib: + try: + value = int(elem.attrib['value']) + istates[-2].list_num = value - 1 + except: + pass + self.mobimlize_content(tag, text, bstate, istates) for child in elem: self.mobimlize_elem(child, stylizer, bstate, istates) tail = None