Skip to content

Fix a problem with HeadingAnchors to not write out html as xml #92

Merged
merged 1 commit into from Nov 8, 2012

2 participants

@hpvb
hpvb commented Oct 18, 2012

This code adds a trivial check on the extension of the template used to generate the file. If the template ends in html or htm it will instruct lxml to treat the stream as HTML.

@mythmon mythmon commented on an outdated diff Oct 18, 2012
wok/contrib/hooks.py
@@ -57,7 +57,14 @@ def __call__(self, page):
heading.set('id', name)
sio_destination = StringIO()
- tree.write(sio_destination)
+
+ ''' Use the extension of the template to determine the type of document '''
@mythmon
Owner
mythmon added a note Oct 18, 2012

This should be a comment instead of a string. This isn't a docstring, so the triple quote syntax shouldn't be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mythmon mythmon commented on an outdated diff Oct 18, 2012
wok/contrib/hooks.py
@@ -57,7 +57,14 @@ def __call__(self, page):
heading.set('id', name)
sio_destination = StringIO()
- tree.write(sio_destination)
+
+ ''' Use the extension of the template to determine the type of document '''
+ if page.template.filename.endswith("html") or page.filename.endswith("htm"):
@mythmon
Owner
mythmon added a note Oct 18, 2012

This should probably check for .html instead of just html. (ie, include the .)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mythmon
Owner
mythmon commented Oct 18, 2012

The commit message should be structures as a short subject, followed by a blank line, followed by the body. The subject should be less than 50 characters.

Notices how the commit message you have now is truncated on the commits tab of this page.

@hpvb hpvb Lxml by default writes out its tree as XML
By default lxml writes its parsetree out using XML rules, closing
empty tags. This is a problem when writing out HTML files.
af332e6
@mythmon mythmon merged commit 50c9405 into mythmon:master Nov 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.