aboutsummaryrefslogtreecommitdiff
path: root/grammars/html.bp
blob: 483db6ac6e2bac347ca5d268bd1b061d0b672f7a (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
# Syntax definitions for some HTML-specific patterns
#
# NOTE: this is *NOT* intended to be a complete definition of the language's
# syntax! Providing a full language grammar is overkill, because the intended
# use case is finding/replacing string patterns. This task does not require a
# full parse tree, and having one makes the task considerably more complicated.
# See the accompanying README.md for more info.

doctype: "<!DOCTYPE" ..%\n `>

html-element: void-element / raw-element / template-element / normal-element

void-element: `< ("area"/"base"/"br"/"col"/"embed"/"hr"/"img"/"input"/"link"/"meta"/"param"/"source"/"track"/"wbr") __attributes__ [`/] __ `>

template-element: "<template>" ..%(\n / comment / html-element) "</template>"

raw-element: `< @tag=("script"/"style"/"textarea"/"title") __attributes__ `> ..%\n ("</"tag__`>)

normal-element: `< @tag=id __attributes__ `> ..%(\n / comment / html-element) ("</"tag`>)

comment: "<!--" ..%\n "-->"

attributes: *attribute%__
attribute: (+id%`:)__`=__ (id / string)