Download the PHP package gusvasconcelos/markdown-converter without Composer
On this page you can find all versions of the php package gusvasconcelos/markdown-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gusvasconcelos/markdown-converter
More information about gusvasconcelos/markdown-converter
Files in gusvasconcelos/markdown-converter
Package markdown-converter
Short Description A PHP library for generating structured content in Markdown format with support for various elements and customization options
License MIT
Informations about the package markdown-converter
PHP Markdown Converter
An elegant and fluent PHP library for generating structured Markdown content with support for all essential elements and advanced customization options.
โจ Features
- Fluent Interface: Chainable methods for intuitive document construction
- Complete Support: All essential Markdown elements supported
- Element Management: Easily manipulate, replace, and remove elements
- Extensible Architecture: Based on design patterns and SOLID principles
- Zero Dependencies: Independent and lightweight library
- PSR-4 Compatible: Standard autoloading
๐ฆ Installation
Install via Composer:
โก Requirements
- PHP 7.4 or higher
- Composer
๐ Basic Usage
Fluent Interface
All methods return the converter instance, allowing method chaining:
๐ Available Methods
Text Elements
heading(string $text, int $level = 1)
Creates a heading with the specified text and level (1-6).
paragraph(string $text)
Adds a paragraph with the specified text.
bold(string $text)
Adds bold text.
italic(string $text)
Adds italic text.
blockquote(string $text)
Adds a block quote.
Code Elements
code(string $code)
Adds inline code.
codeBlock(string $code, string $language = "")
Adds a code block with optional language. json // {"name":"John","age":30} //
Media Elements
image(string $url, string $altText, ?string $title = null)
Adds an image with URL, alternative text and optional title.
link(string $url, string $text, ?string $title = null)
Adds a link with URL, text and optional title.
List Elements
orderedList(array $items)
Adds an ordered list with the specified items.
unorderedList(array $items)
Adds an unordered list with the specified items.
Structural Elements
horizontalRule()
Adds a horizontal rule (divider).
emoji(string $emoji)
Adds an emoji to the content.
Output Methods
write(string $directory, string $filename)
Writes the markdown content to a file.
__toString()
Returns the markdown content as a string.
๐ง Element Management
The library provides advanced methods for manipulating individual elements:
Manipulation Methods
get(int $position)
Gets an element by position.
removeAt(int $position)
Removes an element by position.
replace(int $position, MarkdownSyntaxInterface $element)
Replaces an element at a specific position.
count()
Returns the total number of elements.
clear()
Removes all elements from the collection.
all()
Returns the complete collection of elements.
Practical Management Example
๐ก Use Cases
๐ Automated Reports
Create structured reports from system data:
๐ System Logs
Structure error and debug logs:
๐ง Email Templates
Generate content for transactional emails:
๐งช Testing
Run the test suite to ensure everything works correctly:
The library includes comprehensive tests covering:
- All Markdown syntax elements
- Element management operations
- File writing functionality
- Method chaining behavior
- Edge cases and error conditions
๐ License
This project is open-sourced under the MIT License - see the LICENSE file for details.
๐ค Contributing
Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.
Contributing Guidelines
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
composer test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and follow the existing code style.