- Description:
This key defines configuration options for content parser configurations.
The value is an object that can contain
editor_key,indented_by,default,trim_text,allow_nested,raw,forbidden_tokens,optional,allow_leading,escape_indented_blocks,parse_newline_character,ignore_unpaired_backticks,escape_fenced_blocks, andstyleproperties. These options control how content between snippet boundaries is parsed.- Appears in:
└── Snippet └── params └── * └── Content Parser Configuration └── options- Type:
ObjectRequired- Properties:
This key toggles whether the first line of the content needs to be indented when an
indented_byvalue is set.Setting this key to
truewill allow the first line of the content to not be indented, but subsequent lines must be indented.By default, this key is
false(i.e., all lines including the first must be indented).Show examplesHide examples
Copied to clipboardparser: content options: editor_key: highlighted_text indented_by: ' ' allow_leading: true{ "parser": "content", "options": { "editor_key": "highlighted_text", "indented_by": " ", "allow_leading": true } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> My highlighted content! <</highlight>> <<highlight>>Some initial content More highlighted content! <</highlight>> Morbi leo risus, porta ac consectetur ac, vestibulum at eros.This will parse correctly as
My highlighted content!This will also parse correctly, as
Some initial content\nMore highlighted content!, despite the first line not being indented.This key toggles whether nested snippets will be parsed and returned.
Setting this key to
truewill parse and return nested snippets.By default, this key is
false(i.e., nested snippets are not parsed and returned).Show examplesHide examples
Copied to clipboardparser: content options: editor_key: highlighted_text allow_nested: true{ "parser": "content", "options": { "editor_key": "highlighted_text", "allow_nested": true } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> My highlighted <<highlight>>content!<</highlight>> <</highlight>> Morbi leo risus, porta ac consectetur ac, vestibulum at eros.With
allow_nestedturned on, the content parser will detect and parse the nested<<highlight>>tags as another snippet, rather than plaintext.This doesn't have to be the same snippet, any configured snippet will be parsed inside the content parser.
If
allow_nestedis set to false, inner snippets will still be parsed, but will not be returned. This means that in the above example,My highlighted <<highlight>>content!<</highlight>>would be the raw text withallow_nested: false. If inner snippets were not parsed, the content parser would end parsing at the first<</highlight>>, giving you the text:My highlighted <<highlight>>content!. This is the behavior of therawoption.This key defines the default number of literals, which is used when adding a new snippet to a page in CloudCannon.
This key defines the key that a user in CloudCannon will see to edit this value.
The value returned by this parser is a number input that can be edited to change how many literals are output by the parser.
Show examplesHide examples
Copied to clipboard_snippets: custom_title: snippet: '[[hashes]] [[title]]' params: hashes: parser: repeating_literal options: literal: '#' minimum: 1 editor_key: heading_level title: parser: content options: editor_key: title forbidden_tokens: - |+{ "_snippets": { "custom_title": { "snippet": "[[hashes]] [[title]]", "params": { "hashes": { "parser": "repeating_literal", "options": { "literal": "#", "minimum": 1, "editor_key": "heading_level" } }, "title": { "parser": "content", "options": { "editor_key": "title", "forbidden_tokens": [ "\n" ] } } } } } }Example usage:
MarkdownCopied to clipboard# My blog post Aenean lacinia bibendum nulla sed consectetur. ## My heading Morbi leo risus, porta ac consectetur ac, vestibulum at eros.If editing these as snippets in CloudCannon, the editor will see
heading_levelas a number input. Changing this value will add or remove#characters to the source code to match the number.This key toggles whether CloudCannon will escape fenced code blocks (triple backticks) when parsing content.
Setting this key to
truewill escape fenced code blocks in the content, preventing them from being interpreted as code blocks.By default, this key is
false(i.e., fenced code blocks are not escaped).Defaults to:
falseShow examplesHide examples
In this example, we have configured content parser to escape fenced code blocks.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text escape_fenced_blocks: true{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "escape_fenced_blocks": true } } } } } }This key toggles whether CloudCannon will escape indented code blocks (4 spaces) when parsing content.
Setting this key to
truewill escape indented code blocks in the content, preventing them from being interpreted as code blocks.By default, this key is
false(i.e., indented code blocks are not escaped).Defaults to:
falseShow examplesHide examples
In this example, we have configured content parser to escape indented code blocks.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text escape_indented_blocks: true{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "escape_indented_blocks": true } } } } } }This key defines tokens that stop parsing content when encountered in content parser configurations.
The value is an array of strings, where each string specifies a forbidden token. This is useful when the content parser is being greedy and consuming more input than intended.
Show examplesHide examples
In this example, we have configured forbidden tokens to stop parsing when encountering a less-than sign.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text forbidden_tokens: - <{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "forbidden_tokens": [ "<" ] } } } } } }This key toggles whether CloudCannon will ignore unpaired backticks when parsing content.
Setting this key to
falsewill cause CloudCannon to treat unpaired backticks as parsing errors.By default, this key is
true(i.e., unpaired backticks are ignored).Defaults to:
trueShow examplesHide examples
In this example, we have configured content parser to ignore unpaired backticks.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text ignore_unpaired_backticks: true{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "ignore_unpaired_backticks": true } } } } } }This key defines the whitespace indentation required when parsing content.
Configures the content parser to require whitespace indentation when parsing. Used when a snippet continues for as long as content is indented.
This option should only be used if required, since it prevents your Snippet from parsing if the whitespace does not match.
If you want parsing to be flexible, but the output to be formatted, use the Style options instead.
Show examplesHide examples
Copied to clipboard_snippets: highlight: snippet: |- <<highlight>> [[inner]] <</highlight>> params: inner: parser: content options: editor_key: highlighted_text indented_by: ' '{ "_snippets": { "highlight": { "snippet": "<<highlight>>\n[[inner]]\n<</highlight>>", "params": { "inner": { "parser": "content", "options": { "editor_key": "highlighted_text", "indented_by": " " } } } } } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> My highlighted content! <</highlight>> <<highlight>> My highlighted content! <</highlight>> <<highlight>> My highlighted content! <</highlight>> Morbi leo risus, porta ac consectetur ac, vestibulum at eros.This will parse correctly as
My highlighted content!This will strip only the indentation that matches, and return
My highlighted content!This will not match this parser, as indentation is required. Use the
style.block.indentoption instead.This key toggles whether CloudCannon will treat content as optional when parsing snippet parameters.
Setting this key to
truewill make the content parameter optional, allowing snippets to match even when the content is missing.By default, this key is
false(i.e., content is required).Show examplesHide examples
In this example, we have configured content parser to treat content as optional.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text optional: true{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "optional": true } } } } } }This key toggles whether the parser treats
\nas line breaks instead of literal characters.Setting this key to
truewill treat\nas line breaks instead of literal characters. This is useful if you are editing your content in a multiline editing interface.By default, this key is
false(i.e.,\nis treated as literal characters).Defaults to:
falseShow examplesHide examples
Copied to clipboardparser: content options: parse_newline_character: true{ "parser": "content", "options": { "parse_newline_character": true } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> Line One\nLine Two <</highlight>>This content will be displayed on two lines when opened in an editing interface, instead of showing the literal
\ncharacters.This key toggles whether the parser performs no parsing of the inner text.
Setting this key to
truewill perform no parsing of the inner text. This is a stricter version ofallow_nested: false. Useful to improve the performance of the content parser, but can misbehave.By default, this key is
false(i.e., inner text is parsed).Show examplesHide examples
Copied to clipboardparser: content options: editor_key: highlighted_text raw: true{ "parser": "content", "options": { "editor_key": "highlighted_text", "raw": true } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> My highlighted <<highlight>>content!<</highlight>> <</highlight>> Morbi leo risus, porta ac consectetur ac, vestibulum at eros.With
rawturned on, the content parser will perform no parsing on the text it is capturing. This means that the nested<<highlight>>will not be detected as a snippet and the first<</highlight>>tag found will end the content parser, giving you the parsed contentMy highlighted <<highlight>>content!.This key defines styling options for snippet output formatting.
The value is an object that can contain
output,inline, andblockproperties. These options control how snippet content is parsed and formatted to produce cleaner source code.Show examplesHide examples
In this example, we have configured snippet style with inline and block formatting options.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: style: inline: leading: ' ' trailing: ' ' block: leading: \n trailing: \n indent: ' '{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "style": { "inline": { "leading": " ", "trailing": " " }, "block": { "leading": "\\n", "trailing": "\\n", "indent": " " } } } } } } } }This key toggles whether all whitespace and newlines will be trimmed from the start and end of the content before it is presented to an editor in CloudCannon.
Setting this key to
truewill trim all whitespace and newlines from the start and end of the content.By default, this key is
false(i.e., whitespace and newlines are not trimmed).Show examplesHide examples
Copied to clipboardparser: content options: editor_key: highlighted_text trim_text: true{ "parser": "content", "options": { "editor_key": "highlighted_text", "trim_text": true } }Example usage:
MarkdownCopied to clipboard## My blog post <<highlight>> My highlighted content! <</highlight>> <<highlight>> My highlighted content! <</highlight>> Morbi leo risus, porta ac consectetur ac, vestibulum at eros.Both of these will parse as
My highlighted content!, despite the newlines and whitespace surrounding them.To add whitespace back in when outputting the snippet, use the Style options.
- Examples:
In this example, we have configured content parser options with an editor key and forbidden tokens.
Copied to clipboard_snippets: highlight: snippet: <<highlight>> [[content]] <</highlight>> params: content: parser: content options: editor_key: highlighted_text forbidden_tokens: - <{ "_snippets": { "highlight": { "snippet": "<<highlight>> [[content]] <</highlight>>", "params": { "content": { "parser": "content", "options": { "editor_key": "highlighted_text", "forbidden_tokens": [ "<" ] } } } } } }