Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 98 | | All time: 9,836 This week: 488 |
|
Description | | Author |
This package can compose and generate Markdown documents.
It provides a document class that can generate Markdown documents by adding different document elements like paragraphs, headings, lists, text formatted with styles, etc.
The package also provides a trait that can export the generated document to a file with a given path. The trait creates the directory of the output file path if it does not exist. Innovation Award
 August 2020
Winner
Prize: One official elePHPant Plush Mascott |
Markdown became a popular file format to represent documents that can be displayed in plain text format, or in HTML Web pages or other document formats.
This package provides a solution to compose documents in a programmatic way, so it can output the document content in Markdown format.
Manuel Lemos |
| |
 |
|
Innovation award
 Nominee: 4x
Winner: 1x |
|
Example
<?php
// Include Composer Autoloader.
require_once __DIR__ . '/../vendor/autoload.php';
use ABGEO\MDGenerator\Document;
use ABGEO\MDGenerator\Element;
$document = new Document();
$document
->addElement(Element::createHeading('Heading level 1'))
->addElement(Element::createHeading('Heading level 5', 6))
->addElement(Element::createParagraph('Paragraph 1'))
->addElement(Element::createParagraph('Paragraph 2'))
->addElement(
Element::concatenateElements(
'Paragraph',
Element::createBreak(),
'With Break.'
)
)
->addElement(Element::createBreak())
->addElement(Element::createBold('Bold Text'))
->addElement(Element::createItalic('Italic Text'))
->addElement(Element::createBoldAndItalic('Bold and Italic Text'))
->addElement(Element::createBlockquote('Blockquote 1'))
->addElement(Element::createBreak())
->addElement(Element::createBreak())
->addElement(
Element::createBlockquote('Multiline', 'Blockquote')
)
->addElement(Element::createBreak())
->addElement(Element::createBreak())
->addElement(
Element::createBlockquote(
'Multiline',
Element::createBlockquote('Nested'),
'Blockquote'
)
)
->addElement(Element::createBreak())
->addElement(Element::createList(['Unordered Item 1', 'Unordered Item 2']))
->addElement(Element::createBreak())
->addElement(
Element::createList(
['Ordered Item 1', 'Ordered Item 2'],
Element::LIST_ORDERED
)
)
->addElement(Element::createLine())
->addElement(Element::createLink('www.abgeo.dev', 'https://www.abgeo.dev'))
->addElement(
Element::createLink(
'Link with title',
'https://informatics.ge',
'Informatics.Ge'
)
)
->addElement(Element::createLine())
->addElement(
Element::createImage(
'https://informatics.ge/images/blue-robot-hi.png',
'Informatics.Ge',
'www.informatics.ge'
)
)
// Create link with image.
->addElement(
Element::createLink(
Element::createImage(
'https://abgeo.dev/img/favicon.png',
'ABGEOs Personal website'
),
'https://abgeo.dev'
)
);
// Export document to file.
$document->export2File(__DIR__ . '/generated/example.MD');
|
Details
gen-md
PHP Library for generating Markdown document



Installation
You can install this library with Composer:
-
`composer require abgeo/gen-md`
Usage
Include composer autoloader in your main file (Ex.: index.php)
-
`require_once __DIR__ . '/../vendor/autoload.php';`
Classes
The library has two classes:
-
`\ABGEO\MDGenerator\Document` - For generating Markdown Document;
-
`\ABGEO\MDGenerator\Element` - For generating Markdown element;
Class Document
Import ABGEO\MDGenerator\Document
class.
Public Methods
-
`addElement()` - Add element to Document content;
-
`clear()` -Clear Document content;
Note: See usage in example.php
Class Element
Import ABGEO\MDGenerator\Element
class.
Public Methods
-
`concatenateElements()` - Concatenate given elements;
-
`createHeading()` - Create heading element;
-
`createParagraph()` - Create Paragraph element;
-
`createBreak()` - Create Line Break element;
-
`createBold()` - Create Bold element;
-
`createItalic()` - Create Italic element;
-
`createBoldAndItalic()` - Create Bold and Italic element;
-
`createBlockquote()` - Create Blockquote element;
-
`createList()` - Create List element;
-
`createLine()` - Create Line element;
-
`createLink()` - Create Link element;
-
`createImage()` - Create Image element;
Note: See usage in example.php
Exporting
The ABGEO\MDGenerator\Document
class has export2File()
method that takes one argument
- File path for generated document.
Example
...
// Export document to file.
$document->export2File(__DIR__ . '/generated/example.MD');
...
Examples
See full example in example.php.
Authors
-
Temuri Takalandze - Initial work - ABGEO
License
This project is licensed under the MIT License - see the LICENSE file for details
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.