Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

reStructuredText rendering errors have incorrect line numbers #145

Open
matt-garman opened this issue Nov 17, 2015 · 1 comment
Open

reStructuredText rendering errors have incorrect line numbers #145

matt-garman opened this issue Nov 17, 2015 · 1 comment

Comments

@matt-garman
Copy link
Contributor

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
Copy link
Owner

mythmon commented Nov 17, 2015

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.

matt-garman added a commit to matt-garman/wok that referenced this issue Dec 7, 2015
…of metadata. This is to fix issue mythmon#145: reStructuredText rendering errors have incorrect line numbers
matt-garman added a commit to matt-garman/wok that referenced this issue Dec 14, 2015
Prepend page content with X newlines, where X is the number of lines
of YAML metadata.  This is to fix issue mythmon#145: reStructuredText rendering
errors have incorrect line numbers.

Note: cherry-picked from 2cd19ed,
re-creating branch to cleanup my git mess.

Conflicts:
	test_site/content/tests/rest_error.rst
matt-garman added a commit to matt-garman/wok that referenced this issue Dec 16, 2015
- Add file "test_site/wok_expected_output-test_site" which is the
  output of "wok -v" when run with current upstream master.
- Introduce new environment variable "CMP_OUTPUT" in .travis.yml.
- Enhance bin/site-tests such that if CMP_OUTPUT==true, it will run
  cmp on the wok_expected_output-$TEST_SITE file versus the output
  of the "wok -v" run.
- Goal of this enhancement is to support more robust testing of
  fixes for issues mythmon#144 and mythmon#145.
edunham pushed a commit to edunham/wok that referenced this issue Nov 15, 2016
- Add file "test_site/wok_expected_output-test_site" which is the
  output of "wok -v" when run with current upstream master.
- Introduce new environment variable "CMP_OUTPUT" in .travis.yml.
- Enhance bin/site-tests such that if CMP_OUTPUT==true, it will run
  cmp on the wok_expected_output-$TEST_SITE file versus the output
  of the "wok -v" run.
- Goal of this enhancement is to support more robust testing of
  fixes for issues mythmon#144 and mythmon#145.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants