Skip to content

Commit a10a198

Browse files
committed
fix: setup prettyprint
1 parent e1f1c9e commit a10a198

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

docs_theme/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ <h3 class="modal-title fs-5" id="search_modal_label">
193193
</script>
194194

195195
<script src="{{ 'dist/main.js'|url }}"></script>
196+
<script src="{{ 'dist/prettify-1.0.js'|url }}"></script>
196197

197198
{% for path in config.extra_javascript %}
198199
<script src="{{ path|url }}" defer></script>

docs_theme/src/js/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ import "../../node_modules/bootstrap/js/dist/toast";
1212
import "../../node_modules/bootstrap/js/dist/tooltip";
1313

1414
import "../scss/styles.scss";
15+
16+
const codeBlocks = document.querySelectorAll("pre code");
17+
codeBlocks.forEach((block) => {
18+
block.parentElement.classList.add(["prettyprint", "well"]);
19+
});

docs_theme/src/scss/styles.scss

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ $code-color: #d14;
6666
a {
6767
color: #a30000;
6868
text-decoration: none;
69+
70+
&:hover,
71+
&:active {
72+
color: #c20000;
73+
text-decoration: underline;
74+
}
6975
}
7076

7177
pre.prettyprint {
@@ -86,6 +92,18 @@ code {
8692
padding: 2px 4px;
8793
}
8894

95+
pre {
96+
background-color: #f7f7f9;
97+
}
98+
99+
pre code {
100+
border: none;
101+
}
102+
103+
.nav-link {
104+
padding: 2px 15px 3px;
105+
}
106+
89107
.body-content {
90108
padding-top: 120px;
91109
padding-bottom: 70px;
@@ -101,4 +119,55 @@ code {
101119
color: #333;
102120
}
103121

104-
// Code Blocks
122+
// Prettify Code
123+
.com {
124+
color: #93a1a1;
125+
}
126+
.lit {
127+
color: #195f91;
128+
}
129+
.pun,
130+
.opn,
131+
.clo {
132+
color: #93a1a1;
133+
}
134+
.fun {
135+
color: #dc322f;
136+
}
137+
.str,
138+
.atv {
139+
color: #d14;
140+
}
141+
.kwd,
142+
.prettyprint .tag {
143+
color: #1e347b;
144+
}
145+
.typ,
146+
.atn,
147+
.dec,
148+
.var {
149+
color: teal;
150+
}
151+
.pln {
152+
color: #48484c;
153+
}
154+
155+
.prettyprint {
156+
padding: 8px;
157+
background-color: #f7f7f9;
158+
border: 1px solid #e1e1e8;
159+
}
160+
.prettyprint.linenums {
161+
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
162+
}
163+
164+
/* Specify class=linenums on a pre to get line numbering */
165+
ol.linenums {
166+
margin: 0 0 0 33px; /* IE indents via margin-left */
167+
}
168+
ol.linenums li {
169+
padding-left: 12px;
170+
color: #bebec5;
171+
line-height: 20px;
172+
text-shadow: 0 1px 0 #fff;
173+
}

0 commit comments

Comments
 (0)