Skip to content

Commit 3de645e

Browse files
committed
add(doc): add Syntax section
1 parent e4abc9f commit 3de645e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,57 @@ There is a [known bug in remark-react](https://github.com/mapbox/remark-react/is
4646
A [PR](https://github.com/mapbox/remark-react/pull/43) is in waiting, do not hesitate to upvote it !
4747
The [corresponding issue is here](https://github.com/medfreeman/remark-generic-extensions/issues/9).
4848

49+
50+
## Syntax
51+
52+
`!Extension[Content](Argument){Properties}`
53+
54+
:information_source: The extension syntax is validated through [regexes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp), that you can inspect [here](https://github.com/medfreeman/remark-generic-extensions/blob/master/src/utils/regexes.js) if needed
55+
56+
- `Extension` defines the element you want to use
57+
58+
It matches the `\w` character class.
59+
60+
```
61+
Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_].
62+
```
63+
64+
- `Content` defines the element content
65+
66+
It matches everything but the `]` character.
67+
68+
It can be mapped to any hast element property or value, see [placeholders](#placeholders).
69+
70+
- `Argument` defines the element argument
71+
72+
It matches everything but the `)` character.
73+
74+
It can be mapped to any hast element property or value, see [placeholders](#placeholders).
75+
76+
- `Properties` defines the element properties
77+
78+
They can have leading and / or trailing spaces before / after the opening / closing braces.
79+
80+
The different properties are separated by spaces, and so each of them match any character but spaces, except for quoted properties.
81+
82+
### Available properties
83+
84+
- id: `#my-id`
85+
86+
It will be applied to the top-level hast element.
87+
- class: `.my-class .my-other-class`
88+
89+
It will be applied to the top-level hast element.
90+
- key / value property: `my-prop=my-value`
91+
92+
It can be mapped to any hast element property or value, see [placeholders](#placeholders).
93+
- key / value quoted property: `my-other-prop="my value with spaces"`
94+
95+
It can be mapped to any hast element property or value, see [placeholders](#placeholders).
96+
- lone property: `my-alone-prop`
97+
98+
It can be mapped to any hast element property or value, see [placeholders](#placeholders).
99+
49100
## Installation
50101

51102
```bash

0 commit comments

Comments
 (0)