aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: c5f74cb89fc192864f049888c24a941416bdd979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

mardown-attribute-parser
===========

A node plugin to parse attributes (custom HTML attributes).


## Syntax

The syntax is common :

```markdown
{#thisIsAnId .thisIsAClass thisKey=thisValue}

{thatKey="value" thisKey='thatValue'}
```

## Usage

```js
const parseAttr = require('markdown-attribute-parser');


parseAttr('{ width=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('{ width=500px editable=true #unicorn .dangerous .cute }');
```

```js
{
  prop: {
    class: ['dangerous', 'cute'],
    id: 'unicorn',
    width: '500px',
    editable: 'true',
  },
  eaten: '{ width=500px editable=true #unicorn .dangerous .cute }',
}
```


## Licence

MIT