Search by

mj-zana / view-markdown

mjnable

Safe Markdown rendering for mj-zana/view, on league/commonmark

Package info

github.com/mjnable/zana-view-markdown

pkg:composer/mj-zana/view-markdown

Statistics

Installs: 21

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.5.0 2026-10-26 14:55 UTC

This package is auto-updated.

Last update: 2026-10-27 16:30:09 UTC


README

Safe Markdown for mj-zana/view, on league/commonmark.

composer require mj-zana/view-markdown

Register MarkdownServiceProvider after ViewServiceProvider. Templates then print editors' Markdown with <?= $this->markdown($post->body) ?> (Twig: {{ markdown(post.body) }}).

  • Raw HTML is escaped, never passed through, so editors cannot inject scripts.
  • Unsafe links are removed: javascript:, vbscript:, file:, and data: other than images.
  • Headings get ids for links to sections (view.markdown.heading_anchors).
  • GitHub-flavoured Markdown: tables, strikethrough, task lists and autolinks.
  • Rendering costs time: store the HTML with the content when it is saved, through MarkdownRendererInterface, instead of rendering on every request.

License

MIT