[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7845":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":31,"readmeContent":32,"aiSummary":33,"trendingCount":16,"starSnapshotCount":16,"syncStatus":34,"lastSyncTime":35,"discoverSource":36},7845,"rouge","rouge-ruby\u002Frouge","rouge-ruby","A pure Ruby code highlighter that is compatible with Pygments","https:\u002F\u002Frouge.jneen.ca\u002F",null,"Ruby",3443,813,51,153,0,1,7,16,4,67.83,"Other",false,"main",true,[27,28,29,30],"minitest","rubocop","ruby","syntax-highlighting","2026-06-12 04:00:36","# Rouge\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Frouge-ruby\u002Frouge\u002Factions\u002Fworkflows\u002Fruby.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Frouge-ruby\u002Frouge\u002Factions\u002Fworkflows\u002Fruby.yml)\n[![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Frouge.svg)](https:\u002F\u002Frubygems.org\u002Fgems\u002Frouge)\n[![YARD Docs](http:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fyard-docs-blue.svg)](https:\u002F\u002Frouge-ruby.github.io\u002Fdocs\u002F)\n\n[Rouge][] is a pure Ruby syntax highlighter. It can highlight\n[over 200 different languages][languages-doc], and output HTML\nor ANSI 256-color text. Its HTML output is compatible with\nstylesheets designed for [Pygments][].\n\n[rouge]: http:\u002F\u002Frouge.jneen.net\u002F \"Rouge\"\n[languages-doc]: https:\u002F\u002Frouge-ruby.github.io\u002Fdocs\u002Ffile.Languages.html \"Languages\"\n[pygments]: http:\u002F\u002Fpygments.org \"Pygments\"\n\n## Installation\n\nIn your Gemfile, add:\n\n```ruby\ngem 'rouge'\n```\n\nor\n\n```bash\ngem install rouge\n```\n\n## Usage\n\nRouge's most common uses are as a Ruby library, as part of Jekyll and as a\ncommand line tool.\n\n### Library\n\nHere's a quick example of using Rouge as you would any other regular Ruby\nlibrary:\n\n```ruby\nrequire 'rouge'\n\n# make some nice lexed html\nsource = File.read('\u002Fetc\u002Fbashrc')\nformatter = Rouge::Formatters::HTML.new\nlexer = Rouge::Lexers::Shell.new\nformatter.format(lexer.lex(source))\n\n# Get some CSS\nRouge::Themes::Base16.mode(:light).render(scope: '.highlight')\n# Or use Theme#find with string input\nRouge::Theme.find('base16.light').render(scope: '.highlight')\n```\n\n### Jekyll\n\nRouge is Jekyll's default syntax highlighter. Out of the box, Rouge will be\nused to highlight text wrapped in the `{% highlight %}` template tags. The\n`{% highlight %}` tag provides minimal options: you can specify the language to\nuse and whether to enable line numbers or not. More information is available in\n[the Jekyll docs][j-docs].\n\n[j-docs]: https:\u002F\u002Fjekyllrb.com\u002Fdocs\u002Fliquid\u002Ftags\u002F#code-snippet-highlighting \"Code snippet highlighting in the Jekyll documentation\"\n\n### Command Line\n\nRouge ships with a `rougify` command which allows you to easily highlight files\nin your terminal:\n\n```console\n$ rougify foo.rb\n$ rougify foo.rb -t monokai.sublime\n$ rougify style monokai.sublime > syntax.css\n```\n\n## Configuration\n\n### Formatters\n\nRouge comes with a number of formatters built-in but as of Rouge 2.0, you are\nencouraged to write your own formatter if you need something custom.\n\nThe built-in formatters are:\n\n- `Rouge::Formatters::HTML.new` will render your code with standard class names\n  for tokens, with no div-wrapping or other bells or whistles.\n\n- `Rouge::Formatters::HTMLInline.new(theme)` will render your code with no class\n  names, but instead inline the styling options into the `style=` attribute.\n  This is good for emails and other systems where CSS support is minimal.\n\n- `Rouge::Formatters::HTMLLinewise.new(formatter, class: 'line-%i')` will split\n  your code into lines, each contained in its own div. The `class` option will\n  be used to add a class name to the div, given the line number.\n\n- `Rouge::Formatters::HTMLLineHighlighter.new(formatter, highlight_lines: [3, 5])`\n  will split your code into lines and wrap the lines specified by the\n  `highlight_lines` option in a span with a class name specified by the\n  `highlight_line_class` option (default: `hll`).\n\n- `Rouge::Formatters::HTMLLineTable.new(formatter, opts={})` will output an HTML\n  table containing numbered lines, each contained in its own table-row. Options\n  are:\n\n  - `start_line: 1` - the number of the first row\n  - `line_id: 'line-%i'` - a `sprintf` template for `id` attribute with\n    current line number\n  - `line_class: 'lineno'` - a CSS class for each table-row\n  - `table_class: 'rouge-line-table'` - a CSS class for the table\n  - `gutter_class: 'rouge-gutter'` - a CSS class for the line-number cell\n  - `code_class: 'rouge-code'` - a CSS class for the code cell\n\n- `Rouge::Formatters::HTMLPygments.new(formatter, css_class='codehilite')` wraps\n  the given formatter with div wrappers generally expected by stylesheets\n  designed for Pygments.\n\n- `Rouge::Formatters::HTMLTable.new(formatter, opts={})` will output an HTML\n  table containing numbered lines similar to `Rouge::Formatters::HTMLLineTable`,\n  except that the table from this formatter has just a single table-row.\n  Therefore, while the table is more DOM-friendly for JavaScript scripting, long\n  code lines will mess with the column alignment. Options are:\n\n  - `start_line: 1` - the number of the first line\n  - `line_format: '%i'` - a `sprintf` template for the line number itself\n  - `table_class: 'rouge-table'` - a CSS class for the table\n  - `gutter_class: 'rouge-gutter'` - a CSS class for the gutter\n  - `code_class: 'rouge-code'` - a CSS class for the code column\n\n- `Rouge::Formatters::HTMLLegacy.new(opts={})` is a backwards-compatibility\n  class intended for users of Rouge 1.x, with options that were supported then.\n  Options are:\n\n  - `inline_theme: nil` - use an HTMLInline formatter with the given theme\n  - `line_numbers: false` - use an HTMLTable formatter\n  - `wrap: true` - use an HTMLPygments wrapper\n  - `css_class: 'codehilite'` - a CSS class to use for the Pygments wrapper\n\n- `Rouge::Formatters::Terminal256.new(theme)` is a formatter for generating\n  highlighted text for use in the terminal. `theme` must be an instance of\n  `Rouge::Theme`, or a `Hash` structure with `:theme` entry.\n\n- `Rouge::Formatters::TerminalTruecolor.new(theme)` is similar to the previous,\n  except it outputs ANSI truecolor codes, instead of approximating with a 256-color\n  scheme.\n\n- `Rouge::Formatters::Tex.new` is a formatter for TeX systems which wraps each\n  token with an `\\RG{toktype}{text}` tag. You can then use\n  `rougify style mystyle --tex`\n  to generate definitions for these tags and the surrounding environment.\n\n#### Writing your own HTML formatter\n\nFor the majority of applications, there are custom requirements for presenting\nhighlighted text, as HTML or otherwise. In these cases, rather than patching or\npost-processing the output of Rouge, it is usually better to **write your own\nformatter**.\n\nThis may sound intimidating, but it is actually quite easy! All you have to do\nis subclass `Rouge::Formatter`, define a `tag`, and implement a method\n`#stream(tokens, &block)`, which receives an Enumerable of token\u002Fvalue pairs,\nand yields out chunks of strings which will be concatenated.\n\nThe `Formatter` base class contains the helper method `#token_lines(stream, &block)`,\nwhich separates tokens into distinct lines, and `Rouge::Formatters::HTML`\ncontains the helper `#span(token, value)` to escape and render\nstandard `\u003Cspan>` tags for HTML.\n\nAlternatively, if you want to override how individual spans are rendered,\nyou can override `#safe_span(token, safe_value)`, which will be passed the\ntoken type and pre-escaped content for the token.\n\n```ruby\nclass MyFormatter \u003C Rouge::Formatters::HTML\n\n  # this is the main entry method. override this to customize the behavior of\n  # the HTML blob as a whole. it should receive an Enumerable of (token, value)\n  # pairs and yield out fragments of the resulting html string. see the docs\n  # for the methods available on Token.\n  def stream(tokens, &block)\n    yield \"\u003Cdiv class='my-outer-div'>\"\n\n    tokens.each do |token, value|\n      # for every token in the output, we render a span\n      yield span(token, value)\n    end\n\n    yield \"\u003C\u002Fdiv>\"\n  end\n\n  # or, if you need linewise processing, try:\n  def stream(tokens, &block)\n    token_lines(tokens).each do |line_tokens|\n      yield \"\u003Cdiv class='my-cool-line'>\"\n      line_tokens.each do |token, value|\n        yield span(token, value)\n      end\n      yield \"\u003C\u002Fdiv>\"\n    end\n  end\n\n  # Override this method to control how individual spans are rendered.\n  # The value `safe_value` will already be HTML-escaped.\n  def safe_span(token, safe_value)\n    # in this case, \"text\" tokens don't get surrounded by a span\n    if token == Token::Tokens::Text\n      safe_value\n    else\n      \"\u003Cspan class=\\\"#{token.shortname}\\\">#{safe_value}\u003C\u002Fspan>\"\n    end\n  end\nend\n```\n\n### Lexer Options\n\n- `debug: true` will print a trace of the lex on stdout. For safety, this only works if `Rouge::Lexer.enable_debug!` has been called.\n\n- `parent: ''` allows you to specify which language the template is inside.\n\n### Theme Options\n\n- `scope: '.highlight'` sets the CSS selector to which styles are applied,\n  e.g.:\n\n  ```ruby\n  Rouge::Themes::MonokaiSublime.render(scope: 'code')\n  ```\n\n## Documentation\n\nRouge's documentation is available at [rouge-ruby.github.io\u002Fdocs\u002F][docs].\n\n[docs]: https:\u002F\u002Frouge-ruby.github.io\u002Fdocs \"Rouge's official documentation\"\n\n## Requirements\n\n### Ruby\n\nRouge is compatible with all versions of Ruby from 3.0 onwards. It has no\nexternal dependencies.\n\n### Encodings\n\nRouge only supports UTF-8 strings. If you'd like to highlight a string with a\ndifferent encoding, please convert it to UTF-8 first.\n\n## Integrations\n\n- Middleman:\n  - [middleman-syntax][] (@bhollis)\n  - [middleman-rouge][] (@Linuus)\n- RDoc: [rdoc-rouge][] (@zzak)\n- Rails: [Rouge::Rails][] (@jacobsimeon)\n\n[middleman-syntax]: https:\u002F\u002Fgithub.com\u002Fmiddleman\u002Fmiddleman-syntax\n[middleman-rouge]: https:\u002F\u002Fgithub.com\u002FLinuus\u002Fmiddleman-rouge\n[rdoc-rouge]: https:\u002F\u002Fgithub.com\u002Fzzak\u002Frdoc-rouge\n[rouge::rails]: https:\u002F\u002Fgithub.com\u002Fjacobsimeon\u002Frouge-rails\n\n## Contributing\n\nWe're always excited to welcome new contributors to Rouge. By it's nature, a\nsyntax highlighter relies for its success on submissions from users of the\nlanguages being highlighted. You can help Rouge by filing bug reports or\ndeveloping new lexers.\n\nEveryone interacting in Rouge and its sub-projects' code bases is expected to\nfollow the Rouge [Code of Conduct][code-of-conduct].\n\n[code-of-conduct]: CODE_OF_CONDUCT.md\n\n### Bug Reports\n\nRouge uses GitHub's Issues to report bugs. You can [choose][issue-chooser] from\none of our templates or create a custom issue. Issues that have not been active\nfor a year are automatically closed by GitHub's [Probot][].\n\n[issue-chooser]: https:\u002F\u002Fgithub.com\u002Frouge-ruby\u002Frouge\u002Fissues\u002Fnew\u002Fchoose \"Choose an issue from the templates\"\n[probot]: https:\u002F\u002Fprobot.github.io \"Read more about GitHub's Probot\"\n\n### Developing Lexers\n\n**NOTE**: Please don't submit lexers that are copy-pasted from other files.\nThese submission will be rejected and we don't want you to waste your time.\n\nWe want to make it as easy as we can for anyone to contribute a lexer to Rouge.\nTo help get you started, we have [a guide][lexer-dev-doc] on lexer\ndevelopment in the documentation. The best place is to start there.\n\n[lexer-dev-doc]: https:\u002F\u002Frouge-ruby.github.io\u002Fdocs\u002Ffile.LexerDevelopment.html \"Rouge's lexer development guide\"\n\nIf you get stuck and need help, submit a pull request with what you have and\nmake it clear in your submission that the lexer isn't finished yet. We'll do our\nbest to answer any questions you have and sometimes the best way to do that is\nwith actual code.\n\nIf your language is internal or obscure, or it is taking far too long to merge\ninto baseline Rouge, you can very easily write a plugin for language support.\nCheck out our [plugin example repository][plugin-example] for a good starting point.\n\n[plugin-example]: https:\u002F\u002Fgithub.com\u002Frouge-ruby\u002Frouge-plugin-example \"Rouge Plugin Example\"\n\n### Testing Rouge\n\nOnce you've cloned the repository from GitHub, you can test the core of Rouge\nsimply by running `rake` (no `bundle exec` required). You can also run a single\ntest file by setting the `TEST` environment variable to the path of the desired\ntest. For example, to test just the _`ruby` lexer_ (located at path\n`spec\u002Flexers\u002Fruby_spec.rb`) simply run the following:\n\n```bash\nTEST=spec\u002Flexers\u002Fruby_spec.rb rake\n```\n\nTo test a lexer visually, run `puma` from the top-level working directory and\nyou should have a web server running and ready to go. Visit\n\u003Chttp:\u002F\u002Flocalhost:9292> to see the full list of Rouge's lexers.\n\nOnce you've selected a particular lexer, you can add `?debug=1` to your URL\nstring to see a lot of helpful debugging info printed on stdout.\n\n## Maintainers\n\nRouge is largely the result of the hard work of unpaid volunteers. It was\noriginally developed by Jeanine Adkisson (@jneen) and is currently maintained by\nJeanine Adkisson, Drew Blessing (@dblessing), Goro Fuji (@gfx) and Tan Le\n(@tancnle).\n\n## License\n\nRouge is released under the MIT license. Please see the [LICENSE][license] file for more\ninformation.\n\n[license]: LICENSE\n","Rouge 是一个纯 Ruby 代码高亮库，与 Pygments 兼容。它支持超过200种编程语言的语法高亮，并能输出HTML或ANSI 256色文本。Rouge的核心功能包括通过Ruby库、Jekyll插件和命令行工具进行使用，具有丰富的内置格式化选项，如标准类名渲染、内联样式渲染以及按行分割等。该工具适用于需要在网页、终端或邮件中展示代码片段的场景，特别是那些已经使用Ruby技术栈或Jekyll静态网站生成器的项目。",2,"2026-06-11 03:14:41","top_language"]