content = parse_inline_desc(state, i).strip()
if content: out.parsed += '<code>{}</code>'.format(content)
- elif i.tag in ['emphasis', 'bold', 'small']:
+ elif i.tag in ['emphasis', 'bold', 'small', 'superscript', 'subscript']:
mapping = {'emphasis': 'em',
'bold': 'strong',
- 'small': 'small'}
+ 'small': 'small',
+ 'superscript': 'sup',
+ 'subscript': 'sub'}
content = parse_inline_desc(state, i).strip()
if content: out.parsed += '<{0}{1}>{2}</{0}>'.format(
else:
out.parsed += '<span>{}</span>'.format(content)
- # WHAT THE HELL WHY IS THIS NOT AN XML ENTITY
- elif i.tag in ['mdash', 'ndash', 'laquo', 'raquo']:
- out.parsed += '&{};'.format(i.tag)
- elif i.tag == 'nonbreakablespace':
- out.parsed += ' '
-
- # Something new :O
- else: # pragma: no cover
- logging.warning("{}: ignoring <{}> in desc".format(state.current, i.tag))
+ else:
+ # Most of these are the same as HTML entities, but not all
+ mapping = {'nonbreakablespace': 'nbsp',
+ 'iexcl': 'iexcl',
+ 'cent': 'cent',
+ 'pound': 'pound',
+ 'curren': 'curren',
+ 'yen': 'yen',
+ 'brvbar': 'brvbar',
+ 'sect': 'sect',
+ 'umlaut': 'uml',
+ 'copy': 'copy',
+ 'ordf': 'ordf',
+ 'laquo': 'laquo',
+ 'not': 'not',
+ 'shy': 'shy',
+ 'registered': 'reg',
+ 'macr': 'macr',
+ 'deg': 'deg',
+ 'plusmn': 'plusmn',
+ 'sup2': 'sup2',
+ 'sup3': 'sup3',
+ 'acute': 'acute',
+ 'micro': 'micro',
+ 'para': 'para',
+ 'middot': 'middot',
+ 'cedil': 'cedil',
+ 'sup1': 'sup1',
+ 'ordm': 'ordm',
+ 'raquo': 'raquo',
+ 'frac14': 'frac14',
+ 'frac12': 'frac12',
+ 'frac34': 'frac34',
+ 'iquest': 'iquest',
+ 'Agrave': 'Agrave',
+ 'Aacute': 'Aacute',
+ 'Acirc': 'Acirc',
+ 'Atilde': 'Atilde',
+ 'Aumlaut': 'Auml',
+ 'Aring': 'Aring',
+ 'AElig': 'AElig',
+ 'Ccedil': 'Ccedil',
+ 'Egrave': 'Egrave',
+ 'Eacute': 'Eacute',
+ 'Ecirc': 'Ecirc',
+ 'Eumlaut': 'Euml',
+ 'Igrave': 'Igrave',
+ 'Iacute': 'Iacute',
+ 'Icirc': 'Icirc',
+ 'Iumlaut': 'Iuml',
+ 'ETH': 'ETH',
+ 'Ntilde': 'Ntilde',
+ 'Ograve': 'Ograve',
+ 'Oacute': 'Oacute',
+ 'Ocirc': 'Ocirc',
+ 'Otilde': 'Otilde',
+ 'Oumlaut': 'Ouml',
+ 'times': 'times',
+ 'Oslash': 'Oslash',
+ 'Ugrave': 'Ugrave',
+ 'Uacute': 'Uacute',
+ 'Ucirc': 'Ucirc',
+ 'Uumlaut': 'Uuml',
+ 'Yacute': 'Yacute',
+ 'THORN': 'THORN',
+ 'szlig': 'szlig',
+ 'agrave': 'agrave',
+ 'aacute': 'aacute',
+ 'acirc': 'acirc',
+ 'atilde': 'atilde',
+ 'aumlaut': 'auml',
+ 'aring': 'aring',
+ 'aelig': 'aelig',
+ 'ccedil': 'ccedil',
+ 'egrave': 'egrave',
+ 'eacute': 'eacute',
+ 'ecirc': 'ecirc',
+ 'eumlaut': 'euml',
+ 'igrave': 'igrave',
+ 'iacute': 'iacute',
+ 'icirc': 'icirc',
+ 'iumlaut': 'iuml',
+ 'eth': 'eth',
+ 'ntilde': 'ntilde',
+ 'ograve': 'ograve',
+ 'oacute': 'oacute',
+ 'ocirc': 'ocirc',
+ 'otilde': 'otilde',
+ 'oumlaut': 'ouml',
+ 'divide': 'divide',
+ 'oslash': 'oslash',
+ 'ugrave': 'ugrave',
+ 'uacute': 'uacute',
+ 'ucirc': 'ucirc',
+ 'uumlaut': 'uuml',
+ 'yacute': 'yacute',
+ 'thorn': 'thorn',
+ 'yumlaut': 'yuml',
+ 'fnof': 'fnof',
+ 'Alpha': 'Alpha',
+ 'Beta': 'Beta',
+ 'Gamma': 'Gamma',
+ 'Delta': 'Delta',
+ 'Epsilon': 'Epsilon',
+ 'Zeta': 'Zeta',
+ 'Eta': 'Eta',
+ 'Theta': 'Theta',
+ 'Iota': 'Iota',
+ 'Kappa': 'Kappa',
+ 'Lambda': 'Lambda',
+ 'Mu': 'Mu',
+ 'Nu': 'Nu',
+ 'Xi': 'Xi',
+ 'Omicron': 'Omicron',
+ 'Pi': 'Pi',
+ 'Rho': 'Rho',
+ 'Sigma': 'Sigma',
+ 'Tau': 'Tau',
+ 'Upsilon': 'Upsilon',
+ 'Phi': 'Phi',
+ 'Chi': 'Chi',
+ 'Psi': 'Psi',
+ 'Omega': 'Omega',
+ 'alpha': 'alpha',
+ 'beta': 'beta',
+ 'gamma': 'gamma',
+ 'delta': 'delta',
+ 'epsilon': 'epsilon',
+ 'zeta': 'zeta',
+ 'eta': 'eta',
+ 'theta': 'theta',
+ 'iota': 'iota',
+ 'kappa': 'kappa',
+ 'lambda': 'lambda',
+ 'mu': 'mu',
+ 'nu': 'nu',
+ 'xi': 'xi',
+ 'omicron': 'omicron',
+ 'pi': 'pi',
+ 'rho': 'rho',
+ 'sigmaf': 'sigmaf',
+ 'sigma': 'sigma',
+ 'tau': 'tau',
+ 'upsilon': 'upsilon',
+ 'phi': 'phi',
+ 'chi': 'chi',
+ 'psi': 'psi',
+ 'omega': 'omega',
+ 'thetasym': 'thetasym',
+ 'upsih': 'upsih',
+ 'piv': 'piv',
+ 'bull': 'bull',
+ 'hellip': 'hellip',
+ 'prime': 'prime',
+ 'Prime': 'Prime',
+ 'oline': 'oline',
+ 'frasl': 'frasl',
+ 'weierp': 'weierp',
+ 'imaginary': 'image',
+ 'real': 'real',
+ 'trademark': 'trade',
+ 'alefsym': 'alefsym',
+ 'larr': 'larr',
+ 'uarr': 'uarr',
+ 'rarr': 'rarr',
+ 'darr': 'darr',
+ 'harr': 'harr',
+ 'crarr': 'crarr',
+ 'lArr': 'lArr',
+ 'uArr': 'uArr',
+ 'rArr': 'rArr',
+ 'dArr': 'dArr',
+ 'hArr': 'hArr',
+ 'forall': 'forall',
+ 'part': 'part',
+ 'exist': 'exist',
+ 'empty': 'empty',
+ 'nabla': 'nabla',
+ 'isin': 'isin',
+ 'notin': 'notin',
+ 'ni': 'ni',
+ 'prod': 'prod',
+ 'sum': 'sum',
+ 'minus': 'minus',
+ 'lowast': 'lowast',
+ 'radic': 'radic',
+ 'prop': 'prop',
+ 'infin': 'infin',
+ 'ang': 'ang',
+ 'and': 'and',
+ 'or': 'or',
+ 'cap': 'cap',
+ 'cup': 'cup',
+ 'int': 'int',
+ 'there4': 'there4',
+ 'sim': 'sim',
+ 'cong': 'cong',
+ 'asymp': 'asymp',
+ 'ne': 'ne',
+ 'equiv': 'equiv',
+ 'le': 'le',
+ 'ge': 'ge',
+ 'sub': 'sub',
+ 'sup': 'sup',
+ 'nsub': 'nsub',
+ 'sube': 'sube',
+ 'supe': 'supe',
+ 'oplus': 'oplus',
+ 'otimes': 'otimes',
+ 'perp': 'perp',
+ 'sdot': 'sdot',
+ 'lceil': 'lceil',
+ 'rceil': 'rceil',
+ 'lfloor': 'lfloor',
+ 'rfloor': 'rfloor',
+ 'lang': 'lang',
+ 'rang': 'rang',
+ 'loz': 'loz',
+ 'spades': 'spades',
+ 'clubs': 'clubs',
+ 'hearts': 'hearts',
+ 'diams': 'diams',
+ 'OElig': 'OElig',
+ 'oelig': 'oelig',
+ 'Scaron': 'Scaron',
+ 'scaron': 'scaron',
+ 'Yumlaut': 'Yuml',
+ 'circ': 'circ',
+ 'tilde': 'tilde',
+ 'ensp': 'ensp',
+ 'emsp': 'emsp',
+ 'thinsp': 'thinsp',
+ 'zwnj': 'zwnj',
+ 'zwj': 'zwj',
+ 'lrm': 'lrm',
+ 'rlm': 'rlm',
+ 'ndash': 'ndash',
+ 'mdash': 'mdash',
+ 'lsquo': 'lsquo',
+ 'rsquo': 'rsquo',
+ 'sbquo': 'sbquo',
+ 'ldquo': 'ldquo',
+ 'rdquo': 'rdquo',
+ 'bdquo': 'bdquo',
+ 'dagger': 'dagger',
+ 'Dagger': 'Dagger',
+ 'permil': 'permil',
+ 'lsaquo': 'lsaquo',
+ 'rsaquo': 'rsaquo',
+ 'euro': 'euro',
+ 'tm': 'trade'}
+ try:
+ entity = mapping[i.tag]
+ except:
+ logging.warning("{}: ignoring <{}> in desc".format(state.current, i.tag))
+ out.parsed += '&{};'.format(entity)
# Now we can reset previous_section to None, nobody needs it anymore.
# Of course we're resetting it only in case nothing else (such as the
<blockquote><p>A blockquote.</p></blockquote><pre>Preformatted text.
</pre><p>Paragraph<br />with<br />explicit<br />line<br />breaks.</p><section id="section"><h2><a href="#section">Page section</a></h2><pre>Differently
preformatted
-text.</pre><ul><li>Unordered</li><li>list</li><li>of<ul><li>nested</li><li>items</li></ul></li><li>and back</li></ul><ol><li>Ordered</li><li>list</li><li>of<ol><li>nested</li><li>items</li></ol></li><li>and back</li></ol><p><a name="an-anchor"></a> This is a <code>typewriter text</code>, <em>emphasis</em> and <strong>bold</strong>. <em>Emphasis with <code>typewriter</code> and <strong>bold</strong> nested.</em> <a href="http://google.com">http:/<wbr />/<wbr />google.com</a> and <a href="http://google.com">URL</a>. <small>Small <em>text</em>.</small> En-dash – and em-dash —. Reference to a <a href="index.html#section" class="m-doc">Page section</a>. Named reference with special characters in title: <a href="index.html#section" class="m-doc">» Warnings «</a>. Reference with escaped characters in title: <a href="index.html#an-anchor" class="m-doc"><anchor></a>.</p><p>Empty elements:</p><pre></pre><hr/><p>Above is a horizontal line.</p></section>
+text.</pre><ul><li>Unordered</li><li>list</li><li>of<ul><li>nested</li><li>items</li></ul></li><li>and back</li></ul><ol><li>Ordered</li><li>list</li><li>of<ol><li>nested</li><li>items</li></ol></li><li>and back</li></ol><p><a name="an-anchor"></a> This is a <code>typewriter text</code>, <em>emphasis</em> and <strong>bold</strong>. <em>Emphasis with <code>typewriter</code> and <strong>bold</strong> nested.</em> <a href="http://google.com">http:/<wbr />/<wbr />google.com</a> and <a href="http://google.com">URL</a>. <small>Small <em>text</em>.</small> En-dash – and em-dash —. Reference to a <a href="index.html#section" class="m-doc">Page section</a>. Named reference with special characters in title: <a href="index.html#section" class="m-doc">» Warnings «</a>. Reference with escaped characters in title: <a href="index.html#an-anchor" class="m-doc"><anchor></a>.</p><p>2<sup>nd</sup> is L<sub>∞</sub> ∀ ∇ π ℜ ℑ This costs no $, €, £, ¥ or ¤.</p><p>Empty elements:</p><pre></pre><hr/><p>Above is a horizontal line.</p></section>
</div>
</div>
</div>
characters in title: @ref section "» Warnings «". Reference with
escaped characters in title: @ref an-anchor "<anchor>".
+2<sup>nd</sup> is L<sub>∞</sub> ∀ ∇ π ℜ ℑ
+This costs no $, €, £, ¥ or ¤.
+
Empty elements: <em></em> <tt></tt> <strong></strong> <pre></pre> <small></small>
- - -