Hyogen Blocks
hyogen.md logic lives inside HTML comments so Markdown previews stay clean.
Standard form
<!--
@hg
const greeting = "hello"
@endhg
-->
Variants that work equally:
<!--@hg
const x = 1
@endhg-->
<!--@hg /* one-line block */ @endhg-->
Shorthand form
@@ … @@ is equivalent to @hg … @endhg:
<!--@@
include ./partials/header.md
@@-->
<!--@@ include ./partials/footer.md @@-->
Use /* */ for inline comments in one-line blocks (not //, which ends at newline).
What goes inside
| Category | Examples |
|---|---|
| Declarations | const, let, reassignment |
| Includes | include, component … as, extend |
| Control flow | if / else / each (structural — wrap Markdown body) |
| Loops | for (…), do … while |
See Declarations and Control flow.
Code fences are ignored
Hyogen blocks inside fenced code blocks are not executed:
```html
<!-- @hg const x = 1 @endhg -->
```
Output preservation
By default, hyogen comment blocks are removed from output. Set preserveHgComments: true to keep them for debugging.
JS comments inside blocks
<!--
@hg
// line comment
/* block comment */
@endhg
-->