Repository: zestedesavoir/zmarkdown (js)

Issue:
abbr ending with a period are not parsed
WIth this markdown ; 

```
LLPANMP

L.L.P.A.N.M.P.


*[L.L.P.A.N.M.P.]: Les légendes pour les sigles ne marchent plus
*[LLPANMP]: Les légendes pour les sigles ne marchent plus
```
we get :  

```html
<p><abbr title="Les légendes pour les sigles ne marchent plus">LLPANMP</abbr></p>
<p>L.L.P.A.N.M.P.</p>
```

but we expected: 

```html
<p><abbr title="Les légendes pour les sigles ne marchent plus">LLPANMP</abbr></p>
<p><abbr title="Les légendes pour les sigles ne marchent plus">L.L.P.A.N.M.P.</abbr></p>
```

Pull request description:
remark-abbr: abbr ending with period are now parsed
fix #244

Patch:
diff --git a/packages/remark-abbr/dist/index.js b/packages/remark-abbr/dist/index.js
index 0b75e9c9..cd900792 100644
--- a/packages/remark-abbr/dist/index.js
+++ b/packages/remark-abbr/dist/index.js
@@ -63,7 +63,7 @@ function plugin() {
     }
 
     var pattern = Object.keys(abbrs).map(escapeRegExp).join('|');
-    var regex = new RegExp('\\b(' + pattern + ')\\b');
+    var regex = new RegExp('(\\b|\\W)(' + pattern + ')(\\b|\\W)');
 
     function one(node, index, parent) {
       if (Object.keys(abbrs).length === 0) return;
diff --git a/packages/remark-abbr/src/index.js b/packages/remark-abbr/src/index.js
index bf60e440..24e8cafb 100644
--- a/packages/remark-abbr/src/index.js
+++ b/packages/remark-abbr/src/index.js
@@ -58,7 +58,7 @@ function plugin () {
     }
 
     const pattern = Object.keys(abbrs).map(escapeRegExp).join('|')
-    const regex = new RegExp(`\\b(${pattern})\\b`)
+    const regex = new RegExp(`(\\b|\\W)(${pattern})(\\b|\\W)`)
 
     function one (node, index, parent) {
       if (Object.keys(abbrs).length === 0) return


Test patch:
diff --git a/packages/remark-abbr/__tests__/index.js b/packages/remark-abbr/__tests__/index.js
index 9acada07..accf5c82 100644
--- a/packages/remark-abbr/__tests__/index.js
+++ b/packages/remark-abbr/__tests__/index.js
@@ -112,3 +112,46 @@ test('compiles to markdown', () => {
 
   expect(contents1).toBe(contents2)
 })
+
+it('handles abbreviations ending with a period', () => {
+  const {contents} = render(dedent`
+    A.B.C. and C-D%F. foo
+
+    *[A.B.C.]: ref1
+    *[C-D%F.]: ref2
+  `)
+
+  expect(contents).toBe(
+    `<p><abbr title="ref1">A.B.C.</abbr> and ` +
+    `<abbr title="ref2">C-D%F.</abbr> foo</p>`)
+})
+
+it('does not parse words starting with abbr', () => {
+  const {contents} = render(dedent`
+    ABC ABC ABC
+
+    *[AB]: ref1
+  `)
+
+  expect(contents).not.toContain('<abbr')
+})
+
+it('does not parse words ending with abbr', () => {
+  const {contents} = render(dedent`
+    ABC ABC ABC
+
+    *[BC]: ref1
+  `)
+
+  expect(contents).not.toContain('<abbr')
+})
+
+it('does not parse words containing abbr', () => {
+  const {contents} = render(dedent`
+    ABC ABC ABC
+
+    *[B]: ref1
+  `)
+
+  expect(contents).not.toContain('<abbr')
+})