Skip to content

Commit

Permalink
Rename allowIndentation to ignoreIndentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyClifford committed Oct 23, 2023
1 parent a533473 commit 52175fb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .changeset/hip-rockets-glow.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@astrojs/markdoc': minor
---

Added allowIndentation as a markdoc integration option to enable better readability
Added ignoreIndentation as a markdoc integration option to enable better readability of source code.
10 changes: 5 additions & 5 deletions packages/integrations/markdoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,21 +458,21 @@ To achieve a more Markdown-like experience, where HTML elements can be included
> **Warning**
> 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.
### `allowIndentation`
### `ignoreIndentation`
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.
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 allowIndentation option.
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.
```diff lang="js" "allowIndentation: true"
```diff lang="js" "ignoreIndentation: true"
// astro.config.mjs
import { defineConfig } from 'astro/config';
import markdoc from '@astrojs/markdoc';

export default defineConfig({
// ...
+ integrations: [markdoc({ allowIndentation: true })],
// ^^^^^^^^^^^^^^^^^^^^^^
+ integrations: [markdoc({ ignoreIndentation: true })],
// ^^^^^^^^^^^^^^^^^^^^^^^
});
```
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/markdoc/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface MarkdocIntegrationOptions {
allowHTML?: boolean;
allowIndentation?: boolean;
ignoreIndentation?: boolean;
}
2 changes: 1 addition & 1 deletion packages/integrations/markdoc/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getMarkdocTokenizer(options: MarkdocIntegrationOptions | undefin
// enable HTML token detection in markdown-it
tokenizerOptions.html = true;
}
if (options?.allowIndentation) {
if (options?.ignoreIndentation) {
// allow indentation so nested Markdoc tags can be formatted for better readability
tokenizerOptions.allowIndentation = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import markdoc from '@astrojs/markdoc';

// https://astro.build/config
export default defineConfig({
integrations: [markdoc({ allowIndentation: true })],
integrations: [markdoc({ ignoreIndentation: true })],
});

0 comments on commit 52175fb

Please sign in to comment.