{"library":"postcss-inherit-parser","title":"PostCSS Inherit Parser","description":"postcss-inherit-parser is a specialized parser for PostCSS, designed to interpret a custom CSS syntax that facilitates \"inherit\" declarations, specifically in conjunction with the `postcss-inherit` plugin. This parser enables the processing of CSS where rules can leverage inheritance from other selectors, including those with pseudo-classes, as exemplified by syntax like `.a { inherit: .b:before; }`. The package, currently at version 0.2.0, was last published approximately 8 years ago, suggesting it is no longer actively maintained. Its core functionality is to provide the Abstract Syntax Tree (AST) representation for this non-standard inheritance syntax, allowing subsequent PostCSS plugins to apply transformation logic. A key feature is the configurable `propertyRegExp` option, which allows consumers to define custom keywords for inheritance, such as `extend` instead of `inherit`. Given its age and low version, developers should be aware of potential compatibility issues with newer Node.js or PostCSS versions.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install postcss-inherit-parser"],"cli":null},"imports":["const parse = require('postcss-inherit-parser');","const postcss = require('postcss');\nconst inheritParser = require('postcss-inherit-parser');\n\nconst processor = postcss().use(/* your plugins here */);\nconst root = await processor.process(cssInput, { parser: inheritParser }).root;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const postcss = require('postcss');\nconst inheritParser = require('postcss-inherit-parser');\n\nasync function processCssWithInherit() {\n  const cssInput = `\n    .b:before {\n      content: \"\";\n      color: blue;\n    }\n    .a {\n      inherit: .b:before;\n      font-size: 16px;\n    }\n    .c {\n      extend: .a;\n      border: 1px solid black;\n    }\n  `;\n\n  // Use the parser with custom propertyRegExp\n  const root = await postcss().process(cssInput, {\n    from: undefined,\n    parser: inheritParser.parse,\n    parserOptions: { propertyRegExp: /^(inherit|extend)s?$/i }\n  }).root;\n\n  console.log('Parsed AST (first rule selector):', root.nodes[0].selector); // .b:before\n  console.log('Parsed AST (second rule inherit property):', root.nodes[1].nodes[0].prop); // inherit\n  console.log('Parsed AST (third rule extend property):', root.nodes[2].nodes[0].prop); // extend\n\n  // To apply the actual inheritance, you would typically use postcss-inherit as a plugin:\n  const postcssInherit = require('postcss-inherit');\n  const result = await postcss([postcssInherit()]).process(cssInput, {\n    from: undefined,\n    parser: inheritParser.parse,\n    parserOptions: { propertyRegExp: /^(inherit|extend)s?$/i }\n  });\n  console.log('\\nCSS after processing with postcss-inherit:\\n', result.css);\n}\n\nprocessCssWithInherit();","lang":"javascript","description":"This quickstart demonstrates how to use `postcss-inherit-parser` to parse CSS containing custom `inherit` or `extend` declarations, and then how to process it with the `postcss-inherit` plugin to apply the inheritance logic, including customizing the property name regex.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}