TagHelperPack icon indicating copy to clipboard operation
TagHelperPack copied to clipboard

Add a markdown Tag Helper

Open DamianEdwards opened this issue 7 years ago • 3 comments

Add a Tag Helper that renders markdown. Features:

  • [x] Support element body as markdown content
  • [ ] Support pointing at a source markdown file (with caching)
  • ~~Cache the conversion with invalidation when the source changes (easy for body, slightly more difficult for source file but done already in the ScriptInliningTagHelper)~~ This turned out to be a bad idea for element body at least as it might be dynamic. User can wrap in <cache> if they want it cached. Will revisit when adding support for source markdown file.

Example:

<markdown>
    # This is Markdown
    Some source **markdown** to be rendered as *HTML*.
    1. This is great
    1. I know right!?
</markdown>

<markdown src="greeting.md" />

DamianEdwards avatar Jun 30 '17 00:06 DamianEdwards

I have a markdown tag helper I wrote that doesn't do the src thing, but it does allow sanitized inline HTML (via an allow-html attribute). It also supports a normalize-whitespace attribute to strip leading whitespace based on the first line of non-empty content. It's an adaption of https://github.com/RickStrahl/Westwind.AspNetCore.Markdown but with stronger HTML sanitization (it's been pentested by a security firm).

Let me know if you're interested.

haacked avatar Jul 09 '22 16:07 haacked

Take a look at the one in this library already and if you think it could benefit from improvements in yours then by all means send a PR!

DamianEdwards avatar Jul 09 '22 22:07 DamianEdwards

https://github.com/DamianEdwards/TagHelperPack/pull/46 Done!

haacked avatar Jul 10 '22 18:07 haacked