##// END OF EJS Templates
markup: fix styling for check-lists, ref #5513
marcink -
r3683:3f847060 new-ui
parent child Browse files
Show More
@@ -1,62 +1,110 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2019 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import markdown
22 22
23 from mdx_gfm import GithubFlavoredMarkdownExtension # pragma: no cover
23 from markdown.extensions import Extension
24 from markdown.extensions.fenced_code import FencedCodeExtension
25 from markdown.extensions.smart_strong import SmartEmphasisExtension
26 from markdown.extensions.tables import TableExtension
27 from markdown.extensions.nl2br import Nl2BrExtension
28
29 import gfm
30
31
32 class GithubFlavoredMarkdownExtension(Extension):
33 """
34 An extension that is as compatible as possible with GitHub-flavored
35 Markdown (GFM).
36
37 This extension aims to be compatible with the variant of GFM that GitHub
38 uses for Markdown-formatted gists and files (including READMEs). This
39 variant seems to have all the extensions described in the `GFM
40 documentation`_, except:
41
42 - Newlines in paragraphs are not transformed into ``br`` tags.
43 - Intra-GitHub links to commits, repositories, and issues are not
44 supported.
45
46 If you need support for features specific to GitHub comments and issues,
47 please use :class:`mdx_gfm.GithubFlavoredMarkdownExtension`.
48
49 .. _GFM documentation: https://guides.github.com/features/mastering-markdown/
50 """
51
52 def extendMarkdown(self, md, md_globals):
53 # Built-in extensions
54 FencedCodeExtension().extendMarkdown(md, md_globals)
55 SmartEmphasisExtension().extendMarkdown(md, md_globals)
56 TableExtension().extendMarkdown(md, md_globals)
57
58 # Custom extensions
59 gfm.AutolinkExtension().extendMarkdown(md, md_globals)
60 gfm.AutomailExtension().extendMarkdown(md, md_globals)
61 gfm.HiddenHiliteExtension([
62 ('guess_lang', 'False'),
63 ('css_class', 'highlight')
64 ]).extendMarkdown(md, md_globals)
65 gfm.SemiSaneListExtension().extendMarkdown(md, md_globals)
66 gfm.SpacedLinkExtension().extendMarkdown(md, md_globals)
67 gfm.StrikethroughExtension().extendMarkdown(md, md_globals)
68 gfm.TaskListExtension([
69 ('list_attrs', {'class': 'checkbox'})
70 ]).extendMarkdown(md, md_globals)
71 Nl2BrExtension().extendMarkdown(md, md_globals)
24 72
25 73
26 74 # Global Vars
27 75 URLIZE_RE = '(%s)' % '|'.join([
28 76 r'<(?:f|ht)tps?://[^>]*>',
29 77 r'\b(?:f|ht)tps?://[^)<>\s]+[^.,)<>\s]',
30 78 r'\bwww\.[^)<>\s]+[^.,)<>\s]',
31 79 r'[^(<\s]+\.(?:com|net|org)\b',
32 80 ])
33 81
34 82
35 83 class UrlizePattern(markdown.inlinepatterns.Pattern):
36 84 """ Return a link Element given an autolink (`http://example/com`). """
37 85 def handleMatch(self, m):
38 86 url = m.group(2)
39 87
40 88 if url.startswith('<'):
41 89 url = url[1:-1]
42 90
43 91 text = url
44 92
45 93 if not url.split('://')[0] in ('http','https','ftp'):
46 94 if '@' in url and not '/' in url:
47 95 url = 'mailto:' + url
48 96 else:
49 97 url = 'http://' + url
50 98
51 99 el = markdown.util.etree.Element("a")
52 100 el.set('href', url)
53 101 el.text = markdown.util.AtomicString(text)
54 102 return el
55 103
56 104
57 105 class UrlizeExtension(markdown.Extension):
58 106 """ Urlize Extension for Python-Markdown. """
59 107
60 108 def extendMarkdown(self, md, md_globals):
61 109 """ Replace autolink with UrlizePattern """
62 110 md.inlinePatterns['autolink'] = UrlizePattern(URLIZE_RE, md)
@@ -1,383 +1,397 b''
1 1
2 2 /** MODAL **/
3 3 .modal-open {
4 4 overflow:hidden;
5 5 }
6 6 body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
7 7 margin-right:15px;
8 8 }
9 9 .modal {
10 10 position:fixed;
11 11 top:0;
12 12 right:0;
13 13 bottom:0;
14 14 left:0;
15 15 z-index:1040;
16 16 display:none;
17 17 overflow-y:scroll;
18 18 &.fade .modal-dialog {
19 19 -webkit-transform:translate(0,-25%);
20 20 -ms-transform:translate(0,-25%);
21 21 transform:translate(0,-25%);
22 22 -webkit-transition:-webkit-transform 0.3s ease-out;
23 23 -moz-transition:-moz-transform 0.3s ease-out;
24 24 -o-transition:-o-transform 0.3s ease-out;
25 25 transition:transform 0.3s ease-out;
26 26 }
27 27 &.in .modal-dialog {
28 28 -webkit-transform:translate(0,0);
29 29 -ms-transform:translate(0,0);
30 30 transform:translate(0,0);
31 31 }
32 32 }
33 33 .modal-dialog {
34 34 z-index:1050;
35 35 width:auto;
36 36 padding:10px;
37 37 margin-right:auto;
38 38 margin-left:auto;
39 39 }
40 40 .modal-content {
41 41 position:relative;
42 42 background-color:#ffffff;
43 43 border: @border-thickness solid rgba(0,0,0,0.2);
44 44 .border-radius(@border-radius);
45 45 outline:none;
46 46 -webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);
47 47 box-shadow:0 3px 9px rgba(0,0,0,0.5);
48 48 background-clip:padding-box;
49 49 }
50 50 .modal-backdrop {
51 51 position:fixed;
52 52 top:0;
53 53 right:0;
54 54 bottom:0;
55 55 left:0;
56 56 z-index:1030;
57 57 background-color:#000000;
58 58
59 59 &.modal-backdrop.fade {
60 60 opacity:0;
61 61 filter:alpha(opacity=0);
62 62 }
63 63 &.in {
64 64 opacity:0.5;
65 65 filter:alpha(opacity=50);
66 66 }
67 67 }
68 68 .modal-header {
69 69 min-height:16.428571429px;
70 70 padding:15px;
71 71 border-bottom: @border-thickness solid @grey6;
72 72 .close {
73 73 margin-top:-2px;
74 74 }
75 75 }
76 76 .modal-title {
77 77 margin:0;
78 78 line-height:1.428571429;
79 79 }
80 80 .modal-body {
81 81 position:relative;
82 82 padding:20px;
83 83 }
84 84 .modal-footer {
85 85 padding:19px 20px 20px;
86 86 margin-top:15px;
87 87 text-align:right;
88 88 border-top:1px solid #e5e5e5;
89 89 .btn + .btn {
90 90 margin-bottom:0;
91 91 margin-left:5px;
92 92 }
93 93 .btn-group .btn + .btn {
94 94 margin-left:-1px;
95 95 }
96 96 .btn-block + .btn-block {
97 97 margin-left:0;
98 98 }
99 99 &:before {
100 100 display:table;
101 101 content:" ";
102 102 }
103 103 &:after {
104 104 display:table;
105 105 content:" ";
106 106 clear:both;
107 107 }
108 108 }
109 109
110 110 /** MARKDOWN styling **/
111 111 div.markdown-block {
112 112 clear: both;
113 113 overflow: hidden;
114 114 margin: 0;
115 115 padding: 3px 15px 3px;
116 116 }
117 117
118 118 div.markdown-block h1,
119 119 div.markdown-block h2,
120 120 div.markdown-block h3,
121 121 div.markdown-block h4,
122 122 div.markdown-block h5,
123 123 div.markdown-block h6 {
124 124 border-bottom: none !important;
125 125 padding: 0 !important;
126 126 overflow: visible !important;
127 127 }
128 128
129 129 div.markdown-block h1,
130 130 div.markdown-block h2 {
131 131 border-bottom: 1px #e6e5e5 solid !important;
132 132 }
133 133
134 134 div.markdown-block h1 {
135 135 font-size: 32px;
136 136 margin: 15px 0 15px 0 !important;
137 137 padding-bottom: 5px !important;
138 138 }
139 139
140 140 div.markdown-block h2 {
141 141 font-size: 24px !important;
142 142 margin: 34px 0 10px 0 !important;
143 143 padding-top: 15px !important;
144 144 padding-bottom: 8px !important;
145 145 }
146 146
147 147 div.markdown-block h3 {
148 148 font-size: 18px !important;
149 149 margin: 30px 0 8px 0 !important;
150 150 padding-bottom: 2px !important;
151 151 }
152 152
153 153 div.markdown-block h4 {
154 154 font-size: 13px !important;
155 155 margin: 18px 0 3px 0 !important;
156 156 }
157 157
158 158 div.markdown-block h5 {
159 159 font-size: 12px !important;
160 160 margin: 15px 0 3px 0 !important;
161 161 }
162 162
163 163 div.markdown-block h6 {
164 164 font-size: 12px;
165 165 color: #777777;
166 166 margin: 15px 0 3px 0 !important;
167 167 }
168 168
169 169 div.markdown-block hr {
170 170 border: 0;
171 171 color: #e6e5e5;
172 172 background-color: #e6e5e5;
173 173 height: 3px;
174 174 margin-bottom: 13px;
175 175 }
176 176
177 177 div.markdown-block ol,
178 178 div.markdown-block ul,
179 179 div.markdown-block p,
180 180 div.markdown-block blockquote,
181 181 div.markdown-block dl,
182 182 div.markdown-block li,
183 183 div.markdown-block table {
184 184 margin: 3px 0px 13px 0px !important;
185 185 color: #424242 !important;
186 186 font-size: 13px !important;
187 187 font-family: @text-regular;
188 188 font-weight: normal !important;
189 189 overflow: visible !important;
190 190 line-height: 140% !important;
191 191 }
192 192
193 193 div.markdown-block pre {
194 194 margin: 3px 0px 13px 0px !important;
195 195 padding: .5em;
196 196 color: #424242 !important;
197 197 font-size: 13px !important;
198 198 overflow: visible !important;
199 199 line-height: 140% !important;
200 200 background-color: @grey7;
201 201 }
202 202
203 203 div.markdown-block img {
204 204 border-style: none;
205 205 background-color: #fff;
206 206 padding-right: 20px;
207 207 }
208 208
209 209
210 210 div.markdown-block strong {
211 211 font-weight: 600;
212 212 margin: 0;
213 213 }
214 214
215 div.markdown-block ul.checkbox,
216 div.markdown-block ol.checkbox {
217 padding-left: 20px !important;
218 margin-top: 0px !important;
219 margin-bottom: 18px !important;
220 }
221
215 222 div.markdown-block ul,
216 223 div.markdown-block ol {
217 224 padding-left: 30px !important;
218 225 margin-top: 0px !important;
219 226 margin-bottom: 18px !important;
220 227 }
221 228
229 div.markdown-block ul.checkbox li,
230 div.markdown-block ol.checkbox li {
231 list-style: none !important;
232 margin: 6px !important;
233 padding: 0 !important;
234 }
235
222 236 div.markdown-block ul li,
223 237 div.markdown-block ol li {
224 238 list-style: disc !important;
225 239 margin: 6px !important;
226 240 padding: 0 !important;
227 241 }
228 242
229 243 div.markdown-block ol li {
230 244 list-style: decimal !important;
231 245 }
232 246
233 247 /*
234 248 div.markdown-block a,
235 249 div.markdown-block a:visited {
236 250 color: #4183C4 !important;
237 251 background-color: inherit;
238 252 text-decoration: none;
239 253 }
240 254 */
241 255
242 256 div.markdown-block #message {
243 257 .border-radius(@border-radius);
244 258 border: @border-thickness solid @grey5;
245 259 display: block;
246 260 width: 100%;
247 261 height: 60px;
248 262 margin: 6px 0px;
249 263 }
250 264
251 265 div.markdown-block button,
252 266 div.markdown-block #ws {
253 267 font-size: @basefontsize;
254 268 padding: 4px 6px;
255 269 .border-radius(@border-radius);
256 270 border: @border-thickness solid @grey5;
257 271 background-color: @grey6;
258 272 }
259 273
260 274 div.markdown-block code,
261 275 div.markdown-block pre,
262 276 div.markdown-block #ws,
263 277 div.markdown-block #message {
264 278 font-family: @text-monospace;
265 279 font-size: 11px;
266 280 .border-radius(@border-radius);
267 281 background-color: white;
268 282 color: @grey3;
269 283 }
270 284
271 285
272 286 div.markdown-block code {
273 287 border: @border-thickness solid @grey6;
274 288 margin: 0 2px;
275 289 padding: 0 5px;
276 290 }
277 291
278 292 div.markdown-block pre {
279 293 border: @border-thickness solid @grey5;
280 294 overflow: auto;
281 295 padding: .5em;
282 296 background-color: @grey7;
283 297 }
284 298
285 299 div.markdown-block pre > code {
286 300 border: 0;
287 301 margin: 0;
288 302 padding: 0;
289 303 }
290 304
291 305 /** RST STYLE **/
292 306 div.rst-block {
293 307 clear: both;
294 308 overflow: hidden;
295 309 margin: 0;
296 310 padding: 3px 15px 3px;
297 311 }
298 312
299 313 div.rst-block h2 {
300 314 font-weight: normal;
301 315 }
302 316
303 317 div.rst-block h1,
304 318 div.rst-block h2,
305 319 div.rst-block h3,
306 320 div.rst-block h4,
307 321 div.rst-block h5,
308 322 div.rst-block h6 {
309 323 border-bottom: 0 !important;
310 324 margin: 0 !important;
311 325 padding: 0 !important;
312 326 line-height: 1.5em !important;
313 327 }
314 328
315 329
316 330 div.rst-block h1:first-child {
317 331 padding-top: .25em !important;
318 332 }
319 333
320 334 div.rst-block h2,
321 335 div.rst-block h3 {
322 336 margin: 1em 0 !important;
323 337 }
324 338
325 339 div.rst-block h1,
326 340 div.rst-block h2 {
327 341 border-bottom: 1px #e6e5e5 solid !important;
328 342 }
329 343
330 344 div.rst-block h2 {
331 345 margin-top: 1.5em !important;
332 346 padding-top: .5em !important;
333 347 }
334 348
335 349 div.rst-block p {
336 350 color: black !important;
337 351 margin: 1em 0 !important;
338 352 line-height: 1.5em !important;
339 353 }
340 354
341 355 div.rst-block ul {
342 356 list-style: disc !important;
343 357 margin: 1em 0 1em 2em !important;
344 358 clear: both;
345 359 }
346 360
347 361 div.rst-block ol {
348 362 list-style: decimal;
349 363 margin: 1em 0 1em 2em !important;
350 364 }
351 365
352 366 div.rst-block pre,
353 367 div.rst-block code {
354 368 font: 12px "Bitstream Vera Sans Mono","Courier",monospace;
355 369 }
356 370
357 371 div.rst-block code {
358 372 font-size: 12px !important;
359 373 background-color: ghostWhite !important;
360 374 color: #444 !important;
361 375 padding: 0 .2em !important;
362 376 border: 1px solid #dedede !important;
363 377 }
364 378
365 379 div.rst-block pre code {
366 380 padding: 0 !important;
367 381 font-size: 12px !important;
368 382 background-color: #eee !important;
369 383 border: none !important;
370 384 }
371 385
372 386 div.rst-block pre {
373 387 margin: 1em 0;
374 388 padding: @padding;
375 389 border: 1px solid @grey6;
376 390 .border-radius(@border-radius);
377 391 overflow: auto;
378 392 font-size: 12px;
379 393 color: #444;
380 394 background-color: @grey7;
381 395 }
382 396
383 397
General Comments 0
You need to be logged in to leave comments. Login now