Skip to content

Commit b5d5537

Browse files
committed
How to give custom CSS to externally rendered html
1 parent 4919bf6 commit b5d5537

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,71 @@ Once your configuration changes have been made, restart Gitea to have changes ta
9898

9999
**Note**: Prior to Gitea 1.12 there was a single `markup.sanitiser` section with keys that were redefined for multiple rules, however,
100100
there were significant problems with this method of configuration necessitating configuration through multiple sections.
101+
102+
## Customising CSS
103+
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 `<div>` with classes `markup` and `XXXXX`. You can use these classes to specifically target the contents of your rendered HTML.
104+
105+
And so you could write some Less:
106+
```less
107+
.markup.XXXXX {
108+
109+
html {
110+
font-size: 100%;
111+
overflow-y: scroll;
112+
-webkit-text-size-adjust: 100%;
113+
-ms-text-size-adjust: 100%;
114+
}
115+
116+
body {
117+
color: #444;
118+
font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
119+
font-size: 12px;
120+
line-height: 1.7;
121+
padding: 1em;
122+
margin: auto;
123+
max-width: 42em;
124+
background: #fefefe;
125+
}
126+
127+
p {
128+
color: orangered;
129+
}
130+
}
131+
```
132+
which is equivalent to:
133+
```css
134+
.markup.XXXXX html {
135+
font-size: 100%;
136+
overflow-y: scroll;
137+
-webkit-text-size-adjust: 100%;
138+
-ms-text-size-adjust: 100%;
139+
}
140+
141+
.markup.XXXXX body {
142+
color: #444;
143+
font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
144+
font-size: 12px;
145+
line-height: 1.7;
146+
padding: 1em;
147+
margin: auto;
148+
max-width: 42em;
149+
background: #fefefe;
150+
}
151+
152+
.markup.XXXXX p {
153+
color: orangered;
154+
}
155+
```
156+
Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.less` or `custom/public/css/my-style-XXXXX.css`
157+
158+
Then to import it, add it to the custom header or footer. `custom/templates/custom/header.tmpl`
159+
```html
160+
<link rel="stylesheet/less" type="text/css" href="{{AppSubUrl}}/css/my-style-XXXXX.less" />
161+
<script src="//cdn.jsdelivr.net/npm/less" ></script>
162+
```
163+
164+
or if using pure CSS
165+
166+
```html
167+
<link rel="stylesheet/less" type="text/css" href="{{AppSubUrl}}/css/my-style-XXXXX.css" />
168+
```

0 commit comments

Comments
 (0)