Repository: arve0/markdown-it-attrs (js)

Issue:
setting options requires one setting all options
Code to reproduce:
```js
const md = require('markdown-it')();
const markdownItAttrs = require('./');

md.use(markdownItAttrs, {
  allowedAttributes: ['id', 'class', /^regex.*$/]
});

let src = 'asdf *asd*{.c} khg';

let res = md.render(src);

console.log(res);  // eslint-disable-line
```

Current result: Throws error
```
/Users/arve/git/markdown-it-attrs/utils.js:227
  return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
           ^

TypeError: Cannot read property 'replace' of undefined
    at Object.escapeRegExp (/Users/arve/git/markdown-it-attrs/utils.js:227:12)
    at module.exports.options (/Users/arve/git/markdown-it-attrs/patterns.js:11:35)
    at Function.attributes (/Users/arve/git/markdown-it-attrs/index.js:16:20)
    at MarkdownIt.use (/Users/arve/git/markdown-it-attrs/node_modules/markdown-it/lib/index.js:496:10)
    at Object.<anonymous> (/Users/arve/git/markdown-it-attrs/debug.js:5:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
```

Expected result: Should not throw error.

Reported in https://github.com/kidonng/markdown-it-attrs/pull/1

Pull request description:
only override options that are set
fixes #88 

Patch:
diff --git a/README.md b/README.md
index 8c117e0..e3324dc 100644
--- a/README.md
+++ b/README.md
@@ -174,7 +174,7 @@ Remember to [render attributes](https://github.com/arve0/markdown-it-attrs/blob/
 
 ## Custom delimiters
 
-To use different delimiters than the default, add configuration for `leftDelimiter` and `rightDelimiter`:
+To use different delimiters then the default, add configuration for `leftDelimiter` and `rightDelimiter`:
 
 ```js
 md.use(attrs, {
diff --git a/index.js b/index.js
index 7b0c63a..8d8e19f 100644
--- a/index.js
+++ b/index.js
@@ -8,10 +8,9 @@ const defaultOptions = {
   allowedAttributes: []
 };
 
-module.exports = function attributes(md, options) {
-  if (!options) {
-    options = defaultOptions;
-  }
+module.exports = function attributes(md, options_) {
+  let options = Object.assign({}, defaultOptions);
+  options = Object.assign(options, options_);
 
   const patterns = patternsConfig(options);
 


Test patch:
diff --git a/test.js b/test.js
index bcdf416..cad860b 100644
--- a/test.js
+++ b/test.js
@@ -22,6 +22,17 @@ describeTestsWithOptions({
   rightDelimiter: ']]'
 }, ' with [[ ]] delimiters');
 
+describe('markdown-it-attrs', () => {
+  let md, src, expected;
+
+  it('should not throw when getting only allowedAttributes option', () => {
+    md = Md().use(attrs, { allowedAttributes: [/^(class|attr)$/] });
+    src = 'text {.someclass #someid attr=allowed}';
+    expected = '<p class="someclass" attr="allowed">text</p>\n';
+    assert.equal(md.render(src), expected);
+  });
+});
+
 function describeTestsWithOptions(options, postText) {
   describe('markdown-it-attrs.utils' + postText, () => {
     it(replaceDelimiters('should parse {.class ..css-module #id key=val .class.with.dot}', options), () => {