php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Feature request: Disable certain markdown elements from rendering

Open robbieaverill opened this issue 9 years ago • 5 comments

Hi,

It may be useful in some applications to be able to disable certain types of markdown elements from being rendered, for example I might not want headings to be rendered in a "content block", preferring them to have their own type of content block instead.

I've covered this in my fork - would like some feedback before creating a pull request for it. It may be something specific to me that I can implement in my business logic instead. Commit: 5679ee8b3b199f1a86ba2d81e7a9725581b8cb98

Cheers, Robbie

robbieaverill avatar Feb 23 '16 04:02 robbieaverill

Disabling heading and other types of content makes sense. But I'm not sure it's a good idea to make an API that would depend on the internal function names like you are doing in your fork. Those might change, and some functions in the block gamut will cause weird things to happen if not called: paragraphs, but also code blocks in Markdown Extra where the HTML block parser has its own code block detecting logic that expects code blocks to be processed later.

michelf avatar Feb 23 '16 19:02 michelf

Yes I had the same thought regarding naming. Would probably need to define a transition list somewhere, but I wanted to avoid repetition as much as possible.

On Wednesday, 24 February 2016, Michel Fortin [email protected] wrote:

Disabling heading and other types of content makes sense. But I'm not sure it's a good idea to make an API that would depend on the internal function names like you are doing in your fork. Those might change, and some functions in the block gamut will cause weird things to happen if not called: paragraphs, but also code blocks in Markdown Extra where the HTML block parser has its own code block detecting logic that expects code blocks to be processed later.

— Reply to this email directly or view it on GitHub https://github.com/michelf/php-markdown/issues/228#issuecomment-187867097 .

Robbie Averill LA PETITE MANOUCHE - NZ Gypsy Jazz Guitar Duo Phone: +64 27 321 4758 [email protected] www.lapetitemanouche.com

robbieaverill avatar Feb 23 '16 20:02 robbieaverill

I can see why someone would want to disallow headers, but I can't really see a reason to disallow code blocks, blockquotes and lists. Maybe we only need a configuration variable for headers.

michelf avatar Feb 25 '16 23:02 michelf

Would be a simpler application- I just figured it should be generic. I'll adjust and pull request it since it's all I need right now anyway!

robbieaverill avatar Feb 26 '16 00:02 robbieaverill

I'd also like to disable headers, is it possible to also define the level to be disabled? (for example only disable the titles of level 1 and 2)

edhelas avatar May 23 '17 06:05 edhelas