PHPackages                             enegalan/easy-parser - 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. enegalan/easy-parser

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

enegalan/easy-parser
====================

All in one HTML and Markdown parser

v1.2(1y ago)010MITPHP

Since Mar 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/enegalan/easy-parser)[ Packagist](https://packagist.org/packages/enegalan/easy-parser)[ RSS](/packages/enegalan-easy-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

EasyParser - HTML and Markdown parser for PHP
=============================================

[](#easyparser---html-and-markdown-parser-for-php)

`EasyParser` is a PHP library designed to convert HTML content to markdown in a simple and efficient way. It uses [league/html-to-markdown](https://github.com/thephpleague/html-to-markdown) library for converting HTML to markdown and [erusev/parsedown](https://github.com/erusev/parsedown) for markdown to HTML, offering an ALL-IN-ONE library.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher.
- Composer to manage dependencies.

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

[](#installation)

To use `EasyParser`, first install the dependencies via Composer:

```
composer require enegalan/easy-parser
```

How to use it
-------------

[](#how-to-use-it)

`EasyParser` provides `convert` and all methods provided by `Parsedown`.

```
$parser = new EasyParser();
echo $parser->convert('Hello world'); // return "# Hello World"
```

```
$parser = new EasyParser();
echo $parser->text('# Hello world'); // return "Hello world"
```

The included `customs` directory contains custom EasyParser extended class examples.

Conversion options for `thephpleague/html-to-markdown`
------------------------------------------------------

[](#conversion-options-for-thephpleaguehtml-to-markdown)

Note

Conversion is fully adapted to EasyMDE output markdown with default formatting options. You can create a custom class that extends `EasyParser` and implement methods to adapt the conversion to your needs.

To strip HTML tags that don't have a Markdown equivalent while preserving the content inside them, set `strip_tags` to true, like this:

```
$options = array('strip_tags' => true);
$parser = new EasyParser($options);
echo $parser->convert('Turnips!'); // return "Turnips!"
```

Or more explicitly, like this:

```
$parser = new EasyParser();
$parser->converter->getConfig()->setOption('strip_tags', true);
echo $parser->convert('Turnips!'); // return "Turnips!"
```

Note that only the tags themselves are stripped, not the content they hold.

To strip tags and their content, pass a space-separated list of tags in `remove_nodes`, like this:

```
$options = array('remove_nodes' => 'span div');
$parser = new EasyParser($options);
echo $parser->convert('Turnips!Monkeys!'); // return ""
```

By default, all comments are stripped from the content. To preserve them, use the `preserve_comments` option, like this:

```
$options = array('preserve_comments' => true);
$parser = new EasyParser($options);
echo $parser->convert('Turnips!'); // return "Turnips!"
```

To preserve only specific comments, set `preserve_comments` with an array of strings, like this:

```
$options = array('preserve_comments' => array('Eggs!'));
$parser = new EasyParser($options);
echo $parser->convert('Turnips!'); // return "Turnips!"
```

By default, placeholder links are preserved. To strip the placeholder links, use the `strip_placeholder_links` option, like this:

```
$options = array('strip_placeholder_links' => true);
$parser = new EasyParser($options);
echo $parser->convert('Github'); // return "Github"
```

### Style options

[](#style-options)

By default bold tags are converted using the asterisk syntax, and italic tags are converted using the underlined syntax. Change these by using the `bold_style` and `italic_style` options.

```
$options = array(
    'italic_style' => '*',
    'bold_style' => '__',
);
$parser = new EasyParser($options);
echo $parser->convert('Italic and a bold'); // return "*Italic* and a __bold__"
```

### Line break options

[](#line-break-options)

By default, `br` tags are converted to two spaces followed by a newline character as per [traditional Markdown](https://daringfireball.net/projects/markdown/syntax#p). Set `hard_break` to `true` to omit the two spaces, as per GitHub Flavored Markdown (GFM).

```
$parser = new EasyParser();
$html = 'testline break';

$parser->converter->getConfig()->setOption('hard_break', true);
echo $parser->convert($html); // return "test\nline break"

$parser->converter->getConfig()->setOption('hard_break', false);
echo $parser->convert($html); // return "test  \nline break"
```

### Autolinking options

[](#autolinking-options)

By default, `a` tags are converted to the easiest possible link syntax, i.e. if no text or title is available, then the `` syntax will be used rather than the full `[url](url)` syntax. Set `use_autolinks` to `false` to change this behavior to always use the full link syntax.

```
$parser = new EasyParser();
$html = 'https://thephpleague.com';

$parser->converter->getConfig()->setOption('use_autolinks', true);
echo $parser->convert($html); // return ""

$parser->converter->getConfig()->setOption('use_autolinks', false);
echo $parser->convert($html); // return "[https://thephpleague.com](https://thephpleague.com)"
```

### Passing custom Environment object

[](#passing-custom-environment-object)

You can pass current Environment object to customize i.e. which converters should be used.

```
$environment = new Environment(array(
    // your configuration here
));
$environment->addConverter(new HeaderConverter()); // optionally - add converter manually
$options = array();
$parser = new EasyParser($options, $environment);
$html = 'Header

';
echo $parser->convert($html); // return "### Header" and ""
```

Limitations
-----------

[](#limitations)

Markdown Extra, MultiMarkdown and other variants aren't supported – just Markdown.

Style notes
-----------

[](#style-notes)

- Setext (underlined) headers are the default for H1 and H2. If you prefer the ATX style for H1 and H2 (# Header 1 and ## Header 2), set `header_style` to 'atx' in the options array when you instantiate the object:

```
$converter = new EasyParser(array('header_style'=>'atx'));
```

Headers of H3 priority and lower always use atx style.

- Links and images are referenced inline. Footnote references (where image src and anchor href attributes are listed in the footnotes) are not used.
- Blockquotes aren't line wrapped – it makes the converted Markdown easier to edit.

Dependencies
------------

[](#dependencies)

HTML To Markdown requires PHP's [xml](http://www.php.net/manual/en/xml.installation.php), [lib-xml](http://www.php.net/manual/en/libxml.installation.php), and [dom](http://www.php.net/manual/en/dom.installation.php) extensions, all of which are enabled by default on most distributions.

Errors such as "Fatal error: Class 'DOMDocument' not found" on distributions such as CentOS that disable PHP's xml extension can be resolved by installing php-xml.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance49

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~31 days

Total

3

Last Release

372d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a868b6d6225f867a4ccc1bef96eda2127133f35424f7497a1dd02be7ad6bb2cc?d=identicon)[enegalan](/maintainers/enegalan)

---

Top Contributors

[![enegalan](https://avatars.githubusercontent.com/u/114651369?v=4)](https://github.com/enegalan "enegalan (8 commits)")

---

Tags

parserhtmlmarkdown

### Embed Badge

![Health badge](/badges/enegalan-easy-parser/health.svg)

```
[![Health](https://phpackages.com/badges/enegalan-easy-parser/health.svg)](https://phpackages.com/packages/enegalan-easy-parser)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[erusev/parsedown-extra

An extension of Parsedown that adds support for Markdown Extra.

84314.8M192](/packages/erusev-parsedown-extra)[tovic/parsedown-extra-plugin

Configurable Markdown to HTML converter with Parsedown Extra.

5933.7k](/packages/tovic-parsedown-extra-plugin)[taufik-nurrohman/parsedown-extra-plugin

Configurable Markdown to HTML converter with Parsedown Extra.

5932.3k](/packages/taufik-nurrohman-parsedown-extra-plugin)[jbroadway/slimdown

A simple regex-based Markdown parser.

357.7k](/packages/jbroadway-slimdown)[benjaminhoegh/parsedown-toc

Table of Contents Extension for Parsedown.

2133.6k4](/packages/benjaminhoegh-parsedown-toc)

PHPackages © 2026

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