"flag" attributes
panglesd opened this issue · 3 comments
Hello !
The djot syntax reference does not allow flag attributes (attributes without a value, or empty attributes, as they are called in html).
I think those flag attributes are useful! Is there a reason for not supporting them?
(I would have the same question for pandoc's markdown, but since pandoc has so many more features, I though asking in this syntax-specific repo was better).
Anyway, thanks a lot for all your work on markup languages!
I'm open to reconsidering this. My thinking originally was that if we allow flag attributes there is greater chance of capturing something that was meant as regular text, e.g. {this is just plain text in braces}
. But if we assume that braces are very rarely used in regular text, this isn't a big problem.
Semantically, how should flag attributes be represented? In HTML, checked
is semantically equivalent to checked="checked"
and also, I think, to checked=""
. So, we could parse a bare checked
as a key-value attribute checked=checked
.
I could only find the equivalence of empty attributes with attributes with value ""
:
Empty attribute syntax
Just the attribute name. The value is implicitly the empty string.
Using the already existing equivalence of a flag/empty attributes with an attribute of value ""
is indeed a good way to add the feature without changing the AST. Alternatively, there could be a new kind of attributes, "flag" attributes, which have a key but not a value.
A possible value for the representation of flag attributes in the AST would be true
: element.checked
would be true in boolean context but you could also do if ( element.checked == true )
to distinguish {checked}
from {checked=checked}
for better roundtripping.
In Pandoc Markdown I always use backslashes or verbatim for non-attribute braces but TBH I also always disable shortcut reference links so that I don’t have to remember to escape brackets around phonetic transcriptions! I do occasionally use braces around shorthand transliterations1 but I use verbatim with a class for those. I would believe that braces are even more unusal in text than brackets but there probably is some discipline which uses braces a lot! However I don’t think djot should disallow flag attributes because of that.
Footnotes
-
Because shorthand is difficult to reproduce in electronic documents it is common to use a longhand transcription like
{InTrODUKTion}
where{In}
,{Tr}
, and{Tion}
represent a single shorthand grapheme each, i.e. each shorthand grapheme is represented by an uppercase letter followed by zero or more lowercase letters. Some punctuation and symbols are used as well. ↩