Improve mechanisms of encoding
- we now let writers return already-encoded text, this helps in a few cases. darcs-hash:20090707200621-82ea9-e012cd62add13db0c62016414585846a6ed817f7.gz
This commit is contained in:
parent
db794fc512
commit
73548040fe
@ -158,8 +158,10 @@ class Config(object):
|
|||||||
# If it doesn't, then it's assumed that the write took
|
# If it doesn't, then it's assumed that the write took
|
||||||
# care of writing (or publishing or emailing or wikifying)
|
# care of writing (or publishing or emailing or wikifying)
|
||||||
# it itself.
|
# it itself.
|
||||||
|
if isinstance(text, unicode):
|
||||||
|
text = self.enc(text)
|
||||||
if isinstance(text, (str, unicode)):
|
if isinstance(text, (str, unicode)):
|
||||||
self.writeToFile(self.enc(text), rawname+extension)
|
self.writeToFile(text, rawname+extension)
|
||||||
def writeToFile(self, string, filename):
|
def writeToFile(self, string, filename):
|
||||||
"""Write a given string to a file"""
|
"""Write a given string to a file"""
|
||||||
# The reason we have this method just for this is to proxy
|
# The reason we have this method just for this is to proxy
|
||||||
|
11
writers.py
11
writers.py
@ -140,7 +140,8 @@ class HTMLlog(_BaseWriter):
|
|||||||
# That's only right before the i/o functions in the Config
|
# That's only right before the i/o functions in the Config
|
||||||
# object.
|
# object.
|
||||||
formatter = HtmlFormatter(lineanchors='l',
|
formatter = HtmlFormatter(lineanchors='l',
|
||||||
full=True, style=M.config.pygmentizeStyle)
|
full=True, style=M.config.pygmentizeStyle,
|
||||||
|
output_encoding=self.M.config.output_codec)
|
||||||
Lexer = IrcLogsLexer
|
Lexer = IrcLogsLexer
|
||||||
Lexer.tokens['msg'][1:1] = \
|
Lexer.tokens['msg'][1:1] = \
|
||||||
[ # match: #topic commands
|
[ # match: #topic commands
|
||||||
@ -390,11 +391,5 @@ class HTMLfromReST(_BaseWriter):
|
|||||||
rstToHTML = docutils.core.publish_string(rst, writer_name='html',
|
rstToHTML = docutils.core.publish_string(rst, writer_name='html',
|
||||||
settings_overrides={'file_insertion_enabled': 0,
|
settings_overrides={'file_insertion_enabled': 0,
|
||||||
'raw_enabled': 0,
|
'raw_enabled': 0,
|
||||||
'output_encoding':'utf-8'})
|
'output_encoding':self.M.config.output_codec})
|
||||||
# Unfortunantly, docutils forces us to encode to some charset.
|
|
||||||
# We have to return a utf-8 thing to be encoded later, so we
|
|
||||||
# hack decode here, only to be re-encoded later. (I've dug
|
|
||||||
# into the docutils internals, it's not obvious that I could
|
|
||||||
# do this easily.)
|
|
||||||
rstToHTML = rstToHTML.decode('utf-8', 'replace')
|
|
||||||
return rstToHTML
|
return rstToHTML
|
||||||
|
Loading…
Reference in New Issue
Block a user