diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-02-16 17:13:48 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-02-16 17:13:48 +0200 |
commit | e133e66ac3255a3abf88e0bea5a9177f21a8bf0f (patch) | |
tree | d959840c0408959089ce3c0b5bcc8ffcf7379a22 | |
parent | b362d4ddb335dda487417ff1a59e97946c2c2819 (diff) | |
download | jt-e133e66ac3255a3abf88e0bea5a9177f21a8bf0f.tar.gz |
Handle unicode more consistentlyliw/nonascii
-rw-r--r-- | jtlib/app.py | 8 | ||||
-rw-r--r-- | jtlib/draftsdir.py | 2 | ||||
-rw-r--r-- | yarns/020-basic-workflow.yarn | 9 |
3 files changed, 13 insertions, 6 deletions
diff --git a/jtlib/app.py b/jtlib/app.py index ad0d7a3..ddbb94a 100644 --- a/jtlib/app.py +++ b/jtlib/app.py @@ -134,5 +134,9 @@ class JournalTool(cliapp.Application): def render_template(self, basename, vars): text = self.read_template(basename) - template = jinja2.Template(text) - return template.render(**vars) + utext = unicode(text, 'utf8') + uvars = dict( + (unicode(k, 'utf8'), unicode(v, 'utf8')) + for k, v in vars.items()) + template = jinja2.Template(utext) + return template.render(**uvars) diff --git a/jtlib/draftsdir.py b/jtlib/draftsdir.py index 59eb47d..67b4e66 100644 --- a/jtlib/draftsdir.py +++ b/jtlib/draftsdir.py @@ -39,7 +39,7 @@ class DraftsDirectory(object): draft_id = self._pick_available_draft_id() pathname = self.get_draft_pathname(draft_id) with open(pathname, 'w') as f: - f.write(content) + f.write(content.encode('utf8')) return draft_id def _pick_available_draft_id(self): diff --git a/yarns/020-basic-workflow.yarn b/yarns/020-basic-workflow.yarn index fc1c756..d86ab0b 100644 --- a/yarns/020-basic-workflow.yarn +++ b/yarns/020-basic-workflow.yarn @@ -12,16 +12,19 @@ invoked, because it'd be difficult to control the editor. SCENARIO add a simple note GIVEN an empty journal in SRC AND the time is 2014-11-22 17:30:45 - WHEN I run jt new TITLE + WHEN I run jt new TITLE-TRÖÖT THEN file SRC/drafts/0.mdwn exists - AND file SRC/drafts/0.mdwn matches title="TITLE" + AND file SRC/drafts/0.mdwn matches title="TITLE-TRÖÖT" + +(Note that we use a title with non-ASCII characters to make sure jt +handles that.) This is where the user would normally use their editor to edit the draft, and exit the editor when done. WHEN I run jt finish THEN file SRC/drafts/0.mdwn doesn't exist - AND file SRC/notes/2014/11/22/title.mdwn exists + AND file SRC/notes/2014/11/22/title-tr_t.mdwn exists This is how you create a note, in the simplest case. A more complex case is when there's more than one draft at a time. |