Skip to content

Commit

Permalink
feat: add markdoc syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Jan 6, 2025
1 parent f4ae708 commit ecf2626
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ This [EclipseⓇ](https://eclipse.org) plug-in adds syntax highlighting support
1. Kotlin - https://kotlinlang.org/
1. LDIF - https://en.wikipedia.org/wiki/LDAP_Data_Interchange_Format
1. Mako Templates (`*.mako`) - https://www.makotemplates.org/
1. Markdoc (`*.markdoc`) - https://markdoc.dev/
1. Markdown (`*.md`) - https://daringfireball.net/projects/markdown/
1. MDX (`*.mdx`) - https://mdxjs.com/
1. Mermaid (`*.mmd, *.mermaid`) - https://github.com/mermaid-js/mermaid/
Expand Down Expand Up @@ -165,6 +166,7 @@ To install the plugin into an existing Eclipse installation do:
| Kotlin <img src="plugin/syntaxes/kotlin/icon.png" width=16/> | file-extensions="kt, kts" | [main@fwcd/vscode-kotlin](https://github.com/fwcd/vscode-kotlin/tree/4a7c1538754828c1d22a8bee8ff3400045b4352a/)
| LDIF File | file-extensions="ldif" | [master@FlashSystems/LDIF-Syntax](https://github.com/FlashSystems/LDIF-Syntax/tree/f00c21eb1cc5fe5966cf6ef158e854a65449a9fa/)
| Mako Template | file-extensions="mako" | [master@marconi/mako-tmbundle](https://github.com/marconi/mako-tmbundle/tree/45037e4e98f0c215b55b194d303811d43b85407c/Syntaxes)
| Markdoc <img src="plugin/syntaxes/markdoc/icon.png" width=16/> | file-extensions="markdoc, markdoc.md, mdoc" | [main@markdoc/language-server](https://github.com/markdoc/language-server/tree/a6b8babf602735dc31bae1d10fad903dc40c9761/)
| Markdown | file-extensions="livemd, markdown, md, mdown, mdwn, mkd, mkdn, mkdown, ronn, scd, workbook" | [main@wooorm/markdown-tm-language](https://github.com/wooorm/markdown-tm-language/tree/c78b1e5df644d24fa76716bbe26f4b48a6fc1610/)
| MDX <img src="plugin/syntaxes/mdx/mdx.png" width=16/> | file-extensions="mdx" | [main@mdx-js/mdx-analyzer](https://github.com/mdx-js/mdx-analyzer/tree/89920f33d0be84498e4f7d794159235eecc3b293/packages/vscode-mdx)
| mermaid <img src="plugin/syntaxes/mermaid/icon.png" width=16/> | file-extensions="mermaid, mmd" | [master@bpruitt-goddard/vscode-mermaid-syntax-highlight](https://github.com/bpruitt-goddard/vscode-mermaid-syntax-highlight/tree/dff0421fb9e5d07d752f71181e7a154bd103994d/)
Expand Down
31 changes: 31 additions & 0 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,37 @@
<snippet name="Mako Template Example" path="syntaxes/mako/mako.example.mako" scopeName="text.html.mako" />
</extension>

<!-- ======================================== -->
<!-- markdoc/markdoc: Markdoc -->
<!-- ======================================== -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="extra-syntax-highlighting.markdoc" name="Markdoc" base-type="extra-syntax-highlighting.basetype" priority="normal"
file-extensions="markdoc,mdoc" file-patterns="*.markdoc.md" />
</extension>
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="text.html.markdown.markdoc" path="syntaxes/markdoc/markdoc.tmLanguage.json" />
<scopeNameContentTypeBinding scopeName="text.html.markdown.markdoc" contentTypeId="extra-syntax-highlighting.markdoc" />
</extension>

<extension point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
<languageConfiguration contentTypeId="extra-syntax-highlighting.markdoc" path="syntaxes/markdoc/markdoc.language-configuration.json" />
</extension>

<extension point="org.eclipse.ui.genericeditor.icons">
<icon contentType="extra-syntax-highlighting.markdoc" icon="syntaxes/markdoc/icon.png"/>
</extension>

<extension point="org.eclipse.tm4e.ui.snippets">
<snippet name="Markdoc Example" path="syntaxes/markdoc/markdoc.example.mdoc" scopeName="text.html.markdown.markdoc" />
</extension>

<!-- ======================================== -->
<!-- markdoc: Inline Grammars -->
<!-- ======================================== -->
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="text.html.markdown.markdoc.injection" path="syntaxes/markdoc/text.html.markdown.markdoc.injection.tmLanguage.json" />
</extension>

<!-- ======================================== -->
<!-- markdown/markdown: Markdown -->
<!-- ======================================== -->
Expand Down
21 changes: 21 additions & 0 deletions plugin/syntaxes/markdoc/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2021- Stripe, Inc. (https://stripe.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Binary file added plugin/syntaxes/markdoc/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin/syntaxes/markdoc/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions plugin/syntaxes/markdoc/markdoc.example.mdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

---
title: "Markdoc Example File"
description: "A simple example to demonstrate Markdoc's syntax and features."
date: "2025-01-06"
author: "Your Name"
---

# Welcome to Markdoc

Markdoc is a Markdown-based authoring tool that supports custom syntax, making it flexible and extensible. This document demonstrates its core capabilities.

## Basic Markdown Features

You can use all standard Markdown syntax, such as:

### Headings

```markdown
# Heading 1
## Heading 2
### Heading 3
```

### Lists

- Item 1
- Sub-item 1
- Sub-item 2
- Item 2

### Links and Images

[Visit the official Markdoc website](https://markdoc.io)

![Example Image](https://via.placeholder.com/150)

### Inline Styles

You can include **bold**, *italic*, or `code` inline.

---

## Custom Markdoc Features

Markdoc allows you to define custom tags and components. Here's an example of a custom tag:

### Info Box

{% info %}
This is an example of an **info box** created using a custom tag.
{% /info %}

### Parameters

You can pass parameters to custom tags:

{% callout type="warning" title="Be Careful!" %}
Always validate your inputs!
{% /callout %}

### Variables

Use variables to dynamically insert content into your document:

```markdoc
{% $variable %}
```

For example:

{% $greeting %}

---

## Code Blocks

```javascript
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("World"));
```

---

## Conclusion

Markdoc combines the simplicity of Markdown with the power of custom syntax. For more details, check out the [official documentation](https://markdoc.io).
42 changes: 42 additions & 0 deletions plugin/syntaxes/markdoc/markdoc.language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"comments": {
"blockComment": [ "<!--", "-->" ]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"colorizedBracketPairs": [],
"autoClosingPairs": [
{
"open": "[",
"close": "]"
},
{
"open": "(",
"close": ")"
},
],
"surroundingPairs": [
["(", ")"],
["[", "]"],
["`", "`"],
["_", "_"],
["*", "*"],
["{", "}"],
["'", "'"],
["\"", "\""]
],
"folding": {
"offSide": true,
"markers": {
"start": "^\\s*<!--\\s*#?region\\b.*-->",
"end": "^\\s*<!--\\s*#?endregion\\b.*-->"
}
},
"wordPattern": {
"pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*",
"flags": "ug"
},
}
6 changes: 6 additions & 0 deletions plugin/syntaxes/markdoc/markdoc.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "markdoc",
"scopeName": "text.html.markdown.markdoc",
"patterns": [{ "include": "text.html.markdown" }]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"scopeName": "text.html.markdown.markdoc.injection",
"injectionSelector": ["L:text.html.markdown", "L:text.html.markdown.markdoc"],
"patterns": [{ "include": "#tag" }],
"repository": {
"shortcut": {
"match": "(\\$|\\.|#)([-_:a-zA-Z0-9]+)",
"name": "string.other.markdoc-shortcut"
},
"attribute": {
"match": "([-_a-zA-Z0-9]+)(=)",
"captures": {
"1": { "name": "entity.other.attribute-name" },
"2": { "name": "punctuation.definition.tag.equal.markdoc" }
}
},
"tag": {
"name": "punctuation.definition.tag",
"begin": "({%)\\s*/?([-_a-zA-Z0-9]+)?",
"end": "\\s*/?\\s*%}",
"beginCaptures": {
"1": { "name": "punctuation.definition.tag.begin.markdoc" },
"2": { "name": "entity.name.tag" }
},
"endCaptures": {
"0": { "name": "punctuation.definition.tag.end.markdoc" }
},
"patterns": [
{ "include": "#attribute" },
{ "include": "#shortcut" },
{ "include": "source.json" }
]
}
}
}
5 changes: 5 additions & 0 deletions plugin/updater/updater-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ sources:
file-extensions:
- .mako

markdoc:
type: vscode-extension
github:
repo: markdoc/language-server

markdown:
type: custom
github:
Expand Down
15 changes: 15 additions & 0 deletions plugin/updater/updater-state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,21 @@ extensions:
scope-name: text.html.mako
file-extensions:
- .mako
markdoc:
github:
repo: markdoc/language-server
ref: main
commit: a6b8babf602735dc31bae1d10fad903dc40c9761
languages:
markdoc:
label: Markdoc
scope-name: text.html.markdown.markdoc
file-extensions:
- .markdoc
- .markdoc.md
- .mdoc
inline-grammars:
- text.html.markdown.markdoc.injection
markdown:
github:
repo: wooorm/markdown-tm-language
Expand Down

0 comments on commit ecf2626

Please sign in to comment.