Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@favware/syntax-highlighter-react

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@favware/syntax-highlighter-react

React bindings for @favware/syntax-highlighter-core

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
2
Created
Source

logo

@favware/syntax-highlighter-react

A lightweight, easy-to-use and framework agnostic syntax highlighter for your code examples(snippets) in web applications

License Depfu Patreon

npm npm

Stencil

Support Server

Table of Contents

Why yet another code highlighter?

There are many syntax highlighters avaliable already but most of those are either complex to setup or front end framework specific. @favware/syntax-highlighter-react is built using StencilJS. You can use it everywhere, i.e. Angular, React, Vue, any framework, No Framework!

This is an adoptation of snippet-highlight from rahulbhooteshwar

Features

  • Uses PrismJS for syntax highlighting
  • Light and Dark mode supported
  • Copy code support
  • Supports many languages, see Supported Languages
  • Will default to using Fira Code as font family
    • The library first falls back to popular fonts such as Cascadia Code and Meslo NGF if it isn't available. If these are also not available it will go through various more popular coding fonts, ending in monospace

Installation

yarn add @favware/syntax-highlighter-react @favware/syntax-highlighter-react
# or npm install @favware/syntax-highlighter-react @favware/syntax-highlighter-react

Usage

Edit Button

The syntax is kept fairly simple. Here's a basic example of some simple JavaScript code:

import { SyntaxHighlighter } from '@favware/syntax-highlighter-react';

<SyntaxHighlighter theme="dark" language="javascript" content="import { SyntaxHighlighter } from @favware/syntax-highlighter-react" />;

Supported Languages

To limit the size of this library a selection has been made from all langauges supported by PrismJS. The chosen languages are those that we consider the most popular / common. If you want to see another languages supported you're always free to open an issue

javascript, typescript, asciidoc, autohotkey, autoit, bash, batch,
 
c, clike, clojure, coffeescript, cpp, csharp, csp, css, dart,
 
diff, docker, elixir, gherkin, git, go, graphql, groovy, http,
 
ini, java, json, jsx, kotlin, less, lua, makefile, markdown,
 
nginx, objectivec, powershell, python, ruby, rust, sass, scala,
 
scss, sql, swift, tsx, vim, visual-basic, wasm, wiki, yaml

Screenshots

Dark Mode

Light Mode

Keywords

favware

FAQs

Package last updated on 19 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts