feat: code highlight supported

This commit is contained in:
Kilerd Chan 2018-10-22 17:11:21 +08:00
parent 3eb2bf7671
commit 37aa9b6ef8
4 changed files with 192 additions and 9 deletions

View File

@ -4,11 +4,12 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="statics/style.css">
<link rel="stylesheet" href="/statics/style.css">
<title>{% block title %}Rubble{% endblock title %}</title>
</head>
<body>
{% block body %}
{% endblock body %}
<script src="/statics/prism.js" type="text/javascript"></script>
</body>
</html>

View File

@ -13,7 +13,7 @@
<section class="article">
<p class="mate">{{ post.timestamp | date(format="%B %d, %Y") }}</p>
<a class="title" href="{% if post.post.url %}{{ post.post.url }}{% else %}archives/{{ post.post.id }}{% endif %}">{{ post.post.title }}</a>
<section class="desc">
<section class="yue desc">
{{ post.description }}
</section>
</section>

44
static/resources/prism.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,11 +2,13 @@
box-sizing: border-box;
margin: 0;
padding: 0;
font: 300 1em/1.5 PingFangSC-Regular, Microsoft Yahei UI, Noto Sans CJK SC DemiLight, sans-serif;
/*font: 300 1em/1.5 PingFangSC-Regular, Microsoft Yahei UI, Noto Sans CJK SC DemiLight, sans-serif;*/
font-family:PingFangSC-Regular, Microsoft Yahei UI, Noto Sans CJK SC DemiLight, sans-serif;
}
html {
font-size: 14px;
}
.container {
@ -336,10 +338,7 @@ section.article section.desc {
}
.yue code, .yue tt {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
padding: 0 3px;
padding-top: .2em;
padding-bottom: .2em;
padding: .2em 3px;
margin: 0;
font-size: 90%;
background-color: rgba(0, 0, 0, .04);
@ -348,10 +347,9 @@ section.article section.desc {
}
.yue pre {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
padding: 16px;
overflow: auto;
font-size: 95%;
/*font-size: 95%;*/
line-height: 1.45;
background-color: #f7f7f7;
border-radius: 3px
@ -420,3 +418,143 @@ section.article section.desc {
img {
max-width: 100%;
}
/*CODE HIGHLIGHT*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
.token {
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f7f7f7;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}