Skip to content

Commit

Permalink
fix: Fix notitle includef for empty files
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 18, 2024
1 parent 674fa20 commit 39be5e4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transform/plugins/includes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {MarkdownItIncluded} from './types';
const INCLUDE_REGEXP = /^{%\s*include\s*(notitle)?\s*\[(.+?)]\((.+?)\)\s*%}$/;

function stripTitleTokens(tokens: Token[]) {
if (tokens[0].type === 'heading_open' && tokens[2].type === 'heading_close') {
const [open, _, close] = tokens;

if (open?.type === 'heading_open' && close?.type === 'heading_close') {
tokens.splice(0, 3);
}
}
Expand Down Expand Up @@ -73,6 +75,7 @@ function unfoldIncludes(md: MarkdownItIncluded, state: StateCore, path: string,

let includedTokens;
if (hash) {
// TODO: add warning about missed block
includedTokens = findBlockTokens(fileTokens, hash);
} else {
includedTokens = fileTokens;
Expand Down

0 comments on commit 39be5e4

Please sign in to comment.