Download the PHP package php-markdown/parser without Composer

On this page you can find all versions of the php package php-markdown/parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package parser

php-markdown

A lightweight, standalone PHP library (8.2–8.4) that parses CommonMark-flavored Markdown and converts it into clean, semantic HTML5. Zero runtime dependencies.

PHP PSR-12 No dependencies License


Requirements


Installation

Via Composer (recommended)

Manual (no Composer)

Copy the src/ directory into your project, then require the files in this order:


Try it — Docker Playground

No PHP installation required. From the project root:

Open http://localhost:8080 in your browser. See playground/README.md for full setup details, port-override instructions, and caveats.


Quick Start

Front Matter

parse() also accepts front matter — it strips the block silently, so existing code needs no changes.

GFM Tables

Raw HTML pass-through

Raw HTML is escaped by default (XSS-safe). Opt in to sanitized pass-through with allowRawHtml: true:

Options

All constructor arguments are optional and named:

A custom NormalizerInterface can also be passed as normalizer: (defaults to IcuNormalizer).


Supported Features

Block elements

Feature Syntax Output
Headings H1–H6 (ATX) # Heading … ###### Heading (empty content allowed: #) <h1> … <h6>
Headings H1–H2 (Setext) Heading\n=== / Heading\n--- (multiline content supported) <h1> / <h2>
Paragraph plain text (soft line breaks preserved as newlines) <p>
Blockquote (nested) > text <blockquote>
Unordered list - item / * item / + item <ul><li>
Ordered list 1. item / 1) item (start number kept: 3. item) <ol><li> / <ol start="3">
Nested lists indented - item inside list item <ul> inside <li>
Task list - [x] done / - [ ] todo <li><input type="checkbox" …>
Fenced code block lang … or~lang … ~|
`
Mermaid diagram mermaid … |
`
Indented code block 4-space / 1-tab indent <pre><code>
Horizontal rule --- / *** / ___ <hr />
GFM Table \| col \| col \| + separator row <table><thead><tbody> with align
Front Matter ---\nkey: value\n--- at file top parsed into meta array via parseWithMeta()
Raw HTML block <div>…</div> escaped (default) or sanitized (allowRawHtml: true)
Two-column layout :::columns … \|\|\| … ::: <div class="grid grid-cols-2 …">
Footnote definition [^label]: body rendered in <section class="footnotes">

Inline elements

Feature Syntax Output
Bold **text** or __text__ <strong>
Italic *text* or _text_ <em>
Strikethrough ~~text~~ <del>
Inline code `code` | <code>
Link (inline) [text](url) or [text](<url>), optional title in "…", '…' or (…) <a href="…">
Link (reference) [text][ref] with [ref]: url or [ref]: <url> definition <a href="…">
Image ![alt](src), ![alt](src "title") or ![alt][ref] <img src="…" alt="…" />
Autolink <https://…> or <[email protected]> <a href="…">
Hard line break two trailing spaces + newline <br />
HTML entity / numeric reference &copy;, &#42;, &#x2A; decoded to the character, then re-escaped
Backslash escape \*not emphasis\* literal punctuation
Raw HTML inline <span class="x"> escaped (default) or sanitized (allowRawHtml: true)
Footnote reference [^label] <sup><a href="#fn-…">

Architecture

The library is built as a three-stage pipeline. Each stage is independent and testable in isolation.

Class Responsibility
Lexer Tokenises the input line by line into Token[] (tabs expanded to 4-column stops, CommonMark §2.1)
InlineParser Recursive delimiter-stack scanner for inline elements
Parser Consumes Token[] and builds a DocumentNode AST
HtmlRenderer Traverses the AST and emits escaped HTML; void elements are self-closed (<br />, <hr />, <img … />) as in the CommonMark spec
HtmlSanitizer DOM-based sanitizer used when allowRawHtml: true
FrontMatterParser Extracts and parses the YAML-subset front matter block
IcuNormalizer NFC-normalizes input via PHP intl if available
MarkdownParser Public façade — wires all stages together

All AST nodes are immutable (readonly properties, PHP 8.2+).


Security

All user-supplied content is escaped via htmlspecialchars(ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') before being written to output. This covers:

Dangerous URL schemes (javascript:, vbscript:, data:) in links are detected at parse time and rendered as literal text rather than <a> elements.

Raw HTML is escaped by default. Passing allowRawHtml: true enables DOM-based sanitization via HtmlSanitizer:

Resource limits: input is limited to maxBytes (1 MiB by default). Short table rows are completed with empty cells up to 100,000 cells per document; past that, they stay short. Parse time stays roughly linear in input size on pathological input (tests/Security). Memory use is high at the limit: a 1 MiB document needed from about 100 MB to 800 MB in stress tests, depending on its content, so use a lower maxBytes with PHP's default memory_limit of 128 MB.


Testing


Benchmark

benchmark/ compares this library with league/commonmark, Parsedown and michelf/php-markdown on the same generated document (headings, emphasis, links, lists, fenced code, blockquote, table) in three sizes. It installs the library from the parent directory as a Composer path repository, so it measures your working copy.

Sample results (PHP 8.2.29, Windows x64, no OPcache/JIT, best time per parser over 6 runs), lower is better:

Document php-markdown/parser Parsedown michelf/php-markdown league/commonmark
small (1 KB, 1,000 runs) 0.57 ms 0.38 ms 0.45 ms 2.01 ms
medium (10 KB, 200 runs) 4.30 ms 4.75 ms 4.72 ms 14.47 ms
large (82 KB, 20 runs) 35.73 ms 32.61 ms 37.05 ms 117.58 ms

Timings vary by machine and between runs. On the small document, the order was the same in every run. On the medium and large documents, the three fastest parsers swapped places from run to run, so their differences there are within the noise. The memory column printed by the script is the memory_get_usage() delta across the loop, not peak usage, so it is not reported here.


Limitations

The following are not supported:


License

MIT © 2026


All versions of parser with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-ctype Version *
ext-intl Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-markdown/parser contains the following files

Loading the files please wait ...