From b301c30eb6c2f8ac995ff14910df2059ffad5694 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 23 Apr 2018 11:29:08 +0200 Subject: Add a README --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 README.md 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 + -- cgit v1.2.3