No body when delimiters match
Closed this issue · 2 comments
F1LT3R commented
I would expect matching delimiters to work. Ie: code fences in Markdown.
```js
const foo = bar => baz
```
It seems imposible to balance matching delimiters with balanced-match
.
Is this expected?
Example:
const balanced = require('balanced-match')
const contents = 'PRE ___BODY___ POST'
const result = balanced('___', '___', contents)
console.log(result)
Result:
(Where is the body?)
{ start: 11, end: 11, pre: 'PRE ___BODY', body: '', post: ' POST' }
Expected:
(I was thinking we should see this)
{ start: 4, end: 11, pre: 'PRE ', body: 'BODY', post: ' POST' }
dimaio77 commented
this is a issue because a === b .
adding the following in line 31 fix the problem
if(a===b) {return [ai,bi]}
juliangruber commented
Thank you for reporting and investigating this, would you mind opening a PR with your fix, and even better, with some tests too?