Skip to content

Instantly share code, notes, and snippets.

View kantoniak's full-sized avatar

kantoniak

View GitHub Profile
@kantoniak
kantoniak / FigureExtParsedown.class.php
Last active March 6, 2025 15:17
Parsedown extension to wrap single-image lines in <figure>, not <p>. Public domain. See https://github.com/erusev/parsedown/issues/180#issuecomment-451486639
<?php
class FigureExtParsedown extends Parsedown {
// Matches Markdown image definition
private $MarkdownImageRegex = "~^!\[.*?\]\(.*?\)$~";
public function __construct () {
// Add blockFigure to non-exclusive handlers for text starting with !
$this->BlockTypes['!'][] = 'Figure';