summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2004-09-12 21:18:45 +0000
committergoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2004-09-12 21:18:45 +0000
commit439e10c3dc34a84fe174a288bfbefd7491c9f070 (patch)
treea43f5380f232439981aac9965f93fc13bd4698e3
parent1a6a5138cc6fe3ede8e5ef7f6ff62cbb9e064128 (diff)
downloaddocutils-439e10c3dc34a84fe174a288bfbefd7491c9f070.tar.gz
updated
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2594 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt34
-rw-r--r--docs/user/config.txt19
-rw-r--r--docutils/writers/latex2e.py4
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_tables.py110
4 files changed, 150 insertions, 17 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index fbe799499..6e450729e 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -14,11 +14,38 @@
Changes Since 0.3.5
===================
+* docutils/frontend.py:
+
+ - Added --input-encoding-error-handler option & setting.
+
+* docutils/io.py:
+
+ - Added support for input encoding error handler.
+
+* docutils/nodes.py:
+
+ - Added dispatch_visit and dispatch_departure methods to
+ NodeVisitor; useful as a hook for Visitors.
+
+* docutils/parsers/rst/directives/__init__.py:
+
+ - Added ``encoding`` directive option conversion function.
+
+* docutils/parsers/rst/directives/misc.py:
+
+ - Added "encoding" option to "include" and "raw" directives.
+
* docutils/parsers/rst/directives/parts.py:
- Directive "sectnum" now accepts "prefix", "suffix", and "start"
options. Thanks to Lele Gaifax.
+* docutils/parsers/rst/directives/tables.py:
+
+ - Added "encoding" directive to "csv-table" directive.
+ - Added workaround for lack of Unicode support in csv.py, for
+ non-ASCII CSV input.
+
* docutils/transforms/misc.py:
- Fixed bug when multiple "class" directives are applied to a single
@@ -26,9 +53,12 @@ Changes Since 0.3.5
* docutils/writers/latex2e.py:
- - Add ``\PreloadUnicodePage{n}`` to the header if in LaTeX code
+ - Added ``\PreloadUnicodePage{n}`` to the header if in LaTeX code
uses unicode.
- - Add option "font-encoding".
+ - Added option "font-encoding".
+ - Added "class" attribute support via the --call-class-command
+ option and ``\\docutilsclass`` TeX calls.
+
Release 0.3.5 (2004-07-29)
==========================
diff --git a/docs/user/config.txt b/docs/user/config.txt
index 98fa32cac..776e8cbdd 100644
--- a/docs/user/config.txt
+++ b/docs/user/config.txt
@@ -254,6 +254,25 @@ _`input_encoding`
Default: auto-detect (None). Options: ``--input-encoding, -i``.
+_`input_encoding_error_handler`
+ The error handler for undecodable characters in the input.
+ Acceptable values include:
+
+ strict
+ Raise an exception in case of an encoding error.
+ replace
+ Replace malformed data with the official Unicode replacement
+ character, U+FFFD.
+ ignore
+ Ignore malformed data and continue without further notice.
+
+ Acceptable values are the same as for the "error" parameter of
+ Python's ``unicode`` function; other values may be defined in
+ applications or in future versions of Python.
+
+ Default: "strict". Options: ``--input-encoding-error-handler,
+ --input-encoding, -i``.
+
_`language_code`
`ISO 639`_ 2-letter language code (3-letter codes used only if no
2-letter code exists).
diff --git a/docutils/writers/latex2e.py b/docutils/writers/latex2e.py
index 95079fd04..1aa8a5ce8 100644
--- a/docutils/writers/latex2e.py
+++ b/docutils/writers/latex2e.py
@@ -510,14 +510,14 @@ class Table:
class LaTeXTranslator(nodes.NodeVisitor):
- def dispatch_visit(self, node, method_name):
+ def dispatch_visit(self, node):
if self.call_class and \
isinstance(node, nodes.Element) and \
node.hasattr('class'):
self.body.append('\\docutilsclass{%s}{' % node.get('class'))
return nodes.NodeVisitor.dispatch_visit(self, node, method_name)
- def dispatch_depart(self, node, method_name):
+ def dispatch_depart(self, node):
r = nodes.NodeVisitor.dispatch_depart(self, node, method_name)
if self.call_class and \
isinstance(node, nodes.Element) and \
diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py
index e3def1aa0..50a03f2e5 100755
--- a/test/test_parsers/test_rst/test_directives/test_tables.py
+++ b/test/test_parsers/test_rst/test_directives/test_tables.py
@@ -12,6 +12,7 @@ Tests for tables.py directives.
from __init__ import DocutilsTestSupport
+import os
try:
import csv
except ImportError:
@@ -23,6 +24,10 @@ def suite():
s.generateTests(totest)
return s
+mydir = os.path.dirname(suite.func_code.co_filename)
+utf_16_csv = os.path.join(mydir, 'utf-16.csv')
+utf_16_csv_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_csv)
+
totest = {}
totest['table'] = [
@@ -101,7 +106,10 @@ totest['table'] = [
"""],
]
-if csv:
+if not csv:
+ print ('Tests of "csv-table" directive skipped; '
+ 'Python 2.3 or higher required.')
+else:
totest['csv-table'] = [
["""\
.. csv-table:: inline with integral header
@@ -388,7 +396,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: insufficient header row data
:header-rows: 2
-
+ \n\
some, csv, data
"""],
["""\
@@ -405,7 +413,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: insufficient body data
:header-rows: 1
-
+ \n\
some, csv, data
"""],
["""\
@@ -422,7 +430,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: content and external
:file: bogus.csv
-
+ \n\
some, csv, data
"""],
["""\
@@ -449,7 +457,7 @@ u"""\
<document source="test data">
<table>
<title>
- error in the
+ error in the \n\
<problematic id="id2" refid="id1">
*
title
@@ -514,7 +522,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: column mismatch
:widths: 10,20
-
+ \n\
some, csv, data
"""],
["""\
@@ -538,7 +546,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: bad column widths
:widths: 10,y,z
-
+ \n\
some, csv, data
<system_message level="3" line="6" source="test data" type="ERROR">
<paragraph>
@@ -548,7 +556,7 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: bad column widths
:widths: 0 0 0
-
+ \n\
some, csv, data
"""],
["""\
@@ -686,7 +694,7 @@ u"""\
newline inside string
<literal_block xml:space="preserve">
.. csv-table:: bad CSV data
-
+ \n\
"bad", \"csv, data
"""],
["""\
@@ -704,13 +712,89 @@ u"""\
<literal_block xml:space="preserve">
.. csv-table:: bad CSV header data
:header: "bad", \"csv, data
-
+ \n\
good, csv, data
"""],
+["""\
+.. csv-table:: bad encoding
+ :file: %s
+ :encoding: latin-1
+
+(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+""" % utf_16_csv,
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error with CSV data in "csv-table" directive:
+ string with NUL bytes
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad encoding
+ :file: %s
+ :encoding: latin-1
+ <paragraph>
+ (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+""" % utf_16_csv],
+["""\
+.. csv-table:: good encoding
+ :file: %s
+ :encoding: utf-16
+ :header-rows: 1
+""" % utf_16_csv,
+u"""\
+<document source="test data">
+ <table>
+ <title>
+ good encoding
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <paragraph>
+ Description
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatr\u00b0\u00df
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ \u00a1On a \u03c3\u03c4\u03b9\u03ba!
+ <row>
+ <entry>
+ <paragraph>
+ Crunchy Frog
+ <entry>
+ <paragraph>
+ 1.49
+ <entry>
+ <paragraph>
+ If we took the b\u00f6nes out, it wouldn\u2019t be
+ crunchy, now would it?
+ <row>
+ <entry>
+ <paragraph>
+ Gannet Ripple
+ <entry>
+ <paragraph>
+ 1.99
+ <entry>
+ <paragraph>
+ \u00bfOn a \u03c3\u03c4\u03b9\u03ba?
+"""],
]
-else:
- print ('Tests of "csv-table" directive skipped; '
- 'Python 2.3 or higher required.')
if __name__ == '__main__':