-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Allow empty/ default attributes in markdown codeblocks #9791
Comments
@jgm, I'm about to start working on this unless you disagree (it's a slow Friday night) |
I just haven't decided on this issue yet. The suggestion has come up before -- perhaps in these issues, perhaps on pandoc-discuss, perhaps in commonmark issue tracker or forum, I can't recall. Some have advocated reserving the bare names for another purpose. It would be good to locate the prior discussion before proceeding further. |
I didn't see anything in discussions, but here's a quick scan of 100+ open issues with the very loose search "markdown attribute" (search quey: https://github.com/search?q=repo%3Ajgm%2Fpandoc+markdown+attribute++&type=issues&state=open&p=12):
I don't see anyone claiming this exact solution, you hint that to solve the issue quarto is facing, attribute behavior would have to be addressed in #8645 (comment) The only case I can really think that would be affected is the quarto implementation. regex here: The proposed change would just add a superfluous attribute to quarto documents since they check directly against the text, but it wouldn't break their pipeline. I did a quick test: Here's ```{python}
import numpy as np
```
```python {foo}
import numpy as np
``` Here's current behavior for <p><code>{python} import numpy as np</code></p>
<p><code>python {foo} import numpy as np</code></p> Here's the result of the proposed behavior: <pre data-python=""><code>import numpy as np</code></pre>
<div class="sourceCode" id="cb2" data-foo=""><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span></code></pre></div> |
Here is one of the issues I may have been thinking of (in djot, but djot uses basically the same attribute syntax as pandoc's markdown): jgm/djot#257 The worry expressed there is that if bare words are allowed, there's more chance of "false positives" for attributes: With current attribute syntax this kind of "false positive" would be very unlikely. You might think that this isn't a big problem in pandoc, since attributes are only allowed in certain special contexts. But we might want to expand this to allow attributes on every element. I'm not sure how much of a concern this is, but it's the sort of issue that needs some thought before there is any expansion of current attribute syntax. |
Thanks for connecting the two issues, but (as a Quarto dev) let me just say that Quarto already has enough going on and workarounds for the current behavior. I don't think it's necessary to try and address #8645 together with this. |
Hmm, the conversation in Single token Obviously, GitHub does not cover all markdown text, but I don't think this is an observed pattern. |
Describe your proposed improvement and the problem it solves.
Currently ```{attribute=} is fine, so ```{attribute} should be fine. I think this notation is a tiny bit cleaner; and is consistent with HTML. This is currently breaking behavior that causes the code block to not be recognized at all, but this is also fine on looser matches like github:
This also solves #8645 since quarto can just use the empty attribute (they currently have an additional filter to get around this behavior).
Implementation
This might be a bit far-reaching (since
attribute
is used in multiple places), but here's a simple fix:But could also scope this to just
codeblockFenced
Describe alternatives you've considered.
Just be more verbose and use the {attribute=} notation, but this "feature" borders on bug for me.
Let me know if this is a won't fix- otherwise I'll submit a PR
The text was updated successfully, but these errors were encountered: