mythmon / wok

A static website generator - Toss some content, templates, and media in a pan and fry it up!
http://wok.mythmon.com
Other
112 stars 48 forks source link

reStructuredText rendering errors have incorrect line numbers #145

Open matt-garman opened 8 years ago

matt-garman commented 8 years ago

When rendering a ReStructuredText document (not sure about other document types), if an error is encountered, the line numbers shown are incorrect. For example:

<string>:29: (ERROR/3) Unexpected indentation.

The actual error is on line 34 of my document. This appears to be due to the YAML metadata header in my document, which happens to be exactly 5 lines long. This is consistent across other documents with varying YAML metadata line counts. Clearly the YAML header is stripped off the RST document before being fed to docutils.

It's not too hard to mentally workaround this now that I know to keep it in mind.

I can think of two possible fixes for this:

  1. Prepend N blank lines to the RST document that is fed to docutils, where N is equal to the number of YAML metadata lines. Kind of a hack, but presumably easier.
  2. Extract metadata from RST directly, rather than using YAML. Before coming to Wok, I was dabbling with Pelican (another static blog generator that supports RST). Pelican does this exactly, i.e. instead of mixing YAML + RST, the entire source document is pure RST (or Markdown), and the metadata is extracted using the native document tools.
mythmon commented 8 years ago

I think prepending the N blank lines is the better solution here. Wok works with multiple sources of data, including Markdown and plain text, neither of which have metadata options built in. I would prefer to have a consistent metadata structure, and the header provides that.