Multiple or custom replace tag
Closed this issue · 3 comments
Could we support either multiple replace tags like [toc]
so we can allow [toc]
, [[_TOC_]]
, {:toc}
etc.
For reference see: https://gitlab.com/gitlab-org/gitlab/-/issues/21901#note_280349199
Or a way to override the const TAG_TOC
so I can change it to my liking, in my case [[_TOC_]]
.
Do you mean a user-defined ToC
tag? Cool! Let's do it.
By chance, I was refactoring some in organize-test-suite branch and the below part might help us implement this. A getter
method to get the ToC
tag.
parsedown-extension_table-of-contents/Extension.php
Lines 45 to 53 in be69f9a
parsedown-extension_table-of-contents/Extension.php
Lines 206 to 218 in be69f9a
parsedown-extension_table-of-contents/Extension.php
Lines 220 to 236 in be69f9a
So, implementing the setter
method might satisfy our needs. Doesn't it?
As soon as I merge the organize-test-suite
branch, I will draft a PR for this request!
I believe there must be a smarter way to implement but I released v1.1.2 which implements your request. Thank you for the cool request!
Please update the plug-in and use the setTagToc('[[_TOC_]]')
method to set the ToC markdown tag you like. Hope this suits your needs! 🤞
<?php
require_once __DIR__ . '/vendor/autoload.php';
$text_markdown = file_get_contents('SAMPLE.md');
$Parsedown = new \ParsedownToC();
$Parsedown->setTagToc('[[_TOC_]]');
$html = $Parsedown->text($text_markdown);
echo $html . PHP_EOL;
These are the tests for the custom ToC tag
- test_vanilla_user_defined_toc_tag_style1.sh -> for
"[[TOC]]"
- test_vanilla_user_defined_toc_tag_style2.sh -> for
"{:toc}"
- test_vanilla_user_defined_toc_tag_style3.sh -> for
"[[_TOC_]]"