Skip to content
New issue

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

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

Already on GitHub? # to your account

Generators/Markdown: fix line break and indentation handling #737

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 27, 2024

Description

As things were, line breaks in a <standard> block were not respected for proper display in markdown.

As a side-effect of this, an indented text line in a <standard> block directly after a blank line, would unintentionally cause the markdown to display the line as a code block (via the indentation).

This has now been fixed by:

  • Trimming indentation off each line.
  • Adding two spaces to the end of each line as long as the line is not followed by a blank line or at the end of the standard block. The two spaces will ensure markdown will recognize the line break (in most markdown flavours).

Includes updated test expectations.

Refs:

Before

3-standard-markdown-blank-line-and-indent-before-example-1
3-standard-markdown-blank-line-and-indent-before-example-2

After

3-standard-markdown-blank-line-and-indent-after-example-1
3-standard-markdown-blank-line-and-indent-after-example-2

Suggested changelog entry

Generators/Markdown: line breaks in blocks will now be respected when generating the Markdown documentation.
This also prevents additional paragraphs from being displayed as code blocks.

Related issues/external references

This PR is part of a series of PRs which will add a complete set of tests (and improvements) for the Generator feature.

Also see: #671 and #717.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

As things were, line breaks in a `<standard>` block were not respected for proper display in markdown.

As a side-effect of this, an indented text line in a `<standard>` block directly after a blank line, would unintentionally cause the markdown to display the line as a code block (via the indentation).

This has now been fixed by:
* Trimming indentation off each line.
* Adding two spaces to the end of each line as long as the line is not followed by a blank line or at the end of the standard block.
    The two spaces will ensure markdown will recognize the line break (in most markdown flavours).

Includes updated test expectations.

Refs:
* https://www.markdownguide.org/basic-syntax/#paragraph-best-practices
* https://www.markdownguide.org/basic-syntax/#line-break-best-practices
* https://daringfireball.net/projects/markdown/syntax#p
@jrfnl jrfnl added this to the 3.11.2 milestone Nov 27, 2024
@jrfnl jrfnl merged commit fbe7599 into master Dec 1, 2024
59 checks passed
@jrfnl jrfnl deleted the feature/generator-markdown-fix-line-break-indentation-handling branch December 1, 2024 07:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant