rasendubi / uniorg

An accurate Org-mode parser for JavaScript/TypeScript
https://oleksii.shmalko.com/uniorg
GNU General Public License v3.0
256 stars 24 forks source link

fix: failed to parse headline tags like ":hello:你好:" #73

Closed xandeer closed 1 year ago

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 67579ad2ae4ea5fad46dc4b26c898913921ae064

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------ | ----- | | uniorg-parse | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov[bot] commented 1 year ago

Codecov Report

Merging #73 (a86b45b) into master (a74a80b) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head a86b45b differs from pull request most recent head 67579ad. Consider uploading reports for the commit 67579ad to get more accurate results

@@           Coverage Diff           @@
##           master      #73   +/-   ##
=======================================
  Coverage   96.31%   96.31%           
=======================================
  Files          15       15           
  Lines        1820     1820           
  Branches      599      599           
=======================================
  Hits         1753     1753           
  Misses         66       66           
  Partials        1        1           
Impacted Files Coverage Δ
packages/uniorg-parse/src/parser.ts 95.63% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

rasendubi commented 1 year ago

Thanks for the PR!

Could you add a test case for this?

I'm also a bit worried that regex is too lax now so it can capture whitespace and other forbidden characters

xandeer commented 1 year ago

Thanks for the PR! Could you add a test case for this? I'm also a bit worried that regex is too lax now so it can capture whitespace and other forbidden characters

Based on your reminder, I avoided spaces and tabs, but I don’t know how to add tests. Can you help me add tests?

xandeer commented 1 year ago

Do we need to check the asterisk at the beginning of the line?

rasendubi commented 1 year ago

Hey. Sorry for the long reply. I have added a test case to parser.spec.ts file and updated the regex to match Emacs implementation.

Emacs uses the following regex: "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$" in this place which is more strict (e.g., it does not allow punctuation). ^\* is not required as the current position is after parsing initial stars, todo keyword, priority and comment.

I will release the fix in a second