Skip to content

Commit b8ef1fa

Browse files
author
Jason Ward
committed
refs #29: namespaced all the css classes
1 parent 730adb5 commit b8ef1fa

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ OR, let's say FOO is your new favorite markup language. Simply customize your ow
166166

167167
The base parser `Docx2Html` relies on certain css class being set for certain behaviour to occur. Currently these include:
168168

169-
* class `insert` -> Turns the text green.
170-
* class `delete` -> Turns the text red and draws a line through the text.
171-
* class `center` -> Aligns the text to the center.
172-
* class `right` -> Aligns the text to the right.
173-
* class `left` -> Aligns the text to the left.
174-
* class `comment` -> Turns the text blue.
169+
* class `pydocx-insert` -> Turns the text green.
170+
* class `pydocx-delete` -> Turns the text red and draws a line through the text.
171+
* class `pydocx-center` -> Aligns the text to the center.
172+
* class `pydocx-right` -> Aligns the text to the right.
173+
* class `pydocx-left` -> Aligns the text to the left.
174+
* class `pydocx-comment` -> Turns the text blue.
175175
* class `pydocx-underline` -> Underlines the text.

pydocx/parsers/Docx2Html.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ def head(self):
2121

2222
def style(self):
2323
result = (
24-
'<style>.insert {color:green;}'
25-
'.delete {color:red;text-decoration:line-through;}'
26-
'.center {text-align:center;}'
27-
'.right {text-align:right;}'
28-
'.left {text-align:left;}'
29-
'.comment {color:blue;}'
24+
'<style>'
25+
'.pydocx-insert {color:green;}'
26+
'.pydocx-delete {color:red;text-decoration:line-through;}'
27+
'.pydocx-center {text-align:center;}'
28+
'.pydocx-right {text-align:right;}'
29+
'.pydocx-left {text-align:left;}'
30+
'.pydocx-comment {color:blue;}'
3031
'.pydocx-underline {text-decoration: underline;}'
3132
'body {width:%(width)spx;margin:0px auto;}'
3233
'</style>'
@@ -53,7 +54,7 @@ def heading(self, text, heading_value):
5354

5455
def insertion(self, text, author, date):
5556
return (
56-
"<span class='insert' author='%(author)s' "
57+
"<span class='pydocx-insert' author='%(author)s' "
5758
"date='%(date)s'>%(text)s</span>"
5859
) % {
5960
'author': author,
@@ -87,7 +88,7 @@ def image(self, path, x, y):
8788

8889
def deletion(self, text, author, date):
8990
return (
90-
"<span class='delete' author='%(author)s' "
91+
"<span class='pydocx-delete' author='%(author)s' "
9192
"date='%(date)s'>%(text)s</span>"
9293
) % {
9394
'author': author,
@@ -150,7 +151,7 @@ def page_break(self):
150151
def indent(self, text, just='', firstLine='', left='', right=''):
151152
slug = '<div'
152153
if just:
153-
slug += " class='%(just)s'"
154+
slug += " class='pydocx-%(just)s'"
154155
if firstLine or left or right:
155156
slug += " style='"
156157
if firstLine:

pydocx/tests/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
from unittest import TestCase
1313

1414
STYLE = (
15-
'<style>.insert {color:green;}'
16-
'.delete {color:red;text-decoration:line-through;}'
17-
'.center {text-align:center;}'
18-
'.right {text-align:right;}'
19-
'.left {text-align:left;}'
20-
'.comment {color:blue;}'
15+
'<style>'
16+
'.pydocx-insert {color:green;}'
17+
'.pydocx-delete {color:red;text-decoration:line-through;}'
18+
'.pydocx-center {text-align:center;}'
19+
'.pydocx-right {text-align:right;}'
20+
'.pydocx-left {text-align:left;}'
21+
'.pydocx-comment {color:blue;}'
2122
'.pydocx-underline {text-decoration: underline;}'
2223
'body {width:612px;margin:0px auto;}'
2324
'</style>'

pydocx/tests/test_docx.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ def test_table_col_row_span():
166166
</tr>
167167
<tr>
168168
<td>
169-
<div class='right'>EEE
169+
<div class='pydocx-right'>EEE
170170
</div></td>
171171
<td rowspan="2">FFF</td>
172172
</tr>
173173
<tr>
174174
<td>
175-
<div class='right'>GGG
175+
<div class='pydocx-right'>GGG
176176
</div></td>
177177
</tr>
178178
</table>
@@ -611,7 +611,7 @@ def test_has_title():
611611
actual_html = convert(file_path)
612612
assert_html_equal(actual_html, BASE_HTML % '''
613613
<p>Title</p>
614-
<p><div class='left'>Text</div></p>
614+
<p><div class='pydocx-left'>Text</div></p>
615615
''')
616616

617617

@@ -667,18 +667,19 @@ def test_justification():
667667
actual_html = convert(file_path)
668668
assert_html_equal(actual_html, BASE_HTML % '''
669669
<p>
670-
<div class='center'>Center Justified</div>
670+
<div class='pydocx-center'>Center Justified</div>
671671
</p>
672672
<p>
673-
<div class='right'>Right justified</div>
673+
<div class='pydocx-right'>Right justified</div>
674674
</p>
675675
<p>
676-
<div class='right' style='margin-right:96.0px;'>
676+
<div class='pydocx-right' style='margin-right:96.0px;'>
677677
Right justified and pushed in from right
678678
</div>
679679
</p>
680680
<p>
681-
<div class='center' style='margin-left:252.0px;margin-right:96.0px;'>
681+
<div class='pydocx-center'
682+
style='margin-left:252.0px;margin-right:96.0px;'>
682683
Center justified and pushed in from left and it is
683684
great and it is the coolest thing of all time and I like it and
684685
I think it is cool

pydocx/tests/test_xml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def test_performance(self):
641641

642642
class NonStandardTextTagsTestCase(_TranslationTestCase):
643643
expected_output = '''
644-
<p><span class='insert' author='' date=''>insert </span>
644+
<p><span class='pydocx-insert' author='' date=''>insert </span>
645645
smarttag</p>
646646
'''
647647

@@ -675,7 +675,7 @@ class DeleteTagInList(_TranslationTestCase):
675675
expected_output = '''
676676
<ol list-style-type="decimal">
677677
<li>AAA<br />
678-
<span class='delete' author='' date=''>BBB</span>
678+
<span class='pydocx-delete' author='' date=''>BBB</span>
679679
</li>
680680
<li>CCC</li>
681681
</ol>
@@ -697,7 +697,7 @@ class InsertTagInList(_TranslationTestCase):
697697
expected_output = '''
698698
<ol list-style-type="decimal">
699699
<li>AAA<br />
700-
<span class='insert' author='' date=''>BBB</span>
700+
<span class='pydocx-insert' author='' date=''>BBB</span>
701701
</li>
702702
<li>CCC</li>
703703
</ol>

0 commit comments

Comments
 (0)