Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"flag" attributes #257

Open
panglesd opened this issue Nov 17, 2023 · 3 comments
Open

"flag" attributes #257

panglesd opened this issue Nov 17, 2023 · 3 comments

Comments

@panglesd
Copy link

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!

@jgm
Copy link
Owner

jgm commented Nov 17, 2023

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.

@panglesd
Copy link
Author

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.

@bpj
Copy link

bpj commented Nov 17, 2023

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

  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants