donatj / mddom
A Simple Markdown DOM
Fund package maintenance!
www.paypal.me/donatj/15
Ko Fi
donatj
Installs: 28 227
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 0
Open Issues: 3
Requires
- php: >=7.2
Requires (Dev)
- ext-dom: *
- ext-libxml: *
- corpus/coding-standard: ^0.6.0
- donatj/drop: ~1.0.0
- erusev/parsedown: ^1.7
- friendsofphp/php-cs-fixer: ^3.3
- phpunit/phpunit: ^8.5 | ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-11-01 07:09:40 UTC
README
A Simple Easy To Use Way to Generate Markdown Using a "DOM" Like Interface
Requirements
- php: >=7.2
Installing
Install the latest version with:
composer require 'donatj/mddom'
Example
<?php use donatj\MDDom; require __DIR__ . '/../vendor/autoload.php'; $doc = new MDDom\Document; $doc->appendChild(new MDDom\Header("Hello World!")); $doc->appendChild(new MDDom\Paragraph("This text is in a paragraph")); $doc->appendChild(new MDDom\Paragraph("This text is in a separate paragraph")); $sub = new MDDom\DocumentDepth; $doc->appendChild($sub); // Header Level, e.g. <h2> is determined by the depth. $sub->appendChild(new MDDom\Header("Sub-Header!")); $sub->appendChild(new MDDom\CodeBlock("echo 'Hello World';", 'php')); echo $doc->exportMarkdown();
Outputs:
# Hello World! This text is in a paragraph This text is in a separate paragraph ## Sub-Header! ```php echo 'Hello World'; ```