[docs] add syntax highlight (#12398)

This commit is contained in:
Ivan Blinkov 2020-07-10 17:32:18 +03:00 committed by GitHub
parent eb6fbdfd4b
commit a256e7e117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -55,6 +55,13 @@ def adjust_markdown_html(content):
if a_href and a_href.startswith('http'):
a.attrs['target'] = '_blank'
for code in soup.find_all('code'):
code_class = code.attrs.get('class')
if code_class:
code.attrs['class'] = code_class + ['syntax']
else:
code.attrs['class'] = 'syntax'
for iframe in soup.find_all('iframe'):
handle_iframe(iframe, soup)

View File

@ -72,3 +72,28 @@
.syntax .vg { color: #ef6155 } /* Name.Variable.Global */
.syntax .vi { color: #ef6155 } /* Name.Variable.Instance */
.syntax .il { color: #f99b15 } /* Literal.Number.Integer.Long */
@media (prefers-color-scheme: dark) {
.syntax { background: #2f1e2e; color: #f8f9fa }
.syntax .k { color: #c78cff } /* Keyword */
.syntax .gi { color: #64ffbb } /* Generic.Inserted */
.syntax .ld { color: #64ffbb } /* Literal.Date */
.syntax .s { color: #64ffbb } /* Literal.String */
.syntax .sb { color: #64ffbb } /* Literal.String.Backtick */
.syntax .s2 { color: #64ffbb } /* Literal.String.Double */
.syntax .sh { color: #64ffbb } /* Literal.String.Heredoc */
.syntax .sx { color: #64ffbb } /* Literal.String.Other */
.syntax .sr { color: #64ffbb } /* Literal.String.Regex */
.syntax .s1 { color: #64ffbb } /* Literal.String.Single */
.syntax .ss { color: #64ffbb } /* Literal.String.Symbol */
.syntax .c { color: #64ffbb } /* Comment */
.syntax .n { color: #f8f9fa } /* Name */
.syntax .p { color: #f8f9fa } /* Punctuation */
.syntax .gh { color: #f8f9fa; font-weight: bold } /* Generic.Heading */
.syntax .nb { color: #f8f9fa } /* Name.Builtin */
.syntax .ni { color: #f8f9fa } /* Name.Entity */
.syntax .nl { color: #f8f9fa } /* Name.Label */
.syntax .py { color: #f8f9fa } /* Name.Property */
.syntax .w { color: #f8f9fa } /* Text.Whitespace */
.syntax .sc { color: #f8f9fa } /* Literal.String.Char */
}