File tree 2 files changed +31
-1
lines changed
org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/internal/javadoc
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 16
16
import java .util .ArrayList ;
17
17
import java .util .Arrays ;
18
18
import java .util .List ;
19
+ import java .util .regex .Pattern ;
19
20
20
21
import org .commonmark .Extension ;
21
22
import org .commonmark .ext .gfm .tables .TablesExtension ;
@@ -52,12 +53,17 @@ private void init() {
52
53
fRenderer = HtmlRenderer .builder ().extensions (extensions ).build ();
53
54
}
54
55
56
+ final static Pattern UnicodePattern = Pattern .compile ("\\ \\ u([0-9A-Fa-f]{4})" ); //$NON-NLS-1$
57
+
55
58
@ Override
56
59
protected String removeDocLineIntros (String textWithSlashes ) {
60
+ // replace unicode characters
61
+ String content = UnicodePattern .matcher (textWithSlashes ).replaceAll (s -> String .valueOf ((char )Integer .parseInt (s .group (1 ), 16 )));
62
+
57
63
String lineBreakGroup = "(\\ r\\ n?|\\ n)" ; //$NON-NLS-1$
58
64
String noBreakSpace = "[^\r \n &&\\ s]" ; //$NON-NLS-1$
59
65
// in the markdown case relevant leading whitespace is contained in TextElements, no need to preserve blanks *between* elements
60
- return textWithSlashes .replaceAll (lineBreakGroup + noBreakSpace + "*///" + noBreakSpace + '*' , "$1" ); //$NON-NLS-1$ //$NON-NLS-2$
66
+ return content .replaceAll (lineBreakGroup + noBreakSpace + "*///" + noBreakSpace + '*' , "$1" ); //$NON-NLS-1$ //$NON-NLS-2$
61
67
}
62
68
63
69
@ Override
Original file line number Diff line number Diff line change @@ -900,6 +900,30 @@ <p>This is a test Javadoc for method test4()
900
900
assertHtmlContent (expectedContent , actualHtmlContent );
901
901
}
902
902
@ Test
903
+ public void testGH1787 () throws CoreException {
904
+ String source = """
905
+ package p;
906
+
907
+ public class E {
908
+ /// Unicode in markdown \u000A ///\u000D///\u000D\u000A///here
909
+ public void m() {}
910
+ }
911
+
912
+ """ ;
913
+ ICompilationUnit cu = getWorkingCopy ("/TestSetupProject/src/p/E.java" , source , null );
914
+ assertNotNull ("E.java" , cu );
915
+
916
+ IType type = cu .getType ("E" );
917
+
918
+ IMethod method = type .getMethods ()[0 ];
919
+ String actualHtmlContent = getHoverHtmlContent (cu , method );
920
+ assertHtmlContent ("""
921
+ <p>Unicode in markdown</p>
922
+ <p>here</p>
923
+ """ ,
924
+ actualHtmlContent );
925
+ }
926
+ @ Test
903
927
public void testFenceLenFour_1 () throws CoreException {
904
928
String source = """
905
929
/// ````
You can’t perform that action at this time.
0 commit comments