commonmark / commonmark-java

Java library for parsing and rendering CommonMark (Markdown)
BSD 2-Clause "Simplified" License
2.31k stars 288 forks source link

Text content line break rendering #344

Closed robinst closed 1 month ago

robinst commented 1 month ago

Fixes #264. Users will be able to configure the line break rendering like this:

var renderer = TextContentRenderer.builder().lineBreakRendering(LineBreakRendering.SEPARATE_BLOCKS).build();

Then input Markdown like this:

foo

bar

Will be rendered like this:

foo

bar

Note that it will separate all blocks (which is slightly different from preserving what the input was), e.g. this:

foo
1. bar

Will be rendered:

foo

1. bar
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 95.45455% with 4 lines in your changes missing coverage. Please review.

Project coverage is 95.02%. Comparing base (f82f1e6) to head (6cef998). Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...ark/renderer/text/CoreTextContentNodeRenderer.java 95.12% 1 Missing and 1 partial :warning:
.../commonmark/renderer/text/TextContentRenderer.java 75.00% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #344 +/- ## ============================================ + Coverage 94.97% 95.02% +0.04% + Complexity 254 252 -2 ============================================ Files 136 137 +1 Lines 4360 4380 +20 Branches 621 620 -1 ============================================ + Hits 4141 4162 +21 Misses 116 116 + Partials 103 102 -1 ``` | [Files with missing lines](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark) | Coverage Δ | | |---|---|---| | [.../tables/internal/TableTextContentNodeRenderer.java](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?src=pr&el=tree&filepath=commonmark-ext-gfm-tables%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommonmark%2Fext%2Fgfm%2Ftables%2Finternal%2FTableTextContentNodeRenderer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark#diff-Y29tbW9ubWFyay1leHQtZ2ZtLXRhYmxlcy9zcmMvbWFpbi9qYXZhL29yZy9jb21tb25tYXJrL2V4dC9nZm0vdGFibGVzL2ludGVybmFsL1RhYmxlVGV4dENvbnRlbnROb2RlUmVuZGVyZXIuamF2YQ==) | `100.00% <100.00%> (+6.45%)` | :arrow_up: | | [...g/commonmark/renderer/text/LineBreakRendering.java](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?src=pr&el=tree&filepath=commonmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommonmark%2Frenderer%2Ftext%2FLineBreakRendering.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark#diff-Y29tbW9ubWFyay9zcmMvbWFpbi9qYXZhL29yZy9jb21tb25tYXJrL3JlbmRlcmVyL3RleHQvTGluZUJyZWFrUmVuZGVyaW5nLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...rg/commonmark/renderer/text/TextContentWriter.java](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?src=pr&el=tree&filepath=commonmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommonmark%2Frenderer%2Ftext%2FTextContentWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark#diff-Y29tbW9ubWFyay9zcmMvbWFpbi9qYXZhL29yZy9jb21tb25tYXJrL3JlbmRlcmVyL3RleHQvVGV4dENvbnRlbnRXcml0ZXIuamF2YQ==) | `86.53% <100.00%> (+8.41%)` | :arrow_up: | | [...ark/renderer/text/CoreTextContentNodeRenderer.java](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?src=pr&el=tree&filepath=commonmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommonmark%2Frenderer%2Ftext%2FCoreTextContentNodeRenderer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark#diff-Y29tbW9ubWFyay9zcmMvbWFpbi9qYXZhL29yZy9jb21tb25tYXJrL3JlbmRlcmVyL3RleHQvQ29yZVRleHRDb250ZW50Tm9kZVJlbmRlcmVyLmphdmE=) | `92.74% <95.12%> (+0.55%)` | :arrow_up: | | [.../commonmark/renderer/text/TextContentRenderer.java](https://app.codecov.io/gh/commonmark/commonmark-java/pull/344?src=pr&el=tree&filepath=commonmark%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommonmark%2Frenderer%2Ftext%2FTextContentRenderer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=commonmark#diff-Y29tbW9ubWFyay9zcmMvbWFpbi9qYXZhL29yZy9jb21tb25tYXJrL3JlbmRlcmVyL3RleHQvVGV4dENvbnRlbnRSZW5kZXJlci5qYXZh) | `93.02% <75.00%> (-4.48%)` | :arrow_down: |