lib/rouge/cli.rb in rouge-3.4.1 vs lib/rouge/cli.rb in rouge-3.5.0

- old
+ new

@@ -297,10 +297,11 @@ when 'html' then Formatters::HTML.new when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class]) when 'html-inline' then Formatters::HTMLInline.new(theme) when 'html-table' then Formatters::HTMLTable.new(Formatters::HTML.new) when 'null', 'raw', 'tokens' then Formatters::Null.new + when 'tex' then Formatters::Tex.new else error! "unknown formatter preset #{opts[:formatter]}" end @escape = opts[:escape] @@ -332,22 +333,34 @@ yield %|passed to the theme. To select a mode (light/dark) for the| yield %|theme, append '.light' or '.dark' to the <theme-name>| yield %|respectively. Theme defaults to thankful_eyes.| yield %|| yield %|options:| - yield %| --scope (default: .highlight) a css selector to scope by| + yield %| --scope (default: .highlight) a css selector to scope by| + yield %| --tex (default: false) render as TeX| + yield %| --tex-prefix (default: RG) a command prefix for TeX| + yield %| implies --tex if specified| yield %|| yield %|available themes:| yield %| #{Theme.registry.keys.sort.join(', ')}| end def self.parse(argv) - opts = { :theme_name => 'thankful_eyes' } + opts = { + :theme_name => 'thankful_eyes', + :tex => false, + :tex_prefix => 'RG' + } until argv.empty? arg = argv.shift case arg + when '--tex' + opts[:tex] = true + when '--tex-prefix' + opts[:tex] = true + opts[:tex_prefix] = argv.shift when /--(\w+)/ opts[$1.tr('-', '_').to_sym] = argv.shift else opts[:theme_name] = arg end @@ -360,9 +373,13 @@ theme_name = opts.delete(:theme_name) theme_class = Theme.find(theme_name) \ or error! "unknown theme: #{theme_name}" @theme = theme_class.new(opts) + if opts[:tex] + tex_prefix = opts[:tex_prefix] + @theme = TexThemeRenderer.new(@theme, prefix: tex_prefix) + end end def run @theme.render(&method(:puts)) end