Juan Camacho - 2023-08-16 05:30:06 -
In reply to message 1 from Martin Price
Hi Martin,
Here's how you can add CSS to the page to achieve a GitHub-like look:
1. Include GitHub Markdown CSS:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css">
2. Wrap the generated HTML output from MarkDownify in a <div> element with the class markdown-body. This class is defined in the GitHub Markdown CSS and applies the styling consistent with GitHub's Markdown rendering.
// Markdown content
$text = "# Hello, MarkDownify!\n\nThis is **bold** and *italic* text.";
// Create a new instance of MarkDownify
$parser = new MarkDownify($text);
// Parse Markdown into HTML
$html = $parser ->parse();
echo '<div class="markdown-body">' . $html . '</div>';