parsedown-extra icon indicating copy to clipboard operation
parsedown-extra copied to clipboard

Updated the attribute parser to handle extra attributes aside from just a `class` and `id`.

Open the0neWhoKnocks opened this issue 9 years ago • 4 comments

  • 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 the parseAttributeData 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 attributes class="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 like width & height can be added.

the0neWhoKnocks avatar Jan 07 '16 04:01 the0neWhoKnocks

:+1:

PhrozenByte avatar Jan 20 '16 03:01 PhrozenByte

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

the0neWhoKnocks avatar Jan 20 '16 05:01 the0neWhoKnocks

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">

taufik-nurrohman avatar May 06 '16 02:05 taufik-nurrohman

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!

bernd-wechner avatar Sep 19 '20 01:09 bernd-wechner