From 8a7f415b516ed12ec13dce27abeac6482a1d8ca1 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 19 May 2018 01:15:53 +0200 Subject: Configuration specification in the README --- README.md | 70 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 32 insertions(+), 38 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 02d6994..2ac14ca 100644 --- a/README.md +++ b/README.md @@ -67,9 +67,7 @@ gives: npm install remark-attr ``` -## Usage - -### Dependencies: +## Dependencies: ```javascript const unified = require('unified') @@ -80,7 +78,7 @@ const remarkAttr = require('remark-attr') ``` -### Usage: +## Usage: ```javascript const testFile = ` @@ -109,58 +107,54 @@ $ node index.js

ache avatar

``` -This package can be configurated. +## API -```javascript -unified() - .use(remarkParse) - .use(remarkAttr, config) - .use(remark2rehype) - .use(stringify) - .process( testFile, (err, file) => { - console.log(String(file)) - } ) -``` +### `remarkAttr([options])` -Here are the defaults options : +Parse attributes of markdown elements. -```javascript - { - allowDangerousDOMEventHandlers: false, - elements: ['link', 'image', 'header'], - extends: {}, - scope: 'specific', - }; -``` +#### `remarkAttr.SUPPORTED_ELEMENTS` + +The list of currently supported elements. + +`['link', 'atxHeading', 'strong', 'emphasis', 'deletion', 'code', 'setextHeading']` -**allowDangerousDOMEventHandlers** : A boolean +##### Options -Allow the use of `on-*` attributs. They are depreciated and disabled by default for security reason. +###### `options.allowDangerousDOMEventHandlers` -**elements** : A list of elements from this list `[ 'link', 'image', 'header', 'strong', 'emphasis', 'deletion', 'code', 'atxHeader' ]` or `"*"`. +Whether to allow the use of `on-*` attributs. They are depreciated and disabled by default for security reason. Its a boolean (default: `false`). +If allowed, DOM event handlers will be added to the global scope. -List of every tags on witch remark-attr will be activated or `'*'` to activate remark-attr on every supported tags. +###### `options.elements` -**extends** : An object that extends the list of attributs supported for some elements. +The list of elements witch the attributes should be parsed. It's a list of string, a sublist of `SUPPORTED_ELEMENTS`. + +###### `options.extend` + +An object that extends the list of attributs supported for some elements. Example : + ``` -{extends: {image: ['original', 'quality', 'format', 'exposition']}} +extend: {atxHeading: ['original', 'quality', 'format', 'toc']} ``` -With this configuration, if the scope permit it, 4 mores attributs will be supported for image elements. +With this configuration, if the scope permit it, 4 mores attributs will be supported for atxHeading elements. + +###### `options.scope` -**scope** : A string with the value `"global"` or `"specific"` or `"extented"` or `"none"` or `"every"`. +A string with the value `"global"` or `"specific"` or `"extented"` or `"none"` or `"every"`. -`"none"` will disable the plugin -`"global"` will activate only the global attributs -`"specific"` will activate global and specific attributs. -`"extented"` will add personalized tags for some elements. -`"permissive"` or `"every"` will allow every attributs (execpt dangerous one) on every elements supported. + - `"none"` will disable the plugin. + - `"global"` will activate only the global attributs. + - `"specific"` will activate global and specific attributs. + - `"extented"` will add personalized tags for some elements. + - `"permissive"` or `"every"` will allow every attributs (execept dangerous one) on every elements supported. ## License - +Distributed under a MIT-like license. [npm]: https://www.npmjs.com/package/remark-attr -- cgit v1.2.3