From: <mi...@us...> - 2012-09-12 13:11:08
|
Revision: 7511 http://docutils.svn.sourceforge.net/docutils/?rev=7511&view=rev Author: milde Date: 2012-09-12 13:11:02 +0000 (Wed, 12 Sep 2012) Log Message: ----------- Use ``<code>`` tag for inline "code", do not drop nested inline nodes (syntax highlight tokens). Modified Paths: -------------- trunk/docutils/HISTORY.txt trunk/docutils/docutils/writers/html4css1/__init__.py trunk/docutils/test/functional/expected/standalone_rst_html4css1.html Modified: trunk/docutils/HISTORY.txt =================================================================== --- trunk/docutils/HISTORY.txt 2012-09-12 07:22:25 UTC (rev 7510) +++ trunk/docutils/HISTORY.txt 2012-09-12 13:11:02 UTC (rev 7511) @@ -35,6 +35,11 @@ - Fix [ 3546533 ] Unicode error with `date` directive. +* docutils/writers/html4css1/__init__.py + + - Use ``<code>`` tag for inline "code", + do not drop nested inline nodes (syntax highlight tokens). + * docutils/tools/test/test_buildhtml.py - Fix [ 3521167 ] allow running in any directory. Modified: trunk/docutils/docutils/writers/html4css1/__init__.py =================================================================== --- trunk/docutils/docutils/writers/html4css1/__init__.py 2012-09-12 07:22:25 UTC (rev 7510) +++ trunk/docutils/docutils/writers/html4css1/__init__.py 2012-09-12 13:11:02 UTC (rev 7511) @@ -253,7 +253,7 @@ generator = ('<meta name="generator" content="Docutils %s: ' 'http://docutils.sourceforge.net/" />\n') - + # Template for the MathJax script in the header: mathjax_script = '<script type="text/javascript" src="%s"></script>\n' # The latest version of MathJax from the distributed server: @@ -266,7 +266,7 @@ # a) as extra option or # b) appended to math-output="MathJax"? # - # If b), which delimiter/delimter-set (':', ',', ' ')? + # If b), which delimiter/delimter-set (':', ',', ' ')? stylesheet_link = '<link rel="stylesheet" href="%s" type="text/css" />\n' embedded_stylesheet = '<style type="text/css">\n\n%s\n</style>\n' @@ -288,7 +288,7 @@ # encoding not interpolated: self.html_prolog.append(self.xml_declaration) self.head = self.meta[:] - self.stylesheet = [self.stylesheet_call(path) + self.stylesheet = [self.stylesheet_call(path) for path in utils.get_stylesheet_list(settings)] self.body_prefix = ['</head>\n<body>\n'] # document title, subtitle display @@ -1124,7 +1124,15 @@ self.body.append('</li>\n') def visit_literal(self, node): - """Process text to prevent tokens from wrapping.""" + # special case: inline code: + classes = node.get('classes', []) + if 'code' in classes: + # filter 'code' from class arguments + node['classes'] = [cls for cls in classes if cls != 'code'] + self.body.append(self.starttag(node, 'code', '')) + node['classes'] = classes # restore for test in depart_literal() + return + # Process text to prevent tokens from wrapping. self.body.append( self.starttag(node, 'tt', '', CLASS='docutils literal')) text = node.astext() @@ -1147,6 +1155,10 @@ # Content already processed: raise nodes.SkipNode + def depart_literal(self, node): + if 'code' in node.get('classes', []): + self.body.append('</code>') + def visit_literal_block(self, node): self.body.append(self.starttag(node, 'pre', CLASS='literal-block')) @@ -1201,7 +1213,7 @@ self.body.append(self.starttag(node, 'p')) self.body.append(u','.join(err.args)) self.body.append('</p>\n') - self.body.append(self.starttag(node, 'pre', + self.body.append(self.starttag(node, 'pre', CLASS='literal-block')) self.body.append(self.encode(math_code)) self.body.append('\n</pre>\n') Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2012-09-12 07:22:25 UTC (rev 7510) +++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2012-09-12 13:11:02 UTC (rev 7511) @@ -184,7 +184,7 @@ <p>The default role for interpreted text is <cite>Title Reference</cite>. Here are some explicit interpreted text roles: a PEP reference (<a class="reference external" href="http://www.python.org/dev/peps/pep-0287">PEP 287</a>); an RFC reference (<a class="reference external" href="http://www.faqs.org/rfcs/rfc2822.html">RFC 2822</a>); an abbreviation (<abbr>abb.</abbr>), an acronym -(<acronym>reST</acronym>), code (<tt class="code docutils literal">print "hello world"</tt>); a <sub>subscript</sub>; +(<acronym>reST</acronym>), code (<code>print "hello world"</code>); a <sub>subscript</sub>; a <sup>superscript</sup> and explicit roles for <cite>Docutils</cite>' <em>standard</em> <strong>inline</strong> <tt class="docutils literal">markup</tt>.</p> <!-- DO NOT RE-WRAP THE FOLLOWING PARAGRAPH! --> @@ -863,7 +863,7 @@ <!-- --> <blockquote> Docutils uses LaTeX syntax for math directives and roles: -<tt class="code latex tex docutils literal">\alpha = f(x)</tt> prints <span class="math"> +<code class="latex tex">\alpha = f(x)</code> prints <span class="math"> \(\alpha = f(x)\)</span> .</blockquote> <p>The <tt class="docutils literal">:code:</tt> option of the <cite>include</cite> directive sets the included content This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |