Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Peg version of python supported. #1

Merged
merged 4 commits into from

1 participant

Jason Ward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2013
  1. refs #1: Yay for travis

    authored
  2. refs #1: removed broken import

    authored
  3. refs #1: flake8

    authored
  4. refs #1: pegging reqs

    authored
This page is out of date. Refresh to see the latest.
Showing with 33 additions and 11 deletions.
  1. +9 −0 .travis.yml
  2. +23 −11 pydocx/parsers/Docx2Html.py
  3. +1 −0  requirements.txt
9 .travis.yml
View
@@ -0,0 +1,9 @@
+language: python
+python:
+ - "2.7"
+script: python main.py
+install:
+ - pip install -r requirements.txt
+notifications:
+ email:
+ - jason.louard.ward@gmail.com
34 pydocx/parsers/Docx2Html.py
View
@@ -1,8 +1,8 @@
from pydocx.DocxParser import DocxParser
-from pydocx.NewDocxParser import Parser
import xml.sax.saxutils
+
class Docx2Html(DocxParser):
@property
@@ -10,11 +10,15 @@ def parsed(self):
self._parsed = self._parsed.replace('<p></p><p></p>', '<br />')
self._parsed = self._parsed.replace('</p><br /><p>', '</p><p>')
self._parsed = self._parsed.replace('</p><br /><ul>', '</p><ul>')
- return '<html><head><style>.insert{{color:red}}.delete{{color:red; text-decoration:line-through}}' \
- '.center{{text-align:center}}.right{{text-align:right}}</style></head><body>{}</body></html>'.format(self._parsed)
+ return (
+ '<html><head><style>.insert{{color:red}}.delete'
+ '{{color:red; text-decoration:line-through}}.center'
+ '{{text-align:center}}.right{{text-align:right}}'
+ '</style></head><body>{}</body></html>'
+ ).format(self._parsed)
def escape(self, text):
- return xml.sax.saxutils.quoteattr(text)[1:-1]
+ return xml.sax.saxutils.quoteattr(text)[1:-1]
def linebreak(self, pre=None):
return '<br />'
@@ -23,10 +27,16 @@ def paragraph(self, text, pre=None):
return '<p>' + text + '</p>'
def insertion(self, text, author, date):
- return "<span class='insert' author='{author}' date='{date}'>{text}</span>".format(author=author, date=date, text=text)
+ return (
+ "<span class='insert' author='{author}' "
+ "date='{date}'>{text}</span>"
+ ).format(author=author, date=date, text=text)
def deletion(self, text, author, date):
- return "<span class='delete' author='{author}' date='{date}'>{text}</span>".format(author=author, date=date, text=text)
+ return (
+ "<span class='delete' author='{author}' "
+ "date='{date}'>{text}</span>"
+ ).format(author=author, date=date, text=text)
def list_element(self, text):
return "<li>{text}</li>".format(text=text)
@@ -43,11 +53,13 @@ def bold(self, text):
def italics(self, text):
return '<i>' + text + '</i>'
- def underline(self,text):
+ def underline(self, text):
return '<u>' + text + '</u>'
def tab(self):
- return '&nbsp&nbsp&nbsp&nbsp' #### insert before the text right?? so got the text and just do an insert at the beginning!
+ # Insert before the text right?? So got the text and just do an insert
+ # at the beginning!
+ return '&nbsp&nbsp&nbsp&nbsp'
def table(self, text):
return '<table border=1>' + text + '</table>'
@@ -61,11 +73,11 @@ def table_cell(self, text):
def page_break(self):
return '<hr>'
- def center_justify(self,text):
+ def center_justify(self, text):
return "<div class = 'center'>" + text + '</div>'
- def right_justify(self,text):
+ def right_justify(self, text):
return "<div class = 'right'>" + text + '</div>'
def indent(self, text, right, left, firstLine):
- return "<div style = 'margin-left:{}pt'>{}</div>".format(left,text)
+ return "<div style = 'margin-left:{}pt'>{}</div>".format(left, text)
1  requirements.txt
View
@@ -0,0 +1 @@
+beautifulsoup4>=4.1.0
Something went wrong with that request. Please try again.