TagHelperPack
TagHelperPack copied to clipboard
Add a markdown Tag Helper
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" />
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.
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!
https://github.com/DamianEdwards/TagHelperPack/pull/46 Done!