Skip to content

manualdousuario/markdown-comments-for-wordpress

 
 

Repository files navigation

Markdown Comments for WordPress®

Allow users to write comments in Markdown format and automatically convert them into safe, semantic HTML on the frontend.

WordPress Version PHP Version License

Features

  • Enables Markdown formatting in WordPress comments
  • Parses common syntax: **bold**, *italic*, `code`, [links](url), headings, and lists
  • Clean, minimal, and secure output
  • Adds optional help text under the comment box
  • Admin setting to enable/disable Markdown support

How It Works

Once activated, the plugin:

  1. Adds a checkbox setting under Settings → Discussion to enable/disable Markdown comments.
  2. Displays a small hint below the comment textarea so users know they can use Markdown.
  3. Parses comment content using a custom Markdown parser before rendering.
  4. Strips conflicting WordPress formatting like wpautop and wptexturize.
  5. Outputs safe, sanitized HTML using wp_kses_post().

Installation

  1. Upload the plugin to your /wp-content/plugins/ directory or install via the Plugins screen.
  2. Activate the plugin.
  3. Visit Settings -> Discussion and check "Enable Markdown for Comments".

Supported Markdown Syntax

Syntax Example Output
Bold **bold** or __bold__ bold
Italic *italic* or _italic_ italic
Inline Code `code` code
Links [text](https://example.com) text
Headings # H1, ## H2, ... <h1>, <h2>, ...
Unordered Lists - Item / * Item / + Item <ul><li>Item</li></ul>
Ordered Lists 1. First 2. Second <ol><li>...</li></ol>
Paragraphs Line breaks Proper <p> tags

Security & Performance

  • Uses esc_html() and wp_kses_post() to sanitize all output.
  • Does not load external libraries — no JavaScript Markdown libraries, no front-end dependencies.
  • Lightweight and fast — designed to work out of the box on most WordPress sites.

Developer Notes

  • You can customize the comment formatting logic by editing markdown_comments_parse_markdown() and markdown_comments_apply_inline_formatting().
  • The plugin does not allow raw HTML input in comments, keeping comment sections secure and clean.
  • For advanced Markdown needs (e.g., tables, blockquotes), consider integrating a full Markdown parser (e.g., Parsedown) - but this plugin intentionally keeps it minimal for performance and security.

Plugin Details

Key Value
Plugin Name Markdown Comments for WordPress®
Version 1.0.0
Author Robert DeVore
License GPL-2.0 or later
Plugin URI GitHub Repo
Requires PHP 7.4+
Requires WP 5.5+

FAQ

Q: Can users still use HTML in comments?
A: Only safe HTML output generated by Markdown is allowed. Raw HTML input is stripped for security.

Q: Does this support replies or threaded comments?
A: Yes. It works with any comment — top-level or nested.

Q: Will this affect existing comments?
A: Only if Markdown is enabled — and only when those comments are rendered. It doesn’t permanently alter comment data in the database.

Roadmap

  • Add support for blockquotes (>)
  • Toggle for displaying Markdown helper hint
  • Extendable filters/hooks for developers

Contributing

Pull requests and suggestions welcome! Feel free to fork the repo and submit improvements. For issues, use the GitHub issue tracker.

LICENSE

Markdown Comments for WordPress® is licensed under the GPL 2.0 or later.


About

Allow users to write comments in Markdown format and automatically parse them into HTML.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 96.0%
  • JavaScript 3.3%
  • CSS 0.7%