Skip to content

Commit 833d235

Browse files
robertoaloifacebook-github-bot
authored andcommitted
Support for embedded Markdown comments
Summary: Erlang/OTP 27 introduces Markdown comments. While this makes it in theory simpler to author in-code documentation, the VS Code extension does not yet recognize comments as Markdown. This change makes VS Code recognize doc blocks as Markdown, using the concept of an [embedded language](https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#embedded-languages). This provides features such as: * Syntax highlighting for italic, bold, code blocks, etc * Matching parentheses * Ability to embed Erlang code blocks with syntax highlighting * Etc While this simply works(TM), it makes the doc block too evident and distracting: {F1978476087} To preserve the look-and-feel of the old edoc-style comment, we override the default colour for the embedded markdown block. This seems to work fine in both light and dark mode and can always be overridden by a user using the `settings.json` file: ``` "editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "meta.embedded.block.markdown", "settings": { "foreground": "MY_FAVOURITE_COLOUR" } } ], } ``` The change is being upstreamed [here](erlang-ls/grammar#18). Reviewed By: alanz Differential Revision: D75152988 fbshipit-source-id: 3922007c13678be99fb27c99e53f8597c7dcba8f
1 parent 846bba1 commit 833d235

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

editors/code/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@
330330
}
331331
}
332332
},
333+
"configurationDefaults": {
334+
"editor.tokenColorCustomizations": {
335+
"textMateRules": [
336+
{
337+
"scope": "meta.embedded.block.markdown",
338+
"settings": {
339+
"foreground": "#6A9955"
340+
}
341+
}
342+
]
343+
}
344+
},
333345
"semanticTokenTypes": [],
334346
"semanticTokenModifiers": [
335347
{

editors/code/third-party/grammar/Erlang.plist

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,13 @@
604604
</dict>
605605
<key>name</key>
606606
<string>meta.directive.doc.erlang</string>
607+
<key>contentName</key>
608+
<string>meta.embedded.block.markdown</string>
607609
<key>patterns</key>
608610
<array>
609611
<dict>
610-
<key>begin</key>
611-
<string>\G</string>
612-
<key>contentName</key>
613-
<string>comment.block.documentation.erlang</string>
614-
<key>while</key>
615-
<string>(^)(?!\s*(\5))</string>
612+
<key>include</key>
613+
<string>text.html.markdown</string>
616614
</dict>
617615
</array>
618616
</dict>

0 commit comments

Comments
 (0)