PHP code example of gusvasconcelos / markdown-converter
1. Go to this page and download the library: Download gusvasconcelos/markdown-converter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gusvasconcelos / markdown-converter example snippets
use GusVasconcelos\MarkdownConverter\MarkdownConverter;
// Initialize the converter
$converter = new MarkdownConverter();
// Create markdown content
$converter
->heading('API Request Log')
->paragraph('Request ID: 1234567890')
->horizontalRule()
->codeBlock('{"name":"John","age":30,"email":"[email protected]"}', "json")
->link('https://api.example.com', 'API Documentation')
->write(__DIR__, "example"); // Writes to example.md file
$document = (new MarkdownConverter())
->heading('System Log', 2)
->paragraph('Timestamp: ' . date('Y-m-d H:i:s'))
->horizontalRule()
->codeBlock($errorDetails, 'php')
->bold('Status: ')
->code('ERROR')
->paragraph('')
->blockquote('This is an important system message')
->link('https://support.example.com', 'Get Support')
->write(__DIR__, "system-log");
$converter->heading('Main Title'); // # Main Title
$converter->heading('Subtitle', 2); // ## Subtitle
$converter->paragraph('This is an example paragraph.');
// This is an example paragraph.
use GusVasconcelos\MarkdownConverter\Syntax\BoldSyntax;
$converter->heading('Title')->paragraph('Text');
$converter->replace(1, new BoldSyntax('Bold Text')); // Replaces the paragraph
$document = new MarkdownConverter();
// Build document
$document
->heading('Sales Report')
->paragraph('First quarter data')
->codeBlock('// Example code', 'php')
->paragraph('Detailed analysis');
// Check number of elements
echo "Total elements: " . $document->count(); // 4
// Replace code with a list
use GusVasconcelos\MarkdownConverter\Syntax\UnorderedListSyntax;
$list = new UnorderedListSyntax(['Sales: 100k', 'Profit: 25k', 'Customers: 500']);
$document->replace(2, $list);
// Remove last paragraph
$document->removeAt(3);
// Get final result
$finalContent = (string) $document;
$emailTemplate = new MarkdownConverter();
$emailTemplate
->heading('Welcome to our platform!', 1)
->emoji('🎉')
->paragraph('Hello John, we\'re happy to have you with us!')
->heading('Next Steps', 2)
->orderedList([
'Complete your profile',
'Explore our features',
'Contact us if you need help'
])
->horizontalRule()
->paragraph('Need help?')
->link('https://support.example.com', 'Help Center')
->paragraph('')
->italic('Example Team');
// Convert to HTML via Markdown parser
$htmlContent = $markdownParser->parse((string) $emailTemplate);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.