Skip to content

Embedding the include at the bottom of the page#1753

Merged
goldserg merged 5 commits intomasterfrom
merge-include-ch1
Mar 13, 2026
Merged

Embedding the include at the bottom of the page#1753
goldserg merged 5 commits intomasterfrom
merge-include-ch1

Conversation

@goldserg
Copy link
Contributor

No description provided.

@goldserg goldserg requested a review from a team as a code owner March 11, 2026 08:00
@goldserg goldserg requested review from main-kun and removed request for a team March 11, 2026 08:00
@goldserg goldserg force-pushed the merge-include-ch1 branch from 88b12c3 to 7584bf1 Compare March 11, 2026 09:57
@goldserg goldserg force-pushed the merge-include-ch1 branch 4 times, most recently from c638d63 to 992b77b Compare March 12, 2026 14:02
const isFileNotFound =
error instanceof Error && 'code' in error && error.code === 'ENOENT';

if (isFileNotFound && from) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isFileNotFound && from condition is triggered for any include file in all build modes, not just when mergingIncludes. In regular md2html without pre-md2md, if the include file is actually missing from the disk, the error will be swallowed and the file will be silently rendered as empty. The user will receive a page with missing content without any error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

preprocess: {
hashIncludes: true,
mergeIncludes: false,
mergeIncludes: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we consider this change to be breaking for other users of the open-source part of the cli? maybe we should enable this behavior with flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only for test. I change this before merge. And set true, after part 2

depContent = addIndent(depContent, indent);
}

// Add source map comment at the beginning of inlined content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a dead code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I test the sourcemaps in our documentation.

const appendix = '\n' + blocks.join('\n');
scheduler.add([0, 0], async (content) => content + appendix, {});
}
} as StepFunction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file has more than 500 lines. Can we split it into more readable parts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking about it, and it's going to get a little bigger when the terms are processed. I think I'll break it in the second final PR

} catch (error) {
const isMergedInput =
this.config.outputFormat !== 'md' && this.config.preprocess?.mergeIncludes;
if (isMergedInput) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In merge-includes mode, any error is still caught, not just ENOENT. For example: the file exists, but there are no read permissions, and the error will be swallowed.

} catch (error) {
    ...
    const isFileNotFound =
        error instanceof Error && 'code' in error && error.code === 'ENOENT';
    if (isMergedInput && isFileNotFound) {
        return [];
    }
    throw error;
}

chore: linting, tests, sonar

chore: sonar
chore: refactoring

chore: refactoring

chore: refactoring

chore: fix after review
@goldserg goldserg force-pushed the merge-include-ch1 branch from 0ef18c5 to 13d26f7 Compare March 13, 2026 11:00
@sonarqubecloud
Copy link

@goldserg goldserg merged commit c5e45b6 into master Mar 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants