Code Monkey home page Code Monkey logo

2001-syntax-highlighter's Introduction

2001-syntax-highlighter

GNU Nano-style syntax highlighting on the web.

Including in your project

The highlighter is written in pure JavaScript, so no additional libraries are required. Just include the highlight and language files inside your .html project.

<link rel=stylesheet href=path/to/Language.css>
<script src=path/to/Language.js></script>
<script src=path/to/2001.js></script>
path/to/ | -> 2001.js
         | -> Language.js
         | -> Language.css

Usage

Insert code you want to highlight between <code> tags, then add the correct language to let the script provide correct colouring.

<code class=Language>
Lorem Ipsum...
</code>

Features

Function
highlight() Adds correct syntax highlighting to all <code> blocks inside the file.

Obtaining text from inside a formatted <code> block

var text = document.getElementById(id).innerText;

Custom syntax highlighting

2001 supports different themes within a language.

  1. *.JS contains the regex and intended color code.
  2. *.CSS matches those color codes into the correct text color. By customising the .CSS file, or creating new files, you can use a different theme for a language.

Contributing

Additional syntax themes for new languages, or new themes for currently supported languages, are always welcome. Ensure you make clear what language your are supporting and the name of your theme inside the pull request in order to get it accepted swiftly.

2001-syntax-highlighter's People

Contributors

cutwell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.