aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren2023-03-01 22:30:51 +0100
committerGitHub2023-03-01 16:30:51 -0500
commitde6c718b46ebd3b7f6362c766eed328044d95ec7 (patch)
tree3f8a28f3b97cdb5b32646c816d453d3b88a548ce
parent545495dcb0a4cb9d820132dde4f1127f7fe91aa4 (diff)
Allow `<video>` in MarkDown (#22892)
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. ## Help Needed To have this fully functional, personally I feel the following things are still missing, and would appreciate some help from the Gitea team. ### Styling 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; } ``` ### Default Attributes 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. ### Integration with the attachments system 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.
-rw-r--r--modules/markup/sanitizer.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go
index e59f6c7c8..600ccbf3c 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