diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go index 59cde61a68..21feefa301 100644 --- a/modules/markup/sanitizer.go +++ b/modules/markup/sanitizer.go @@ -87,6 +87,9 @@ func createDefaultPolicy() *bluemonday.Policy { // Allow classes for task lists policy.AllowAttrs("class").Matching(regexp.MustCompile(`task-list-item`)).OnElements("li") + // Allow classes for org mode list item status. + policy.AllowAttrs("class").Matching(regexp.MustCompile(`^(unchecked|checked|indeterminate)$`)).OnElements("li") + // Allow icons policy.AllowAttrs("class").Matching(regexp.MustCompile(`^icon(\s+[\p{L}\p{N}_-]+)+$`)).OnElements("i") diff --git a/modules/markup/sanitizer_test.go b/modules/markup/sanitizer_test.go index 0c22ce3ba0..6e17c1bbc6 100644 --- a/modules/markup/sanitizer_test.go +++ b/modules/markup/sanitizer_test.go @@ -53,6 +53,11 @@ func Test_Sanitizer(t *testing.T) { `
Hello World
`, `Hello World
`, `Hello World
`, `Hello World
`,
+ // Org mode status of list items.
+ ``, ``,
+ ``, ``,
+ ``, ``,
+
// URLs
`[my custom URL scheme](cbthunderlink://somebase64string)`, `[my custom URL scheme](cbthunderlink://somebase64string)`,
`[my custom URL scheme](matrix:roomid/psumPMeAfzgAeQpXMG:feneas.org?action=join)`, `[my custom URL scheme](matrix:roomid/psumPMeAfzgAeQpXMG:feneas.org?action=join)`,
diff --git a/web_src/css/markup/content.css b/web_src/css/markup/content.css
index 2a645e522a..eebec3d6b7 100644
--- a/web_src/css/markup/content.css
+++ b/web_src/css/markup/content.css
@@ -556,3 +556,26 @@
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
+
+.file-view.markup.orgmode li.unchecked::before {
+ content: '[ ] ';
+}
+
+.file-view.markup.orgmode li.checked::before {
+ content: '[x] ';
+}
+
+.file-view.markup.orgmode li.indeterminate::before {
+ content: '[-] ';
+}
+
+/* This is only needed for because they are literally acting as paragraphs, + * and thus having an ::before on the same line would force the paragraph to + * move to the next line. This can be avoided by an inline-block display that + * avoids that property while still having the other properties of the block + * display. */ +.file-view.markup.orgmode li.unchecked > p, +.file-view.markup.orgmode li.checked > p, +.file-view.markup.orgmode li.indeterminate > p { + display: inline-block; +}