-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I initially researched the possibilities to get a live markdown preview in Micro. However, after thinking about the problem I realized that the syntax highlighting in a markdown file is (for me at least) a good enough preview. But what I really missed was syntax highlighting of fenced code blocks. This might be a solved problem, but I didn't find any other solution.
I realized that using the syntax yaml files I could pretty easily define any fenced code block and inside that rule set include all the syntax highlighting rules for Python.
#(markdown.yaml syntax file)
# ----- Rule set for language: python -----
- comment:
start: (?i)^```python$
end: ^```$
rules:I then extended this to a project that creates a .yaml file. That gives syntax highlighting for any (or all) language that is in the Micro repository, as long its inside a fenced code block:
```python
def greet():
for i in range(10):
print(f"Hello World, {i}!")
```
```javascript
function greet() {
for (let i = 0; i < 10; i++) {
console.log(`Hello World, ${i}!`);
}
}
```
```java
public class Main {
public static void greet() {
for (int i = 0; i < 10; i++) {
System.out.println("Hello World, " + i + "!");
}
}
}Hope this is something more people will find usefull. If the maintainers are interested in including the resulting .yaml file or any of the code I'll be glad to issue a PR.