{"id":13441173,"url":"https://github.com/rouge-ruby/rouge","last_synced_at":"2025-12-17T03:52:18.294Z","repository":{"id":4487956,"uuid":"5627139","full_name":"rouge-ruby/rouge","owner":"rouge-ruby","description":"A pure Ruby code highlighter that is compatible with Pygments","archived":false,"fork":false,"pushed_at":"2025-11-18T21:46:16.000Z","size":5076,"stargazers_count":3402,"open_issues_count":267,"forks_count":786,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-12-11T16:23:01.326Z","etag":null,"topics":["minitest","rubocop","ruby","syntax-highlighting"],"latest_commit_sha":null,"homepage":"https://rouge.jneen.net/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rouge-ruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-08-31T09:54:51.000Z","updated_at":"2025-12-09T11:11:15.000Z","dependencies_parsed_at":"2023-12-24T01:30:06.680Z","dependency_job_id":"c1f770b8-2b48-4251-bbf2-1bb23098fad0","html_url":"https://github.com/rouge-ruby/rouge","commit_stats":{"total_commits":2301,"total_committers":436,"mean_commits":5.277522935779817,"dds":0.7331594958713603,"last_synced_commit":"bf007b7382070f33f49350c48502b47ee2aaab20"},"previous_names":["jneen/rouge","jayferd/rouge"],"tags_count":138,"template":false,"template_full_name":null,"purl":"pkg:github/rouge-ruby/rouge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rouge-ruby%2Frouge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rouge-ruby%2Frouge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rouge-ruby%2Frouge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rouge-ruby%2Frouge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rouge-ruby","download_url":"https://codeload.github.com/rouge-ruby/rouge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rouge-ruby%2Frouge/sbom","scorecard":{"id":525040,"data":{"date":"2025-08-11","repo":{"name":"github.com/rouge-ruby/rouge","commit":"327071fe99f3efbe295d3b3a9263c7bec5bdec47"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.3,"checks":[{"name":"Code-Review","score":5,"reason":"Found 15/30 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"13 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ruby.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ruby.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ruby.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ruby.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ruby.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ruby.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ruby.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ruby.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ruby.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/rouge-ruby/rouge/ruby.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T04:07:59.333Z","repository_id":4487956,"created_at":"2025-08-20T04:07:59.333Z","updated_at":"2025-08-20T04:07:59.333Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27669902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-11T02:00:11.302Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["minitest","rubocop","ruby","syntax-highlighting"],"created_at":"2024-07-31T03:01:30.738Z","updated_at":"2025-12-17T03:52:18.279Z","avatar_url":"https://github.com/rouge-ruby.png","language":"Ruby","readme":"# Rouge\n\n[![Build Status](https://github.com/rouge-ruby/rouge/actions/workflows/ruby.yml/badge.svg)](https://github.com/rouge-ruby/rouge/actions/workflows/ruby.yml)\n[![Gem Version](https://badge.fury.io/rb/rouge.svg)](https://rubygems.org/gems/rouge)\n[![YARD Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rouge-ruby.github.io/docs/)\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://rouge.jneen.net/ \"Rouge\"\n[languages-doc]: https://rouge-ruby.github.io/docs/file.Languages.html \"Languages\"\n[pygments]: http://pygments.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('/etc/bashrc')\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://jekyllrb.com/docs/liquid/tags/#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```bash\nrougify foo.rb\nrougify style monokai.sublime \u003e 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#### Writing your own HTML formatter\n\nIf the above formatters are not sufficient, and you wish to customize the layout\nof the HTML document, we suggest writing your own HTML formatter. This can be\naccomplished by subclassing `Rouge::Formatters::HTML` and overriding specific\nmethods:\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, \u0026block)\n    yield \"\u003cdiv class='my-outer-div'\u003e\"\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/div\u003e\"\n  end\n\n  # or, if you need linewise processing, try:\n  def stream(tokens, \u0026block)\n    token_lines(tokens).each do |line_tokens|\n      yield \"\u003cdiv class='my-cool-line'\u003e\"\n      line_tokens.each do |token, value|\n        yield span(token, value)\n      end\n      yield \"\u003c/div\u003e\"\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}\\\"\u003e#{safe_value}\u003c/span\u003e\"\n    end\n  end\nend\n```\n\n### Lexer Options\n\n- `debug: false` will print a trace of the lex on stdout.\n\n- `parent: ''` allows you to specify which language the template is inside.\n\n### CSS 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/docs/][docs].\n\n[docs]: https://rouge-ruby.github.io/docs \"Rouge's official documentation\"\n\n## Requirements\n\n### Ruby\n\nRouge is compatible with all versions of Ruby from 2.0.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://github.com/middleman/middleman-syntax\n[middleman-rouge]: https://github.com/Linuus/middleman-rouge\n[rdoc-rouge]: https://github.com/zzak/rdoc-rouge\n[rouge::rails]: https://github.com/jacobsimeon/rouge-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://github.com/rouge-ruby/rouge/issues/new/choose \"Choose an issue from the templates\"\n[probot]: https://probot.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 shiny new guide][lexer-dev-doc] on lexer\ndevelopment in the documentation. The best place is to start there.\n\n[lexer-dev-doc]: https://rouge-ruby.github.io/docs/file.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\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/lexers/ruby_spec.rb`) simply run the following:\n\n```bash\nTEST=spec/lexers/ruby_spec.rb rake\n```\n\nTo test a lexer visually, run `rackup` from the top-level working directory and\nyou should have a web server running and ready to go. Visit\n\u003chttp://localhost:9292\u003e 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## Versioning\n\nRouge uses [Semantic Versioning 2.0.0][sv2].\n\n[sv2]: http://semver.org/\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","funding_links":[],"categories":["HarmonyOS","Ruby","File preview"],"sub_categories":["Windows Manager","Plugin manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frouge-ruby%2Frouge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frouge-ruby%2Frouge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frouge-ruby%2Frouge/lists"}