diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-05-26 10:18:42 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-26 10:32:10 +0200 |
| commit | 75d54ad0c5d9bdcb02e9934401f1a23bc0645de7 (patch) | |
| tree | ab7fb3dd8e20b29c4c71c35533384728b5cae580 | |
| parent | caee6369ebdee3d34f066042dea833ee37922481 (diff) | |
add syntax PrefixDefinition; improve text on Markdown
| -rw-r--r-- | _markdown.qmd | 48 | ||||
| -rw-r--r-- | _syntax.qmd | 4 | ||||
| -rw-r--r-- | syntax/def.peg | 1 | ||||
| -rwxr-xr-x | syntax/def_BlockX.py | 17 | ||||
| -rwxr-xr-x | syntax/def_PrefixDefinition.py | 17 |
5 files changed, 69 insertions, 18 deletions
diff --git a/_markdown.qmd b/_markdown.qmd index d038cc8..542b175 100644 --- a/_markdown.qmd +++ b/_markdown.qmd @@ -233,7 +233,7 @@ Syntax of `AnnotatedWords` and `LinkedWords`, extended with `SemWords`. ::: The new `SemWords` are components in the RDF language, -which is described further in @sec-rdf +which is described further in @sec-rdf; either an angle-bracketed `Uri` or a `Curie`. Each component has an optional prefix to denote whether it is an RDF subject, predicate or object. @@ -254,24 +254,36 @@ Syntax of `SemWords`, `SemWord`, `Curie` and `SEMPREFIX`. ::: -## Expectations of processors +## Suggestions for processors -Parsing should be human-friendly, -in the spirit of Markdown -(see @sec-spirit). -This may translate to the annotations being dropped, -unlike Markdown in general but like link definition blocks. +The purpose of these analyses is parsing, +as covered in the follwing chapters. +To conclude follows some general suggestions +for parsing the Markdown extension Semantic Markdown. -For a Markdown parser to cover the Markdown extension Semantic Markdown, -it needs to cover the existing extension AnnotatedWords, -extended to include `Uri` and `Curie`, -and it needs to cover AnnotatedWords not only immediately after Words, -but also as leading or trailing Words for a block. +For a parser of existing Markdown to be extended +to cover the Markdown extension Semantic Markdown, +it needs to cover the existing extension `AnnotatedWords`, +extended to contain `Uri` and `Curie`, +and `AnnotatedWords` should be permitted not only immediately after Words, +but also as initial or final `Words` in a block. +Additionally, the new block type `PrefixDefinition` needs to be covered, +similar to `LinkDefinition` but a simpler structure +with `Curie` as the initial element. -Additionally, a new block type needs to be covered, -similar to LinkDefinition but a simpler structure -with a `Curie` as initial element. +Parsing of Semantic Markdown should be human-friendly, +in the spirit of Markdown +(see @sec-spirit). +For properly matched annotations, +this translates to the markup being removed from content, +similar to the removal of `LinkTarget` inlines and `LinkDefinition` blocks +in core Markdown, +and non-semantic `AnnotatedWords` in some dialects. +Non-matched data should be preserved, treated as content. -These new Word and Block syntaxes should be prioritized, -as the `Uri` and `Curie` patterns are unlikely to collide -with existing Markdown or non-markup plain text. +These extended or new `Word` and `Block` syntaxes -- +`AnnotatedWords` and `PrefixDefinition` -- +should be safe to parse prioritized, +because the majorly involved `Curie` pattern should not collide +with any existing Markdown, +and is unlikely to appear in natural language text. diff --git a/_syntax.qmd b/_syntax.qmd index 0dd6204..e0bfb4e 100644 --- a/_syntax.qmd +++ b/_syntax.qmd @@ -6,12 +6,16 @@ regular expressions and the negative predicate from PEG notation.  + +    + +   diff --git a/syntax/def.peg b/syntax/def.peg index 11ce1ab..ab809ac 100644 --- a/syntax/def.peg +++ b/syntax/def.peg @@ -49,6 +49,7 @@ NEWLINE <- '\r\n' # Semantic Markdown # @see <https://source.jones.dk/semantic-markdown/about/> +PrefixDefinition <- '{' CuriePrefix '}' ':' _? SemWord NEWLINE AnnotatedWordsX <- '[' Words ']' ('{' (SemWords / ![{}] PlainWords) '}') SemWords <- SemWord (_ SemWord)* diff --git a/syntax/def_BlockX.py b/syntax/def_BlockX.py new file mode 100755 index 0000000..da38385 --- /dev/null +++ b/syntax/def_BlockX.py @@ -0,0 +1,17 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +from railroad import * + +Diagram( + Choice(0, + NonTerminal("Header"), + NonTerminal("List"), + Group(NonTerminal("PrefixDefinition")), + NonTerminal("LinkDefinition"), + NonTerminal("Paragraph") + ), + type="complex" +).writeStandalone(sys.stdout.write) diff --git a/syntax/def_PrefixDefinition.py b/syntax/def_PrefixDefinition.py new file mode 100755 index 0000000..c0e108a --- /dev/null +++ b/syntax/def_PrefixDefinition.py @@ -0,0 +1,17 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +from railroad import * + +Diagram( + "{", + NonTerminal("CuriePrefix"), + "}", + ":", + Choice(0, NonTerminal("_"), Skip()), + NonTerminal("SemWord"), + NonTerminal("NEWLINE"), + type="complex" +).writeStandalone(sys.stdout.write) |
