PHPackages                             danhunsaker/markua - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. danhunsaker/markua

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

danhunsaker/markua
==================

Markdown parser for PHP based on the Markua spec

0202PHP

Since Sep 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/danhunsaker/markua)[ Packagist](https://packagist.org/packages/danhunsaker/markua)[ RSS](/packages/danhunsaker-markua/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Markua
======

[](#markua)

[![Build Status](https://camo.githubusercontent.com/649cd31506c8eb327f5fa816eceaaadacf0e058011b6c11c254cf5188fa265b5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e68756e73616b65722f6d61726b75612f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/danhunsaker/markua/build-status/master)[![Code Climate](https://camo.githubusercontent.com/782a888ac9956cf5e4946ef312fcb19bb7b14b9d127ae94540a961f5f98a417b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f64616e68756e73616b65722f6d61726b75612f6261646765732f6770612e737667)](https://codeclimate.com/github/danhunsaker/markua)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0956039eb7c3bc96c55b04708b30c2eadb58e9e9bd92ada9a133135362d7576e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e68756e73616b65722f6d61726b75612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/danhunsaker/markua/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/dc7cc5182b94726b6d4fe47523511156f68eec4602b69691a4d02a5c4ab6d29d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e68756e73616b65722f6d61726b75612f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/danhunsaker/markua/?branch=master)

**danhunsaker/markua** is a Markdown parser for PHP which intends to support the full [Markua](http://markua.org/) spec. The Markua spec is [still evolving](https://leanpub.com/markua/read).

Goals
-----

[](#goals)

This aims to fully support the Markua specification, and will continue to evolve as the spec does.

### League\\CommonMark

[](#leaguecommonmark)

This package depends on [League\\CommonMark](http://commonmark.thephpleague.com) and functions identically except for using the Markua specification.

Installation
------------

[](#installation)

This project can be installed via [Composer](https://getcomposer.org/):

```
$ composer require danhunsaker/markua
```

Basic Usage
-----------

[](#basic-usage)

The `MarkuaConverter` class provides a simple wrapper for converting Markua to HTML:

```
use Danhunsaker\Markua\MarkuaConverter;

$converter = new MarkuaConverter();
echo $converter->convertToHtml('# Hello World!');

// Hello World!
```

Advanced Usage &amp; Customization
----------------------------------

[](#advanced-usage--customization)

The actual conversion process requires two steps:

1. Parsing the Markdown input into an AST
2. Rendering the AST document as HTML

Although the `MarkuaConverter` wrapper simplifies this process for you, advanced users will likely want to do this themselves:

```
use League\CommonMark\DocParser;
use League\CommonMark\Environment;
use League\CommonMark\HtmlRenderer;
use Danhunsaker\Markua\Environment\Markua;

// Obtain a pre-configured Environment with all the Markua parsers/renderers ready-to-go
$environment = Environment::createEnvironment(new Markua());

// Optional: Add your own parsers/renderers here, if desired
// For example:  $environment->addInlineParser(new TwitterHandleParser());

// Create the document parser and HTML renderer engines
$parser = new DocParser($environment);
$htmlRenderer = new HtmlRenderer($environment);

// Here's our sample input
$markdown = '# Hello World!';

// 1. Parse the Markdown to AST
$documentAST = $parser->parse($markdown);

// Optional: If you want to access/modify the AST before rendering, do it here

// 2. Render the AST as HTML
echo $htmlRenderer->renderBlock($documentAST);

// The output should be:
// Hello World!
```

This approach allows you to access/modify the AST before rendering it.

You can also add custom parsers/renderers by [registering them with the `Environment` class](http://commonmark.thephpleague.com/customization/environment/). The [league/commonmark documentation](http://commonmark.thephpleague.com/) provides several [customization examples](http://commonmark.thephpleague.com/customization/overview/#examples) such as:

- [Parsing Twitter handles into profile links](http://commonmark.thephpleague.com/customization/inline-parsing#example-1---twitter-handles)
- [Converting smilies into emoticon images](http://commonmark.thephpleague.com/customization/inline-parsing#example-2---emoticons)

You can also reference the core CommonMark parsers/renderers as they use the same functionality available to you.

Compatibility with Markua
-------------------------

[](#compatibility-with-markua)

This project aims to fully support the entire [Markua Spec](https://leanpub.com/markua/read). Other flavors of Markdown may work but are not supported. Any/all changes made to the spec should eventually find their way back into this codebase.

This package is **not** part of Markua, but rather a compatible derivative.

Documentation
-------------

[](#documentation)

TODO.

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Stability and Versioning
------------------------

[](#stability-and-versioning)

While this package does work well, the underlying code should not be considered "stable" yet. The original spec may undergo changes in the near future, which will result in corresponding changes to this code. Any methods tagged with `@api` are not expected to change, but other methods/classes might.

Major release 1.0.0 will be reserved for when both Markua and this project are considered stable. 0.x.x will be used until that happens.

SemVer will be followed [closely](http://semver.org/).

Contributing
------------

[](#contributing)

If you encounter a bug in the spec, please report it to the [Markua](http://markua.org/) project. Any resulting fix will eventually be implemented in this project as well.

Please see [CONTRIBUTING](https://github.com/thephpleague/commonmark/blob/master/CONTRIBUTING.md) for additional details.

Credits &amp; Acknowledgements
------------------------------

[](#credits--acknowledgements)

- [Davey Shafik](https://github.com/dshafik)
- [Colin O'Dell](https://github.com/colinodell)
- [John MacFarlane](https://github.com/jgm)
- [All Contributors](https://github.com/danhunsaker/markua/contributors)

License
-------

[](#license)

**danhunsaker/markua** is licensed under the BSD-3 license. See the `LICENSE` file for more details.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1534396?v=4)[Hennik Hunsaker](/maintainers/danhunsaker)[@danhunsaker](https://github.com/danhunsaker)

---

Top Contributors

[![dshafik](https://avatars.githubusercontent.com/u/58074?v=4)](https://github.com/dshafik "dshafik (13 commits)")[![danhunsaker](https://avatars.githubusercontent.com/u/1534396?v=4)](https://github.com/danhunsaker "danhunsaker (1 commits)")[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (1 commits)")

### Embed Badge

![Health badge](/badges/danhunsaker-markua/health.svg)

```
[![Health](https://phpackages.com/badges/danhunsaker-markua/health.svg)](https://phpackages.com/packages/danhunsaker-markua)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M283](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M343](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
