Skip to content

Commit 8d650bd

Browse files
updates for version 2.0
1 parent 5fac28e commit 8d650bd

38 files changed

+2795
-809
lines changed

404.html

+6-18
Large diffs are not rendered by default.

Exercise_solutions.html

+1,163
Large diffs are not rendered by default.

ayu-highlight.css

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
88
overflow-x: auto;
99
background: #191f26;
1010
color: #e6e1cf;
11-
padding: 0.5em;
1211
}
1312

1413
.hljs-comment,

basename-dirname.html

+38-24
Large diffs are not rendered by default.

book.js

+27-8
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ function playground_text(playground) {
108108

109109
let text = playground_text(code_block);
110110
let classes = code_block.querySelector('code').classList;
111-
let has_2018 = classes.contains("edition2018");
112-
let edition = has_2018 ? "2018" : "2015";
113-
111+
let edition = "2015";
112+
if(classes.contains("edition2018")) {
113+
edition = "2018";
114+
} else if(classes.contains("edition2021")) {
115+
edition = "2021";
116+
}
114117
var params = {
115118
version: "stable",
116119
optimize: "0",
@@ -133,7 +136,15 @@ function playground_text(playground) {
133136
body: JSON.stringify(params)
134137
})
135138
.then(response => response.json())
136-
.then(response => result_block.innerText = response.result)
139+
.then(response => {
140+
if (response.result.trim() === '') {
141+
result_block.innerText = "No output";
142+
result_block.classList.add("result-no-output");
143+
} else {
144+
result_block.innerText = response.result;
145+
result_block.classList.remove("result-no-output");
146+
}
147+
})
137148
.catch(error => result_block.innerText = "Playground Communication: " + error.message);
138149
}
139150

@@ -151,12 +162,13 @@ function playground_text(playground) {
151162
if (window.ace) {
152163
// language-rust class needs to be removed for editable
153164
// blocks or highlightjs will capture events
154-
Array
155-
.from(document.querySelectorAll('code.editable'))
165+
code_nodes
166+
.filter(function (node) {return node.classList.contains("editable"); })
156167
.forEach(function (block) { block.classList.remove('language-rust'); });
157168

158169
Array
159-
.from(document.querySelectorAll('code:not(.editable)'))
170+
code_nodes
171+
.filter(function (node) {return !node.classList.contains("editable"); })
160172
.forEach(function (block) { hljs.highlightBlock(block); });
161173
} else {
162174
code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
@@ -359,7 +371,14 @@ function playground_text(playground) {
359371
});
360372

361373
themePopup.addEventListener('click', function (e) {
362-
var theme = e.target.id || e.target.parentElement.id;
374+
var theme;
375+
if (e.target.className === "theme") {
376+
theme = e.target.id;
377+
} else if (e.target.parentElement.className === "theme") {
378+
theme = e.target.parentElement.id;
379+
} else {
380+
return;
381+
}
363382
set_theme(theme);
364383
});
365384

buy.html

+6-18
Large diffs are not rendered by default.

cat-tac.html

+133-58
Large diffs are not rendered by default.

comm.html

+56-21
Large diffs are not rendered by default.

cover.html

+6-18
Large diffs are not rendered by default.

csplit.html

+159-60
Large diffs are not rendered by default.

css/chrome.css

+44-5
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,63 @@ pre {
208208
pre > .buttons {
209209
position: absolute;
210210
z-index: 100;
211-
right: 5px;
212-
top: 5px;
211+
right: 0px;
212+
top: 2px;
213+
margin: 0px;
214+
padding: 2px 0px;
213215

214216
color: var(--sidebar-fg);
215217
cursor: pointer;
218+
visibility: hidden;
219+
opacity: 0;
220+
transition: visibility 0.1s linear, opacity 0.1s linear;
221+
}
222+
pre:hover > .buttons {
223+
visibility: visible;
224+
opacity: 1
216225
}
217226
pre > .buttons :hover {
218227
color: var(--sidebar-active);
228+
border-color: var(--icons-hover);
229+
background-color: var(--theme-hover);
219230
}
220231
pre > .buttons i {
221232
margin-left: 8px;
222233
}
223234
pre > .buttons button {
224-
color: inherit;
225-
background: transparent;
226-
border: none;
227235
cursor: inherit;
236+
margin: 0px 5px;
237+
padding: 3px 5px;
238+
font-size: 14px;
239+
240+
border-style: solid;
241+
border-width: 1px;
242+
border-radius: 4px;
243+
border-color: var(--icons);
244+
background-color: var(--theme-popup-bg);
245+
transition: 100ms;
246+
transition-property: color,border-color,background-color;
247+
color: var(--icons);
228248
}
249+
@media (pointer: coarse) {
250+
pre > .buttons button {
251+
/* On mobile, make it easier to tap buttons. */
252+
padding: 0.3rem 1rem;
253+
}
254+
}
255+
pre > code {
256+
padding: 1rem;
257+
}
258+
259+
/* FIXME: ACE editors overlap their buttons because ACE does absolute
260+
positioning within the code block which breaks padding. The only solution I
261+
can think of is to move the padding to the outer pre tag (or insert a div
262+
wrapper), but that would require fixing a whole bunch of CSS rules.
263+
*/
264+
.hljs.ace_editor {
265+
padding: 0rem 0rem;
266+
}
267+
229268
pre > .result {
230269
margin-top: 10px;
231270
}

css/general.css

+17-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ html {
1212
color: var(--fg);
1313
background-color: var(--bg);
1414
text-size-adjust: none;
15+
-webkit-text-size-adjust: none;
1516
}
1617

1718
body {
@@ -25,6 +26,16 @@ code {
2526
font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
2627
}
2728

29+
/* make long words/inline code not x overflow */
30+
main {
31+
overflow-wrap: break-word;
32+
}
33+
34+
/* make wide tables scroll if they overflow */
35+
.table-wrapper {
36+
overflow-x: auto;
37+
}
38+
2839
/* Don't change font size in headers. */
2940
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
3041
font-size: unset;
@@ -79,8 +90,7 @@ h6:target::before {
7990

8091
.content {
8192
overflow-y: auto;
82-
padding: 0 15px;
83-
padding-bottom: 50px;
93+
padding: 0 5px 50px 5px;
8494
}
8595
.content main {
8696
margin-left: auto;
@@ -92,7 +102,7 @@ h6:target::before {
92102
.content ul { line-height: 1.45em; }
93103
.content a { text-decoration: none; }
94104
.content a:hover { text-decoration: underline; }
95-
.content img { max-width: 100%; }
105+
.content img, .content video { max-width: 100%; }
96106
.content .header:link,
97107
.content .header:visited {
98108
color: var(--fg);
@@ -175,3 +185,7 @@ blockquote {
175185
margin: 5px 0px;
176186
font-weight: bold;
177187
}
188+
189+
.result-no-output {
190+
font-style: italic;
191+
}

css/variables.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
--links: #2b79a2;
6969

70-
--inline-code-color: #c5c8c6;;
70+
--inline-code-color: #c5c8c6;
7171

7272
--theme-popup-bg: #141617;
7373
--theme-popup-border: #43484d;
@@ -147,7 +147,7 @@
147147

148148
--links: #2b79a2;
149149

150-
--inline-code-color: #c5c8c6;;
150+
--inline-code-color: #c5c8c6;
151151

152152
--theme-popup-bg: #161923;
153153
--theme-popup-border: #737480;
@@ -228,7 +228,7 @@
228228

229229
--links: #2b79a2;
230230

231-
--inline-code-color: #c5c8c6;;
231+
--inline-code-color: #c5c8c6;
232232

233233
--theme-popup-bg: #141617;
234234
--theme-popup-border: #43484d;

0 commit comments

Comments
 (0)