BNF

Backus-Naur Form

Wikipedia / BNF

 

Le but de ce document est de montrer la BNF que HtmGem utilise et la façon dont il détermine le type de ligne et quelles informations il en tire. Pour cela, il utilise des accolades pour montrer explicitement quelles informations il prend. De plus, la forme canonique montre comment ça devrait être affiché.

 

———————————————————— ✀ ————————————————————

 

textgemini = *(link / preformat / heading / ulist / quoted / plain)

; Preformat toggle starts as 'false'.

 

plain = {[WSP] text} [WSP] end-of-line

; If preformat toggle is false, wrap text to the

; width of the display. Otherwise, do no wrapping.

; canonical form = {[WSP] text}

 

preformat = "```" [WSP] [{alt-text}] [WSP] end-of-line

; Preformat toggle set to opposite state:

; false goes to true

; true goes to false

; While in preformat toggle is true, link, heading,

; ulist and quoted lines are NOT interpreted, but

; displayed as is to the user.

; canonical form = ``` [SP {alt-text}]

 

link = '=>' [WSP] [{URI-reference}] [[WSP] {text}] end-of-line

; canonical form = '=>' SP {uri-reference} [SP {text}]

 

heading = '#' [WSP] [{text}] [WSP] end-of-line

/ '##' [WSP] {text} [WSP] end-of-line

/ '###' [WSP] {text} [WSP] end-of-line

; canonical form = ('#' / '##' / '###') [SP {text}]

 

ulist = '*' [WSP] {text} [WSP] end-of-line

; canonical form = '*' SP {text}

 

quoted = '>' [WSP] {text} [WSP] end-of-line

; canonical form = '>' SP {text}

 

alt-text = text

text = *UVCHAR

end-of-line = [CR] LF

 

UVCHAR = VCHAR / UTF8-2v / UTF8-3 / UTF8-4

UTF8-2v = %xC2 %xA0-BF UTF8-tail ; no C1 control set

/ %xC3-DF UTF8-tail

 

; CRLF from RFC-5234

; DIGIT from RFC-5234

; SP from RFC-5234

; VCHAR from RFC-5234

; OCTET from RFC-5234

; WSP from RFC-5234

;

; UTF8-3 from RFC-3629

; UTF8-4 from RFC-3629

; UTF8-tail from RFC-3629

 

———————————————————— ✀ ————————————————————

 

Cette BNF a été adaptée à l’implémentation de HtmGem depuis la version du groupe de travail.

Gitlab / Original ticket

 

Changements :

 

Les espaces blancs terminant une ligne ne sont jamais utilisés. Voir la définition de text dans la BNF, qui ne contient plus SP.

 

Exemples

 

=> liens

 

Lien normal

link = '=>' [WSP] [{URI-reference}] [[WSP] {text}] end-of-line

; canonical form = '=>' SP {uri-reference} [SP {text}]

 

Source: => foo.invalid text of the link

Data: '=>' {'foo.invalid'} {'text of the link'}

Canonical: => foo.invalid text of the link

Html: <a href="foo.invalid">text of the link</a>

 

Source: =>foo.invalid text of the link

Data: '=>' {'foo.invalid'} {'text of the link'}

Canonical: => foo.invalid text of the link

Html: <a href="foo.invalid">text of the link</a>

 

Source: => just_a_page

Data: '=>' {'just_a_page'} {}

Canonical: => just_a_page

Html: <a href="just_a_page">just_a_page</a>

 

Source: =>

Data: '=>' {''} {''}

Canonical: =>

Html: <a href="">&nbsp;</a>

 

# En-têtes

heading = '#' [WSP] [{text}] [WSP] end-of-line

(…)

; canonical form = ('#' / '##' / '###') [SP {text}]

 

Source: #title

Data: '#' {"title"}

Canonical: # title

 

Source: # title with two spaces between title and with

Data: '#' {"title with spaces"}

Canonical: # title with two spaces between title and with