2025-11-12 21:02:39 +01:00
2025-11-12 19:28:52 +01:00
2025-11-12 19:28:48 +01:00
2025-11-12 19:26:14 +01:00
2025-11-12 19:27:59 +01:00
2025-11-12 19:27:55 +01:00
2025-11-12 21:02:39 +01:00

m2h

A lightweight, pure Perl markdown to HTML converter that uses a state machine for parsing.

Features

  • Pure Perl implementation - no external dependencies
  • State machine-based parsing for efficient and maintainable code
  • Converts standard markdown syntax to HTML
  • Secure HTML output, especially against XSS or file protocols
  • Fast and lightweight

Requirements

  • Perl 5.42 or higher

Installation

No installation required. Simply download the script and make it executable:

chmod +x m2h.pl

Usage

Basic Usage

Convert a markdown file to HTML:

perl -Ilibm2h.pl input.md > output.html

Or read from stdin:

cat input.md | perl -Ilib m2h.pl > output.html

Command Line Options

m2h [options] [file]

Options:
    -h, --help      Show this help message
    -v, --version   Show version information
    -o, --output    Specify output file (default: stdout)

Install the script using:

make install

Run the test suite using:

make test

Supported Markdown Features

  • Headers (H1-H6)
  • Paragraphs
  • Bold and italic text
  • Links
  • Images
  • Lists (ordered and unordered)
  • Code blocks and inline code
  • Blockquotes
  • Horizontal rules
  • Tables

How It Works

m2h uses a state machine to parse markdown text. The parser transitions between different states (e.g., paragraph, code block, list) based on the input it encounters, allowing for efficient and accurate parsing of markdown syntax.

Example

Input (markdown)

# Hello World

This is a **bold** and _italic_ example.

- Item 1
- Item 2
- Item 3

Output (HTML)

<h1>Hello World</h1>
<p>This is a <strong>bold</strong> and <em>italic</em> example.</p>
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

License

MIT License, see LICENSE for details.

Description
Simple markdown to HTML converter
Readme MIT 52 KiB
Languages
Perl 97.5%
Makefile 2.5%