-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Proposal: Punctuation Character for Code Block's language specifier #281
Comments
Actually, the current djot.js parser does allow On the other hand, using Curious to hear other comments on this. |
Yup! It's why I pushed it as an alternative. Glad we're aligned there.
It is pretty intuitive at this point to reach for ``` isn't it? I didn't even know about
Same. This other issues linked above are already filled with plenty of insights, but I don't think any of them touched on this specific issue/proposal. |
Ah, one more comment on:
Requiring Without Hard Break
leads to <p>~~~ I’m a paragraph~~~</p> With Hard BreakWhile
becomes <pre><code class="language-I'm">a paragraph
</code></pre> |
The rule being:
Then
Should perhaps
(Depending on imposing or not restrictions on language specifiers) |
@Omikhleia As is, calling it a syntax error might be difficult. Verbatim text, is:
This is verbatim text:
but so is this:
|
After writing that last comment, I think I'm slowly pushing myself over towards using tilde instead of backticks. So, a code block would look like:
or
(Everything after Which has a number of advantages:
|
Proposal
Utilize a punctuation character for fenced code block language specifier.
I use
?
below, but would be happy for any character.Why?
Current syntax introduces ambiguity and breaks djot's design goals. Namely goal 7 and 3 (in spirit).
In addition to resolving these breaks from the goals, it'd allow easier parsing. As is, it's not until we get to the second word of a line that a parser would know the line is the start of a paragraph rather than a code fence.
Rules 3 and 7 - ambiguity and friendly to hard wrapping
Paragraph
Here we have a paragraph that I'd like to introduce a hard break to. Live Demo
Code Block
Add a hard break at the wrong spot, and we no longer have a paragraph. Live Demo
What it'd look like
Using a specifier character, we know from the beginning that this is a fenced code block or a paragraph
With Specifier Character
Without Specifier Character
With Language
Optional Spacing
Raw Fencing
Additional Benefits
Multiple words are allowed in a code fence, as suggested in #214.
Additional Thoughts
The character doesn't need to be
?
. It's just a character I thought would be easy to utilize in this context.=
would of been my first choice, but that's used for raw html blocks.Alternatives
Use tilde instead of backtick
Having punctuation characters pull double duty is what creates the ambiguity. Backtick is used for verbatim and code blocks. Tilde is used for subscript. But, unlike in verbatim, a series of
~
doesn't do anything special for subscripts. I'd lean heavier into this alternative myself, but backticks for code fences is fairly well understood by users and they'd be the ones who'd have to adapt.Block Attributes
I'd love to use a block attribute to set the language specifier, but that doesn't resolve the ambiguities nor the non-friendliness towards hard breaks.
Related or Similar Issues
#41
#214
The text was updated successfully, but these errors were encountered: