Skip to content

Commit f4340f7

Browse files
committed
Fix #134: Strip whitespace in codeblock languages
Avoids some import errors and other confusion.
1 parent 738886f commit f4340f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index/import/markdown.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ export function markdownSourceImport(
135135
// This is an indented-style codeblock.
136136
blocks.set(start, new CodeblockData(start, end, blockOrdinal++, [], "indent", start, end, block.id));
137137
} else {
138-
const languages = match.length > 1 && match[1] ? match[1].split(",") : [];
138+
// Pull out all languages in the block, stripping whitespace and empty blocks.
139+
const rawLanguages = match.length > 1 && match[1] ? match[1].split(",") : [];
140+
const languages = rawLanguages.map((lang) => lang.trim()).filter((lang) => lang.length > 0);
141+
139142
blocks.set(
140143
start,
141144
new CodeblockData(start, end, blockOrdinal++, languages, "fenced", start + 1, end - 1, block.id)

0 commit comments

Comments
 (0)