## Parser You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object][1] ```js const editor = grapesjs.init({ parser: { // options } }) ``` Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance ```js const { Parser } = editor; ``` ## Available Events * `parse:html` On HTML parse, an object containing the input and the output of the parser is passed as an argument. ```javascript editor.on('parse:html', ({ input, output }) => { ... }); ``` * `parse:html:before` Event triggered before the HTML parsing starts. An object containing the input is passed as an argument. ```javascript editor.on('parse:html:before', (options) => { console.log('Parser input', options.input); // You can also process the input and update `options.input` options.input += '
Extra content
'; }); ``` * `parse:css` On CSS parse, an object containing the input and the output of the parser is passed as an argument. ```javascript editor.on('parse:css', ({ input, output }) => { ... }); ``` * `parse:css:before` Event triggered before the CSS parsing starts. An object containing the input is passed as an argument. ```javascript editor.on('parse:css:before', (options) => { console.log('Parser input', options.input); // You can also process the input and update `options.input` options.input += '.my-class { color: red; }'; }); ``` * `parse` Catch-all event for all the events mentioned above. An object containing all the available data about the triggered event is passed as an argument to the callback. ```javascript editor.on('parse', ({ event, ... }) => { ... }); ``` ## Methods * [getConfig][2] * [parseHtml][3] * [parseCss][4] ## getConfig Get configuration object Returns **[Object][5]** ## parseHtml Parse HTML string and return the object containing the Component Definition ### Parameters * `input` **[String][6]** HTML string to parse * `options` **[Object][5]?** Options (optional, default `{}`) * `options.htmlType` **[String][6]?** [HTML mime type][7] to parse * `options.allowScripts` **[Boolean][8]** Allow `