Fix heading detection in fenced code blocks#9
Merged
Conversation
### CHANGES - Add `biome.enabled` setting to VSCode config - Reorder imports in `md-tree.js` for clarity - Use radix in `Number.parseInt` for consistency - Track and ignore headings in code blocks - Adjust heading levels outside code blocks only - Update package version to `1.6.1` - Upgrade dev dependencies: ESLint, Prettier, etc. - Add test for CLI handling of code blocks
|
@ksylvan thanks for fixing this. I see 1.6.1 was created on npm 11 hours ago so I would guess this fix is in that version? I'm a newbie so was wondering if you'd have a CHANGELOG or Releases file that shows which issues are fixed in each releases? Also whether something could auto generate that? Also whether you can auto link issues like this to the release it shipped in? Thanks. |
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.
Fix heading detection in fenced code blocks
Summary
This PR introduces improvements to code parsing reliability by fixing issues with heading detection inside fenced code blocks, updates development dependencies to their latest versions, and makes minor code quality improvements throughout the codebase.
Related Issues
Closes #7
Files Changed
.vscode/settings.json: Disabled Biome linter integration to prevent conflicts with the existing ESLint setup.bin/md-tree.js: Fixed critical bug where markdown headings inside code blocks were incorrectly parsed as actual document headings. Also improvedparseIntcalls by explicitly specifying radix parameter and reorganized imports alphabetically.index.js: Reordered export statements alphabetically for better code organization.package.json&package-lock.json: Updated version to 1.6.1 and upgraded development dependencies to latest versions.pnpm-lock.yaml: Updated lockfile to reflect dependency changes.test/test-cli.js: Added new test case to verify correct handling of hash symbols inside code blocks.test/test.js: Minor import statement reordering for consistency.Code Changes
Critical Bug Fix - Code Block Parsing
parseInt Improvements
Reason for Changes
Code Block Bug Fix: Users reported that markdown documents containing code examples with bash comments (starting with
#) were being incorrectly parsed, causing sections to be truncated when using theexplodecommand. This was a critical issue affecting document integrity.parseInt Radix: Added explicit radix parameter (base 10) to all
parseIntcalls to follow JavaScript best practices and avoid potential parsing issues with strings that could be interpreted as octal or hexadecimal.Dependency Updates: Updated ESLint, Prettier, and Node.js types to benefit from latest bug fixes and improvements.
Code Organization: Alphabetized imports and exports for better maintainability and consistency across the codebase.
Impact of Changes
Functionality: The
explodeand section extraction commands now correctly handle markdown documents containing code blocks with hash symbols, preventing data loss and ensuring document integrity.Reliability: Explicit radix in
parseIntcalls eliminates edge cases where numeric strings could be misinterpreted.Development Experience: Updated development dependencies provide better linting, formatting, and type checking capabilities.
Performance: No performance impact expected; changes are primarily bug fixes and code organization improvements.
Test Plan
Added comprehensive test case
CLI explode handles # inside code blocksthat:Existing tests continue to pass, confirming backward compatibility.
Additional Notes
extractAllSectionsandadjustHeadingLevelsmethods to ensure consistent behavior across all CLI commands.