aboutsummaryrefslogtreecommitdiff
path: root/grammars/html.bp
blob: 1000670f3abfcaedb94b445e2eb31b79b0d340b4 (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 `>

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 / element) "</template>"

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

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

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

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