@astrojs/markdoc 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/options.d.ts +1 -0
- package/dist/tokenizer.js +3 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -458,6 +458,40 @@ To achieve a more Markdown-like experience, where HTML elements can be included
|
|
|
458
458
|
> **Warning**
|
|
459
459
|
> When `allowHTML` is enabled, HTML markup inside Markdoc documents will be rendered as actual HTML elements (including `<script>`), making attack vectors like XSS possible. Ensure that any HTML markup comes from trusted sources.
|
|
460
460
|
|
|
461
|
+
### `ignoreIndentation`
|
|
462
|
+
|
|
463
|
+
By default, any content that is indented by four spaces is treated as a code block. Unfortunately, this behavior makes it difficult to use arbitrary levels of indentation to improve the readability of documents with complex structure.
|
|
464
|
+
|
|
465
|
+
When using nested tags in Markdoc, it can be helpful to indent the content inside of tags so that the level of depth is clear. To support arbitrary indentation, we have to disable the indent-based code blocks and modify several other markdown-it parsing rules that account for indent-based code blocks. These changes can be applied by enabling the ignoreIndentation option.
|
|
466
|
+
|
|
467
|
+
```diff lang="js" "ignoreIndentation: true"
|
|
468
|
+
// astro.config.mjs
|
|
469
|
+
import { defineConfig } from 'astro/config';
|
|
470
|
+
import markdoc from '@astrojs/markdoc';
|
|
471
|
+
|
|
472
|
+
export default defineConfig({
|
|
473
|
+
// ...
|
|
474
|
+
+ integrations: [markdoc({ ignoreIndentation: true })],
|
|
475
|
+
// ^^^^^^^^^^^^^^^^^^^^^^^
|
|
476
|
+
});
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```md
|
|
480
|
+
# Welcome to Markdoc with indented tags 👋
|
|
481
|
+
|
|
482
|
+
# Note: Can use either spaces or tabs for indentation
|
|
483
|
+
|
|
484
|
+
{% custom-tag %}
|
|
485
|
+
{% custom-tag %} ### Tags can be indented for better readability
|
|
486
|
+
|
|
487
|
+
{% another-custom-tag %}
|
|
488
|
+
This is easier to follow when there is a lot of nesting
|
|
489
|
+
{% /another-custom-tag %}
|
|
490
|
+
|
|
491
|
+
{% /custom-tag %}
|
|
492
|
+
{% /custom-tag %}
|
|
493
|
+
```
|
|
494
|
+
|
|
461
495
|
## Examples
|
|
462
496
|
|
|
463
497
|
- The [Astro Markdoc starter template](https://github.com/withastro/astro/tree/latest/examples/with-markdoc) shows how to use Markdoc files in your Astro project.
|
package/dist/options.d.ts
CHANGED
package/dist/tokenizer.js
CHANGED
|
@@ -11,6 +11,9 @@ function getMarkdocTokenizer(options) {
|
|
|
11
11
|
tokenizerOptions.allowIndentation = true;
|
|
12
12
|
tokenizerOptions.html = true;
|
|
13
13
|
}
|
|
14
|
+
if (options?.ignoreIndentation) {
|
|
15
|
+
tokenizerOptions.allowIndentation = true;
|
|
16
|
+
}
|
|
14
17
|
_cachedMarkdocTokenizers[key] = new Markdoc.Tokenizer(tokenizerOptions);
|
|
15
18
|
}
|
|
16
19
|
return _cachedMarkdocTokenizers[key];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdoc",
|
|
3
3
|
"description": "Add support for Markdoc in your Astro site",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@astrojs/prism": "3.0.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"astro": "^3.3.
|
|
71
|
+
"astro": "^3.3.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/chai": "^4.3.5",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"rollup": "^3.28.1",
|
|
83
83
|
"vite": "^4.4.9",
|
|
84
84
|
"@astrojs/markdown-remark": "3.3.0",
|
|
85
|
-
"astro": "3.3.
|
|
85
|
+
"astro": "3.3.4",
|
|
86
86
|
"astro-scripts": "0.0.14"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|