Skip to content

Syntax reported as unsupported-syntax ​

The parser never throws. Input it does not model becomes an unsupported-syntax error at the first offset it cannot read, and the rest of that line is skipped. This file lists every known source of that error. Anything else that produces unsupported-syntax is a bug.

"Invalid Pug" marks forms that Pug itself rejects; they are listed because the parser reports them with this code too.

Lines ​

FormExampleNotes
Interpolated tag name#{tag} text, #{tag}/
Interpolated mixin name+#{name}()+ name (spaces after +) is a mixin call.
Text block without a taga line that is only ., with text lines nested under itPug puts the text in the parent. Use | lines.
Tag interpolation or mustache at line start#[b x] y, Use | #[b x] y / | .
Anything else that does not start a Pug construct), @x, .5
Lines nested under piped text| a with an indented p below itInvalid Pug. Reported once, at the first nested line; the nested lines are skipped and form an error-recovery region (doc.lines kind continuation). Lines nested under literal HTML (<ul>) are valid: Pug makes them siblings, and so does the parser.
Lines nested under buffered code= x or != x with an indented p below itInvalid Pug. Reported and recovered as under piped text. Under p= x the lines are children of p, as in Pug.

After a tag or mixin call head ​

FormExampleNotes
Unbuffered code after a tagp- x
. followed by more on the linep. text, p.: aInvalid Pug.
Text block after a mixin call+m.
Block expansion after a mixin call+m: pMixinCall has no expansion field. As the child it is fine: li: +m.
/ after a mixin call+m/
Block expansion after /img/: xInvalid Pug.
: not followed by a space and a childli:, li(x):b, when 1:Invalid Pug.
Expansion child that is not a tag or mixin callli: | x, li: <b>x</b>, li: = x, li: // c, li: if x, when 1: each x in yA control keyword is never read as a tag name here.
Tag followed by an inline filterp: :markdown text

Control heads ​

FormExampleNotes
Block expansion after a conditional or loopelse: p, else : p, if x: p, unless x: p, else if x: p, while x: p, case x: p, each a in b: p, for a in b: pInvalid Pug. Reported at the first : of the head outside strings and brackets that does not close a top-level ? (so if a ? b : c and each v in {a: 1} are fine). Expansion works after when and default: when 1: p a.

Filters ​

FormExampleNotes
Anything but text after the filter head:a(x):b, :md.xNested filters are read only as :a:b(attrs), with attributes after the last name.

Tag interpolation #[…] ​

FormExampleNotes
Not starting with a tag#[+m], #[| x], #[- x], #[:cdata x]Mixin calls, text, code and filters are not read inside #[…].
Head followed by anything but text, =/!= code or : child#[p.], #[p- x], #[img/: x]

Parsed without an error, but not as Pug does ​

Found by the differential oracle (tests/oracle, Task 17).

FormExampleNotes
Comment after a block nameblock content // cPug ends the name at // and makes the rest a sibling comment that also takes the nested lines. The parser keeps it in the block head.
Duplicate attribute or ida(x=1 x=2), #a#bPug rejects them; the parser accepts them.
Empty else after eacheach x in y … else with nothing nestedPug rejects it; the parser accepts it.

Released under the MIT License.