From 1e80949cba60b4e2873a891e9b1f16c35fd21d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@blender.org> Date: Mon, 13 Feb 2023 16:10:24 +0100 Subject: [PATCH] Allow `<video>` in MarkDown As you can imagine, for the Blender development process it is rather nice to be able to include videos in issues, pull requests, etc. This PR allows the `<video>` HTML tag to be used in MarkDown, with the `src`, `autoplay`, and `controls` attributes. To have this fully functional, personally I feel the following things are still missing, and would appreciate some help from the Gitea team. Some CSS is needed, but I couldn't figure out which of the LESS files would work. I tried `web_src/less/markup/content.less` and `web_src/less/_base.less`, but after running `make` the changes weren't seen in the frontend. This I would consider a minimal set of CSS rules to be applied: ```css video { max-width: 100%; max-height: 100vh; } ``` It would be fantastic if Gitea could add some default attributes to the `<video>` tag. Basically `controls` should always be there, as there is no point in disallowing scrolling through videos, looping them, etc. Another thing that could be added, but probably should be done in a separate PR, is the integration with the attachments system. Dragging in a video should attach it, then generate the appropriate MarkDown/HTML. --- modules/markup/sanitizer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go index e59f6c7c8424b..600ccbf3c6126 100644 --- a/modules/markup/sanitizer.go +++ b/modules/markup/sanitizer.go @@ -132,6 +132,8 @@ func createDefaultPolicy() *bluemonday.Policy { policy.AllowAttrs(generalSafeAttrs...).OnElements(generalSafeElements...) + policy.AllowAttrs("src", "autoplay", "controls").OnElements("video") + policy.AllowAttrs("itemscope", "itemtype").OnElements("div") // FIXME: Need to handle longdesc in img but there is no easy way to do it