From c62877622c1e6d2b74f6ddaa6b6a5b898b8bfaa5 Mon Sep 17 00:00:00 2001 From: Katsuma Ito Date: Sun, 9 Jun 2013 03:52:06 +0900 Subject: [PATCH] Generate ReST header line with width of characters. --- pelican/tools/pelican_import.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index 5d0937fd..9efc57d9 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -344,7 +344,9 @@ def feed2fields(file): def build_header(title, date, author, categories, tags, slug): """Build a header from a list of fields""" - header = '%s\n%s\n' % (title, '#' * len(title)) + import unicodedata + title_width = sum([(2 if unicodedata.east_asian_width(c) in u"WFA" else 1) for c in title]) + header = '%s\n%s\n' % (title, '#' * title_width) if date: header += ':date: %s\n' % date if author: