bp/grammars/html.bp

25 lines
1017 B
Plaintext

# 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)