|
From: <mi...@us...> - 2013-05-07 10:53:02
|
Revision: 7661
http://sourceforge.net/p/docutils/code/7661
Author: milde
Date: 2013-05-07 10:52:59 +0000 (Tue, 07 May 2013)
Log Message:
-----------
Avoid repeated class declarations in html4css1 writer
Modified version of patch [ 104 ].
HtmlTranslator.starttag() no longer adds class arguments to the node.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/html4css1/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2013-05-07 09:01:00 UTC (rev 7660)
+++ trunk/docutils/HISTORY.txt 2013-05-07 10:52:59 UTC (rev 7661)
@@ -55,6 +55,8 @@
where stylesheets are found. Used by `stylesheet_path` when expanding
relative path arguments.
- New default for math-output_: ``HTML math.css``.
+ - Avoid repeated class declarations in html4css1 writer
+ (modified version of patch [ 104 ]).
.. _math-output: docs/user/config.html#math-output
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2013-05-07 09:01:00 UTC (rev 7660)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2013-05-07 10:52:59 UTC (rev 7661)
@@ -402,19 +402,19 @@
ids = []
for (name, value) in attributes.items():
atts[name.lower()] = value
- classes = node.get('classes', [])
- if 'class' in atts:
- classes.append(atts.pop('class'))
- # move language specification to 'lang' attribute
- languages = [cls for cls in classes
- if cls.startswith('language-')]
+ classes = []
+ languages = []
+ # unify class arguments and move language specification
+ for cls in node.get('classes', []) + atts.pop('class', '').split() :
+ if cls.startswith('language-'):
+ languages.append(cls[9:])
+ elif cls.strip() and cls not in classes:
+ classes.append(cls)
if languages:
# attribute name is 'lang' in XHTML 1.0 but 'xml:lang' in 1.1
- atts[self.lang_attribute] = languages[0][9:]
- classes.pop(classes.index(languages[0]))
- classes = ' '.join(classes).strip()
+ atts[self.lang_attribute] = languages[0]
if classes:
- atts['class'] = classes
+ atts['class'] = ' '.join(classes)
assert 'id' not in atts
ids.extend(node.get('ids', []))
if 'ids' in atts:
@@ -906,7 +906,8 @@
and len(node.astext()) > self.settings.field_name_limit):
atts['colspan'] = 2
self.context.append('</tr>\n'
- + self.starttag(node.parent, 'tr', '')
+ + self.starttag(node.parent, 'tr', '',
+ CLASS='field')
+ '<td> </td>')
else:
self.context.append('')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|