New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video Support #849
Comments
To do this you can extend the class and create a <?php
class Markdown extends \Parsedown{
public function __construct(){
$this->BlockTypes["{"] = array('Media');
$this->InlineTypes["{"] = array('Media');
}
protected function blockMedia($Line, $Block = null) {
if (preg_match('/^(\s*)\{(.+?)\}\((.+?)\)\((\S+?)\)$/', $Line['body'], $matches)){
$description = $matches[2];
$type = $matches[3];
$link = $matches[4];
$html = '';
if (strtolower($type) === 'video') {
$html .= '<video controls>';
} else {
$html .= '<audio controls>';
}
$html .= '<source src="' . htmlspecialchars($link) . '">';
if (strtolower($type) === 'video') {
$html .= '</video>';
} else {
$html .= '</audio>';
}
$html .= '<p>' . htmlspecialchars($description) . ' (' . htmlspecialchars($type) . ')</p>';
$Block = array(
'markup' => $html,
);
return $Block;
}
}
} Now to format video use this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal is to allow videos to be embedded just like images
In GitHub Markdown that works by having the link to a video surrounded by 2 empty lines. According to some blogs, in regular Markdown that's supposed to work exactly like with images, so like ![video title](video link). Now, perhaps Parsedown already has this, but if so then it doesn't work with .webm video files.
And just to clarify, when I talk about embedding I don't mean from sites like YouTube, but actual Video files
The text was updated successfully, but these errors were encountered: