| title | description |
|---|---|
Syntax Reference |
Complete guide to markdown-magic block syntax, including all available syntax variations, option formats, and best practices |
Markdown-magic supports multiple syntax styles for transform blocks. Choose the style that works best for your project.
All transform blocks follow this basic structure:
<!-- matchWord transformName [options] -->
Content to be replaced
<!-- /matchWord -->Where:
matchWordis the opening keyword (default:docs)transformNameis the name of the transform to applyoptionsare optional parameters for the transform- Content between the tags will be replaced by the transform output
The simplest form - just specify the transform name and options:
<!-- docs transformName optionOne='hello' optionTwo='there' -->
content to be replaced
<!-- /docs -->Wrap the transform name in curly braces:
<!-- docs {transformName} optionOne='hello' optionTwo='there' -->
content to be replaced
<!-- /docs -->Wrap the transform name in square brackets:
<!-- docs [transformName] optionOne='hello' optionTwo='there' -->
content to be replaced
<!-- /docs -->Wrap the transform name in parentheses:
<!-- docs (transformName) optionOne='hello' optionTwo='there' -->
content to be replaced
<!-- /docs -->Use function-like syntax with parentheses for options:
<!-- docs transformName(
foo='bar'
baz=['qux', 'quux']
) -->
content to be replaced
<!-- /docs --><!-- docs transform option='string value' --><!-- docs transform enabled=true disabled=false --><!-- docs transform items=['one', 'two', 'three'] --><!-- docs transform
url='https://example.com'
format='json'
cache=true
items=['a', 'b', 'c']
-->You can customize the opening keyword by configuring the matchWord option:
// In your config file
module.exports = {
matchWord: 'auto-gen', // Custom match word
// ... other options
}Then use it in your markdown:
<!-- auto-gen transformName -->
content to be replaced
<!-- /auto-gen -->- Consistency: Choose one syntax style and stick with it across your project
- Readability: Use the function style for complex options
- Comments: Add comments above complex transforms to explain their purpose
- Validation: Always test your syntax changes before committing
See the examples directory for real-world usage patterns and the Advanced Usage guide for complex scenarios.