Giter Club home page Giter Club logo

pointillist's Introduction

Pointillist

Convert Atom stylesheets into Pygments-compatible syntax highlighting.

Creating new languages

You'll need CoffeeScript installed. You'll also need cson installed, globally:

npm install -g cson

With that out of the way, you can now run script/add-language, which takes two arguments:

  1. The GitHub username/repository with a language file you're interested in
  2. The name of the <grammer>.cson file you want to copy.

For example, to fetch Atom's CoffeeScript highlighting, you'd invoke:

script/add-language atom/language-coffee-script coffeescript

That second coffeescript string comes from the fact that the filename under grammars is called coffeescript.cson.

How does it work?

Textpow does most of the heavy lifting. It reads YAML files of TextMate language definitions, and expects a processor to transform a string into some desirable output--in this case, an HTML document with Pygments class names.

Atom's syntax highlighting consists of CSON files generated from TextMate language definitions. We can easily convert this CSON to JSON, and, since JSON is considered a subset of YAML, we can use Textpow's same YAML.load calls to generate a mapping. All this library really does is define a renderer, called pygments.render, which maps TextMate grammar rules to expected HTML. For example:

begin: <span class="c1">
end: </span>
selector: comment.line.number-sign

In this example, when Textpow detects a string falling within a comment.line.number-sign rule, it wraps it up in <span class="c1">.

What if I don't lke Pygments?

Hey, that's cool. The definition for the HTML output is defined as a YAML file. You could write your own render format as an array of keys containing begin, end, and selector.

pointillist's People

Contributors

gjtorikian 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.