rouge-3.15.0/0000755000004100000410000000000013610424007012746 5ustar www-datawww-datarouge-3.15.0/bin/0000755000004100000410000000000013610424007013516 5ustar www-datawww-datarouge-3.15.0/bin/rougify0000755000004100000410000000065513610424007015136 0ustar www-datawww-data#!/usr/bin/env ruby # frozen_string_literal: true require 'pathname' ROOT_DIR = Pathname.new(__FILE__).dirname.parent load ROOT_DIR.join('lib/rouge.rb') load ROOT_DIR.join('lib/rouge/cli.rb') Signal.trap('PIPE', 'SYSTEM_DEFAULT') if Signal.list.include? 'PIPE' begin Rouge::CLI.parse(ARGV).run rescue Rouge::CLI::Error => e puts e.message exit e.status rescue Interrupt $stderr.puts "\nrouge: interrupted" exit 2 end rouge-3.15.0/LICENSE0000644000004100000410000001577613610424007013773 0ustar www-datawww-data# MIT license. See http://www.opensource.org/licenses/mit-license.php Copyright (c) 2012 Jeanine Adkisson. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SPECIAL NOTE: Many of the lexers in this project are adaptations of those in Pygments (pygments.org). The license for Pygments is as follows: # BEGIN pygments/LICENSE # Copyright (c) 2006-2012 by the respective authors (see AUTHORS file). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # END pygments/LICENSE # The contents of the AUTHORS file at the time of porting was: # BEGIN pygments/AUTHORS # Pygments is written and maintained by Georg Brandl . Major developers are Tim Hatch and Armin Ronacher . Other contributors, listed alphabetically, are: * Sam Aaron -- Ioke lexer * Kumar Appaiah -- Debian control lexer * Ali Afshar -- image formatter * Andreas Amann -- AppleScript lexer * Jeffrey Arnold -- R/S lexer, BUGS lexers * Jeremy Ashkenas -- CoffeeScript lexer * Stefan Matthias Aust -- Smalltalk lexer * Ben Bangert -- Mako lexers * Max Battcher -- Darcs patch lexer * Paul Baumgart, 280 North, Inc. -- Objective-J lexer * Michael Bayer -- Myghty lexers * John Benediktsson -- Factor lexer * Christopher Bertels -- Fancy lexer * Jarrett Billingsley -- MiniD lexer * Adam Blinkinsop -- Haskell, Redcode lexers * Frits van Bommel -- assembler lexers * Pierre Bourdon -- bugfixes * Hiram Chirino -- Scaml and Jade lexers * Leaf Corcoran -- MoonScript lexer * Christopher Creutzig -- MuPAD lexer * Pete Curry -- bugfixes * Owen Durni -- haXe lexer * Nick Efford -- Python 3 lexer * Sven Efftinge -- Xtend lexer * Artem Egorkine -- terminal256 formatter * James H. Fisher -- PostScript lexer * Carlos Galdino -- Elixir and Elixir Console lexers * Naveen Garg -- Autohotkey lexer * Laurent Gautier -- R/S lexer * Alex Gaynor -- PyPy log lexer * Bertrand Goetzmann -- Groovy lexer * Krzysiek Goj -- Scala lexer * Matt Good -- Genshi, Cheetah lexers * Patrick Gotthardt -- PHP namespaces support * Olivier Guibe -- Asymptote lexer * Martin Harriman -- SNOBOL lexer * Matthew Harrison -- SVG formatter * Steven Hazel -- Tcl lexer * Aslak Hellesøy -- Gherkin lexer * Greg Hendershott -- Racket lexer * Jordi Gutiérrez Hermoso -- Octave lexer * David Hess, Fish Software, Inc. -- Objective-J lexer * Varun Hiremath -- Debian control lexer * Doug Hogan -- Mscgen lexer * Ben Hollis -- Mason lexer * Tim Howard -- BlitzMax lexer * Ivan Inozemtsev -- Fantom lexer * Brian R. Jackson -- Tea lexer * Dennis Kaarsemaker -- sources.list lexer * Igor Kalnitsky -- vhdl lexer * Eric Knibbe -- Lasso lexer * Adam Koprowski -- Opa lexer * Benjamin Kowarsch -- Modula-2 lexer * Alexander Kriegisch -- Kconfig and AspectJ lexers * Marek Kubica -- Scheme lexer * Jochen Kupperschmidt -- Markdown processor * Gerd Kurzbach -- Modelica lexer * Olov Lassus -- Dart lexer * Sylvestre Ledru -- Scilab lexer * Mark Lee -- Vala lexer * Ben Mabey -- Gherkin lexer * Simone Margaritelli -- Hybris lexer * Kirk McDonald -- D lexer * Gordon McGregor -- SystemVerilog lexer * Stephen McKamey -- Duel/JBST lexer * Brian McKenna -- F# lexer * Lukas Meuser -- BBCode formatter, Lua lexer * Paul Miller -- LiveScript lexer * Hong Minhee -- HTTP lexer * Michael Mior -- Awk lexer * Jon Morton -- Rust lexer * Paulo Moura -- Logtalk lexer * Mher Movsisyan -- DTD lexer * Ana Nelson -- Ragel, ANTLR, R console lexers * Nam T. Nguyen -- Monokai style * Jesper Noehr -- HTML formatter "anchorlinenos" * Mike Nolta -- Julia lexer * Jonas Obrist -- BBCode lexer * David Oliva -- Rebol lexer * Jon Parise -- Protocol buffers lexer * Ronny Pfannschmidt -- BBCode lexer * Benjamin Peterson -- Test suite refactoring * Dominik Picheta -- Nimrod lexer * Clément Prévost -- UrbiScript lexer * Kashif Rasul -- CUDA lexer * Justin Reidy -- MXML lexer * Norman Richards -- JSON lexer * Lubomir Rintel -- GoodData MAQL and CL lexers * Andre Roberge -- Tango style * Konrad Rudolph -- LaTeX formatter enhancements * Mario Ruggier -- Evoque lexers * Stou Sandalski -- NumPy, FORTRAN, tcsh and XSLT lexers * Matteo Sasso -- Common Lisp lexer * Joe Schafer -- Ada lexer * Ken Schutte -- Matlab lexers * Tassilo Schweyer -- Io, MOOCode lexers * Joerg Sieker -- ABAP lexer * Robert Simmons -- Standard ML lexer * Kirill Simonov -- YAML lexer * Steve Spigarelli -- XQuery lexer * Jerome St-Louis -- eC lexer * James Strachan -- Kotlin lexer * Tiberius Teng -- default style overhaul * Jeremy Thurgood -- Erlang, Squid config lexers * Erick Tryzelaar -- Felix lexer * Daniele Varrazzo -- PostgreSQL lexers * Abe Voelker -- OpenEdge ABL lexer * Whitney Young -- ObjectiveC lexer * Matthias Vallentin -- Bro lexer * Nathan Weizenbaum -- Haml and Sass lexers * Dietmar Winkler -- Modelica lexer * Nils Winter -- Smalltalk lexer * Davy Wybiral -- Clojure lexer * Diego Zamboni -- CFengine3 lexer * Alex Zimin -- Nemerle lexer Many thanks for all contributions! # END pygments/AUTHORS # rouge-3.15.0/lib/0000755000004100000410000000000013610424007013514 5ustar www-datawww-datarouge-3.15.0/lib/rouge/0000755000004100000410000000000013610424007014635 5ustar www-datawww-datarouge-3.15.0/lib/rouge/formatter.rb0000644000004100000410000000464113610424007017172 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge # A Formatter takes a token stream and formats it for human viewing. class Formatter # @private REGISTRY = {} # Specify or get the unique tag for this formatter. This is used # for specifying a formatter in `rougify`. def self.tag(tag=nil) return @tag unless tag REGISTRY[tag] = self @tag = tag end # Find a formatter class given a unique tag. def self.find(tag) REGISTRY[tag] end def self.with_escape Thread.current[:'rouge/with-escape'] = true yield ensure Thread.current[:'rouge/with-escape'] = false end def self.escape_enabled? !!(((defined? @escape_enabled) && @escape_enabled) || Thread.current[:'rouge/with-escape']) end def self.enable_escape! @escape_enabled = true end def self.disable_escape! @escape_enabled = false Thread.current[:'rouge/with-escape'] = false end # Format a token stream. Delegates to {#format}. def self.format(tokens, *a, &b) new(*a).format(tokens, &b) end def initialize(opts={}) # pass end def escape?(tok) tok == Token::Tokens::Escape end def filter_escapes(tokens) tokens.each do |t, v| if t == Token::Tokens::Escape yield Token::Tokens::Error, v else yield t, v end end end # Format a token stream. def format(tokens, &b) tokens = enum_for(:filter_escapes, tokens) unless Formatter.escape_enabled? return stream(tokens, &b) if block_given? out = String.new('') stream(tokens) { |piece| out << piece } out end # @deprecated Use {#format} instead. def render(tokens) warn 'Formatter#render is deprecated, use #format instead.' format(tokens) end # @abstract # yield strings that, when concatenated, form the formatted output def stream(tokens, &b) raise 'abstract' end protected def token_lines(tokens, &b) return enum_for(:token_lines, tokens) unless block_given? out = [] tokens.each do |tok, val| val.scan %r/\n|[^\n]+/ do |s| if s == "\n" yield out out = [] else out << [tok, s] end end end # for inputs not ending in a newline yield out if out.any? end end end rouge-3.15.0/lib/rouge/formatters/0000755000004100000410000000000013610424007017023 5ustar www-datawww-datarouge-3.15.0/lib/rouge/formatters/html_line_table.rb0000644000004100000410000000446313610424007022501 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class HTMLLineTable < Formatter tag 'html_line_table' # @param [Rouge::Formatters::Formatter] formatter An instance of a # `Rouge::Formatters::HTML` or `Rouge::Formatters::HTMLInline` # @param [Hash] opts options for HTMLLineTable instance. # @option opts [Integer] :start_line line number to start from. Defaults to `1`. # @option opts [String] :table_class Class name for the table. # Defaults to `"rouge-line-table"`. # @option opts [String] :line_id a `sprintf` template for generating an `id` # attribute for each table row corresponding to current line number. # Defaults to `"line-%i"`. # @option opts [String] :line_class Class name for each table row. # Defaults to `"lineno"`. # @option opts [String] :gutter_class Class name for rendered line-number cell. # Defaults to `"rouge-gutter"`. # @option opts [String] :code_class Class name for rendered code cell. # Defaults to `"rouge-code"`. def initialize(formatter, opts={}) @formatter = formatter @start_line = opts.fetch :start_line, 1 @table_class = opts.fetch :table_class, 'rouge-line-table' @gutter_class = opts.fetch :gutter_class, 'rouge-gutter' @code_class = opts.fetch :code_class, 'rouge-code' @line_class = opts.fetch :line_class, 'lineno' @line_id = opts.fetch :line_id, 'line-%i' end def stream(tokens, &b) lineno = @start_line - 1 buffer = [%()] token_lines(tokens) do |line_tokens| lineno += 1 buffer << %() buffer << %() buffer << %(" end buffer << %(
) buffer << %(
#{lineno}
)
          @formatter.stream(line_tokens) { |formatted| buffer << formatted }
          buffer << "\n
) yield buffer.join end end end end rouge-3.15.0/lib/rouge/formatters/html_inline.rb0000644000004100000410000000135013610424007021651 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class HTMLInline < HTML tag 'html_inline' def initialize(theme) if theme.is_a?(Class) && theme < Rouge::Theme @theme = theme.new elsif theme.is_a?(Rouge::Theme) @theme = theme elsif theme.is_a?(String) @theme = Rouge::Theme.find(theme).new else raise ArgumentError, "invalid theme: #{theme.inspect}" end end def safe_span(tok, safe_val) return safe_val if tok == Token::Tokens::Text rules = @theme.style_for(tok).rendered_rules "#{safe_val}" end end end end rouge-3.15.0/lib/rouge/formatters/html_legacy.rb0000644000004100000410000000260513610424007021643 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true # stdlib require 'cgi' module Rouge module Formatters # Transforms a token stream into HTML output. class HTMLLegacy < Formatter tag 'html_legacy' # @option opts [String] :css_class ('highlight') # @option opts [true/false] :line_numbers (false) # @option opts [Rouge::CSSTheme] :inline_theme (nil) # @option opts [true/false] :wrap (true) # # Initialize with options. # # If `:inline_theme` is given, then instead of rendering the # tokens as tags with CSS classes, the styles according to # the given theme will be inlined in "style" attributes. This is # useful for formats in which stylesheets are not available. # # Content will be wrapped in a tag (`div` if tableized, `pre` if # not) with the given `:css_class` unless `:wrap` is set to `false`. def initialize(opts={}) @formatter = opts[:inline_theme] ? HTMLInline.new(opts[:inline_theme]) : HTML.new @formatter = HTMLTable.new(@formatter, opts) if opts[:line_numbers] if opts.fetch(:wrap, true) @formatter = HTMLPygments.new(@formatter, opts.fetch(:css_class, 'codehilite')) end end # @yield the html output. def stream(tokens, &b) @formatter.stream(tokens, &b) end end end end rouge-3.15.0/lib/rouge/formatters/null.rb0000644000004100000410000000055513610424007020327 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters # A formatter which renders nothing. class Null < Formatter tag 'null' def initialize(*) end def stream(tokens, &b) tokens.each do |tok, val| yield "#{tok.qualname} #{val.inspect}\n" end end end end end rouge-3.15.0/lib/rouge/formatters/html_linewise.rb0000644000004100000410000000117113610424007022213 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class HTMLLinewise < Formatter def initialize(formatter, opts={}) @formatter = formatter @tag_name = opts.fetch(:tag_name, 'div') @class_format = opts.fetch(:class, 'line-%i') end def stream(tokens, &b) lineno = 0 token_lines(tokens) do |line_tokens| yield %(<#{@tag_name} class="#{sprintf @class_format, lineno += 1}">) @formatter.stream(line_tokens) {|formatted| yield formatted } yield %(\n) end end end end end rouge-3.15.0/lib/rouge/formatters/terminal256.rb0000644000004100000410000001162013610424007021420 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters # A formatter for 256-color terminals class Terminal256 < Formatter tag 'terminal256' # @private attr_reader :theme # @param [Hash,Rouge::Theme] theme # the theme to render with. def initialize(theme = Themes::ThankfulEyes.new) if theme.is_a?(Rouge::Theme) @theme = theme elsif theme.is_a?(Hash) @theme = theme[:theme] || Themes::ThankfulEyes.new else raise ArgumentError, "invalid theme: #{theme.inspect}" end end def stream(tokens, &b) tokens.each do |tok, val| escape = escape_sequence(tok) yield escape.style_string yield val.gsub("\n", "#{escape.reset_string}\n#{escape.style_string}") yield escape.reset_string end end class EscapeSequence attr_reader :style def initialize(style) @style = style end def self.xterm_colors @xterm_colors ||= [].tap do |out| # colors 0..15: 16 basic colors out << [0x00, 0x00, 0x00] # 0 out << [0xcd, 0x00, 0x00] # 1 out << [0x00, 0xcd, 0x00] # 2 out << [0xcd, 0xcd, 0x00] # 3 out << [0x00, 0x00, 0xee] # 4 out << [0xcd, 0x00, 0xcd] # 5 out << [0x00, 0xcd, 0xcd] # 6 out << [0xe5, 0xe5, 0xe5] # 7 out << [0x7f, 0x7f, 0x7f] # 8 out << [0xff, 0x00, 0x00] # 9 out << [0x00, 0xff, 0x00] # 10 out << [0xff, 0xff, 0x00] # 11 out << [0x5c, 0x5c, 0xff] # 12 out << [0xff, 0x00, 0xff] # 13 out << [0x00, 0xff, 0xff] # 14 out << [0xff, 0xff, 0xff] # 15 # colors 16..232: the 6x6x6 color cube valuerange = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff] 217.times do |i| r = valuerange[(i / 36) % 6] g = valuerange[(i / 6) % 6] b = valuerange[i % 6] out << [r, g, b] end # colors 233..253: grayscale 1.upto 22 do |i| v = 8 + i * 10 out << [v, v, v] end end end def fg return @fg if instance_variable_defined? :@fg @fg = style.fg && self.class.color_index(style.fg) end def bg return @bg if instance_variable_defined? :@bg @bg = style.bg && self.class.color_index(style.bg) end def style_string @style_string ||= begin attrs = [] attrs << ['38', '5', fg.to_s] if fg attrs << ['48', '5', bg.to_s] if bg attrs << '01' if style[:bold] attrs << '04' if style[:italic] # underline, but hey, whatevs escape(attrs) end end def reset_string @reset_string ||= begin attrs = [] attrs << '39' if fg # fg reset attrs << '49' if bg # bg reset attrs << '00' if style[:bold] || style[:italic] escape(attrs) end end private def escape(attrs) return '' if attrs.empty? "\e[#{attrs.join(';')}m" end def self.color_index(color) @color_index_cache ||= {} @color_index_cache[color] ||= closest_color(*get_rgb(color)) end def self.get_rgb(color) color = $1 if color =~ /#([0-9a-f]+)/i hexes = case color.size when 3 color.chars.map { |c| "#{c}#{c}" } when 6 color.scan(/../) else raise "invalid color: #{color}" end hexes.map { |h| h.to_i(16) } end # max distance between two colors, #000000 to #ffffff MAX_DISTANCE = 257 * 257 * 3 def self.closest_color(r, g, b) @@colors_cache ||= {} key = (r << 16) + (g << 8) + b @@colors_cache.fetch(key) do distance = MAX_DISTANCE match = 0 xterm_colors.each_with_index do |(cr, cg, cb), i| d = (r - cr)**2 + (g - cg)**2 + (b - cb)**2 next if d >= distance match = i distance = d end match end end end # private def escape_sequence(token) return '' if escape?(token) @escape_sequences ||= {} @escape_sequences[token.qualname] ||= EscapeSequence.new(get_style(token)) end def get_style(token) return text_style if token.ancestors.include? Token::Tokens::Text theme.get_own_style(token) || text_style end def text_style style = theme.get_style(Token['Text']) # don't highlight text backgrounds style.delete :bg style end end end end rouge-3.15.0/lib/rouge/formatters/html_pygments.rb0000644000004100000410000000064113610424007022243 0ustar www-datawww-data# frozen_string_literal: true module Rouge module Formatters class HTMLPygments < Formatter def initialize(inner, css_class='codehilite') @inner = inner @css_class = css_class end def stream(tokens, &b) yield %(
)
        @inner.stream(tokens, &b)
        yield "
" end end end end rouge-3.15.0/lib/rouge/formatters/html_table.rb0000644000004100000410000000322713610424007021467 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class HTMLTable < Formatter tag 'html_table' def initialize(inner, opts={}) @inner = inner @start_line = opts.fetch(:start_line, 1) @line_format = opts.fetch(:line_format, '%i') @table_class = opts.fetch(:table_class, 'rouge-table') @gutter_class = opts.fetch(:gutter_class, 'rouge-gutter') @code_class = opts.fetch(:code_class, 'rouge-code') end def style(scope) yield %(#{scope} .rouge-table { border-spacing: 0 }) yield %(#{scope} .rouge-gutter { text-align: right }) end def stream(tokens, &b) last_val = nil num_lines = tokens.reduce(0) {|count, (_, val)| count + (last_val = val).count(?\n) } formatted = @inner.format(tokens) unless last_val && last_val.end_with?(?\n) num_lines += 1 formatted << ?\n end # generate a string of newline-separated line numbers for the gutter> formatted_line_numbers = (@start_line..(@start_line + num_lines - 1)).map do |i| sprintf(@line_format, i) end.join(?\n) << ?\n buffer = [%()] # the "gl" class applies the style for Generic.Lineno buffer << %(' buffer << %(' buffer << '
) buffer << %(
#{formatted_line_numbers}
) buffer << '
)
        buffer << formatted
        buffer << '
' yield buffer.join end end end end rouge-3.15.0/lib/rouge/formatters/html.rb0000644000004100000410000000305013610424007020312 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters # Transforms a token stream into HTML output. class HTML < Formatter tag 'html' # @yield the html output. def stream(tokens, &b) tokens.each { |tok, val| yield span(tok, val) } end def span(tok, val) return val if escape?(tok) safe_span(tok, escape_special_html_chars(val)) end def safe_span(tok, safe_val) if tok == Token::Tokens::Text safe_val else shortname = tok.shortname \ or raise "unknown token: #{tok.inspect} for #{safe_val.inspect}" "#{safe_val}" end end TABLE_FOR_ESCAPE_HTML = { '&' => '&', '<' => '<', '>' => '>', } private # A performance-oriented helper method to escape `&`, `<` and `>` for the rendered # HTML from this formatter. # # `String#gsub` will always return a new string instance irrespective of whether # a substitution occurs. This method however invokes `String#gsub` only if # a substitution is imminent. # # Returns either the given `value` argument string as is or a new string with the # special characters replaced with their escaped counterparts. def escape_special_html_chars(value) escape_regex = /[&<>]/ return value unless value =~ escape_regex value.gsub(escape_regex, TABLE_FOR_ESCAPE_HTML) end end end end rouge-3.15.0/lib/rouge/formatters/tex.rb0000644000004100000410000000461013610424007020151 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class Tex < Formatter tag 'tex' # A map of TeX escape characters. # Newlines are handled specially by using #token_lines # spaces are preserved as long as they aren't at the beginning # of a line. see #tag_first for our initial-space strategy ESCAPE = { '&' => '\&', '%' => '\%', '$' => '\$', '#' => '\#', '_' => '\_', '{' => '\{', '}' => '\}', '~' => '{\textasciitilde}', '^' => '{\textasciicircum}', '|' => '{\textbar}', '\\' => '{\textbackslash}', '`' => '{\textasciigrave}', "'" => "'{}", '"' => '"{}', "\t" => '{\tab}', } ESCAPE_REGEX = /[#{ESCAPE.keys.map(&Regexp.method(:escape)).join}]/om def initialize(opts={}) @prefix = opts.fetch(:prefix) { 'RG' } end def escape_tex(str) str.gsub(ESCAPE_REGEX, ESCAPE) end def stream(tokens, &b) # surround the output with \begin{RG*}...\end{RG*} yield "\\begin{#{@prefix}*}%\n" # we strip the newline off the last line to avoid # an extra line being rendered. we do this by yielding # the \newline tag *before* every line group except # the first. first = true token_lines tokens do |line| if first first = false else yield "\\newline%\n" end render_line(line, &b) end yield "%\n\\end{#{@prefix}*}%\n" end def render_line(line, &b) line.each do |(tok, val)| hphantom_tag(tok, val, &b) end end # Special handling for leading spaces, since they may be gobbled # by a previous command. We replace all initial spaces with # \hphantom{xxxx}, which renders an empty space equal to the size # of the x's. def hphantom_tag(tok, val) leading = nil val.sub!(/^[ ]+/) { leading = $&.size; '' } yield "\\hphantom{#{'x' * leading}}" if leading yield tag(tok, val) unless val.empty? end def tag(tok, val) if escape?(tok) val elsif tok == Token::Tokens::Text escape_tex(val) else "\\#@prefix{#{tok.shortname}}{#{escape_tex(val)}}" end end end end end rouge-3.15.0/lib/rouge/version.rb0000644000004100000410000000016013610424007016644 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge def self.version "3.15.0" end end rouge-3.15.0/lib/rouge/lexer.rb0000644000004100000410000003331213610424007016303 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true # stdlib require 'strscan' require 'cgi' require 'set' module Rouge # @abstract # A lexer transforms text into a stream of `[token, chunk]` pairs. class Lexer include Token::Tokens @option_docs = {} class << self # Lexes `stream` with the given options. The lex is delegated to a # new instance. # # @see #lex def lex(stream, opts={}, &b) new(opts).lex(stream, &b) end # In case #continue_lex is called statically, we simply # begin a new lex from the beginning, since there is no state. # # @see #continue_lex def continue_lex(*a, &b) lex(*a, &b) end # Given a name in string, return the correct lexer class. # @param [String] name # @return [Class,nil] def find(name) registry[name.to_s] end # Find a lexer, with fancy shiny features. # # * The string you pass can include CGI-style options # # Lexer.find_fancy('erb?parent=tex') # # * You can pass the special name 'guess' so we guess for you, # and you can pass a second argument of the code to guess by # # Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world") # # If the code matches more than one lexer then Guesser::Ambiguous # is raised. # # This is used in the Redcarpet plugin as well as Rouge's own # markdown lexer for highlighting internal code blocks. # def find_fancy(str, code=nil, additional_options={}) if str && !str.include?('?') && str != 'guess' lexer_class = find(str) return lexer_class && lexer_class.new(additional_options) end name, opts = str ? str.split('?', 2) : [nil, ''] # parse the options hash from a cgi-style string opts = CGI.parse(opts || '').map do |k, vals| val = case vals.size when 0 then true when 1 then vals[0] else vals end [ k.to_s, val ] end opts = additional_options.merge(Hash[opts]) lexer_class = case name when 'guess', nil self.guess(:source => code, :mimetype => opts['mimetype']) when String self.find(name) end lexer_class && lexer_class.new(opts) end # Specify or get this lexer's title. Meant to be human-readable. def title(t=nil) if t.nil? t = tag.capitalize end @title ||= t end # Specify or get this lexer's description. def desc(arg=:absent) if arg == :absent @desc else @desc = arg end end def option_docs @option_docs ||= InheritableHash.new(superclass.option_docs) end def option(name, desc) option_docs[name.to_s] = desc end # Specify or get the path name containing a small demo for # this lexer (can be overriden by {demo}). def demo_file(arg=:absent) return @demo_file = Pathname.new(arg) unless arg == :absent @demo_file = Pathname.new(File.join(__dir__, 'demos', tag)) end # Specify or get a small demo string for this lexer def demo(arg=:absent) return @demo = arg unless arg == :absent @demo = File.read(demo_file, mode: 'rt:bom|utf-8') end # @return a list of all lexers. def all @all ||= registry.values.uniq end # Guess which lexer to use based on a hash of info. # # This accepts the same arguments as Lexer.guess, but will never throw # an error. It will return a (possibly empty) list of potential lexers # to use. def guesses(info={}) mimetype, filename, source = info.values_at(:mimetype, :filename, :source) custom_globs = info[:custom_globs] guessers = (info[:guessers] || []).dup guessers << Guessers::Mimetype.new(mimetype) if mimetype guessers << Guessers::GlobMapping.by_pairs(custom_globs, filename) if custom_globs && filename guessers << Guessers::Filename.new(filename) if filename guessers << Guessers::Modeline.new(source) if source guessers << Guessers::Source.new(source) if source guessers << Guessers::Disambiguation.new(filename, source) if source && filename Guesser.guess(guessers, Lexer.all) end # Guess which lexer to use based on a hash of info. # # @option info :mimetype # A mimetype to guess by # @option info :filename # A filename to guess by # @option info :source # The source itself, which, if guessing by mimetype or filename # fails, will be searched for shebangs, tags, and # other hints. # @param [Proc] fallback called if multiple lexers are detected. # If omitted, Guesser::Ambiguous is raised. # # @see Lexer.detect? # @see Lexer.guesses # @return [Class] def guess(info={}, &fallback) lexers = guesses(info) return Lexers::PlainText if lexers.empty? return lexers[0] if lexers.size == 1 if fallback fallback.call(lexers) else raise Guesser::Ambiguous.new(lexers) end end def guess_by_mimetype(mt) guess :mimetype => mt end def guess_by_filename(fname) guess :filename => fname end def guess_by_source(source) guess :source => source end def enable_debug! @debug_enabled = true end def disable_debug! remove_instance_variable :@debug_enabled if defined? @debug_enabled end def debug_enabled? (defined? @debug_enabled) ? true : false end # Determine if a lexer has a method named +:detect?+ defined in its # singleton class. def detectable? @detectable ||= methods(false).include?(:detect?) end protected # @private def register(name, lexer) # reset an existing list of lexers @all = nil if defined?(@all) registry[name.to_s] = lexer end public # Used to specify or get the canonical name of this lexer class. # # @example # class MyLexer < Lexer # tag 'foo' # end # # MyLexer.tag # => 'foo' # # Lexer.find('foo') # => MyLexer def tag(t=nil) return @tag if t.nil? @tag = t.to_s Lexer.register(@tag, self) end # Used to specify alternate names this lexer class may be found by. # # @example # class Erb < Lexer # tag 'erb' # aliases 'eruby', 'rhtml' # end # # Lexer.find('eruby') # => Erb def aliases(*args) args.map!(&:to_s) args.each { |arg| Lexer.register(arg, self) } (@aliases ||= []).concat(args) end # Specify a list of filename globs associated with this lexer. # # If a filename glob is associated with more than one lexer, this can # cause a Guesser::Ambiguous error to be raised in various guessing # methods. These errors can be avoided by disambiguation. Filename globs # are disambiguated in one of two ways. Either the lexer will define a # `self.detect?` method (intended for use with shebangs and doctypes) or a # manual rule will be specified in Guessers::Disambiguation. # # @example # class Ruby < Lexer # filenames '*.rb', '*.ruby', 'Gemfile', 'Rakefile' # end def filenames(*fnames) (@filenames ||= []).concat(fnames) end # Specify a list of mimetypes associated with this lexer. # # @example # class Html < Lexer # mimetypes 'text/html', 'application/xhtml+xml' # end def mimetypes(*mts) (@mimetypes ||= []).concat(mts) end # @private def assert_utf8!(str) encoding = str.encoding.name return if encoding == 'US-ASCII' || encoding == 'UTF-8' || encoding == 'ASCII-8BIT' raise EncodingError.new( "Bad encoding: #{str.encoding.names.join(',')}. " + "Please convert your string to UTF-8." ) end private def registry @registry ||= {} end end # -*- instance methods -*- # attr_reader :options # Create a new lexer with the given options. Individual lexers may # specify extra options. The only current globally accepted option # is `:debug`. # # @option opts :debug # Prints debug information to stdout. The particular info depends # on the lexer in question. In regex lexers, this will log the # state stack at the beginning of each step, along with each regex # tried and each stream consumed. Try it, it's pretty useful. def initialize(opts={}) @options = {} opts.each { |k, v| @options[k.to_s] = v } @debug = Lexer.debug_enabled? && bool_option('debug') end def as_bool(val) case val when nil, false, 0, '0', 'false', 'off' false when Array val.empty? ? true : as_bool(val.last) else true end end def as_string(val) return as_string(val.last) if val.is_a?(Array) val ? val.to_s : nil end def as_list(val) case val when Array val.flat_map { |v| as_list(v) } when String val.split(',') else [] end end def as_lexer(val) return as_lexer(val.last) if val.is_a?(Array) return val.new(@options) if val.is_a?(Class) && val < Lexer case val when Lexer val when String lexer_class = Lexer.find(val) lexer_class && lexer_class.new(@options) end end def as_token(val) return as_token(val.last) if val.is_a?(Array) case val when Token val else Token[val] end end def bool_option(name, &default) name_str = name.to_s if @options.key?(name_str) as_bool(@options[name_str]) else default ? default.call : false end end def string_option(name, &default) as_string(@options.delete(name.to_s, &default)) end def lexer_option(name, &default) as_lexer(@options.delete(name.to_s, &default)) end def list_option(name, &default) as_list(@options.delete(name.to_s, &default)) end def token_option(name, &default) as_token(@options.delete(name.to_s, &default)) end def hash_option(name, defaults, &val_cast) name = name.to_s out = defaults.dup base = @options.delete(name.to_s) base = {} unless base.is_a?(Hash) base.each { |k, v| out[k.to_s] = val_cast ? val_cast.call(v) : v } @options.keys.each do |key| next unless key =~ /(\w+)\[(\w+)\]/ and $1 == name value = @options.delete(key) out[$2] = val_cast ? val_cast.call(value) : value end out end # @abstract # # Called after each lex is finished. The default implementation # is a noop. def reset! end # Given a string, yield [token, chunk] pairs. If no block is given, # an enumerator is returned. # # @option opts :continue # Continue the lex from the previous state (i.e. don't call #reset!) # # @note The use of :continue => true has been deprecated. A warning is # issued if run with `$VERBOSE` set to true. # # @note The use of arbitrary `opts` has never been supported, but we # previously ignored them with no error. We now warn unconditionally. def lex(string, opts=nil, &b) if opts if (opts.keys - [:continue]).size > 0 # improper use of options hash warn('Improper use of Lexer#lex - this method does not receive options.' + ' This will become an error in a future version.') end if opts[:continue] warn '`lex :continue => true` is deprecated, please use #continue_lex instead' return continue_lex(string, &b) end end return enum_for(:lex, string) unless block_given? Lexer.assert_utf8!(string) reset! continue_lex(string, &b) end # Continue the lex from the the current state without resetting def continue_lex(string, &b) return enum_for(:continue_lex, string, &b) unless block_given? # consolidate consecutive tokens of the same type last_token = nil last_val = nil stream_tokens(string) do |tok, val| next if val.empty? if tok == last_token last_val << val next end b.call(last_token, last_val) if last_token last_token = tok last_val = val end b.call(last_token, last_val) if last_token end # delegated to {Lexer.tag} def tag self.class.tag end # @abstract # # Yield `[token, chunk]` pairs, given a prepared input stream. This # must be implemented. # # @param [StringScanner] stream # the stream def stream_tokens(stream, &b) raise 'abstract' end # @abstract # # Return true if there is an in-text indication (such as a shebang # or DOCTYPE declaration) that this lexer should be used. # # @param [TextAnalyzer] text # the text to be analyzed, with a couple of handy methods on it, # like {TextAnalyzer#shebang?} and {TextAnalyzer#doctype?} def self.detect?(text) false end end module Lexers @_loaded_lexers = {} def self.load_lexer(relpath) return if @_loaded_lexers.key?(relpath) @_loaded_lexers[relpath] = true load File.join(__dir__, 'lexers', relpath) end end end rouge-3.15.0/lib/rouge/tex_theme_renderer.rb0000644000004100000410000001000013610424007021021 0ustar www-datawww-data# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge class TexThemeRenderer def initialize(theme, opts={}) @theme = theme @prefix = opts.fetch(:prefix) { 'RG' } end # Our general strategy is this: # # * First, define the \RG{tokname}{content} command, which will # expand into \RG@tok@tokname{content}. We use \csname...\endcsname # to interpolate into a command. # # * Define the default RG* environment, which will enclose the whole # thing. By default this will simply set \ttfamily (select monospace font) # but it can be overridden with \renewcommand by the user to be # any other formatting. # # * Define all the colors using xcolors \definecolor command. First we define # every palette color with a name such as RG@palette@themneame@colorname. # Then we find all foreground and background colors that have literal html # colors embedded in them and define them with names such as # RG@palette@themename@000000. While html allows three-letter colors such # as #FFF, xcolor requires all six characters to be present, so we make sure # to normalize that as well as the case convention in #inline_name. # # * Define the token commands RG@tok@xx. These will take the content as the # argument and format it according to the theme, referring to the color # in the palette. def render(&b) yield <<'END'.gsub('RG', @prefix) \makeatletter \def\RG#1#2{\csname RG@tok@#1\endcsname{#2}}% \newenvironment{RG*}{\ttfamily}{\relax}% END base = @theme.class.base_style yield "\\definecolor{#{@prefix}@fgcolor}{HTML}{#{inline_name(base.fg || '#000000')}}" yield "\\definecolor{#{@prefix}@bgcolor}{HTML}{#{inline_name(base.bg || '#FFFFFF')}}" render_palette(@theme.palette, &b) @theme.styles.each do |tok, style| render_inline_pallete(style, &b) end Token.each_token do |tok| style = @theme.class.get_own_style(tok) style ? render_style(tok, style, &b) : render_blank(tok, &b) end yield '\makeatother' end def render_palette(palette, &b) palette.each do |name, color| hex = inline_name(color) yield "\\definecolor{#{palette_name(name)}}{HTML}{#{hex}}%" end end def render_inline_pallete(style, &b) gen_inline(style[:fg], &b) gen_inline(style[:bg], &b) end def inline_name(color) color =~ /^#(\h+)/ or return nil # xcolor does not support 3-character HTML colors, # so we convert them here case $1.size when 6 $1 when 3 # duplicate every character: abc -> aabbcc $1.gsub(/\h/, '\0\0') else raise "invalid HTML color: #{$1}" end.upcase end def gen_inline(name, &b) # detect inline colors hex = inline_name(name) return unless hex @gen_inline ||= {} @gen_inline[hex] ||= begin yield "\\definecolor{#{palette_name(hex)}}{HTML}{#{hex}}%" end end def camelize(name) name.gsub(/_(.)/) { $1.upcase } end def palette_name(name) name = inline_name(name) || name.to_s "#{@prefix}@palette@#{camelize(@theme.name)}@#{camelize(name.to_s)}" end def token_name(tok) "\\csname #@prefix@tok@#{tok.shortname}\\endcsname" end def render_blank(tok, &b) out = "\\expandafter\\def#{token_name(tok)}#1{#1}" end def render_style(tok, style, &b) out = String.new('') out << "\\expandafter\\def#{token_name(tok)}#1{" out << "\\fboxsep=0pt\\colorbox{#{palette_name(style[:bg])}}{" if style[:bg] out << '\\textbf{' if style[:bold] out << '\\textit{' if style[:italic] out << "\\textcolor{#{palette_name(style[:fg])}}{" if style[:fg] out << "#1" # close the right number of curlies out << "}" if style[:bold] out << "}" if style[:italic] out << "}" if style[:fg] out << "}" if style[:bg] out << "}%" yield out end end end rouge-3.15.0/lib/rouge/demos/0000755000004100000410000000000013610424007015744 5ustar www-datawww-datarouge-3.15.0/lib/rouge/demos/cmhg0000644000004100000410000000042013610424007016601 0ustar www-datawww-data; Header comments #include "definitions.h" command-keyword-table: command_handler foo(min-args:0, max-args:0,; comment international:, invalid-syntax: "syntaxtoken" help-text: "helptoken") rouge-3.15.0/lib/rouge/demos/jsl0000644000004100000410000000021313610424007016453 0ustar www-datawww-data// Create Distribution of Big Class dt = open( "$sample_data\big class.jmp" ); dt << Distribution( Column( :age ), Histograms Only( 1 ) ); rouge-3.15.0/lib/rouge/demos/eex0000644000004100000410000000003513610424007016446 0ustar www-datawww-data<%= @title %> rouge-3.15.0/lib/rouge/demos/io0000644000004100000410000000046713610424007016305 0ustar www-datawww-databottle := method(i, if(i==0, return "no more bottles of beer") if(i==1, return "1 bottle of beer") return i asString .. " bottles of beer" ) for(i, 99, 1, -1, write(bottle(i), " on the wall, ", bottle(i), ",\n") write("take one down, pass it around,\n") write(bottle(i - 1), " on the wall.\n\n") ) rouge-3.15.0/lib/rouge/demos/hql0000644000004100000410000000035013610424007016451 0ustar www-datawww-dataSELECT e.first_name, e.last_name, d.department_name FROM employees e JOIN departments d ON e.department_id = d.department_id; update `table` set name='abc', date=${date}, test_interpolation="${var1}.${var2}" where xyz is null; rouge-3.15.0/lib/rouge/demos/crystal0000644000004100000410000000131513610424007017350 0ustar www-datawww-datalib LibC WNOHANG = 0x00000001 @[ReturnsTwice] fun fork : PidT fun getpgid(pid : PidT) : PidT fun kill(pid : PidT, signal : Int) : Int fun getpid : PidT fun getppid : PidT fun exit(status : Int) : NoReturn ifdef x86_64 alias ClockT = UInt64 else alias ClockT = UInt32 end SC_CLK_TCK = 3 struct Tms utime : ClockT stime : ClockT cutime : ClockT cstime : ClockT end fun times(buffer : Tms*) : ClockT fun sysconf(name : Int) : Long end class Process def self.exit(status = 0) LibC.exit(status) end def self.pid LibC.getpid end def self.getpgid(pid : Int32) ret = LibC.getpgid(pid) raise Errno.new(ret) if ret < 0 ret end end rouge-3.15.0/lib/rouge/demos/cython0000644000004100000410000000014113610424007017167 0ustar www-datawww-datacdef extern from 'foo.h': int foo_int struct foo_struct: pass ctypedef int word rouge-3.15.0/lib/rouge/demos/toml0000644000004100000410000000035213610424007016642 0ustar www-datawww-data# This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? rouge-3.15.0/lib/rouge/demos/cmake0000644000004100000410000000021713610424007016747 0ustar www-datawww-datacmake_minimum_required(VERSION 2.8.3) project(foo C) # some note add_executable(foo utils.c "foo.c") target_link_libraries(foo ${LIBRARIES}) rouge-3.15.0/lib/rouge/demos/liquid0000644000004100000410000000036613610424007017163 0ustar www-datawww-data
    {% for product in products %}
  • {{ product.title }}

    Only {{ product.price | format_as_money }}

    {{ product.description | prettyprint | truncate: 200 }}

  • {% endfor %}
rouge-3.15.0/lib/rouge/demos/bbcbasic0000644000004100000410000000021013610424007017410 0ustar www-datawww-dataREM > DefaultFilename REM Ordinary comment FOR n=1 TO 10 PRINTTAB(n)"Hello there ";FNnumber(n)DIV3+1 NEXT:END DEFFNnumber(x%)=ABS(x%-4) rouge-3.15.0/lib/rouge/demos/sparql0000644000004100000410000000022013610424007017163 0ustar www-datawww-dataSELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } rouge-3.15.0/lib/rouge/demos/apex0000644000004100000410000000033013610424007016620 0ustar www-datawww-datapublic class with sharing Trigger { @Deprecated public void resolveSum(int x, int y) { System.debug('x is ' + x); System.debug('y is ' + y); System.debug('x + y = ' + (x+y)); } } rouge-3.15.0/lib/rouge/demos/mathematica0000644000004100000410000000032513610424007020144 0ustar www-datawww-data(* Fibonacci numbers with memoization *) fib::usage = "f[n] calculates the n'th Fibonacci number."; fib[0] = fib[1] = 1; fib[n_Integer?Positive]:= fib[n] = fib[n-1] + fib[n-2]; In[4]:= fib[42] Out[4]= 433494437 rouge-3.15.0/lib/rouge/demos/cfscript0000644000004100000410000000054513610424007017510 0ustar www-datawww-datacomponent accessors="true" { property type="string" name="firstName" default=""; property string username; function init(){ return this; } public any function submitOrder( required product, coupon="", boolean results=true ){ var foo = function( required string baz, x=true, y=false ){ return "bar!"; }; return foo; } }rouge-3.15.0/lib/rouge/demos/html0000644000004100000410000000033713610424007016636 0ustar www-datawww-data Title!

Hello, World!

rouge-3.15.0/lib/rouge/demos/css0000644000004100000410000000012513610424007016455 0ustar www-datawww-databody { font-size: 12pt; background: #fff url(temp.png) top left no-repeat; } rouge-3.15.0/lib/rouge/demos/xml0000644000004100000410000000011713610424007016466 0ustar www-datawww-data rouge-3.15.0/lib/rouge/demos/coffeescript0000644000004100000410000000012513610424007020341 0ustar www-datawww-data# Objects: math = root: Math.sqrt square: square cube: (x) -> x * square x rouge-3.15.0/lib/rouge/demos/markdown0000644000004100000410000000016413610424007017512 0ustar www-datawww-dataMarkdown has cool [reference links][ref 1] and [regular links too](http://example.com) [ref 1]: http://example.com rouge-3.15.0/lib/rouge/demos/bsl0000644000004100000410000000032513610424007016447 0ustar www-datawww-data#Область ПрограммныйИнтерфейс Процедура ПриветМир() Экспорт Сообщить("Привет мир"); КонецПроцедуры #КонецОбластиrouge-3.15.0/lib/rouge/demos/nasm0000644000004100000410000000106613610424007016630 0ustar www-datawww-data%macro IRQ 2 global irq%1 irq%1: cli push byte 0 ; push a dummy error code push byte %2 ; push the IRQ number jmp irq_common_stub %endmacro extern irq_handler irq_common_stub: pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax mov ax, ds ; Lower 16-bits of eax = ds. push eax ; save the data segment descriptor mov ax, 0x10 ; load the kernel data segment descriptor mov edx, eax call irq_handler %assign i 0 %rep 8 ISR_NOERRCODE i %assign i i+1 %endrep ISR_NOERRCODE 9 rouge-3.15.0/lib/rouge/demos/plist0000644000004100000410000000024613610424007017024 0ustar www-datawww-data// !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* ... */ }; rootObject = B3A67937542EC2041CBF1CA2 /* Project object */; } rouge-3.15.0/lib/rouge/demos/gradle0000644000004100000410000000025113610424007017123 0ustar www-datawww-dataapply plugin: 'java' repositories { jcenter() } dependencies { compile 'org.openjdk.jmh:jmh-core:1.12' compile 'org.openjdk.jmh:jmh-generator-annprocess:1.12' } rouge-3.15.0/lib/rouge/demos/hack0000644000004100000410000000014613610424007016576 0ustar www-datawww-data { return await (() ==> 'Hello, world')(); } rouge-3.15.0/lib/rouge/demos/prolog0000644000004100000410000000035113610424007017170 0ustar www-datawww-datadiff(plus(A,B), X, plus(DA, DB)) <= diff(A, X, DA) and diff(B, X, DB). diff(times(A,B), X, plus(times(A, DB), times(DA, B))) <= diff(A, X, DA) and diff(B, X, DB). equal(X, X). diff(X, X, 1). diff(Y, X, 0) <= not equal(Y, X). rouge-3.15.0/lib/rouge/demos/openedge0000644000004100000410000000017513610424007017460 0ustar www-datawww-dataFORM "Hello World!" VIEW-AS TEXT AT COL 20 ROW 2 btnOK AT COL 20 ROW 4 WITH FRAME f SIZE 50 BY 5 NO-BOX THREE-D. rouge-3.15.0/lib/rouge/demos/mason0000644000004100000410000000107413610424007017006 0ustar www-datawww-data<%doc> This is a mason component. # This is a comment. <%args> $color # this argument is required! $size => 20 # default size $country => undef # this argument is optional, default value is 'undef' @items => (1, 2, 'something else') %pairs => (name => "John", age => 29) % # A random block of Perl code <%perl> my @people = ('mary' 'john' 'pete' 'david'); % # Note how each line of code begins with the mandatory % % foreach my $person (@people) { Name: <% $person %> % } rouge-3.15.0/lib/rouge/demos/minizinc0000644000004100000410000000107113610424007017506 0ustar www-datawww-data% from MiniZinc Handbook: % https://www.minizinc.org/doc-latest/en/modelling.html % Colouring Australia using nc colours int: nc = 3; var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q; var 1..nc: nsw; var 1..nc: v; var 1..nc: t; constraint wa != nt; constraint wa != sa; constraint nt != sa; constraint nt != q; constraint sa != q; constraint sa != nsw; constraint sa != v; constraint q != nsw; constraint nsw != v; solve satisfy; output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n", "q=\(q)\t nsw=\(nsw)\t v=\(v)\n", "t=", show(t), "\n"]; rouge-3.15.0/lib/rouge/demos/mosel0000644000004100000410000000064313610424007017011 0ustar www-datawww-data(!****************************************************** Mosel Example Problems *******************************************************!) ! Objective function: total daily cost Cost:= sum(p in TYPES, t in TIME) (CSTART(p)*start(p,t) + LEN(t)*(CMIN(p)*work(p,t) + CADD(p)*padd(p,t))) ! Limit on power production above minimum level forall(p in TYPES, t in TIME) padd(p,t) <= (PMAX(p)-PMIN(p))*work(p,t) rouge-3.15.0/lib/rouge/demos/matlab0000644000004100000410000000033113610424007017124 0ustar www-datawww-dataA = cat( 3, [1 2 3; 9 8 7; 4 6 5], [0 3 2; 8 8 4; 5 3 5], ... [6 4 7; 6 8 5; 5 4 3]); % The EIG function is applied to each of the horizontal 'slices' of A. for i = 1:3 eig(squeeze(A(i,:,:))) end rouge-3.15.0/lib/rouge/demos/ini0000644000004100000410000000013613610424007016446 0ustar www-datawww-data; last modified 1 April 2001 by John Doe [owner] name=John Doe organization=Acme Widgets Inc. rouge-3.15.0/lib/rouge/demos/supercollider0000644000004100000410000000052113610424007020541 0ustar www-datawww-data// modulate a sine frequency and a noise amplitude with another sine // whose frequency depends on the horizontal mouse pointer position ~myFunction = { var x = SinOsc.ar(MouseX.kr(1, 100)); SinOsc.ar(300 * x + 800, 0, 0.1) + PinkNoise.ar(0.1 * x + 0.1) }; ~myFunction.play; "that's all, folks!".postln; rouge-3.15.0/lib/rouge/demos/jinja0000644000004100000410000000026313610424007016763 0ustar www-datawww-data{% extends "layout.html" %} {% block body %} {% endblock %} rouge-3.15.0/lib/rouge/demos/sml0000644000004100000410000000031613610424007016462 0ustar www-datawww-datadatatype shape = Circle of loc * real (* center and radius *) | Square of loc * real (* upper-left corner and side length; axis-aligned *) | Triangle of loc * loc * loc (* corners *) rouge-3.15.0/lib/rouge/demos/console0000644000004100000410000000017113610424007017330 0ustar www-datawww-data# prints "hello, world" to the screen ~# echo Hello, World Hello, World # don't run this ~# rm -rf --no-preserve-root / rouge-3.15.0/lib/rouge/demos/elixir0000644000004100000410000000004613610424007017163 0ustar www-datawww-dataEnum.map([1,2,3], fn(x) -> x * 2 end) rouge-3.15.0/lib/rouge/demos/ada0000644000004100000410000000120113610424007016406 0ustar www-datawww-datawith Ada.Directories; with Ada.Direct_IO; with Ada.Text_IO; procedure Extra_IO.Read_File (Name : String) is package Dirs renames Ada.Directories; package Text_IO renames Ada.Text_IO; -- Get the size of the file for a new string. Size : Natural := Natural (Dirs.Size (Name)); subtype File_String is String (1 .. Size); -- Instantiate Direct_IO for our file type. package FIO is new Ada.Direct_IO (File_String); File : FIO.File_Type; Contents : File_String; begin FIO.Open (File, FIO.In_File, Name); FIO.Read (File, Contents); FIO.Close (File); Text_IO.Put (Contents); end Extra_IO.Read_File; rouge-3.15.0/lib/rouge/demos/xojo0000644000004100000410000000063413610424007016651 0ustar www-datawww-dataDim f As FolderItem f = GetOpenFolderItem(FileTypes1.jpeg) // defined in the File Type Set editor rem - we should check for nil! If not f.Exists Then Beep 'Just for fun MsgBox("The file " + f.NativePath + "doesn't ""exist.""") Else // document exists ImageWell1.image=Picture.Open(f) End If if f isa folderitem then msgbox(f.name) end if Exception err As NilObjectException MsgBox("Invalid pathname!") rouge-3.15.0/lib/rouge/demos/json0000644000004100000410000000006513610424007016641 0ustar www-datawww-data{ "one": 1, "two": 2, "null": null, "simple": true } rouge-3.15.0/lib/rouge/demos/properties0000644000004100000410000000042113610424007020060 0ustar www-datawww-data# You are reading the ".properties" entry. ! The exclamation mark can also mark text as comments. website = http\://en.wikipedia.org/ language = English country : Poland continent=Europe key.with.dots=This is the value that could be looked up with the key "key.with.dots". rouge-3.15.0/lib/rouge/demos/typescript0000644000004100000410000000006413610424007020075 0ustar www-datawww-data$(document).ready(function() { alert('ready!'); }); rouge-3.15.0/lib/rouge/demos/gherkin0000644000004100000410000000107213610424007017316 0ustar www-datawww-data# language: en Feature: Addition In order to avoid silly mistakes As someone who has trouble with mental math I want to be told the sum of two numbers Scenario Outline: Add two numbers Given I have entered into the calculator And I have entered into the calculator When I press