@realloon/aura
v0.5.1
Published
A syntax-highlighting library for streaming output.
Downloads
562
Maintainers
Readme
aura
A syntax-highlighting library for streaming output.
Install
npm install @realloon/auraUsage
import { Aura, csharp } from '@realloon/aura'
const aura = new Aura().register([csharp])
const stream = aura.createHighlighter('csharp')
html += stream.write('public sealed cla')
html += stream.write('ss Example {}')
html += stream.end()If the UI does not need HTML, use the language lexer directly to avoid token objects and HTML strings:
const lexer = aura.createLexer('cs')
lexer.write(chunk, (text, scope) => renderToken(text, scope))
lexer.end((text, scope) => renderToken(text, scope))Use with Markflow
Aura can be passed to Markflow to highlight fenced code blocks while Markdown is streaming:
import { Aura, csharp } from '@realloon/aura'
import { MarkdownStream } from '@realloon/markflow'
const aura = new Aura().register([csharp])
const stream = new MarkdownStream({ highlighter: aura })