From 4919bf6835cb950fc918743495ac7a1375f2e7db Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 18 Jul 2020 18:17:26 +0000 Subject: [PATCH 1/9] creates and implements generic markup less class --- templates/repo/settings/lfs_file.tmpl | 2 +- templates/repo/view_file.tmpl | 2 +- web_src/less/{_markdown.less => _markup.less} | 6 +++--- web_src/less/index.less | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) rename web_src/less/{_markdown.less => _markup.less} (99%) diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl index 09eeb3f27fe88..7036d9c10a6cc 100644 --- a/templates/repo/settings/lfs_file.tmpl +++ b/templates/repo/settings/lfs_file.tmpl @@ -12,7 +12,7 @@
-
+
{{if .IsMarkup}} {{if .FileContent}}{{.FileContent | Safe}}{{end}} {{else if .IsRenderedHTML}} diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 889cb5a691d0d..d7fbdf2bb7275 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -64,7 +64,7 @@ {{end}}
-
+
{{if .IsMarkup}} {{if .FileContent}}{{.FileContent | Safe}}{{end}} {{else if .IsRenderedHTML}} diff --git a/web_src/less/_markdown.less b/web_src/less/_markup.less similarity index 99% rename from web_src/less/_markdown.less rename to web_src/less/_markup.less index 09c94f0678af5..b189dbbdf8af2 100644 --- a/web_src/less/_markdown.less +++ b/web_src/less/_markup.less @@ -1,4 +1,4 @@ -.markdown:not(code) { +.markup:not(code) { overflow: hidden; font-size: 16px; line-height: 1.6 !important; @@ -513,7 +513,7 @@ } } -.markdown-block-error { +.markup-block-error { margin-bottom: 0 !important; border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important; @@ -524,7 +524,7 @@ text-align: left !important; } -.markdown-block-error + pre { +.markup-block-error + pre { border-top: none !important; margin-top: 0 !important; border-top-left-radius: 0 !important; diff --git a/web_src/less/index.less b/web_src/less/index.less index f1ac49a5136b9..967968537ab7d 100644 --- a/web_src/less/index.less +++ b/web_src/less/index.less @@ -17,6 +17,7 @@ @import "_tribute"; @import "_font_i18n"; @import "_base"; +@import "_markup"; @import "_markdown"; @import "_home"; @import "_install"; From b5d5537e5d5bcda75bd1ffc186a6257d37bbbf20 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 18 Jul 2020 23:05:37 +0000 Subject: [PATCH 2/9] How to give custom CSS to externally rendered html --- .../doc/advanced/external-renderers.en-us.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/docs/content/doc/advanced/external-renderers.en-us.md b/docs/content/doc/advanced/external-renderers.en-us.md index 11e7f73ae9b7f..1f2661202fce2 100644 --- a/docs/content/doc/advanced/external-renderers.en-us.md +++ b/docs/content/doc/advanced/external-renderers.en-us.md @@ -98,3 +98,71 @@ Once your configuration changes have been made, restart Gitea to have changes ta **Note**: Prior to Gitea 1.12 there was a single `markup.sanitiser` section with keys that were redefined for multiple rules, however, there were significant problems with this method of configuration necessitating configuration through multiple sections. + +## Customising CSS +The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. You can use these classes to specifically target the contents of your rendered HTML. + +And so you could write some Less: +```less +.markup.XXXXX { + + html { + font-size: 100%; + overflow-y: scroll; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + } + + body { + color: #444; + font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif; + font-size: 12px; + line-height: 1.7; + padding: 1em; + margin: auto; + max-width: 42em; + background: #fefefe; + } + + p { + color: orangered; + } +} +``` +which is equivalent to: +```css +.markup.XXXXX html { + font-size: 100%; + overflow-y: scroll; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +.markup.XXXXX body { + color: #444; + font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif; + font-size: 12px; + line-height: 1.7; + padding: 1em; + margin: auto; + max-width: 42em; + background: #fefefe; +} + +.markup.XXXXX p { + color: orangered; +} +``` +Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.less` or `custom/public/css/my-style-XXXXX.css` + +Then to import it, add it to the custom header or footer. `custom/templates/custom/header.tmpl` +```html + + +``` + +or if using pure CSS + +```html + +``` \ No newline at end of file From 273f6b0639a31ec0f368630b7743a00ec4b013a1 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 18 Jul 2020 23:13:21 +0000 Subject: [PATCH 3/9] Clarifies sources of CSS styling of markup --- docs/content/doc/advanced/external-renderers.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/advanced/external-renderers.en-us.md b/docs/content/doc/advanced/external-renderers.en-us.md index 1f2661202fce2..d531e8755a9b1 100644 --- a/docs/content/doc/advanced/external-renderers.en-us.md +++ b/docs/content/doc/advanced/external-renderers.en-us.md @@ -100,7 +100,7 @@ Once your configuration changes have been made, restart Gitea to have changes ta there were significant problems with this method of configuration necessitating configuration through multiple sections. ## Customising CSS -The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. You can use these classes to specifically target the contents of your rendered HTML. +The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX`==`markdown`). Otherwise can use these classes to specifically target the contents of your rendered HTML. And so you could write some Less: ```less From 5794c70f7f14e6772d968447ea68f8190c07b68c Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 18 Jul 2020 23:14:47 +0000 Subject: [PATCH 4/9] further clarification of sources of markup styling --- docs/content/doc/advanced/external-renderers.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/advanced/external-renderers.en-us.md b/docs/content/doc/advanced/external-renderers.en-us.md index d531e8755a9b1..3d87c75f929f3 100644 --- a/docs/content/doc/advanced/external-renderers.en-us.md +++ b/docs/content/doc/advanced/external-renderers.en-us.md @@ -100,7 +100,7 @@ Once your configuration changes have been made, restart Gitea to have changes ta there were significant problems with this method of configuration necessitating configuration through multiple sections. ## Customising CSS -The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX`==`markdown`). Otherwise can use these classes to specifically target the contents of your rendered HTML. +The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML. And so you could write some Less: ```less From 67b494de587640430c71e861d2eb238f09303ceb Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 19 Nov 2020 15:18:04 +0000 Subject: [PATCH 5/9] rename _markdown to _markup --- web_src/less/_markup.less | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/web_src/less/_markup.less b/web_src/less/_markup.less index b189dbbdf8af2..54189979b871f 100644 --- a/web_src/less/_markup.less +++ b/web_src/less/_markup.less @@ -473,6 +473,34 @@ box-shadow: inset 0 -1px 0 var(--color-secondary); } +<<<<<<< HEAD +======= + .csv-data td, + .csv-data th { + padding: 5px; + overflow: hidden; + font-size: 12px; + line-height: 1; + text-align: left; + white-space: nowrap; + } + + .csv-data .blob-num { + padding: 10px 8px 9px; + text-align: right; + border: 0; + } + + .csv-data tr { + border-top: 0; + } + + .csv-data th { + font-weight: 600; + border-top: 0; + } + +>>>>>>> e38bfb88d... rename _markdown to _markup .ui.list .list, ol.ui.list ol, ul.ui.list ul { From e6f256ceb461e2ca9d19902eb29b391b3e52db53 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 19 Nov 2020 15:43:28 +0000 Subject: [PATCH 6/9] remove defunct import --- web_src/less/index.less | 1 - 1 file changed, 1 deletion(-) diff --git a/web_src/less/index.less b/web_src/less/index.less index 967968537ab7d..8702c40fe6ee7 100644 --- a/web_src/less/index.less +++ b/web_src/less/index.less @@ -18,7 +18,6 @@ @import "_font_i18n"; @import "_base"; @import "_markup"; -@import "_markdown"; @import "_home"; @import "_install"; @import "_form"; From 82936c5e0422ef65c7051dff897ad1b54b3d6fc6 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 17 Apr 2021 13:44:42 +0100 Subject: [PATCH 7/9] fix orphaned reference --- web_src/js/markdown/mermaid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/markdown/mermaid.js b/web_src/js/markdown/mermaid.js index a518bc73451c7..d0aefd1aff978 100644 --- a/web_src/js/markdown/mermaid.js +++ b/web_src/js/markdown/mermaid.js @@ -3,7 +3,7 @@ const MAX_SOURCE_CHARACTERS = 5000; function displayError(el, err) { el.closest('pre').classList.remove('is-loading'); const errorNode = document.createElement('div'); - errorNode.setAttribute('class', 'ui message error markdown-block-error mono'); + errorNode.setAttribute('class', 'ui message error markup-block-error mono'); errorNode.textContent = err.str || err.message || String(err); el.closest('pre').before(errorNode); } From 66d633739b28e9b0f17512402e2ef9349c684917 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 17 Apr 2021 13:50:29 +0100 Subject: [PATCH 8/9] remove comments --- web_src/less/_markup.less | 3 --- 1 file changed, 3 deletions(-) diff --git a/web_src/less/_markup.less b/web_src/less/_markup.less index 54189979b871f..e5f3613957e9b 100644 --- a/web_src/less/_markup.less +++ b/web_src/less/_markup.less @@ -473,8 +473,6 @@ box-shadow: inset 0 -1px 0 var(--color-secondary); } -<<<<<<< HEAD -======= .csv-data td, .csv-data th { padding: 5px; @@ -500,7 +498,6 @@ border-top: 0; } ->>>>>>> e38bfb88d... rename _markdown to _markup .ui.list .list, ol.ui.list ol, ul.ui.list ul { From 29a2f09770090b62b391dcdcc85d2ff0c1522b3e Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Sat, 17 Apr 2021 21:15:46 +0100 Subject: [PATCH 9/9] fix header navigation --- web_src/js/markdown/anchors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/markdown/anchors.js b/web_src/js/markdown/anchors.js index 62bf8c83c37d7..62561fe2504d8 100644 --- a/web_src/js/markdown/anchors.js +++ b/web_src/js/markdown/anchors.js @@ -16,7 +16,7 @@ function scrollToAnchor() { } export default function initMarkdownAnchors() { - if (!document.querySelector('.markdown')) return; + if (!document.querySelector('.markup')) return; for (const heading of document.querySelectorAll(headingSelector)) { const originalId = heading.id.replace(/^user-content-/, '');