mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-15 06:30:26 +02:00
feat(#204): display videos in md
This commit is contained in:
+10
-4
@@ -141,19 +141,25 @@ function renderMD(md, baseUrl) {
|
|||||||
}
|
}
|
||||||
// call default renderer
|
// call default renderer
|
||||||
return rendererCode.call(this, code, lang, escaped);
|
return rendererCode.call(this, code, lang, escaped);
|
||||||
|
|
||||||
// return rendererCode(code, lang, escaped);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const rendererCodespan = renderer.codespan;
|
const rendererCodespan = renderer.codespan;
|
||||||
renderer.codespan = function (text) {
|
renderer.codespan = function (text) {
|
||||||
const math = mathsExpression(text);
|
const math = mathsExpression(text);
|
||||||
|
|
||||||
if (math) {
|
if (math) {
|
||||||
return math;
|
return math;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rendererCodespan(text);
|
return rendererCodespan.call(this, text);
|
||||||
|
};
|
||||||
|
|
||||||
|
const rendererLink = renderer.link;
|
||||||
|
renderer.link = function (href, title, text) {
|
||||||
|
// wrap videos links (mp4 and mov) with media https://github.blog/2021-05-13-video-uploads-available-github/
|
||||||
|
if (href.match(/\.mp4$|\.mov$/)) {
|
||||||
|
return `<div class="media"><video controls title="${title}" src="${href}">${text}</video></div>`;
|
||||||
|
}
|
||||||
|
return rendererLink.call(this, href, title, text);
|
||||||
};
|
};
|
||||||
return marked.parse(md, { baseUrl, renderer });
|
return marked.parse(md, { baseUrl, renderer });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user