# md-attr-parser

> A parser for markdown's attributes

Latest version **1.3.0** (published 2019-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install md-attr-parser
pnpm add md-attr-parser
yarn add md-attr-parser
bun add md-attr-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2019-09-17 |
| First published | 2018-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ache |
| Maintainers | ache |
| Keywords | markdown, attribute, plugin |

## Links

- npm: https://www.npmjs.com/package/md-attr-parser
- Repository: https://github.com/arobase-che/md-attr-parser
- Homepage: https://github.com/arobase-che/md-attr-parser#readme
- Issues: https://github.com/arobase-che/md-attr-parser/issues
- npm.io page: https://npm.io/package/md-attr-parser

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2019-09-17
- 1.2.1 — 2019-01-03
- 1.2.0 — 2018-11-08
- 1.1.6 — 2018-10-18
- 1.1.5 — 2018-04-24
- 1.1.4 — 2018-04-24
- 1.1.3 — 2018-04-24
- 1.1.2 — 2018-04-24
- 1.1.1 — 2018-04-24
- 1.1.0 — 2018-04-23

## README

md-attr-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('md-attr-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 }',
}
```

### Advanced usage

The parsing can start at a positive offset.

```js
parseAttr('SYNTAX{ width=500px editable=true }', len('SYNTAX'));
```

A configuration can also be specified, actualy, there is only one configuration option.
The default value of key without value.

```js
parseAttr('{ width=500px editable }', 0, {defaultValue: true});
// or
parseAttr('{ width=500px editable }', 0, {defaultValue: key => 'NO_VALUE_FOR_'+key.toUpperCase()});
```

## Licence

MIT

---
_Source: https://npm.io/package/md-attr-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
