Skip to content

Instantly share code, notes, and snippets.

@LinArcX
Forked from tkqubo/html5TagSyntax.bnf
Created December 13, 2020 16:29
Show Gist options
  • Save LinArcX/b315aa5a88abccefb2ae3a9c6c2a79b9 to your computer and use it in GitHub Desktop.
Save LinArcX/b315aa5a88abccefb2ae3a9c6c2a79b9 to your computer and use it in GitHub Desktop.

Revisions

  1. @tkqubo tkqubo revised this gist Jun 22, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion html5TagSyntax.bnf
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,4 @@ attr-double-quoted-value := /[^"]*/

    alphabets := [a-zA-Z]
    digits := /[0-9]/
    ws := /\s+/
    ws := /\s/
  2. @tkqubo tkqubo revised this gist Jun 3, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion html5TagSyntax.bnf
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    tag-open := '<' tag-name ws* attr-list? ws* '/'? '>'
    tag-open := '<' tag-name ws* attr-list? ws* '>'
    tag-empty := '<' tag-name ws* attr-list? ws* '/>'
    tag-close := '</' tag-name ws* '>'


  3. @tkqubo tkqubo renamed this gist May 31, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @tkqubo tkqubo revised this gist May 31, 2012. 1 changed file with 14 additions and 11 deletions.
    25 changes: 14 additions & 11 deletions htmlSyntax.bnf
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,22 @@
    tag-open := '<' tag-name attributes ['/'] '>'
    tag-open := '<' tag-name ws* attr-list? ws* '/'? '>'
    tag-close := '</' tag-name ws* '>'


    attributes := (ws+ attr)*
    attr := empty | unquoted | single-quoted | double-quoted
    empty := attr-name
    unquoted := attr-name ws* = ws* attr-value-nonspace
    single-quoted := attr-name ws* = ws* ' attr-value-nosingle '
    double-quoted := attr-name ws* = ws* " attr-value-nodouble "
    attr-list := (ws+ attr)*
    attr := attr-empty | attr-unquoted | attr-single-quoted | attr-double-quoted

    tag-name := (alphabets | digits)+ # can digits become first letter?
    attr-empty := attr-name
    attr-unquoted := attr-name ws* = ws* attr-unquoted-value
    attr-single-quoted := attr-name ws* = ws* ' attr-single-quoted-value '
    attr-double-quoted := attr-name ws* = ws* " attr-double-quoted-value "

    tag-name := (alphabets | digits)+ # Can digits become first letter?
    attr-name := /[^\s"'>/=\p{Control}]+/
    attr-value-nosingle := /[^']*/
    attr-value-nodouble := /[^"]*/
    attr-value-nonspace := /[^\s"'=<>`]+/

    # These three items should not contain 'ambiguous ampersand'...
    attr-unquoted-value := /[^\s"'=<>`]+/
    attr-single-quoted-value := /[^']*/
    attr-double-quoted-value := /[^"]*/

    alphabets := [a-zA-Z]
    digits := /[0-9]/
  5. @tkqubo tkqubo revised this gist May 31, 2012. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions htmlSyntax.bnf
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,16 @@
    opentag := '<' tagname attributes ['/'] '>'
    closetag := '</' tagname ws* '>'
    tagname := alphabets (alphabets | digits)*
    tag-open := '<' tag-name attributes ['/'] '>'
    tag-close := '</' tag-name ws* '>'


    attributes := (ws+ attr)*
    attr := empty | unquoted | single-quoted | double-quoted
    empty := attr-name
    unquoted := attr-name ws* = ws* attr-value-nonspace
    single-quoted := attr-name ws* = ws* ' attr-value-nosingle '
    double-quoted := attr-name ws* = ws* " attr-value-nodouble "

    tagname := /[a-zA-Z0-9]+/
    attr-name := /[^\s"'>/=]+/
    tag-name := (alphabets | digits)+ # can digits become first letter?
    attr-name := /[^\s"'>/=\p{Control}]+/
    attr-value-nosingle := /[^']*/
    attr-value-nodouble := /[^"]*/
    attr-value-nonspace := /[^\s"'=<>`]+/
  6. @tkqubo tkqubo created this gist May 31, 2012.
    19 changes: 19 additions & 0 deletions htmlSyntax.bnf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    opentag := '<' tagname attributes ['/'] '>'
    closetag := '</' tagname ws* '>'
    tagname := alphabets (alphabets | digits)*
    attributes := (ws+ attr)*
    attr := empty | unquoted | single-quoted | double-quoted
    empty := attr-name
    unquoted := attr-name ws* = ws* attr-value-nonspace
    single-quoted := attr-name ws* = ws* ' attr-value-nosingle '
    double-quoted := attr-name ws* = ws* " attr-value-nodouble "

    tagname := /[a-zA-Z0-9]+/
    attr-name := /[^\s"'>/=]+/
    attr-value-nosingle := /[^']*/
    attr-value-nodouble := /[^"]*/
    attr-value-nonspace := /[^\s"'=<>`]+/

    alphabets := [a-zA-Z]
    digits := /[0-9]/
    ws := /\s+/