{"repo":"wooorm/refractor","free":true,"listed":false,"github":"https://github.com/wooorm/refractor","clone":"git clone https://github.com/wooorm/refractor.git","description":"Lightweight, robust, elegant virtual syntax highlighting using Prism","language":"JavaScript","stars":868,"topics":["syntax-highlighting","virtual-dom","vdom","react","hast","virtual","syntax","highlight","html"],"license":"MIT","category":"ui-components","readme_excerpt":"refractor [![Build][badge-build-image]][badge-build-url] [![Coverage][badge-coverage-image]][badge-coverage-url] [![Downloads][badge-downloads-image]][badge-downloads-url] [![Size][badge-size-image]][badge-size-url] Lightweight, robust, and elegant virtual syntax highlighting using [Prism][github-prism]. Contents What is this? When should I use this? Playground Install Use API refractor Syntax Examples Example: serializing hast as html Example: turning hast into react nodes Data CSS Compatibility Security Related Projects Contribute What is this? This package wraps [Prism][github-prism] to output objects (ASTs) instead of a string of HTML. Prism, through refractor, supports 290+ programming languages. Supporting all of them requires a lot of code. That’s why there are three entry points for refractor: refractor/all — 297 languages refractor/core — 0 languages refractor (default) — 36 common languages Bundled, minified, and gzipped, those are roughly 12.7 kB (core), 40 kB (default), and 211 kB (all). When should I use this? This package is useful when you want to perform syntax highlighting in a place where serialized HTML wouldn’t work or wouldn’t work well. For example, you can use refractor when you want to show code in a CLI by rendering to ANSI sequences, when you’re using virtual DOM frameworks (such as React or Preact) so that diffing can be performant, or when you’re working with ASTs (rehype). A different package, [ lowlight ][github-lowlight], does the same as refrac","default_branch":null,"files":null,"tree":[],"storefront":"/r/wooorm","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/wooorm/refractor/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}