Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html),
with the exception that 0.x versions can break between minor versions.

## [Unreleased]
### Fixed
- Line(s) after a hard line break would sometimes also get an unwanted hard
line break, e.g. if they ended in emphasis or other non-text inlines (#415)

## [0.27.0] - 2025-10-12
### Added
- Autolink extension: Now supports configuration of different link types that
Expand Down Expand Up @@ -510,6 +515,7 @@ API breaking changes (caused by changes in spec):
Initial release of commonmark-java, a port of commonmark.js with extensions
for autolinking URLs, GitHub flavored strikethrough and tables.

[Unreleased]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.27.0...main
[0.27.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.26.0...commonmark-parent-0.27.0
[0.26.0]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.25.1...commonmark-parent-0.26.0
[0.25.1]: https://github.com/commonmark/commonmark-java/compare/commonmark-parent-0.25.0...commonmark-parent-0.25.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,9 @@ static String parseLinkLabel(Scanner scanner) {
private Node parseLineBreak() {
scanner.next();

if (trailingSpaces >= 2) {
var hard = trailingSpaces >= 2;
trailingSpaces = 0;
if (hard) {
return new HardLineBreak();
} else {
return new SoftLineBreak();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CoreRenderingTestCase extends RenderingTestCase {

@Override
protected String render(String source) {
return RENDERER.render(PARSER.parse(source));
var node = PARSER.parse(source);
return RENDERER.render(node);
}
}
15 changes: 15 additions & 0 deletions commonmark/src/test/java/org/commonmark/test/SpecialInputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,19 @@ public void htmlBlockInterruptingList() {
"</ul>\n" +
"</script>\n");
}

@Test
public void emphasisAfterHardLineBreak() {
assertRendering("Hello \n" +
"**Bar**\n" +
"Foo\n", "<p>Hello<br />\n" +
"<strong>Bar</strong>\n" +
"Foo</p>\n");

assertRendering("Hello \n" +
"**Bar** \n" +
"Foo\n", "<p>Hello<br />\n" +
"<strong>Bar</strong><br />\n" +
"Foo</p>\n");
}
}