diff --git a/typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Javadoc.java b/typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Javadoc.java index 840fd20f8..c16dd33b7 100644 --- a/typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Javadoc.java +++ b/typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Javadoc.java @@ -256,11 +256,11 @@ private List getComments(String dComments, List tags) { .replaceAll("\\s*
\\s*", nn) .replaceAll("\\s*

\\s*", nn) .replaceAll("\\s*

\\s*", nn); - result.addAll(Utils.splitMultiline(replacedHtmlLines, true)); + result.addAll(Utils.splitMultiline(convertAnchorToLink(replacedHtmlLines), true)); } if (tags != null) { for (TagInfo tag : tags) { - result.addAll(Utils.splitMultiline(tag.getName() + " " + tag.getText(), true)); + result.addAll(Utils.splitMultiline(tag.getName() + " " + convertAnchorToLink(tag.getText()), true)); } } return result; @@ -271,4 +271,14 @@ private static List combineComments(List firstComments, List(?:\\s+)?(.*)", "{@link $1 $2}"); + } + } diff --git a/typescript-generator-core/src/test/java/cz/habarta/typescript/generator/JavadocTest.java b/typescript-generator-core/src/test/java/cz/habarta/typescript/generator/JavadocTest.java index e7795ecba..4732c03db 100644 --- a/typescript-generator-core/src/test/java/cz/habarta/typescript/generator/JavadocTest.java +++ b/typescript-generator-core/src/test/java/cz/habarta/typescript/generator/JavadocTest.java @@ -105,6 +105,13 @@ public void testJavadoc() { Assertions.assertTrue(!generated.contains("

")); Assertions.assertTrue(generated.contains("Long\n * paragraph\n * \n * Second\n * paragraph")); } + { + final String generated = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ClassWithExternalLinks.class)); + Assertions.assertFalse(generated.contains(""), "Anchor tags should be removed"); + Assertions.assertTrue(generated.contains("{@link https://github.com/vojtechhabarta/typescript-generator link}"), "Links should be converted to TSDoc"); + Assertions.assertTrue(generated.contains("{@link https://github.com/vojtechhabarta/typescript-generator/wiki the wiki}"), "Links should be converted to TSDoc"); + } } /** @@ -217,4 +224,15 @@ public static class ClassWithBrElements { public static class ClassWithPElements { } + /** + * Documentation for ClassWithExternalLinks + * + * This sentence has a link! + * @see + * the wiki + */ + public static class ClassWithExternalLinks { + } + } diff --git a/typescript-generator-core/src/test/javadoc/test-javadoc.xml b/typescript-generator-core/src/test/javadoc/test-javadoc.xml index b1c3175e5..a17642309 100644 --- a/typescript-generator-core/src/test/javadoc/test-javadoc.xml +++ b/typescript-generator-core/src/test/javadoc/test-javadoc.xml @@ -2547,6 +2547,14 @@ + + Documentation for ClassWithExternalLinks + + This sentence has a <a href="https://github.com/vojtechhabarta/typescript-generator">link</a>! + + + + @@ -8213,6 +8221,14 @@ + + Documentation for ClassWithExternalLinks + + This sentence has a <a href="https://github.com/vojtechhabarta/typescript-generator">link</a>! + + + +