Closed RokeJulianLockhart closed 11 months ago
This should work, modified from default rules, not tested.
According to issue8, you may need to reboot the whole PC after build rules.
"markdown-everywhere.customized-rules": [
{
"name": "number-sign",
"whileRegExp": "#",
"example": "",
"languages": [
{"name":"coffeescript","source":"source.coffee"},
{"name":"dockerfile","source":"source.dockerfile"},
{"name":"git-commit","source":"text.git-commit"},
{"name":"git-rebase","source":"text.git-rebase"},
{"name":"diff","source":"source.diff"},
{"name":"ignore","source":"source.ignore"},
{"name":"properties","source":"source.ini"},
{"name":"makefile","source":"source.makefile"},
{"name":"perl","source":"source.perl"},
{"name":"perl6","source":"source.perl.6"},
{"name":"powershell","source":"source.powershell"},
{"name":"python","source":"source.python"},
{"name":"r","source":"source.r"},
{"name":"ruby","source":"source.ruby"},
{"name":"shellscript","source":"source.shell"},
{"name":"yaml","source":"source.yaml"},
{"name":"cython","source":"source.cython"},
{"name":"julia","source":"source.julia"},
{"name":"cmake","source":"source.cmake"}
]
},
{
"name": "slash-star",
"beginRegExp": "/\\*",
"endRegExp": "\\*/",
"example": "",
"languages": [
{"name":"c","source":"source.c"},
{"name":"cpp","source":"source.cpp"},
{"name":"csharp","source":"source.cs"},
{"name":"css","source":"source.css"},
{"name":"go","source":"source.go"},
{"name":"groovy","source":"source.groovy"},
{"name":"hlsl","source":"source.hlsl"},
{"name":"java","source":"source.java"},
{"name":"javascriptreact","source":"source.js.jsx"},
{"name":"javascript","source":"source.js"},
{"name":"json","source":"source.json"},
{"name":"jsonc","source":"source.json.comments"},
{"name":"less","source":"source.css.less"},
{"name":"objective-c","source":"source.objc"},
{"name":"objective-cpp","source":"source.objcpp"},
{"name":"php","source":"text.html.php"},
{"name":"rust","source":"source.rust"},
{"name":"scss","source":"source.css.scss"},
{"name":"shaderlab","source":"source.shaderlab"},
{"name":"sql","source":"source.sql"},
{"name":"swift","source":"source.swift"},
{"name":"typescript","source":"source.ts"},
{"name":"typescriptreact","source":"source.tsx"},
{"name":"antlr","source":"source.antlr"}
]
},
{
"name": "double-slash",
"whileRegExp": "//",
"example": "",
"languages": [
{"name":"c","source":"source.c"},
{"name":"cpp","source":"source.cpp"},
{"name":"csharp","source":"source.cs"},
{"name":"fsharp","source":"source.fsharp"},
{"name":"go","source":"source.go"},
{"name":"groovy","source":"source.groovy"},
{"name":"hlsl","source":"source.hlsl"},
{"name":"java","source":"source.java"},
{"name":"javascriptreact","source":"source.js.jsx"},
{"name":"javascript","source":"source.js"},
{"name":"json","source":"source.json"},
{"name":"jsonc","source":"source.json.comments"},
{"name":"less","source":"source.css.less"},
{"name":"objective-c","source":"source.objc"},
{"name":"objective-cpp","source":"source.objcpp"},
{"name":"php","source":"text.html.php"},
{"name":"rust","source":"source.rust"},
{"name":"scss","source":"source.css.scss"},
{"name":"shaderlab","source":"source.shaderlab"},
{"name":"swift","source":"source.swift"},
{"name":"typescript","source":"source.ts"},
{"name":"typescriptreact","source":"source.tsx"},
{"name":"antlr","source":"source.antlr"},
{"name":"qasm-lang","source":"source.qasm"}
]
},
{
"name": "percentage",
"whileRegExp": "%",
"example": "",
"languages": [
{"name":"matlab","source":"source.matlab"},
{"name":"bibtex","source":"text.bibtex"},
{"name":"tex","source":"text.tex"},
{"name":"latex","source":"text.latex"}
]
},
{
"name": "triple-quote",
"beginRegExp": "\"\"\"",
"endRegExp": " ?\"\"\"",
"example": "",
"languages": [
{"name":"julia","source":"source.julia"},
{"name":"python","source":"source.python"}
]
},
{
"name": "whitespace-triple-quote",
"beginRegExp": "\\s+\"\"\" ?",
"whileRegExp": "\\s*(?!\\s|\"\"\")",
"whileSymbol": " ",
"endRegExp": "\\s*\"\"\" ?",
"example": "",
"languages": [
{"name":"julia","source":"source.julia"},
{"name":"python","source":"source.python"}
]
}
]
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1848230445
@zhaouv, I've thus set my config file to:
```.JSON { "editor.fontFamily": "", "workbench.iconTheme": null, "window.autoDetectColorScheme": true, "scm.inputFontFamily": "", "debug.console.fontFamily": "", "markdown.preview.fontFamily": "", "editor.formatOnType": true, "terminal.integrated.customGlyphs": false, "files.autoSave": "onFocusChange", "editor.renderWhitespace": "all", "gitlab.debug": true, "terminal.integrated.defaultProfile.osx": "", "terminal.integrated.shellIntegration.history": 1e+308, "scm.repositories.visible": 0, "workbench.commandPalette.history": 1e+308, "workbench.localHistory.maxFileEntries": 1e+308, "workbench.localHistory.maxFileSize": 1e+308, "workbench.localHistory.mergeWindow": 1e+308, "interactiveWindow.restore": true, "terminal.external.windowsExec": "alacritty", "terminal.integrated.enableBell": true, "terminal.external.linuxExec": "alacritty", "terminal.external.osxExec": "alacritty", "terminal.integrated.defaultProfile.windows": "", "editor.fontSize": 13, "debug.console.fontSize": 13, "markdown.preview.fontSize": 13, "terminal.integrated.fontSize": 13, "tabnine.experimentalAutoImports": true, "tabnine.receiveBetaChannelUpdates": true, "editor.semanticHighlighting.enabled": true, "git.autofetch": "all", "files.hotExit": "onExitAndWindowClose", "todo-tree.general.debug": true, "todo-tree.general.enableFileWatcher": true, "todo-tree.general.tags": [ "Bug", "Hack", "FixMe", "ToDo", "To-Do", "To Do:", "ToPerform", "To-Perform", "To Perform:", "[ ]", "[x]", "Remediate:", "remediate:", "@toDo", "toDo", "to_do" ], "git.confirmSync": false, "ltex.additionalRules.enablePickyRules": true, "ltex.additionalRules.motherTongue": "en-GB", "ltex.completionEnabled": true, "ltex.statusBarItem": true, "ltex.trace.server": "verbose", "workbench.tree.indent": 4, "typescript.inlayHints.enumMemberValues.enabled": true, "workbench.experimental.cloudChanges.autoStore": "onShutdown", "python.analysis.autoImportCompletions": true, "python.analysis.autoImportUserSymbols": true, "C_Cpp.inlayHints.autoDeclarationTypes.enabled": true, "editor.find.autoFindInSelection": "always", "C_Cpp.inlayHints.autoDeclarationTypes.showOnLeft": true, "files.autoGuessEncoding": true, "files.autoSaveDelay": 0, "merge-conflict.autoNavigateNextConflict.enabled": true, "editor.formatOnPaste": true, "typescript.updateImportsOnFileMove.enabled": "always", "git.openAfterClone": "always", "git.repositoryScanMaxDepth": -1, "cmake.configureOnOpen": true, "C_Cpp.intelliSenseEngineFallback": "enabled", "C_Cpp.codeAnalysis.updateDelay": 0, "editor.tabCompletion": "on", "search.quickOpen.includeSymbols": true, "[python]": { "editor.formatOnType": true, "editor.defaultFormatter": "ms-python.black-formatter" }, "redhat.telemetry.enabled": true, "git.enableSmartCommit": true, "terminal.integrated.enableMultiLinePasteWarning": false, "liveshare.audio.startCallOnShare": true, "flake8.interpreter": [ "python3" ], "python.analysis.diagnosticMode": "workspace", "python.globalModuleInstallation": true, "python.linting.flake8Enabled": true, "python.linting.mypyEnabled": true, "python.linting.prospectorEnabled": true, "python.linting.pycodestyleEnabled": true, "python.linting.pydocstyleEnabled": true, "python.linting.pylamaEnabled": true, "python.linting.pylintEnabled": true, "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": true, "python.diagnostics.sourceMapsEnabled": true, "powershell.codeFormatting.useCorrectCasing": true, "powershell.codeFormatting.useConstantStrings": true, "powershell.codeFormatting.trimWhitespaceAroundPipe": true, "powershell.codeFormatting.whitespaceBetweenParameters": true, "powershell.pester.useLegacyCodeLens": false, "powershell.buttons.showPanelMovementButtons": true, "powershell.codeFormatting.autoCorrectAliases": true, "powershell.codeFormatting.avoidSemicolonsAsLineTerminators": true, "editor.inlineSuggest.showToolbar": "always", "grammarly.files.include": [ "**/*.txt", "**/*.md" ], "grammarly.config.suggestionCategories.oxfordComma": "on", "grammarly.config.suggestionCategories.unnecessaryEllipses": "on", "grammarly.config.documentDomain": "academic", "grammarly.config.suggestionCategories.conjugationAtStartOfSentence": "on", "grammarly.config.suggestionCategories.informalPronounsAcademic": "on", "python.formatting.provider": "none", "python.defaultInterpreterPath": "/usr/bin/python3", "todo-tree.general.statusBar": "tags", "security.workspace.trust.startupPrompt": "never", "security.workspace.trust.enabled": false, "html.format.indentInnerHtml": true, "C_Cpp.vcFormat.indent.braces": true, "editor.insertSpaces": false, "notebook.cellToolbarLocation": { "default": "right", "jupyter-notebook": "left" }, "notebook.lineNumbers": "on", "files.associations": { ".Rmd": "rmd" }, "workbench.editor.highlightModifiedTabs": true, "files.trimFinalNewlines": true, "files.trimTrailingWhitespace": true, "markdown.preview.typographer": true, "livePreview.showServerStatusNotifications": true, "liveshare.featureSet": "insiders", "workbench.editor.pinnedTabsOnSeparateRow": true, "workbench.colorTheme": "Default Dark Modern", "jupyter.themeMatplotlibPlots": true, "r.plot.defaults.colorTheme": "vscode", "chat.editor.fontSize": 13, "editor.inlineSuggest.suppressSuggestions": true, "workbench.editor.enablePreview": false, "markdown-everywhere.customized-rules": [ { "name": "number-sign", "whileRegExp": "#", "example": "", "languages": [ { "name": "coffeescript", "source": "source.coffee" }, { "name": "dockerfile", "source": "source.dockerfile" }, { "name": "git-commit", "source": "text.git-commit" }, { "name": "git-rebase", "source": "text.git-rebase" }, { "name": "diff", "source": "source.diff" }, { "name": "ignore", "source": "source.ignore" }, { "name": "properties", "source": "source.ini" }, { "name": "makefile", "source": "source.makefile" }, { "name": "perl", "source": "source.perl" }, { "name": "perl6", "source": "source.perl.6" }, { "name": "powershell", "source": "source.powershell" }, { "name": "python", "source": "source.python" }, { "name": "r", "source": "source.r" }, { "name": "ruby", "source": "source.ruby" }, { "name": "shellscript", "source": "source.shell" }, { "name": "yaml", "source": "source.yaml" }, { "name": "cython", "source": "source.cython" }, { "name": "julia", "source": "source.julia" }, { "name": "cmake", "source": "source.cmake" } ] }, { "name": "slash-star", "beginRegExp": "/\\*", "endRegExp": "\\*/", "example": "", "languages": [ { "name": "c", "source": "source.c" }, { "name": "cpp", "source": "source.cpp" }, { "name": "csharp", "source": "source.cs" }, { "name": "css", "source": "source.css" }, { "name": "go", "source": "source.go" }, { "name": "groovy", "source": "source.groovy" }, { "name": "hlsl", "source": "source.hlsl" }, { "name": "java", "source": "source.java" }, { "name": "javascriptreact", "source": "source.js.jsx" }, { "name": "javascript", "source": "source.js" }, { "name": "json", "source": "source.json" }, { "name": "jsonc", "source": "source.json.comments" }, { "name": "less", "source": "source.css.less" }, { "name": "objective-c", "source": "source.objc" }, { "name": "objective-cpp", "source": "source.objcpp" }, { "name": "php", "source": "text.html.php" }, { "name": "rust", "source": "source.rust" }, { "name": "scss", "source": "source.css.scss" }, { "name": "shaderlab", "source": "source.shaderlab" }, { "name": "sql", "source": "source.sql" }, { "name": "swift", "source": "source.swift" }, { "name": "typescript", "source": "source.ts" }, { "name": "typescriptreact", "source": "source.tsx" }, { "name": "antlr", "source": "source.antlr" } ] }, { "name": "double-slash", "whileRegExp": "//", "example": "", "languages": [ { "name": "c", "source": "source.c" }, { "name": "cpp", "source": "source.cpp" }, { "name": "csharp", "source": "source.cs" }, { "name": "fsharp", "source": "source.fsharp" }, { "name": "go", "source": "source.go" }, { "name": "groovy", "source": "source.groovy" }, { "name": "hlsl", "source": "source.hlsl" }, { "name": "java", "source": "source.java" }, { "name": "javascriptreact", "source": "source.js.jsx" }, { "name": "javascript", "source": "source.js" }, { "name": "json", "source": "source.json" }, { "name": "jsonc", "source": "source.json.comments" }, { "name": "less", "source": "source.css.less" }, { "name": "objective-c", "source": "source.objc" }, { "name": "objective-cpp", "source": "source.objcpp" }, { "name": "php", "source": "text.html.php" }, { "name": "rust", "source": "source.rust" }, { "name": "scss", "source": "source.css.scss" }, { "name": "shaderlab", "source": "source.shaderlab" }, { "name": "swift", "source": "source.swift" }, { "name": "typescript", "source": "source.ts" }, { "name": "typescriptreact", "source": "source.tsx" }, { "name": "antlr", "source": "source.antlr" }, { "name": "qasm-lang", "source": "source.qasm" } ] }, { "name": "percentage", "whileRegExp": "%", "example": "", "languages": [ { "name": "matlab", "source": "source.matlab" }, { "name": "bibtex", "source": "text.bibtex" }, { "name": "tex", "source": "text.tex" }, { "name": "latex", "source": "text.latex" } ] }, { "name": "triple-quote", "beginRegExp": "\"\"\"", "endRegExp": " ?\"\"\"", "example": "", "languages": [ { "name": "julia", "source": "source.julia" }, { "name": "python", "source": "source.python" } ] }, { "name": "whitespace-triple-quote", "beginRegExp": "\\s+\"\"\" ?", "whileRegExp": "\\s*(?!\\s|\"\"\")", "whileSymbol": " ", "endRegExp": "\\s*\"\"\" ?", "example": "", "languages": [ { "name": "julia", "source": "source.julia" }, { "name": "python", "source": "source.python" } ] } ] } ```
...and rebooted using systemctl reboot
, but I still don't seem to be able to render Markdown on comments at the end of code lines. They seem to need to be segmented from the code with newlines. For instance:
# MD 1. test
# MD 1. test
works, yet
GREETING = str('Hello World!') # MD 1. test
GREETING = str('Hello World!') # MD 1. test
does not. Regardless, I still need to prefix MD
to any commnent, so the rules definitely don't work.
Imitate rules and add new rules to "settings.json". And then run command "Build Markdown Embedding Rules" and then reload (press "F1", type "Build Markdown Embedding Rules" and "Reload Window"). And you need to run build command again when you update this extension.
Did you build the rules?
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1863948335
@zhaouv, can you elaborate what that means?
After you change the markdown-everywhere.customized-rules
, you need to run the command Build Markdown Embedding Rules
, which will build the syntaxes/*.json
files for each rule in the customized-rules
. Then the vcs could render the rules. And because the file changes, you need to reload vcs, by reload vcs or reboot computer.
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1865404622
@zhaouv, I've selected the option via the Command Bar, but there's no progress bar - is it generally instant?
it should be very fast. the readme of the extension will be changed, "example": ""
so you will see all example is blank. you can also view the installed extension source to verify its changed.
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1865408624
@zhaouv, it still doesn't appear to be working despite me following https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1865404622:
Consequently, where is this "example": ""
JSON value I should be looking for? Please be aware that whilst I am nominally a software developer, my skills are in system administration, so I'm not totally aware of how VSCode extensions function under the hood.
the dir is ~/.vscode/extensions/zhaouv.vscode-markdown-everywhere-0.0.12
or ~/.vscode-server/extensions/zhaouv.vscode-markdown-everywhere-0.0.12
the line # The subsequent ...
has been rendered while as markdown.
They seem to need to be segmented from the code with newlines.
it is the designed behavior, you can F1
then type scopes
use the command to check the grammar.
the match regex is "(^|\\G)\\s*(__whileRegExp__) ?"
, __whileRegExp__
is //
for your rule , you can modify the dir/syntaxes/double-slash.json your self to make it work for "not newline", i do not want to do it in this extension now, maybe it will be considered in the next version. delete (^|\\G)\\s*
part and change captures
from 2
to 1
should work for you
what this extension did is just build syntaxes file for each rule from template
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-1867222283
@zhaouv, thanks for the assistance. I've tried to follow your instructions, but I don't think I'm getting anywhere:
I visited:
code-insiders "$HOME/.vscode-server/extensions/zhaouv.vscode-markdown-everywhere-0.0.12"
...which is empty.
I pressed F1, which displayed "Developer: Inspect Editor Tokens and Scopes", which caused the undermentioned to appear:
However, this still didn't appear to provide a way for me to modify the RegEx. Apologies if I'm being dumb. I'm especially confused that I don't see https://github.com/zhaouv/vscode-markdown-everywhere/blob/672ff46b217ebb07edeaf4270cd6116356498737/build/rules.js#L4-L28 in my settings.json
.
Gotta say, the MD
prefix is a strange default.
maybe you could use locate syntaxes/double-slash.json
to find the file
https://github.com/zhaouv/vscode-markdown-everywhere/issues/10#issuecomment-2199499566
@zhaouv, that's remarkable! I didn't know of that binary. Many thanks.
However, I don't see the relevant MD
entry that I expect:
code-insiders "$HOME/.vscode-insiders/extensions/zhaouv.vscode-markdown-everywhere-0.0.15/syntaxes/double-slash.json"
```JSONC { "injectionSelector": "L:source.c -string -meta.embedded.block.everywhere.md, L:source.cpp -string -meta.embedded.block.everywhere.md, L:source.cs -string -meta.embedded.block.everywhere.md, L:source.fsharp -string -meta.embedded.block.everywhere.md, L:source.go -string -meta.embedded.block.everywhere.md, L:source.groovy -string -meta.embedded.block.everywhere.md, L:source.hlsl -string -meta.embedded.block.everywhere.md, L:source.java -string -meta.embedded.block.everywhere.md, L:source.js.jsx -string -meta.embedded.block.everywhere.md, L:source.js -string -meta.embedded.block.everywhere.md, L:source.json -string -meta.embedded.block.everywhere.md, L:source.json.comments -string -meta.embedded.block.everywhere.md, L:source.css.less -string -meta.embedded.block.everywhere.md, L:source.objc -string -meta.embedded.block.everywhere.md, L:source.objcpp -string -meta.embedded.block.everywhere.md, L:text.html.php -string -meta.embedded.block.everywhere.md, L:source.rust -string -meta.embedded.block.everywhere.md, L:source.css.scss -string -meta.embedded.block.everywhere.md, L:source.shaderlab -string -meta.embedded.block.everywhere.md, L:source.swift -string -meta.embedded.block.everywhere.md, L:source.ts -string -meta.embedded.block.everywhere.md, L:source.tsx -string -meta.embedded.block.everywhere.md, L:source.antlr -string -meta.embedded.block.everywhere.md, L:source.qasm -string -meta.embedded.block.everywhere.md", "patterns": [ { "include": "#comment-markdown-cell-inject-double-slash-LRSM" } ], "repository": { "comment-markdown-cell-inject-double-slash-LRSM": { "name": "comment.quote_code.double-slash.LRSM", "begin": "(?<=(?:^|\\G)\\s*//\\s*\\[markdown\\])$", "end": "(^|\\G)(?=\\s*(?!//|\\s)|\\s*$)", "patterns": [ { "include": "#double-slash-quote-LRSM" } ] }, "double-slash-quote-LRSM": { "begin": "(^|\\G)\\s*(//) ?", "captures": { "2": { "name": "comment.punctuation.definition.quote_code.double-slash.LRSM" } }, "contentName": "meta.embedded.block.everywhere.md", "patterns": [ { "include": "text.html.markdown" } ], "while": "(^|\\G)\\s*(//) ?" } }, "scopeName": "comment.markdown-cell-inject.double-slash.LRSM" } ```
Apologies for the hand-holding - I'm no extension developer, so this is all a little confusing for me.
I want all comments in all languages to render as Markdown, regardless of whether they are prefixed with
MD
(like https://github.com/mjbvz/vscode-jsdoc-markdown-highlighting/issues/19#issue-2033156350 describes).