Marko's concise syntax is very similar to the HTML syntax, except it's more... concise. Essentially, you take an HTML tag, remove the angle brackets (<>
) and use indentation rather than a closing tag:
div class="thumbnail"img src="https://example.com/thumb.png"
div class="thumbnail"img src="https://example.com/thumb.png"
Marko provides a shorthand for declaring classes and ids on an element:
div.my-classspan#my-idbutton#submit.primary.large
div.my-classspan#my-idbutton#submit.primary.large
Yields this HTML:
ProTip: These shorthand attributes are available within the HTML syntax as well
Text in concise mode is denoted by two or more dashes (--
).
If there is text on the same line following --
, it is single-line text:
-- Hello world
-- Hello world
The dashes can also follow an element to give it a single text node as a child
div -- Hello world
div -- Hello world
If there is a line break immediately following --
, everything following the --
at the current indentation is parsed as multi-line line text.
divdiv
divdiv
A multi-line text block can be ended by the same number of dashes that opened it. This allows it to have siblings:
divimg src="https://example.com/photo.png"span -- text after
div
There is one "gotcha" that you need to be aware of. The Marko parser starts out in the concise mode. Therefore, given the following template:
Hello WorldWelcome to Marko
Hello WorldWelcome to Marko
The output would be the following:
Instead, prefix the lines with --
so they are parsed as text:
-- Hello World-- Welcome to Marko
-- Hello WorldWelcome to Marko
Helpful? You can thank these awesome people! You can also edit this doc if you see any issues or want to improve it.