zacharyvoase / markdoc

A lightweight Markdown-based wiki system. Current status: abandoned.
http://markdoc.org/
The Unlicense
347 stars 74 forks source link

Support for none-ascii wiki md filename #9

Open yegle opened 12 years ago

yegle commented 12 years ago

When I name my file as 测试.md in wiki and run markdoc build, there will be an exception:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 3: ordinal not in range(128)

Full exception can be find here http://pastie.org/2979381

yegle commented 12 years ago

OK, the title should be change to: use unicode instead of str in the whole project.

I tried to fix this issue but found that I need to convert so many str to unicode using str.unicode().

yegle commented 12 years ago

The right fix, super simple right? :-)

diff --git a/src/markdoc/config.py b/src/markdoc/config.py
index 1a64633..722ac4f 100644
--- a/src/markdoc/config.py
+++ b/src/markdoc/config.py
@@ -64,8 +64,8 @@ class Config(dict):
     def __init__(self, config_file, config):
         super(Config, self).__init__(flatten(config))

-        self['meta.config-file'] = config_file
-        self['meta.root'] = p.dirname(config_file)
+        self['meta.config-file'] = config_file.decode('utf-8')
+        self['meta.root'] = p.dirname(config_file).decode('utf-8')

     def __getitem__(self, key):
         try: