To compile the Constitution, you need to have installed a xelatex compiler, which comes with TeX Live and other package sets.
Then run: xelatex constitution.tex twice and open the resulting PDF file.
Requires Python 3, with lxml and roman and cssselect packages (see below).
Run: python3 convert_tex_to_html.py > file.html and open the resulting HTML file.
Script options:
-F,--final- removes draft markings.-d yyyy-mm-dd,--date- changes the default date (today) to whatever is specified.-f document.tex,--file- changes the default input TeX file (constitution.tex) to whatever is specified.-T Title\ Goes\ Here,--title- defines the title (if empty, prints blank).-P,--parts- used for documents with parts (numbered with Roman numerals).-toc,--toc- adds a table of contents using the highest heading level in the document.
Example: python3 convert_tex_to_html.py > output.html -f input.tex -T Title -P
This will make output.html from input.tex, the contents will be titled 'Title', and it will have part numbering.
The input TeX file can be very basic and does not need a preamble:
\part{Part i}
\section{Section 1}
\begin{enumerate}
\item Item (1)
\item Item (2)
\item Item (3)
\end{enumerate}
Note that \part must be present in the TeX document (at least for now) regardless of whether it actually has parts; this can be an empty \part{} if parts are not intended to be used.
For convenience, two bash scripts are provided to compile multiple documents.
Put documents that are divided into parts into a subdirectory called part and documents that are divided into sections into a subdirectory called section. Files must use the Mediawiki syntax and must have the extension .wik.
The file name is taken from the file name of the .wik file, and the title of the document is taken from the first line of the .wik file.
example_document.wik with the contents
Document Title
=Heading Level 1=
Body.
==Heading Level 2==
* Unordered list item
===Heading Level 3===
# Ordered list item
will produce example_document.html
This works for getting the Python script running in OS X El Capitan (10.11.6). More efficient/appropriate steps may exist, but this worked.
- Install TeX.
- Install Python 3.
- Launch Terminal.
- Install Homebrew
- Install Pandoc with
brew install pandoc. - Install Libxml2 with
brew install libxml2. - Install Libxslt with
brew install libxslt. - Run
link libxml2 --force. - Run
link libxslt --force. - Install lxml with
pip install lxml. - Install Roman with
pip install Roman. - Install cssselect with
pip install cssselect.
System packages: $ apt-get install pandoc texlive-latex-recommended libxml2 libxslt1.1
Using a python3 virtual environment $ pip install lxml cssselect roman