Skip to content

Commit 39be5e4

Browse files
committed
fix: Fix notitle includef for empty files
1 parent 674fa20 commit 39be5e4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/transform/plugins/includes/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import {MarkdownItIncluded} from './types';
1717
const INCLUDE_REGEXP = /^{%\s*include\s*(notitle)?\s*\[(.+?)]\((.+?)\)\s*%}$/;
1818

1919
function stripTitleTokens(tokens: Token[]) {
20-
if (tokens[0].type === 'heading_open' && tokens[2].type === 'heading_close') {
20+
const [open, _, close] = tokens;
21+
22+
if (open?.type === 'heading_open' && close?.type === 'heading_close') {
2123
tokens.splice(0, 3);
2224
}
2325
}
@@ -73,6 +75,7 @@ function unfoldIncludes(md: MarkdownItIncluded, state: StateCore, path: string,
7375

7476
let includedTokens;
7577
if (hash) {
78+
// TODO: add warning about missed block
7679
includedTokens = findBlockTokens(fileTokens, hash);
7780
} else {
7881
includedTokens = fileTokens;

0 commit comments

Comments
 (0)