diff --git a/public/index.html b/public/index.html index e1ac30a..4ef5024 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,8 @@ + + diff --git a/src/Common.css b/src/Common.css index 521bfea..ce10dd9 100644 --- a/src/Common.css +++ b/src/Common.css @@ -59,7 +59,7 @@ margin-left: .15rem; } -.ext-img { +.ext-img, .ext-video { max-width: 100%; max-height: 2000px; display: block; diff --git a/src/Common.js b/src/Common.js index 828407a..2730707 100644 --- a/src/Common.js +++ b/src/Common.js @@ -24,6 +24,15 @@ function escape_regex(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } +function is_video(s) { + try { + let url = new URL(s); + return url.pathname.endsWith('.mp4') || url.pathname.endsWith('.mov'); + } catch (e) { + return false; + } +} + export function build_highlight_re( txt, split = ' ', @@ -150,15 +159,20 @@ export class HighlightedMarkdown extends Component { /## ) : rule === 'url' ? ( - - {p} - - + <> + + {p} + + + {is_video(p) && ( +