diff --git a/src/main/java/com/google/devtools/build/skydoc/rendering/MarkdownUtil.java b/src/main/java/com/google/devtools/build/skydoc/rendering/MarkdownUtil.java index 331c80db798042..e9cd11089c45aa 100644 --- a/src/main/java/com/google/devtools/build/skydoc/rendering/MarkdownUtil.java +++ b/src/main/java/com/google/devtools/build/skydoc/rendering/MarkdownUtil.java @@ -35,21 +35,47 @@ public final class MarkdownUtil { private static final int MAX_LINE_LENGTH = 100; /** - * Return a string that formats the input string so it is displayable in a markdown table cell. - * This performs the following operations: + * Wrapper around {@link #markdownCellFormatWithHtml}, calling it with HTML rendering disabled. * + * @return The formatted string, upon which the following operations have been performed: *
renderHtml
is false, transform the string using {@link #htmlEscape}.
+ * ", "
");
resultString = replaceWithTag(resultString, "`", "", "
");
diff --git a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java
index d5f849e0d9e0de..a0d50b2a0aae01 100644
--- a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java
+++ b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java
@@ -30,6 +30,7 @@
import com.google.devtools.build.skydoc.rendering.DocstringParseException;
import com.google.devtools.build.skydoc.rendering.FunctionUtil;
import com.google.devtools.build.skydoc.rendering.ProtoRenderer;
+import com.google.devtools.build.skydoc.rendering.MarkdownUtil;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.AspectInfo;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.AttributeType;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.ModuleInfo;
@@ -53,6 +54,7 @@
public final class SkydocTest extends BuildViewTestCase {
private SkydocMain skydocMain;
+ private MarkdownUtil util;
@Before
public void setUp() throws IOException {
@@ -83,6 +85,7 @@ public boolean fileExists(String pathString) {
},
"io_bazel",
ImmutableList.of("/other_root", "."));
+ util = new MarkdownUtil();
}
@Test
@@ -829,4 +832,42 @@ public void testModuleDocAcrossFiles() throws Exception {
String moduleDoc = moduleInfo.getModuleDocstring();
assertThat(moduleDoc).isEqualTo("Should be displayed.");
}
+
+ @Test
+ public void testMarkdownCellFormat() throws Exception {
+ // Exercises all the operations of markdownCellFormat()
+ String testData = " test_start :\n"
+ + " Testtest
"
+ + "test
test
"
+ + "test