mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Add SlugRegister so IDs are not duplicated
This commit is contained in:
@@ -6,6 +6,7 @@ use Erusev\Parsedown\AST\Handler;
|
||||
use Erusev\Parsedown\AST\StateRenderable;
|
||||
use Erusev\Parsedown\Components\Block;
|
||||
use Erusev\Parsedown\Configurables\HeaderSlug;
|
||||
use Erusev\Parsedown\Configurables\SlugRegister;
|
||||
use Erusev\Parsedown\Configurables\StrictMode;
|
||||
use Erusev\Parsedown\Html\Renderables\Element;
|
||||
use Erusev\Parsedown\Parsedown;
|
||||
@@ -98,9 +99,10 @@ final class Header implements Block
|
||||
/** @return Element */
|
||||
function (State $State) {
|
||||
$HeaderSlug = $State->get(HeaderSlug::class);
|
||||
$Register = $State->get(SlugRegister::class);
|
||||
$attributes = (
|
||||
$HeaderSlug->isEnabled()
|
||||
? ['id' => $HeaderSlug->transform($this->text())]
|
||||
? ['id' => $HeaderSlug->transform($Register, $this->text())]
|
||||
: []
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user