diff options
author | ache <ache@ache.one> | 2018-04-23 11:29:08 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2018-04-23 11:29:08 +0200 |
commit | b301c30eb6c2f8ac995ff14910df2059ffad5694 (patch) | |
tree | e0aa52d98a90d332e5c1dfd1ca76cf791eb2f7f3 | |
parent | Add a well tested plugin (diff) |
Add a README
-rw-r--r-- | README.md | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..e632f9f --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ + +mardown-attribute-parser +=========== + +A node plugin to parse pandoc-style attributes (custom HTML attributes). + + +## Syntax + +The syntax is the same as pandoc's. + +```markdown +{#thisIsAnId .thisIsAClass thisKey=thisValue} + +{thatKey="value" thisKey='thatValue'} +``` + +## Usage + +```js +const parseAttr = require('markdown-attribute-parser'); + + +parseAttr('{ widgth=500px editable=true }'); + +parseAttr('height=500px'); +``` + +The output is an object of the form : +```js +{ + prop: { // Keep the key-value attribute + class: undefined, // A list of class + id: undefined, // The uniq id + }, + eaten: '', // Every characters parsed +} +``` + +For example this code will output : +```js +parseAttr('{ widgth=500px editable=true #unicorn .dangerous .cute }'); +``` + +```js +{ + prop: { + class: ['dangerous', 'cute'], + id: 'unicorn', + widgth: '500px', + editable: 'true', + }, + eaten: '{ widgth=500px editable=true #unicorn .dangerous .cute }', +} +``` + + +## Licence + +MIT + |