showdown icon indicating copy to clipboard operation
showdown copied to clipboard

Expose blockTags in subParser 'hashHTMLBlock'

Open TheBorgel opened this issue 4 years ago • 2 comments

I am trying to force showdown to ignore my custom HTML tags for my text editor. The block tags is a list of tags that will be ignored during parsing, and adding my custom tag names to this list achieves the desired result: i.e. the text inside the tags are not parsed.

For now I achieved my desired result by adding a div tag around my custom tags like so:

type: 'lang',
regex: /<TagName(.*?)<\/TagName>/gs,
replace: '<div><TagName$1<\/TagName></div>'

TheBorgel avatar Nov 08 '21 20:11 TheBorgel

In a way, the innards of hashHTMLBlock subparser is already exposed.

You can hook to the event makehtml.hashHTMLBlocks.before with a listener extension and replicate the functionality of the HashHTMLBlock parser yourself.

tivie avatar Feb 21 '22 19:02 tivie

True, but I would say that the extra effort for the user and the untidy end result is a bit unnecessary.

Would there not be a fairly common use case for being able to add or remove tags from the list to let the user customize the parser in a clean way?

TheBorgel avatar Feb 21 '22 20:02 TheBorgel