8000 Implement quote blocks · HowProgrammingWorks/Book@2a47d6e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 2a47d6e

Browse files
committed
Implement quote blocks
1 parent 9cd389a commit 2a47d6e

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

content/build.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,27 @@ const generate = (lang) => {
3434
content.push({ text: s, ...config.para });
3535
};
3636

37-
const code = (src) => {
37+
const code = (text) => {
3838
content.push({
3939
table: {
4040
widths: ['*'],
41-
body: [
42-
[
43-
{
44-
margin: [30, 5, 30, 5],
45-
text: src,
46-
preserveLeadingSpaces: true,
47-
},
48-
],
49-
],
41+
body: [[{ margin: [30, 5, 30, 5], text, preserveLeadingSpaces: true }]],
5042
},
5143
...config.code,
5244
});
5345
};
5446

47+
const quote = (s) => {
48+
const text = s.replace('> ', '');
49+
content.push({
50+
table: {
51+
widths: ['*'],
52+
body: [[{ margin: [30, 5, 30, 5], text }]],
53+
},
54+
...config.quote,
55+
});
56+
};
57+
5558
const section = (name) => {
5659
const src = fs.readFileSync(`content/${lang}/${name}.md`, 'utf8');
5760
const rows = src.split('\n');
@@ -60,6 +63,8 @@ const generate = (lang) => {
6063
for (const row of rows) {
6164
if (block === BLOCK_TEXT && row.startsWith('#')) {
6265
caption(row);
66+
} else if (block === BLOCK_TEXT && row.startsWith('>')) {
67+
quote(row);
6368
} else if (row.startsWith('```')) {
6469
if (block === BLOCK_TEXT) {
6570
lines = [];

content/config.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ module.exports = {
1010
'1-5-Decomposition',
1111
'1-6-Engineer',
1212
'1-7-Paradigms',
13+
'2-Basic',
14+
'2-1-Identifiers',
15+
'2-2-Types',
16+
'2-3-Context',
17+
'2-4-Blocks',
18+
'2-5-Procedure',
19+
'2-6-Function',
20+
'2-7-Closure',
21+
'2-8-Errors',
22+
'2-9-Monomorphic',
1323
],
1424
languages: {
1525
en: require('./en/Book.js'),
@@ -59,9 +69,16 @@ module.exports = {
5969
layout: 'noBorders',
6070
fontSize: 11,
6171
color: '#555',
62-
fillColor: '#EEE',
72+
fillColor: '#eee',
6373
font: 'Mono',
6474
},
75+
quote: {
76+
border: false,
77+
layout: 'noBorders',
78+
fontSize: 11,
79+
color: '#000',
80+
fillColor: '#bbb',
81+
},
6582
fonts: {
6683
Roboto: {
6784
normal: 'fonts/Roboto-Regular.ttf',

0 commit comments

Comments
 (0)
0