8000 Fix rendering code examples · HowProgrammingWorks/Book@9cd389a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cd389a

Browse files
committed
Fix rendering code examples
1 parent 3fa742f commit 9cd389a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

content/build.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const generate = (lang) => {
4343
{
4444
margin: [30, 5, 30, 5],
4545
text: src,
46+
preserveLeadingSpaces: true,
4647
},
4748
],
4849
],
@@ -57,7 +58,7 @@ const generate = (lang) => {
5758
let block = BLOCK_TEXT;
5859
let lines = [];
5960
for (const row of rows) {
60-
if (row.startsWith('#')) {
61+
if (block === BLOCK_TEXT && row.startsWith('#')) {
6162
caption(row);
6263
} else if (row.startsWith('```')) {
6364
if (block === BLOCK_TEXT) {
@@ -70,11 +71,9 @@ const generate = (lang) => {
7071
}
7172
} else if (row.trim().substring(0, 3).includes('.')) {
7273
index(row);
73-
} else if (row === '') {
74-
if (block === BLOCK_TEXT) {
75-
para(lines.join(' '));
76-
lines = [];
77-
}
74+
} else if (block === BLOCK_TEXT && row === '') {
75+
para(lines.join(' '));
76+
lines = [];
7877
} else {
7978
lines.push(row);
8079
}

0 commit comments

Comments
 (0)
0