Closed bricebou closed 3 years ago
Try:
$Parsedown->codeAttributesOnParent = ['class', 'data-output', 'id'];
Yeah, that works great ! Is it possible to use a regular expression to replicate all data attributes ? Something like data-* ?
I was wondering also why there is $blockCodeClassFormat which permits to add "language-" while we find the blockFencedCode function in Parsedown which does the same ?
Thanks again and in advance :)
Is it possible to use a regular expression to replicate all data attributes ?
It is not possible for simplicity and maybe security too.
I was wondering also why there is
$blockCodeClassFormat
which permits to addlanguage-
It was for the class name dot prefix behavior in my extension. See the feature about automatic language-
prefix in code block.
It is not possible for simplicity and maybe security too.
Yeah, seems logic :)
It was for the class name dot prefix behavior in my extension. See the feature about automatic
language-
prefix in code block.
I understand the logic but I've got this : language-language-class while doing this:
```shell
I I do that:
```{shell .command-line data-output="2-20"}
I get <pre class="command-line" data-output="2-20"><code shell="shell">
.
I try this:
```shell {.command-line data-output="2-20"}
And I get <pre class="command-line" data-output="2-20"><code>
...
What am I missing ?
I understand the logic but I've got this
language-language-class
Looks like a bug to me.
For the second example, think of any characters between {
and }
as literal HTML attributes. It is just that .foo
and #foo
is special here.
In general, you can do foo="bar"
, foo='bar'
and foo=bar
. When you have attribute without value, it will be parsed to attribute="attribute"
in the output.
Think of shell
in {shell foo="bar"}
as disabled
and readonly
in <input disabled readonly foo="bar">
.
The third example should be invalid. If it works somehow, that will be out of the specs.
What happen if you do this?
``` {class="shell" data-output="2-20"}
I get <pre class="shell" data-output="2-20"><code>
.
Is there a way to combine multiple attributes along with the auto prefix "language-" ?
Is there a way to get this
<pre class="language-shell command-line" data-output="2-20"><code>
besides of
``` {class="language-shell command-line" data-output="2-20"}
Thanks again !
I am afraid that this request will expand to other valid elements that have advance attribute features. You don’t want to have a heading tag with class names that automatically be prefixed by language-
.
### Test {.foo}
Expect <h3 class="foo">
but get <h3 class="language-foo">
.
Right !
Anyway, maybe ParsedownExtraPlugin should test if there is a space between the code block tag ```
and the class:
```html
is already parsed by Parsedown as
<pre><code class="language-html">
ParsedownExtraPlugin should add 'language-' only when we have:
``` html
No ?
Hum... Parsedown adds also "language-" when parsing :
``` html
Thanks !
When I do:
only classes are reported to the
<pre>
parent element even withAm I missing something?