@@ -1778,22 +1778,42 @@ class Test {}
17781778 @ Test
17791779 public void markdownBackslashes () {
17801780 assume ().that (MARKDOWN_JAVADOC_SUPPORTED ).isTrue ();
1781+ // We write `╲` (a box drawing character) instead of `\\` here and then substitute. That makes
1782+ // the test case a bit easier to read and also means that we can see where the line wrapping
1783+ // should happen. (Having to write \\ instead of \ would make the source text lines wider than
1784+ // the strings they represent.)
1785+ @ SuppressWarnings ("MisleadingEscapedSpace" )
17811786 String input =
1782- """
1783- /// \\<br> is not a break.
1784- /// \\* is not an HTML entity.
1785- /// foo\\
1786- /// bar
1787- class Test {}
1788- """ ;
1789- // TODO: the <br> should not cause a line break, and the end-of-line backslash should.
1790- // I don't think anything changes if we do or do not respect the \& backslash.
1787+ """
1788+ /// ╲<br> is not a break.
1789+ /// ╲* is not an HTML entity.
1790+ /// Backslash does not escape the end of a `code span╲` so <br> is a real break,
1791+ /// but backslash does escape the *start* of a ╲`code span so <br> is also a real break.
1792+ /// hard╲
1793+ /// line╲\t \s
1794+ /// breaks
1795+ /// - foo ╲
1796+ /// bar
1797+ /// ╲@param not a param tag
1798+ /// ╲╲@param not a param tag either
1799+ class Test {}
1800+ """
1801+ .replace ('╲' , '\\' );
1802+ // I don't think anything changes if we do or do not respect the \& backslash so nothing here
1803+ // proves whether we do.
17911804 String expected =
1792- """
1793- /// \\<br>
1794- /// is not a break. \\* is not an HTML entity. foo\\ bar
1795- class Test {}
1796- """ ;
1805+ """
1806+ /// ╲<br> is not a break. ╲* is not an HTML entity. Backslash does not escape the end of a `code
1807+ /// span╲` so <br>
1808+ /// is a real break, but backslash does escape the *start* of a ╲`code span so <br>
1809+ /// is also a real break. hard╲
1810+ /// line╲
1811+ /// breaks
1812+ /// - foo ╲
1813+ /// bar ╲@param not a param tag ╲╲@param not a param tag either
1814+ class Test {}
1815+ """
1816+ .replace ('╲' , '\\' );
17971817 doFormatTest (input , expected );
17981818 }
17991819
@@ -1976,14 +1996,6 @@ class Test {}
19761996 // <pre> handling elsewhere. On the other hand, if we don't handle Markdown code spans (`...`)
19771997 // correctly then we might incorrectly recognize HTML tags like `<ul>` inside them.
19781998 //
1979- // - Backslashes
1980- // - \<br> is not a break.
1981- // - \* is not an HTML entity.
1982- // - \⏎ is a hard line break. https://spec.commonmark.org/0.31.2/#hard-line-break
1983- // A hard line break can also be written as two or more spaces followed by a newline. I think
1984- // that is ridiculous and it is absolutely fine to destroy those spaces. However the line
1985- // break will show up in the CommonMark parse.
1986- //
19871999 // - Thematic breaks: ---, ***, ___, which are all rendered as <hr> and should presumably have a
19882000 // line break before and after. https://spec.commonmark.org/0.31.2/#thematic-breaks
19892001 //
0 commit comments