WP Manifestindependent plugin directory
manifest / social / wp-markdown-comments

WP Markdown Comments

Yet Another Markdown plugin for Wordpress, but this one is for comments.

by Znuff · github.com/znuff/wp-markdown-comments · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/znuff/wp-markdown-comments/archive/refs/heads/master.zip

A WordPress plugin that enables GitHub Flavored Markdown (GFM) support for comments, allowing commenters to write rich, formatted comments using Markdown syntax.

Features

  • GitHub Flavored Markdown (GFM) - Full support for GFM syntax including tables, strikethrough, and task lists
  • Live Preview - Real-time preview of formatted comments before submission
  • Markdown Toolbar - Quick-access buttons for common Markdown formatting
  • XSS Protection - Built-in sanitization using WordPress's wp_kses() function
  • Configurable - Admin settings to enable/disable features and control allowed HTML tags
  • Safe Mode - Parsedown safe mode enabled by default to prevent malicious code injection
  • Seamless Integration - Works with your existing WordPress theme

Installation

Manual Installation

  1. Download the plugin files
  2. Upload the wp-markdown-comments folder to /wp-content/plugins/ directory
  3. Activate the plugin through the 'Plugins' menu in WordPress
  4. Go to Settings → Markdown Comments to configure the plugin

Configuration

After activation, navigate to Settings → Markdown Comments in your WordPress admin panel:

  • Enable Markdown: Turn Markdown parsing on/off
  • Live Preview: Allow users to preview formatted comments
  • Show Toolbar: Display formatting toolbar above comment field
  • Allowed HTML Tags: Customize which HTML tags are allowed in rendered Markdown

Supported Markdown Syntax

Text Formatting

**bold text**
*italic text*
~~strikethrough~~
`inline code`

Links and Images

[Link text](https://example.com)
![Alt text](https://example.com/image.jpg)

Headings

# Heading 1
## Heading 2
### Heading 3

Lists

- Unordered list item
- Another item

1. Ordered list item
2. Another item

Blockquotes

> This is a quote
> Multiple lines

Code Blocks

```javascript
function hello() {
    console.log("Hello World");
}
```

Tables (GFM)

| Column 1 | Column 2 |
|----------|----------|
| Cell 1   | Cell 2   |
| Cell 3   | Cell 4   |

Horizontal Rules

---

Security

This plugin implements multiple layers of security:

  1. Parsedown Safe Mode: Escapes HTML in Markdown input
  2. WordPress Sanitization: All output is filtered through wp_kses() with configurable allowed tags
  3. Nonce Verification: AJAX requests are protected with WordPress nonces
  4. Input Validation: All user input is properly escaped and validated

Requirements

  • WordPress 5.0 or higher
  • PHP 7.0 or higher

Frequently Asked Questions

Does this work with my theme?

Yes, the plugin uses WordPress standard hooks and filters to integrate seamlessly with any properly coded WordPress theme.

Can I disable Markdown for specific posts?

Currently, the plugin applies to all posts where comments are enabled. Future versions may include per-post control.

What happens to existing comments?

Existing comments remain unchanged. Only new comments written after plugin activation will be parsed as Markdown. You can edit old comments to add Markdown formatting.

Is the Markdown stored in the database?

Yes, the original Markdown is stored in comment meta (_markdown_source), and it's converted to HTML when displayed. This allows you to disable the plugin without losing formatting.

Development

Plugin Structure

wp-markdown-comments/
├── wp-markdown-comments.php    # Main plugin file
├── includes/
│   ├── class-markdown-parser.php      # Markdown parsing logic
│   ├── class-comment-handler.php      # Comment hooks and filters
│   ├── class-admin-settings.php       # Admin settings page
│   └── class-frontend-assets.php      # CSS/JS enqueuing
├── assets/
│   ├── js/
│   │   └── markdown-comments.js       # Frontend JavaScript
│   └── css/
│       └── markdown-comments.css      # Styling
└── lib/
    ├── Parsedown.php                  # Parsedown library
    └── ParsedownExtra.php             # ParsedownExtra (GFM support)

Changelog

1.0.0

  • Initial release
  • GitHub Flavored Markdown support
  • Live preview functionality
  • Markdown toolbar
  • Admin settings page
  • XSS protection and sanitization

Credits

This plugin uses Parsedown v1.8.0 by Emanuil Rusev for Markdown parsing with GitHub Flavored Markdown (GFM) support.

License

GPL v2 or later

Support

For bug reports and feature requests, please visit [your-support-url].

Author

Your Name - [your-website-url]