@@ -35,19 +35,37 @@ This extension depends on the following extension:
35
35
36
36
* ` markdown-run-snippet.mdToVscodeTypeMap `
37
37
38
+ Map from language specified in Markdown to Visual Studio Code's filetype.
39
+ If there is no entry, the same string is used as Visual Studio Code's filetype.
40
+
38
41
Example:
39
42
40
43
``` json
41
44
"markdown-run-snippet.mdToVscodeTypeMap" : {
42
- "cpp " : " C++ "
45
+ "c++ " : " cpp "
43
46
}
44
47
```
45
48
46
- Map from language specified in Markdown to Visual Studio Code's filetype.
47
- If there is no entry, the same string is used as Visual Studio Code's filetype.
49
+ With the above setting, we can collectly set the filetype to `cpp` for
50
+ snippet below:
51
+
52
+ ```c++
53
+ std::cout << "hello!" << std::endl;
54
+ ```
55
+
56
+ Without the above setting, this extension assume the filetype `c++`. However
57
+ Visual Studio Code can't recognize it, so it fails to run this snippet.
58
+
48
59
49
60
* `markdown-run-snippet.mdTypeToTemplateMap`
50
61
62
+ Map from language specified in Markdown to template (that will be applied to
63
+ the snippet). Template feature is useful for importing common modules,
64
+ including common headers, defining main() function. selected snippet will be
65
+ placed at the position of `$snippet`. The leading ' '(whitespace) before
66
+ `$snippet` is important, because the same amount of ' ' will be prepended to
67
+ all lines of selected snippet.
68
+
51
69
Example:
52
70
53
71
```json
@@ -56,14 +74,41 @@ This extension depends on the following extension:
56
74
}
57
75
```
58
76
59
- Map from language specified in Markdown to template (that will be applied to
60
- the snippet). Template feature is useful for importing common modules,
61
- including common headers, defining main() function. selected snippet will be
62
- placed at the position of `$snippet`. The leading ' '(whitespace) before
63
- `$snippet` is important, because the same amount of ' ' will be prepended to
64
- all lines of selected snippet.
77
+ With above setting, we can run snippet below even if we have to define
78
+ `main()` function in Rust language:
79
+
80
+ ```rust
81
+ let name = "foo";
82
+ println!("Hello, {}", name);
83
+ ```
84
+
85
+ The above snippet will be expanded as follows:
86
+
87
+ ```rust
88
+ fn main() {
89
+ let name = "foo";
90
+ println!("Hello, {}", name);
91
+ }
92
+ ```
93
+
94
+ Similary, C++ requires to define `main()` function. Also C++ needs a lot of
95
+ header files to run. Let's make it template:
96
+
97
+ ```json
98
+ "markdown-run-snippet.mdTypeToTemplateMap" : {
99
+ "rust" : " fn main() {\n $snippet\n }" ,
100
+ "c++" : " #include <iostream>\n #include <string>\n int main(void) {\n $snippet\n }"
101
+ }
102
+ ```
103
+
104
+ Now we can run the snippet below:
105
+
106
+ ```c++
107
+ std::string name = "foo";
108
+ std::cout << "Hello, " << name << std::endl;
109
+ ```
65
110
66
- Configurations defined by default are very very few .
111
+ Very very few (almost no) configurations are defined by default .
67
112
68
113
## Known Issues
69
114
0 commit comments