micromark / micromark-extension-directive

micromark extension to support generic directives (`:cite[smith04]`)
https://unifiedjs.com
MIT License
29 stars 16 forks source link

Avoid exception when unclosed directive container is found within another container and chunkDocument is empty (fixes #16, fixes micromark/micromark#173). #27

Closed DavidAnson closed 2 days ago

DavidAnson commented 3 days ago

Initial checklist

Description of changes

Avoid exception when unclosed directive container is found within another container and chunkDocument is empty (fixes #16, fixes micromark/micromark#173).

I tried for a while to parse the scenario successfully, but couldn't find a way to avoid creating an empty container that didn't break one of the existing "lazy" tests. As it is already an edge-case scenario, giving up like this seems okay to me - definitely better than crashing callers. :)

codecov[bot] commented 3 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (7f23ba8) to head (b85e704). Report is 8 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #27 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 9 9 Lines 1416 1365 -51 ========================================= - Hits 1416 1365 -51 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 2 days ago

Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the no/* labels.

wooorm commented 2 days ago

Thanks for working on this!

I appreciate that errors are not nice. Still, I believe that we must strive towards correctness. You’re silencing an error, and introducing an incorrect result.

I spent some time with the code and introduced a proper fix.

wooorm commented 2 days ago

Released in 3.0.2!

DavidAnson commented 2 days ago

Love it, thank you!