• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a syntax highlighter for react native using https://github.com/conorhastings/react-syntax-highlighter under the hood

React Native Syntax Highlighter

Syntax highlighting component for React Native using react-syntax-highlighter

You can see a demo using snack by Expo

Alternatively you can scan this qr code in The Expo app to access on your phone:

With Highlight.js vdom

With Prism vdom

You can try it out with Expo here

Install

npm install react-native-syntax-highlighter --save

Use

props

Accepts all of the same props as react-syntax-highlighter with three additional props.

  • fontFamily - the font family to use for syntax text.
  • fontSize - the fontSize for syntax text.
  • highligter - defaults to rendering with vdom created from highlightjs, but can pass in prism as alternate option. You can see more about dealing with the prism highlighter in the docs for react-syntax-highlighter but one of the main uses would be better support for jsx
import SyntaxHighlighter from 'react-native-syntax-highlighter';
/*by default component uses hljs so access hljs styles, import from /prism for prism styles */
import { docco } from 'react-syntax-highlighter/styles/hljs';
const Component = () => {
  const codeString = '(num) => num + 1';
  return <SyntaxHighlighter 
  	language='javascript' 
  	style={docco}
  	highlighter={"prism" || "hljs"}
  >
  	{codeString}
  </SyntaxHighlighter>;  
}

Unsupported Props

Some of the react-syntax-highlighter props are not currently supported by the mobile version, you can see which listed below:

  • useInlineStyles
  • showLineNumbers
  • startingLineNumber
  • lineNumberContainerStyle
  • lineNumberStyle

Styles Available -- hljs

  • agate
  • androidstudio
  • arduinoLight
  • arta
  • ascetic
  • atelierCaveDark
  • atelierCaveLight
  • atelierDuneDark
  • atelierDuneLight
  • atelierEstuaryDark
  • atelierEstuaryLight
  • atelierForestDark
  • atelierForestLight
  • atelierHeathDark
  • atelierHeathLight
  • atelierLakesideDark
  • atelierLakesideLight
  • atelierPlateauDark
  • atelierPlateauLight
  • atelierSavannaDark
  • atelierSavannaLight
  • atelierSeasideDark
  • atelierSeasideLight
  • atelierSulphurpoolDark
  • atelierSulphurpoolLight
  • atomOneDark
  • atomOneLight
  • brownPaper
  • codepenEmbed
  • colorBrewer
  • darcula
  • dark
  • darkula
  • defaultStyle
  • docco
  • dracula
  • far
  • foundation
  • githubGist
  • github
  • googlecode
  • grayscale
  • gruvboxDark
  • gruvboxLight
  • hopscotch
  • hybrid
  • idea
  • irBlack
  • kimbieDark
  • kimbieLight
  • magula
  • monoBlue
  • monokaiSublime
  • monokai
  • obsidian
  • ocean
  • paraisoDark
  • paraisoLight
  • pojoaque
  • purebasic
  • qtcreatorDark
  • qtcreatorLight
  • railscasts
  • rainbow
  • routeros
  • schoolBook
  • solarizedDark
  • solarizedLight
  • sunburst
  • tomorrowNightBlue
  • tomorrowNightBright
  • tomorrowNightEighties
  • tomorrowNight
  • tomorrow
  • vs
  • vs2015
  • xcode
  • xt256
  • zenburn

Styles Available -- prism

  • coy
  • dark
  • funky
  • okaidia
  • solarizedlight
  • tomorrow
  • twilight
  • prism
  • atomDark
  • base16AteliersulphurpoolLight
  • cb
  • darcula
  • duotoneDark
  • duotoneEarth
  • duotoneForest
  • duotoneLight
  • duotoneSea
  • duotoneSpace
  • ghcolors
  • hopscotch
  • pojoaque
  • vs
  • xonokai

More Repositories

1

redux-test-recorder

a redux middleware to automatically generate tests for reducers through ui interaction
JavaScript
495
star
2

routeql

backend agnostic, graphql style colocation of data requests in React
JavaScript
122
star
3

react-emoji-react

a clone of slack emoji reactions in react
JavaScript
120
star
4

use-reducer-with-side-effects

JavaScript
88
star
5

react-syntax-highlighter-virtualized-renderer

a way to use react-virtualized to render lines of code for react-syntax-highlighter
JavaScript
31
star
6

react-component-demo

A React Component To make live editable demos of other React Components
JavaScript
24
star
7

remove-flow-types-loader

JavaScript
20
star
8

react-close-on-escape

higher order component to close other react component on press of escape key (or fire whatever function you want but probably it should close)
JavaScript
14
star
9

react-thermometer

a simple thermometer gauge component (does not tell temperature)
JavaScript
12
star
10

apply-loader-after-first-build-webpack-plugin

a webpack plugin that allows you to dynamically add a loader after the initial build has occurred (useful when using watch) and want to do something like lint only changed and new files
JavaScript
5
star
11

redux-test-recorder-react

component providing a gui for redux-test-recorder in react applications
JavaScript
4
star
12

react-code-window

JavaScript
3
star
13

put-stuff-on-website

JavaScript
3
star
14

whitelist-object

a small module for reducing an object to only the desired keys
JavaScript
3
star
15

match-default

JavaScript
3
star
16

github-stars-elm

get total github stars for user , learning elm by writing elm
Elm
3
star
17

redux-session-storage

redux middleware for recording redux actions for a particular session to session storage
JavaScript
3
star
18

react-one-of

take in a set of components and make sure only one is rendered.
JavaScript
3
star
19

react-allowed

a react component that calls a function prop isAllowed to determine whether or not to render children
JavaScript
3
star
20

get-emoji

give emoji name get emoji image
JavaScript
2
star
21

storybook-addon-react-profiler

JavaScript
2
star
22

redux-connected-proptypes

an interface for defining React component props using redux, react-redux and PropTypes
JavaScript
2
star
23

react-async-branch

a component that will asynchronously load, one of two components based on a condition
JavaScript
2
star
24

react-test-generator

generate basic sanity check tests for react components, major WIP, ready to be used by someone, who knows when?
JavaScript
2
star
25

netflix-originals

a react calendar app for netflix original movie releases
JavaScript
2
star
26

react-expiration

A simple component that uses a render callback to expose if a the current date is past a user set expirationDate
JavaScript
2
star
27

clojurescript

learning clojurescript
Clojure
1
star
28

object-value-equality

JavaScript
1
star
29

state-reducers-hook

manage state by dispatching changes using react hooks
TypeScript
1
star
30

AgeComparer

Compare your age to the ages to the average age of professional athletes and become depressed about how relatively old you are in comparison.
JavaScript
1
star
31

object-description-filter

filter nested object based on descriptor object
JavaScript
1
star
32

version-upgrade

don't manually go through all of the different places your node version is stored, let this do it for you!
JavaScript
1
star
33

highlight-code

a javascript module to add syntax highlighting to a code string, uses inline styles for encapsulation
JavaScript
1
star
34

is-today-the-day-that-the-birth-of-jesus-is-celebrated

JavaScript
1
star
35

elm-md

a markdown editor written in elm
Elm
1
star
36

react-app-init

an opinionated, declarative way to start a react/redux app.
JavaScript
1
star
37

use-worker-hook

JavaScript
1
star
38

react-style-px-suffix-codemod

append px to shorthand values in style objects in react in prep for react 15 warning
JavaScript
1
star
39

GIF-Framer

takes in an animated gif and returns all the frames as individual images
JavaScript
1
star
40

highlight.js-js-styles

all of highlight.js css stylesheets as javascript objects
JavaScript
1
star