Repository navigation
fix: keep fenced code blocks intact in llms.txt exports - #2562
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

stripMdxSyntax()insrc/utils/llms.tsremoves MDXimportstatements and JSX tags with regular expressions that run over the whole file, including fenced code blocks. As a result, the/llms/*.txtexports drop code from examples:importlines. For example, the firstindex.mjssample in/llms/api-5x.txtstarts with an empty line instead ofimport express from 'express';.Description=<Awesome Express App>in the systemd unit on the performance best practices page, and the<Alert>usage examples in the blog post guide.This change sets fenced code blocks (backtick or tilde, optionally indented) aside before stripping MDX syntax and puts them back unchanged afterwards. Prose is processed exactly as before.
Testing
tests/unit/llms.test.mjs. Without the fix, 2 of its 3 tests fail. With the fix, all 3 pass.npm run test:unit: 68 tests pass.getRawMarkdown()before and after the change over every file insrc/content: the only differences are lines inside fenced code blocks, which now match the source (2,420 restoredimportlines, plus the cases listed above).Fixes #2561