I used @ianfun's good JavaScript's Markdown admonition syntax parser from Convertng Markdown admonition syntax to HTML, using Lua for Pandoc, but dl element within an admonition box interfered with other dl elements that are not part of the elements because of the CSS elements.
Based on @ianfun's code and on Koen Vendrik's CodePen Home JavaScript Markdown Parser, I worked three days to simplify enough my JavaScript, using regular expressions, and then I almost found the solution. See my Regex 101 library: https://regex101.com/r/ZPbJpf/1
But it worked only for HTML file, and not for Markdown file because Codebraid Preview writes every line as a paragraph.
Open VSCode;
Use the Codebraid Preview extension;
Create a
_codebraid_preview.yamland add:from: markdown standalone: falseCopy the whole text from my https://regex101.com/r/ZPbJpf/1.
Add
<script> </script>at the end of the Markdown file. Here is my code:window.onload = function() { const paragraphs = document.querySelectorAll('p'); paragraphs.forEach(paragraph => { paragraph.innerHTML = paragraph.innerHTML.replace(/^\s{0,3}!!! danger «([\s\S]*?)».*\n([\s\S]*?)^\s{0,3}!!!.*\n/gm, '<div class="admonition danger"><p class="admonition-title">$1</p>$2</div>\n\n') }) }You can test it by clicking the Codebraid Preview at the right of the status bar;
Check the Toggle Developer Tools by pressing Ctrl + Alt + I and select an element of the Markdown text to inspect it.