Update Feb 16: If you came looking for a solution to a template error in the title; see this link for the solution. This post is about static blog generators.
Still blogging with wordpress despite my repeated assurances that I am moving away from it. This time my excuse is the error message in the title. In the previous post, we talked about Cactus, Volt and Cactus blog. That discussion was left off with a character encoding error.
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 772: ordinal not in range(128). — Note: Markdown only accepts unicode input!
This is becuase “Python-Markdown expects Unicode as input (although a simple ASCII string may work) and returns output as Unicode.” (python markdown docs). Less said about unicode support in PHP 5 and wordpress the better. So let’s talk about adapting our input. That can be managed by a slight mod to the markdown.py file. Here is the diff:
4d3
< import codecs
28d26
< print path
31,34c29,30
< with codecs.open(path, mode="r", encoding="utf-8") as f:
<
< text = f.read()
< html = md.convert(text) --- > with open(path, 'r') as f:
> html = md.convert(f.read())
43,44c39
<
< with codecs.open(outPath, "w", encoding="utf-8", errors="xmlcharrefreplace") as f: --- > with open(outPath, 'w') as f:
47c42,44
< '\n'.join(metadata),"","", --- > '\n'.join(metadata),
> md.Meta['extends'][0],
> md.Meta['block'][0],
52c49
< md.reset(); --- >
The diff is against the 18131bc2d3b03ca8ace59ec3f7ae43e8073439e3 commit. This took me a few steps forward. And then:
Traceback (most recent call last):
File "/usr/local/bin/cactus", line 9, in
load_entry_point('Cactus==2.1.3', 'console_scripts', 'cactus')()
File "/usr/local/lib/python2.7/dist-packages/cactus/cli.py", line 75, in main
build(os.getcwd())
File "/usr/local/lib/python2.7/dist-packages/cactus/cli.py", line 28, in build
site.build()
File "/usr/local/lib/python2.7/dist-packages/cactus/site.py", line 128, in build
multiMap(lambda p: p.build(), self.pages())
File "/usr/local/lib/python2.7/dist-packages/cactus/site.py", line 128, in
multiMap(lambda p: p.build(), self.pages())
File "/usr/local/lib/python2.7/dist-packages/cactus/page.py", line 75, in build
data = self.render()
File "/usr/local/lib/python2.7/dist-packages/cactus/page.py", line 67, in render
return Template(data).render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 125, in __init__
self.nodelist = compile_string(template_string, origin)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 153, in compile_string
return parser.parse()
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 267, in parse
compiled_result = compile_func(self, token)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 214, in do_extends
nodelist = parser.parse()
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 267, in parse
compiled_result = compile_func(self, token)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 179, in do_block
raise TemplateSyntaxError("'%s' tag takes only one argument" % bits[0])
django.template.base.TemplateSyntaxError: 'block' tag takes only one argument
Oh well.