module Rouge

The containing module for Rouge

ABAP elements taken from help.sap.com/abapdocu_750/en/index.htm?file=abapdo.htm

DO NOT EDIT This file is automatically generated by `rake builtins:apache`. See tasks/builtins/apache.rake for more info.

Regular expressions based on github.com/SaswatPadhi/prismjs-bibtex and github.com/alecthomas/chroma/blob/master/lexers/b/bibtex.go

Based on/regexes mostly from Brandon Bennett's pygments-routerlexers: github.com/nemith/pygments-routerlexers

TODO: Implement format list support.

C minus minus (Cmm) is a pun on the name C++. It's an intermediate language of the Glasgow Haskell Compiler (GHC) that is very similar to C, but with many features missing and some special constructs.

Cmm is a dialect of C–. The goal of this lexer is to use what GHC produces and parses (Cmm); C– itself is not supported.

gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/cmm-syntax

See www.cs.cmu.edu/afs/andrew/course/15/411/ghc/share/doc/ghc/ext-core/core.pdf for a description of the syntax of the language and www.aosabook.org/en/ghc.html for a high level overview.

DO NOT EDIT This file is automatically generated by `rake builtins:gherkin`. See tasks/builtins/gherkin.rake for more info.

vim: set ts=2 sw=2 et:

Lexer adapted from github.com/pygments/pygments/blob/ad55974ce83b85dbb333ab57764415ab84169461/pygments/lexers/theorem.py

DO NOT EDIT This file is automatically generated by `rake builtins:lasso`. See tasks/builtins/lasso.rake for more info.

NOTE: This is for Lean 3 (community fork).

DO NOT EDIT This file is automatically generated by `rake builtins:llvm`. See tasks/builtins/llvm.rake for more info.

This file is automatically generated by `rake builtins:lua`. See tasks/builtins/lua.rake for more info.

adapted from lustre.rf (adapted from ocaml.rb), hence some ocaml-ism migth remains

This file is automatically generated by `rake builtins:mathematica`. See tasks/builtins/mathematica.rake for more info.

automatically generated by `rake builtins:matlab`

This file is automatically generated by `rake builtins:matlab`. See tasks/builtins/matlab.rake for more info.

Based on Chroma's MiniZinc lexer: github.com/alecthomas/chroma/blob/5152194c717b394686d3d7a7e1946a360ec0728f/lexers/m/minizinc.go

Based on Chroma's NASM lexer implementation github.com/alecthomas/chroma/blob/498eaa690f5ac6ab0e3d6f46237e547a8935cdc7/lexers/n/nasm.go

DO NOT EDIT This file is automatically generated by `rake builtins:php`. See tasks/builtins/php.rake for more info.

Adapted from pygments PostScriptLexer

DO NOT EDIT This file is automatically generated by `rake builtins:viml`. See tasks/builtins/viml.rake for more info.

this file is not require'd from the root. To use this plugin, run:

require 'rouge/plugins/redcarpet'

TODO how are we going to handle soft/hard contrast?

Constants

LIB_DIR

cache value in a constant since `__dir__` allocates a new string on every call.

Public Class Methods

highlight(text, lexer, formatter, &b) click to toggle source

Highlight some text with a given lexer and formatter.

@example

Rouge.highlight('@foo = 1', 'ruby', 'html')
Rouge.highlight('var foo = 1;', 'js', 'terminal256')

# streaming - chunks become available as they are lexed
Rouge.highlight(large_string, 'ruby', 'html') do |chunk|
  $stdout.print chunk
end
# File lib/rouge.rb, line 28
def highlight(text, lexer, formatter, &b)
  lexer = Lexer.find(lexer) unless lexer.respond_to? :lex
  raise "unknown lexer #{lexer}" unless lexer

  formatter = Formatter.find(formatter) unless formatter.respond_to? :format
  raise "unknown formatter #{formatter}" unless formatter

  formatter.format(lexer.lex(text), &b)
end
load_file(path) click to toggle source

Load a file relative to the `lib/rouge` path.

@api private

# File lib/rouge.rb, line 41
def load_file(path)
  Kernel::load File.join(LIB_DIR, "rouge/#{path}.rb")
end
load_lexers() click to toggle source

Load the lexers in the `lib/rouge/lexers` directory.

@api private

# File lib/rouge.rb, line 48
def load_lexers
  lexer_dir = Pathname.new(LIB_DIR) / "rouge/lexers"
  Pathname.glob(lexer_dir / '*.rb').each do |f|
    Lexers.load_lexer(f.relative_path_from(lexer_dir))
  end
end
reload!() click to toggle source
# File lib/rouge.rb, line 13
def reload!
  Object::send :remove_const, :Rouge
  Kernel::load __FILE__
end
version() click to toggle source
# File lib/rouge/version.rb, line 4
def self.version
  "4.5.1"
end