parsedown-extra
parsedown-extra copied to clipboard
Updated the attribute parser to handle extra attributes aside from just a `class` and `id`.
- I wanted the ability to be able to add
width
&height
attributes to images but wasn't able to in the current state so I updated the RegEx rules and theparseAttributeData
method. Now a user can add something like{.test .fu #bar style="color:red; font-style:italic" data-is-cool="'tis true" lang=en_us}
and it'll render out these attributesclass="test fu" id="bar" style="color:red; font-style:italic" data-is-cool="'tis true" lang="en_us"
. - I also added the
inlineImage
method so attributes likewidth
&height
can be added.
:+1:
@PhrozenByte - Updated per your comment and also added the ability to have spaces in the quoted attributes.
On a separate note. Any idea what's up with the tests? Seems travis can't find ParsedownTest.php
and has been failing on that before my commits.
Added to my extension with more stable regex parser which will produces:
-
{#foo}
→<tag id="foo">
-
{#foo#bar}
→<tag id="bar">
-
{.foo}
→<tag class="foo">
-
{.foo.bar}
→<tag class="foo bar">
-
{#foo.bar.baz}
→<tag id="foo" class="bar baz">
-
{#foo .bar .baz}
→<tag id="foo" class="bar baz">
(white-space before#
and.
becomes optional in my extension) -
{foo="bar"}
→<tag foo="bar">
-
{foo="bar baz"}
→<tag foo="bar baz">
-
{foo='bar'}
→<tag foo="bar">
-
{foo='bar baz'}
→<tag foo="bar baz">
-
{foo=bar}
→<tag foo="bar">
-
{foo=}
→<tag foo="">
-
{foo}
→<tag foo="foo">
-
{foo=bar baz}
→<tag foo="bar" baz="baz">
-
{#a#b.c.d e="f" g="h i" j='k' l='m n' o=p q= r s t="u#v.w.x y=z"}
→<tag id="b" class="c d" e="f" g="h i" j="k" l="m n" o="p" q="" r="r" s="s" t="u#v.w.x y=z">
One vote here to see this merged! It's been around long enough and seems to be part of the MarkDown Extra spec:
https://michelf.ca/projects/php-markdown/extra/#spe-attr
and be wildly useful out in the field!