Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <paultremblay@us...> - 2011-10-24 01:50:52
|
Author: paultremblay Date: 2011-10-24 03:50:43 +0200 (Mon, 24 Oct 2011) New Revision: 7200 Added: trunk/sandbox/paultremblay/tools/ trunk/sandbox/paultremblay/tools/get_docutils_standard_tests.sh trunk/sandbox/paultremblay/tools/make_unicode_test.py Modified: trunk/sandbox/paultremblay/ trunk/sandbox/paultremblay/docs/ trunk/sandbox/paultremblay/scripts/docutils_to_fo.sh trunk/sandbox/paultremblay/scripts/rstxml2mathml_sax.py trunk/sandbox/paultremblay/test.sh trunk/sandbox/paultremblay/xsl_fo/bullet_list.xsl trunk/sandbox/paultremblay/xsl_fo/error.xsl trunk/sandbox/paultremblay/xsl_fo/inline.xsl Log: Small changes and fine tuning. Property changes on: trunk/sandbox/paultremblay ___________________________________________________________________ Modified: svn:ignore - build test_output svn_config foo_bar temp.fo temp.xml temp.pdf build dist test.xsl MANIFEST docutils_test + build test_output svn_config foo_bar temp.fo temp.xml temp.pdf build dist test.xsl MANIFEST docutils_test functional Property changes on: trunk/sandbox/paultremblay/docs ___________________________________________________________________ Modified: svn:ignore - html + html user Modified: trunk/sandbox/paultremblay/scripts/docutils_to_fo.sh =================================================================== --- trunk/sandbox/paultremblay/scripts/docutils_to_fo.sh 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/scripts/docutils_to_fo.sh 2011-10-24 01:50:43 UTC (rev 7200) @@ -1,6 +1,6 @@ XSLFO_HOME=/Users/cejohnsonlouisville/Documents/docutils/paultremblay/xsl_fo -RSTML=/Users/cejohnsonlouisville/Documents/docutils/paultremblay/scripts/rstxml2mathml.py -FOPCONF=/Users/cejohnsonlouisville/Documents/docutils/paultremblay/fop.conf +RSTML=/Users/cejohnsonlouisville/Documents/docutils/paultremblay/scripts/rstxml2mathml_sax.py +FOPCONF="/Library/Java/fop-1.0/conf/fop.xconf" if [ "$XSLFO_PDF" != "" ]; then PDF='true' else @@ -40,7 +40,7 @@ --help) Usage;exit 0;; --verbose) VERBOSE='true';; --format) FORMAT='true';; - --test) CLEAN='false';FORMAT='true';VALID='true';TEST='true';STRICT='true';; + --test) CLEAN='false';FORMAT='true';VALID='true';TEST='true';STRICT='true';PDF='true';; --testq) CLEAN='false';VALID='true';FORMAT='true';; --noclean) CLEAN='false';; --pdf) PDF='true';; @@ -102,12 +102,12 @@ if [ "$LATEXML" == 'true' ]; then rst2xml.py --strip-comments --trim-footnote-reference-space --no-doctype $1\ - | python3 $RSTML --mathml latex > $RAW_XML + | python $RSTML --mathml latex > $RAW_XML elif [ "$ASCIIML" == 'true' ]; then rst2xml.py --strip-comments --trim-footnote-reference-space --no-doctype $1\ - | python $RSTML > $RAW_XML + | python3 $RSTML > $RAW_XML else - rst2xml.py --strip-comments --trim-footnote-reference-space --no-doctype $1 $RAW_XML + rst2xml.py --strip-comments --trim-footnote-reference-space --no-doctype $1 > $RAW_XML fi if [ "$FORMAT" == "true" ]; then @@ -131,7 +131,7 @@ if [ "$PDF" == 'true' ]; then PDF_FILE=${DIRNAME}/${BASENAME}.pdf - fop -c $FOPCONF -fo $FO_FILE -pdf ${PDF_FILE} + fop -fo $FO_FILE -pdf ${PDF_FILE} fi if [ "$CLEAN" == "true" ]; then Modified: trunk/sandbox/paultremblay/scripts/rstxml2mathml_sax.py =================================================================== --- trunk/sandbox/paultremblay/scripts/rstxml2mathml_sax.py 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/scripts/rstxml2mathml_sax.py 2011-10-24 01:50:43 UTC (rev 7200) @@ -4,12 +4,20 @@ import os, sys, argparse, io import xml.sax.handler from xml.sax.handler import feature_namespaces -from io import StringIO +from StringIO import StringIO + +""" +if sys.version_info < (3,): +else: + from io import StringIO +""" + import asciimathml from xml.etree.ElementTree import Element, tostring import xml.etree.cElementTree as etree import tempfile, subprocess, os -import docutils.math.latex2mathml +# import docutils.math.latex2mathml +from xml.sax import InputSource """ if sys.version_info < (3,): @@ -28,8 +36,15 @@ self.__mathml = mathml self.__ns_dict = {'http://www.w3.org/XML/1998/namespace';: "xml"} self.__raw = False + self.__fix_soft_hyphens = False + def startDocument(self): + pass + + def startElement(self, name, qname): + print('okay') + def characters (self, characters): self.__characters += characters @@ -76,14 +91,14 @@ def __write_text(self, raw = False): + soft_hyphen = chr(173) if raw: text = self.__characters else: text = xml.sax.saxutils.escape(self.__characters) - if sys.version_info < (3,): - sys.stdout.write(text.encode('utf8')) - else: - sys.stdout.write(text) + if self.__fix_soft_hyphens: + text = text.replace(soft_hyphen, '-') + sys.stdout.write(text) self.__characters = '' def endElementNS(self, name, qname): @@ -94,10 +109,16 @@ math_tree = Element('math', title="%s" % self.__characters, xmlns="http://www.w3.org/1998/Math/MathML";) math_tree.append(raw_tree) string_tree = tostring(math_tree, encoding="utf-8") + sys.stdout.write(string_tree.decode('utf8')) + """ if sys.version_info < (3,): - sys.stdout.write(string_tree) + print(type(string_tree)) + print() + sys.stdout.write(string_tree.decode('utf8')) + # sys.stdout.write(line.encode('utf8')) else: sys.stdout.write(string_tree.decode()) + """ self.__characters = '' elif (el_name == 'math_block' and self.__mathml == 'latex') or (el_name == 'math' and self.__mathml == 'latex'): raw_tree = self.__tralics() @@ -198,7 +219,7 @@ mathml = args.mathml if mathml: mathml = mathml[0] - if isinstance(in_file, io.TextIOWrapper): + if not isinstance(in_file, str): standard_in = True the_string = sys.stdin.read() if standard_in: Modified: trunk/sandbox/paultremblay/test.sh =================================================================== --- trunk/sandbox/paultremblay/test.sh 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/test.sh 2011-10-24 01:50:43 UTC (rev 7200) @@ -3,14 +3,31 @@ # RST_COMMAND="rst2xml.py --strip-comments --trim-footnote-reference-space" # TEST_COMMAND="docutils_to_fo.sh --noclean --format --valid --pdf --test --strict" -files=`find docutils_test \! -name 'standard.txt' \ +files=`find functional\ + \! -name 'standard.txt'\ \! -name 'standalone_rst_html4css1.txt'\ + \! -name 'dangerous.txt'\ + \! -name 'custom_roles.txt'\ + \! -name 'custom_roles_latex.txt'\ + \! -name 'standalone_rst_latex.txt'\ + \! -name 'standalone_rst_pseudoxml.txt'\ + \! -name 'standalone_rst_s5_html.txt'\ + \! -name 'latex.txt'\ + \! -name 'list_table.txt'\ + \! -name 'list_table.txt'\ + \! -name 'header_footer.txt'\ + \! -name 'standalone_rst_xetex.txt'\ -name '*txt'` +# header_footer.txt has no body, and causes fop to throw exception +# serious error with unicode.txt: it crashes with 00AD +# standalone_rst_xetex.txt contains latex raw for the_file in $files do - echo $the_file + echo + echo ======================================================== + echo working on file \"$the_file\" DIR=`dirname $the_file` if [ "$DIR" == "$the_file" ]; then DIRNAME="." @@ -19,15 +36,25 @@ fi PARENT_DIR=`basename $DIRNAME` - if [ "$PARENT_DIR" != "custom" ]; then - docutils_to_fo.sh --test $the_file - fi + docutils_to_fo.sh --test $the_file + echo ======================================================== done -files=`find test_files -name '*rst'` +# special cases for default +# get rid of strict +echo ======================================================== +echo working on standard.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/data/standard.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/standalone_rst_html4css1.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/dangerous.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/data/custom_roles.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/data/custom_roles_latex.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/standalone_rst_latex.txt +docutils_to_fo.sh --noclean --format --valid --pdf functional/input/standalone_rst_pseudoxml.txt + +files=`find test_files -name '*rst'` for the_file in $files do - echo $the_file DIR=`dirname $the_file` if [ "$DIR" == "$the_file" ]; then DIRNAME="." @@ -37,6 +64,7 @@ PARENT_DIR=`basename $DIRNAME` if [ "$PARENT_DIR" != "custom" ]; then + echo $the_file docutils_to_fo.sh --test $the_file fi done Added: trunk/sandbox/paultremblay/tools/get_docutils_standard_tests.sh =================================================================== --- trunk/sandbox/paultremblay/tools/get_docutils_standard_tests.sh (rev 0) +++ trunk/sandbox/paultremblay/tools/get_docutils_standard_tests.sh 2011-10-24 01:50:43 UTC (rev 7200) @@ -0,0 +1,25 @@ +set -e +set -u +Usage() { + echo Gets documents from docutils +} + +while [ $# -gt 0 ] +do + case "$1" in + + -) STDIN='true'; shift; break;; # ====> standard in + -h) Usage;exit 0;; # ==> Help message. + --help) UsaET=$1;; + -*) echo "Illegal command $1"; Usage; exit 1;; # ===> illegal help + *) break;; # first argument + esac + shift +done + +DIR=$1 + + +cp ${DIR}/docs/user/images/* docs/user/images +cp -R ${DIR}/docs/user/rst docs/user +cp -R ${DIR}/test/functional . Added: trunk/sandbox/paultremblay/tools/make_unicode_test.py =================================================================== --- trunk/sandbox/paultremblay/tools/make_unicode_test.py (rev 0) +++ trunk/sandbox/paultremblay/tools/make_unicode_test.py 2011-10-24 01:50:43 UTC (rev 7200) @@ -0,0 +1,12 @@ +import sys +if sys.version_info < (3,): + sys.stderr.write('Only run with pyton 3\n') + sys.stderr.write('Script now quiting\n') + sys.exit(1) + +def make_the_unicode(start_num, end_num): + for i in range(1,10): + char_num = start_num + i + sys.stdout.write(chr(char_num)) + +make_the_unicode(100, 200) Modified: trunk/sandbox/paultremblay/xsl_fo/bullet_list.xsl =================================================================== --- trunk/sandbox/paultremblay/xsl_fo/bullet_list.xsl 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/xsl_fo/bullet_list.xsl 2011-10-24 01:50:43 UTC (rev 7200) @@ -155,17 +155,12 @@ </fo:list-block> </xsl:when> <xsl:otherwise> - <xsl:message> - <xsl:text>Cannot format lists more than 2 levels deep</xsl:text> - </xsl:message> - <xsl:choose> - <xsl:when test="$strict='True'"> - <xsl:message terminate="yes">Processinng stylesheets now quiting</xsl:message> - </xsl:when> - <xsl:otherwise> - <xsl:message>Not formatting text</xsl:message> - </xsl:otherwise> - </xsl:choose> + <xsl:variable name="msg"> + <xsl:text>Cannot format bullet lists more than 2 levels deep</xsl:text> + </xsl:variable> + <xsl:call-template name="error-message"> + <xsl:with-param name="msg" select="$msg"/> + </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> Modified: trunk/sandbox/paultremblay/xsl_fo/error.xsl =================================================================== --- trunk/sandbox/paultremblay/xsl_fo/error.xsl 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/xsl_fo/error.xsl 2011-10-24 01:50:43 UTC (rev 7200) @@ -100,14 +100,16 @@ <xsl:call-template name="trace-siblings"/> </xsl:variable> <xsl:value-of select="$ancestors"/> - <xsl:text>[</xsl:text> - <xsl:for-each select="@*"> - <xsl:value-of select="name(.)"/> - <xsl:text>="</xsl:text> - <xsl:value-of select="."/> - <xsl:text>" </xsl:text> - </xsl:for-each> - <xsl:text>]</xsl:text> + <xsl:if test="@*"> + <xsl:text>[</xsl:text> + <xsl:for-each select="@*"> + <xsl:value-of select="name(.)"/> + <xsl:text>="</xsl:text> + <xsl:value-of select="."/> + <xsl:text>" </xsl:text> + </xsl:for-each> + <xsl:text>]</xsl:text> + </xsl:if> <xsl:text>
</xsl:text> <xsl:value-of select="$siblings"/> </xsl:template> @@ -117,22 +119,13 @@ <xsl:variable name="trace"> <xsl:call-template name="trace"/> </xsl:variable> - <xsl:message> + <xsl:variable name="msg"> <xsl:text>no match for </xsl:text> <xsl:value-of select="$trace"/> - </xsl:message> - <xsl:choose> - <xsl:when test="$strict !=''"> - <xsl:message terminate="yes"> - <xsl:text>Processing XSLT Stylesheets now quiting</xsl:text> - </xsl:message> - </xsl:when> - <xsl:otherwise> - <xsl:message> - <xsl:text>Not processing text in this element.</xsl:text> - </xsl:message> - </xsl:otherwise> - </xsl:choose> + </xsl:variable> + <xsl:call-template name="error-message"> + <xsl:with-param name="msg" select="$msg"/> + </xsl:call-template> </xsl:template> <xsl:template match="system_message[@type='ERROR']"> @@ -163,11 +156,11 @@ <xsl:template match="raw[@format]"> <xsl:if test="@format != 'xml'"> <xsl:variable name="msg"> - <xsl:text>Raw </xsl:text> + <xsl:text>Raw "</xsl:text> <xsl:value-of select="@format"/> - <xsl:text>Not allowd in an XML document</xsl:text> + <xsl:text>" not allowd in an XML document</xsl:text> </xsl:variable> - <xsl:call-template name="quit-message"> + <xsl:call-template name="error-message"> <xsl:with-param name="msg" select="$msg"/> </xsl:call-template> </xsl:if> @@ -184,11 +177,18 @@ <xsl:template name="error-message"> <xsl:param name="text"/> + <xsl:param name="msg"/> + <xsl:choose> + <xsl:when test="$text != ''"> + <xsl:message>Don't use "text" when passing messages to eror-message; use "msg"</xsl:message> + </xsl:when> + </xsl:choose> <xsl:message> <xsl:value-of select="$text"/> + <xsl:value-of select="$msg"/> </xsl:message> <xsl:choose> - <xsl:when test="$strict='True'"> + <xsl:when test="normalize-space($strict) != ''"> <xsl:call-template name="quit-message"/> </xsl:when> <xsl:otherwise> Modified: trunk/sandbox/paultremblay/xsl_fo/inline.xsl =================================================================== --- trunk/sandbox/paultremblay/xsl_fo/inline.xsl 2011-10-21 04:56:37 UTC (rev 7199) +++ trunk/sandbox/paultremblay/xsl_fo/inline.xsl 2011-10-24 01:50:43 UTC (rev 7200) @@ -126,7 +126,7 @@ <xsl:text>"</xsl:text> </xsl:variable> <xsl:call-template name="error-message"> - <xsl:with-param name="text" select="$msg"/> + <xsl:with-param name="msg" select="$msg"/> </xsl:call-template> </xsl:template> |