markdown-run-snippet.mdToVscodeTypeMap
Map from language specified in Markdown to Visual Studio Code's filetype.
If there is no entry, the same string is used as Visual Studio Code's filetype.
Example:
"markdown-run-snippet.mdToVscodeTypeMap": {
"c++": "cpp"
}
With the above setting, we can collectly set the filetype to cpp
for
snippet below:
```c++
std::cout << "hello!" << std::endl;
```
Without the above setting, this extension assume the filetype c++
. However
Visual Studio Code can't recognize it, so it fails to run this snippet.
markdown-run-snippet.mdTypeToTemplateMap
Map from language specified in Markdown to template (that will be applied to
the snippet). Template feature is useful for importing common modules,
including common headers, defining main() function. selected snippet will be
placed at the position of $snippet
. The leading ' '(whitespace) before
$snippet
is important, because the same amount of ' ' will be prepended to
all lines of selected snippet.
Example:
"markdown-run-snippet.mdTypeToTemplateMap": {
"rust": "fn main() {\n $snippet\n}"
}
With above setting, we can run snippet below even if we have to define
main()
function in Rust language:
```rust
let name = "foo";
println!("Hello, {}", name);
```
The above snippet will be expanded as follows:
fn main() {
let name = "foo";
println!("Hello, {}", name);
}
Similary, C++ requires to define main()
function. Also C++ needs a lot of
header files to run. Let's make it template:
"markdown-run-snippet.mdTypeToTemplateMap": {
"rust": "fn main() {\n $snippet\n}",
"c++": "#include <iostream>\n#include <string>\nint main(void) {\n $snippet\n}"
}
Now we can run the snippet below:
```c++
std::string name = "foo";
std::cout << "Hello, " << name << std::endl;
```