thephpleague / commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.

Home Page:https://commonmark.thephpleague.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Config Default Attributes] How to set default attributes without value?

blackjyn opened this issue · comments

For instance, HTML video can have controls and autoplay attributes simply without any values.
I did this

$config = [
	"default_attributes"=>[
		Video::class=>[
			"controls"=>"",
			"autoplay"=>""
		]
	]
];

but rendered value will be :
<video controls="" autoplay="">...</video>

How do I get rendered value simply like this:
<video controls autoplay>...</video>

and notice *I don't want to write custom renderer for this to reduce unnecessary overhead .
Thank you

Env:

  • PHP 8.1
  • CommonMark v2.3

My Godness, it was simply set to true to just perform this.

$config = [
	"default_attributes"=>[
		Video::class=>[
			"controls"=>true,
			"autoplay"=>true
		]
	]
];

Solved!