Last Mate
A rendering engine for tokens generated with TextMate-style grammars. Last Mate is the missing counterpart to atom/first-mate's lexer.
Installing
npm install last-mate
Using
RendererRegistry
To render tokens generated by first-mate use the following code:
var RendererRegistry = RendererRegistry;var registry = ;var renderer = registry;var html = renderer;console;
Outputs
var offset = 3 ;
loadRenderer(rendererPath, callback)
Asynchronously load a renderer and add it to the registry.
rendererPath
- A string path to the renderer file.
callback
- A function to call after the renderer is read and added to the
registry. The callback receives (error, renderer)
arguments.
loadRendererSync(rendererPath)
Synchronously load a renderer and add it to the registry.
rendererPath
- A string path to the renderer file.
Returns a Renderer
instance.
Renderer
renderLines(lineTokens, tagStack=new TagStack())
Render all lines in the given line token array.
lineTokens
- An array of token arrays for each line.
tagStack
- A TagStack object for holding the state of the renderer.
tagStack
- An array of Rule objects that was returned from a previous call
to this method.
Returns a string representation of the line token array rendered with the
body
tag rules defined in this object's markup format.
renderLine(tokens, tagStack=new TagStack())
tokens
- An array of tokens to render.
tagStack
- A TagStack object for holding the state of the renderer.
Returns a string representation of the token array rendered with the line
tag rules defined in this object's markup format.
renderTokens(tokens, tagStack=new TagStack())
tokens
- An array of tokens to render.
tagStack
- A TagStack object for holding the state of the renderer. This
stack will be drained, rendering all closing tags on it, before the
function exits.
Returns a string representation of the token array rendered with the
scope
tag rules defined in this object's markup format.
renderValue(value, tagStack=new TagStack())
tokens
- An array of tokens to render.
tagStack
- A TagStack object for holding the state of the renderer.
Returns a string representation of the token value rendered with the
value
tag rules defined in this object's markup format.
Developing
- Clone the repository
- Run
npm install
- Run
npm test
to run the specs - Run
npm run benchmark
to benchmark fully rendering jQuery 2.0.3 and the CSS for Twitter Bootstrap 3.1.1