[PATCH] D79142: [clangd] Render doc-comment code spans with `backticks` in plaintext mode
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 04:11:10 PDT 2020
sammccall marked an inline comment as done.
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/FormattedString.cpp:365
+ llvm::StringRef Marker = "";
+ if (C.Preserve && C.Kind == Chunk::InlineCode)
+ Marker = "`";
----------------
kadircet wrote:
> should we rather use `renderInlineBlock` here ? because in presence of backticks inside the C.Contents it might become confusing e.g:
>
> ```
> this is`foo(`x`)`
> ```
>
> this would become:
> ```
> this is `foo(``x``)`
> ```
>
> and instead of keeping a marker maybe just:
>
> ```
> if (Preserve && ..)
> OS << Sep << "`" << C.Contents << "`";
> else
> OS << Sep << C.Contents;
> ```
> rather use renderInlineBlock
I don't think humans deal with escaping better than with ambiguity - those two examples seem equally confusing to me :-\
I'd suggest better is to pick another marker that's unused in the chunk:
```
this is 'foo(`x`)'
```
Happy to do that in this patch if you like it.
instead of keeping a marker maybe just:
> instead of keeping a marker maybe just
Happy to do that for now if you like, but I don't think it's much clearer. I factored it this way because I think the marker is likely to have more options in future (bold spans, avoiding conflicts) and wanted to hint at that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79142/new/
https://reviews.llvm.org/D79142
More information about the cfe-commits
mailing list