From: David G. <go...@py...> - 2005-02-25 01:46:59
|
[Pierre-Yves Delens] > Bonjour [from Belgium ==> locale could be of importance : éèàù :( The locale may affect processing, but it doesn't matter if the input text encoding is explicitly declared. Looking at stest.txt, I see several non-ASCII characters (éèàù, assuming a Latin-1 encoding). But your index_PlainPython.py program declares the encoding of all input files as ASCII. > # index_PlainPython.py created as to debug Docutils side of this > Webware servlet > from docutils.core import publish_file, default_description > # import LTF_UtilsA > # ascii , latin-1, iso-8859-1 > overrides = {'input_encoding': 'ascii', This says "all input files are ASCII". But stest.txt is not ASCII. > 'output_encoding': 'latin-1', This is fine. > 'settings':'docutils.conf'} There is no 'settings' setting; this entry will have no effect. There is a "--config" command-line option (and an associated "config" setting), but it can only be used from the command line. In other words, specifying a value for 'config' in settings_overrides has no effect. See http://docutils.sf.net/docs/user/config.html for details of all runtime settings & config files. A docutils.conf file in the current working directory will be picked up automatically. What's in your docutils.conf anyhow? That may affect processing. > publish_file(source_path='C:\\PythonZone\\LTF\\DocutilsTools\\stest.txt', \ You don't need backslashes between lines when they're enclosed in parentheses. > destination_path='C:\\PythonZone\\LTF\\DocutilsTools\\stest.html', > writer_name='html', settings_overrides=overrides) > print 'done' What version of Docutils, Python, and your OS are you running? I recently made a change to the input file decoding which makes it much more deterministic. Previously, a mis-declared input encoding would be ignored. And I just made another change that should make the error reporting much clearer. Try the latest code from CVS or a snapshot. > 1.Bug with Html writer > ---------------------- ... > . QUESTION 1 : What should I do as to get it OK on winXP ? Tell Docutils the correct encoding of the input text. In the case of stext.txt, I think it should be "latin-1", not "ascii". > The bugtrack is copied atthe end of the present mail ; see > especially these 2 lines : > > File "C:\Python23\Lib\site-packages\docutils\writers\html4css1.py", > line 231, in astext > return ''.join(self.head_prefix + self.head This line shouldn't have anything to do with your problem. Unless your docutils.conf has an output_encoding setting. Config file settings take priority over settings in the code, like settings_overrides. And command-line options take highest priority. > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position > 166: ordinal not in range(128) This is significant though. It tells you that some text that is supposed to be ASCII, is not ASCII. > 2.Configuring docutils > ---------------------- > I need to get control on an app' specific docutils.conf and CSS to > be used when publishing with publish_file. > I guess I'm talking about 'runtime settings'. > And also about config files, which I got to understand when I was > working via DocFactory. > > But, despite wreading through numerous docs, I faled to chain > together the 'overrides', and 'settings' related parmas in my > publish_file call. What you're doing is mostly fine. Just change input_encoding="ascii" to input_encoding="latin-1". > I didn't find examples for this use case. There's an extensive explanation here: http://docutils.sf.net/docs/api/runtime-settings.html > Question 2 : Does someone have snippets or examples for this usecase ? Try looking in the docutils/examples.py module. -- David Goodger <http://python.net/~goodger> |