Skip to content

Commit 85aec08

Browse files
committed
chore: update readme.md
1 parent 29b23ca commit 85aec08

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

readme.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,37 @@ Please see below example to understand better.
217217
<x-modal>Submit</x-modal>
218218
```
219219

220+
#### Parser options
221+
222+
You may pass options to `posthtml-parser` via `options.parserOptions`.
223+
224+
```js
225+
// index.js
226+
const options = {
227+
root: './src',
228+
parserOptions: { decodeEntities: true }
229+
};
230+
231+
require('posthtml')(require('posthtml-components')(options))
232+
.process('some HTML', options.parserOptions)
233+
.then(/* ... */)
234+
```
235+
236+
Important: as you can see, whatever `parserOptions` you pass to the plugin, must also be passed in the `process` method in your code, otherwise your PostHTML build will use `posthtml-parser` defaults and will override anything you've passed to `posthtml-component`.
237+
238+
#### Self-closing tags
239+
240+
The plugin supports self-closing tags by default, but you need to make sure to enable them in the `process` method in your code too, by passing `recognizeSelfClosing: true` in the options object:
241+
242+
```js
243+
// index.js
244+
require('posthtml')(require('posthtml-components')({root: './src'}))
245+
.process('your HTML...', {recognizeSelfClosing: true})
246+
.then(/* ... */)
247+
```
248+
249+
If you don't add this to `process`, PostHTML will use `posthtml-parser` defaults and will not support self-closing component tags. This will result in everything after a self-closing tag not being output.
250+
220251
### Multiple folders
221252

222253
You have full control where to place your components. Once you set the base root path of your components, you can then set multiple folders.
@@ -292,7 +323,7 @@ const options = {
292323

293324
Use the component namespace:
294325

295-
``` html
326+
```html
296327
<!-- src/index.html -->
297328
<html>
298329
<body>

0 commit comments

Comments
 (0)