[PATCH] D72462: [clangd] Fix markdown rendering in VSCode
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 08:59:04 PST 2020
kadircet created this revision.
kadircet added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.
Eventough it is OK to have a new line without any preceding spaces in
some markdown specifications, VSCode requires two spaces before a new line to
break a line inside a paragraph.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72462
Files:
clang-tools-extra/clangd/FormattedString.cpp
clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -121,7 +121,7 @@
D.addCodeBlock("test");
D.addParagraph().appendText("bar");
- const char ExpectedMarkdown[] = R"md(foo
+ const char ExpectedMarkdown[] = R"md(foo
```cpp
test
```
@@ -141,7 +141,7 @@
D.addParagraph().appendText("foo");
D.addSpacer();
D.addParagraph().appendText("bar");
- EXPECT_EQ(D.asMarkdown(), "foo\n\nbar");
+ EXPECT_EQ(D.asMarkdown(), "foo \n\nbar");
EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
}
@@ -217,10 +217,10 @@
DeepDoc.addParagraph().appendText("baz");
EXPECT_EQ(L.asMarkdown(), R"md(- foo
- bar
-- foo
- baz
- - foo
- - baz
+- foo
+ baz
+ - foo
+ - baz
baz)md");
EXPECT_EQ(L.asPlainText(), R"pt(- foo
- bar
@@ -234,10 +234,10 @@
Inner.addParagraph().appendText("after");
EXPECT_EQ(L.asMarkdown(), R"md(- foo
- bar
-- foo
- baz
- - foo
- - baz
+- foo
+ baz
+ - foo
+ - baz
baz
after)md");
Index: clang-tools-extra/clangd/FormattedString.cpp
===================================================================
--- clang-tools-extra/clangd/FormattedString.cpp
+++ clang-tools-extra/clangd/FormattedString.cpp
@@ -196,7 +196,8 @@
}
// Paragraphs are translated into markdown lines, not markdown paragraphs.
// Therefore it only has a single linebreak afterwards.
- OS << '\n';
+ // VSCode requires two spaces at the end of line to start a new one.
+ OS << " \n";
}
void Paragraph::renderPlainText(llvm::raw_ostream &OS) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72462.237104.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200109/a317a3d6/attachment.bin>
More information about the cfe-commits
mailing list