aboutsummaryrefslogtreecommitdiff
path: root/grammars/html.bpeg
blob: 5dd93cd689363207252569b4d486f29805a00323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# HTML grammar
HTML: __ [doctype __] 0+html-element%__ __

doctype: "<!DOCTYPE" ..`>

html-element: (
    >(`<("area"/"base"/"br"/"col"/"embed"/"hr"/"img"/"input"/"link"/"meta"/"param"/"source"/"track"/"wbr")) void-element
  / >(`<("script"/"style"/"textarea"/"title")) raw-element
  / >(`<("template")) template-element
  / normal-element)

void-element: `< @tag=(id==match-tag) __attributes__ [`/] __ `>

template-element: `< @tag=(id==match-tag) __`> __ >match-body @body=0+(!`<$. / comment / html-element / !("</"tag__`>)$.) ("</"tag__`>)

raw-element: `< @tag=(id==match-tag) __attributes__ `> >match-body @body=.. ("</"tag__`>)

normal-element: `< @tag=(id==match-tag) __attributes__ `> >match-body @body=0+(!`<$. / comment / html-element / !("</"tag__`>)$.) "</"tag__`>

comment: "<!--" ..."-->"

attributes: 0+attribute%__
attribute: (1+id%`:)__`=__ (id / `" ..`" / `' ..`')
attribute: (1+id%`:)__`=__ (id / `" ..`" / `' ..`')
match-tag: id
match-body: ''