Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

midas

ben-eb8.1kMIT2.0.3

Syntax highlighter based on PostCSS.

css, highlight, postcss

readme


midas


A CSS syntax highlighter based on PostCSS.

Build Status NPM version Dependency Status

midas generates a highly customisable base for syntax highlighting in HTML. Simply pass in a CSS string and it will generate a HTML output. You can then pair it with any of the included themes, or just as easily write your own.

For further details, check out the website!

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

Please help to support this project by purchasing a midas sticker.

License

Base 16 themes used by this module are MIT © 2012 Chris Kempson & contributors.

MIT © Ben Briggs

changelog

2.0.3

  • Resolves an issue where a namespace would not appear in the output - e.g. islands|div would simply show div.

2.0.2

  • Better handling of spaces within at-rule parameters.

2.0.1

  • Update hast-util-to-html to version 3.
  • Resolves an issue where named functions inside at-rule parameters would not be properly highlighted.

2.0.0

  • Adds the ability to render a virtual DOM. A new option, stringify is provided, which will yield the internal HAST to the supplied function. By default this uses hast-util-to-html, so that you can use Midas to render HTML as before. But, if false is passed instead, Midas will return the HAST instead of a string; this makes it easy to use in libraries that rely on virtual DOM, such as React.

Breaking changes

  • The main midas export is now a constructor function Midas which accepts an options object, and exposes a .stringifier property for PostCSS usage and a process method for other usage.
  • Midas cannot be passed in directly to PostCSS anymore, you must instantiate it and then pass the instance's stringifier property to PostCSS.
  • The wrap option will now wrap the root <code></code> node with <pre class="midas"></pre>. Unlike before, setting this to false will not remove the <code></code> from the string, as virtual DOM requires a single root element.
  • The CLI for this module does not make sense now that Midas can yield virtual DOM as well as the previous behaviour of returning a string. It has been removed entirely.

1.2.2

  • midas did not properly parse certain custom media queries and would crash in certain cases; this has now been fixed.

1.2.1

  • Update postcss-value-parser to v3.3.0.
  • Update postcss-selector-parser to v2.0.0.
  • midas will now render spaces before/after function parentheses accurately. e.g. filter: blur( 5px ) will now render with the extra spaces.
  • Now compiled with Babel 6.

1.2.0

  • Adds a wrap option to enable configuration of the HTML container used by midas.
  • Bump dependencies.

1.1.2

  • Fixes parsing of media query parameters since the recent update to postcss-value-parser.

1.1.1

  • CLI command was added to the npm distribution.

1.1.0

  • midas can now be consumed by an existing PostCSS instance.

1.0.0

  • Initial release.