michelf / php-markdown

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.
http://michelf.ca/projects/php-markdown/
Other
3.42k stars 530 forks source link

Add id and class attr for table #393

Closed iwill closed 1 year ago

iwill commented 1 year ago

Add id and class attr for table in Markdown:

| ID | Name   | State |
| -: | :----- | :---: |
|  1 | Task A | DONE  |
|  2 | Task B | TODO  |
{ #id .class }

HTML:

<table id="id" class="class">
   ...
</table>
michelf commented 1 year ago

I see in the logs:

Undefined offset: 4

/home/runner/work/php-markdown/php-markdown/Michelf/MarkdownExtra.php:1199

It seems the error comes from a notice about $matches[4] when there is a table with no extra attribute block. I suggest you use the null coalescing operator ($matches[4] ?? null) to handle more cleanly cases where the regular expression finds no extra attribute block and there is no $matches[4].

iwill commented 1 year ago

@michelf Hi, I fixed the unit test error, would you like to merge this PR?

michelf commented 1 year ago

@iwill Looks good. Sorry about it taking so long. I think GitHub never notified me about you pushing more changes.