executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
759 stars 196 forks source link

Support building line blocks with markdown-it hardbreaks #948

Open jdknight opened 4 months ago

jdknight commented 4 months ago

Provides the ability to build docutils' line-block nodes if an inline element contains hardbreaks. When a hardbreak is detected as a child of an inline token, a line-block will be created and child tokens will be rendered into a prepared line node. Child nodes are placed into a line node until the next hardbreak is detected, where a new line node is created to hold the next child set. The process repeats until all children are processed.


This change is in relation to https://github.com/executablebooks/MyST-Parser/issues/877. The change should allow any translator type to handle these line breaks, without requiring the raw directive.

With a document:

# Test

PATH        to be explained \
PYTHONPATH  to be explained \
GRUB        to be explained

Example renderings:

(HTML) image

(PDF) image

(Confluence) image

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.14%. Comparing base (d3d7fbb) to head (08f1afa).

Files Patch % Lines
myst_parser/mdit_to_docutils/base.py 96.29% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #948 +/- ## ======================================= Coverage 90.14% 90.14% ======================================= Files 24 24 Lines 3418 3441 +23 ======================================= + Hits 3081 3102 +21 - Misses 337 339 +2 ``` | [Flag](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/948/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | | |---|---|---| | [pytests](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | `90.14% <96.29%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.