Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detecting missing blank lines before section headers #47

Open
keewis opened this issue Oct 21, 2023 · 2 comments
Open

detecting missing blank lines before section headers #47

keewis opened this issue Oct 21, 2023 · 2 comments
Labels
question Further information is requested

Comments

@keewis
Copy link

keewis commented Oct 21, 2023

At the moment, this:

paragraph

Section
-------
section content

is parsed to (document (paragraph) (section (title)) (paragraph)).

However, mistakenly omitting the blank line:

paragraph
Section
-------
section content

is parsed to (document (paragraph)), where the paragraph contains a node for each word and every single adornment character.

If we were to change the first line to a definition list:

term : classifier
    definition
Section
-------
section content

the parsed result would contain a error node:

(document (ERROR (list_item (term) (classifier) (definition (paragraph)))))

For comparison, with the blank line, the document parses as

(document (definition_list (list_item (term) (classifier) (definition (paragraph)))) (section (title)) (paragraph))

Would it be possible to always create an error node if there is a blank line missing before a section? If not, what kind of query would I need to use to detect something like this?

@keewis keewis changed the title detecting missing blank lines between sections detecting missing blank lines before sections Oct 21, 2023
@keewis keewis changed the title detecting missing blank lines before sections detecting missing blank lines before section headers Oct 21, 2023
@stsewd
Copy link
Owner

stsewd commented Oct 24, 2023

Would it be possible to always create an error node if there is a blank line missing before a section?

I may look into what docutils does for cases like this.

If not, what kind of query would I need to use to detect something like this?

Since the text is parsed as a text paragraph, you'll need to manually check the text.

@keewis
Copy link
Author

keewis commented Oct 24, 2023

I may look into what docutils does for cases like this.

docutils appears to do something similar: warn / error (not sure how to interpret the output) if there's no blank line between definition list and section, but if there's a paragraph in front of the section concatenate it to that paragraph.

I guess the question now is: is there ever a case where you'd want to have something within a paragraph that resembles a section? If not, I'd argue that it is better to deviate from what docutils is doing and raise an error.

@stsewd stsewd added the question Further information is requested label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants