diff --git a/src/calibre/ebooks/pml/pmlconverter.py b/src/calibre/ebooks/pml/pmlconverter.py index 1c3c749f76..b4ab238da9 100644 --- a/src/calibre/ebooks/pml/pmlconverter.py +++ b/src/calibre/ebooks/pml/pmlconverter.py @@ -34,7 +34,7 @@ PML_HTML_RULES = [ (re.compile(r'\\B(?P.*?)\\B', re.DOTALL), lambda match: '%s' % match.group('text') if match.group('text') else ''), (re.compile(r'\\Sp(?P.*?)\\Sp', re.DOTALL), lambda match: '%s' % match.group('text') if match.group('text') else ''), (re.compile(r'\\Sb(?P.*?)\\Sb', re.DOTALL), lambda match: '%s' % match.group('text') if match.group('text') else ''), - (re.compile(r'\\k(?P.*?)\\k', re.DOTALL), lambda match: '%s' % match.group('text') if match.group('text') else ''), + (re.compile(r'\\k(?P.*?)\\k', re.DOTALL), lambda match: '%s' % match.group('text').upper() if match.group('text') else ''), (re.compile(r'\\a(?P\d\d\d)'), lambda match: '&#%s;' % match.group('num')), (re.compile(r'\\U(?P\d\d\d\d)'), lambda match: '%s' % my_unichr(int(match.group('num'), 16))), (re.compile(r'\\m="(?P.+?)"'), lambda match: '' % image_name(match.group('name')).strip('\x00')), @@ -45,11 +45,11 @@ PML_HTML_RULES = [ (re.compile(r'\\Sd="(?P.+?)"(?P.*?)\\Sd'), lambda match: '%s' % (match.group('target'), match.group('text')) if match.group('text') else ''), # Just italicize index items as that is how the eReader software renders them. (re.compile(r'\\I(?P.*?)\\I', re.DOTALL), lambda match: '%s' % match.group('text') if match.group('text') else ''), - + # Sidebar and Footnotes (re.compile(r'.+?)">\s*(?P.*?)\s*', re.DOTALL), lambda match: '' % (match.group('target'), match.group('text')) if match.group('text') else ''), (re.compile(r'.+?)">\s*(?P.*?)\s*', re.DOTALL), lambda match: '
%s
' % (match.group('target'), match.group('text')) if match.group('text') else ''), - + # eReader files are one paragraph per line. # This forces the lines to wrap properly. (re.compile('^(?P.+)$', re.MULTILINE), lambda match: '

%s

' % match.group('text')), @@ -57,7 +57,7 @@ PML_HTML_RULES = [ (re.compile('

[ ]*

'), lambda match: ''), # Ensure empty lines carry over. (re.compile('(\r\n|\n|\r){3}'), lambda match: '
'), - + # Remove unmatched plm codes. (re.compile(r'(?<=[^\\])\\[pxcriouvtblBk]'), lambda match: ''), (re.compile(r'(?<=[^\\])\\X[0-4]'), lambda match: ''), @@ -65,7 +65,7 @@ PML_HTML_RULES = [ (re.compile(r'(?<=[^\\])\\Sb'), lambda match: ''), # Remove invalid single item pml codes. (re.compile(r'(?<=[^\\])\\.'), lambda match: ''), - + # Replace \\ with \. (re.compile(r'\\\\'), lambda match: '\\'), ] @@ -79,5 +79,5 @@ def pml_to_html(pml): def footnote_sidebar_to_html(id, pml): html = '
%s
' % (id, id, pml_to_html(pml)) - return html + return html