{"id":13878282,"url":"https://github.com/rubocop/rubocop-md","last_synced_at":"2025-05-16T05:07:31.646Z","repository":{"id":43192941,"uuid":"113966061","full_name":"rubocop/rubocop-md","owner":"rubocop","description":"RuboCop for Markdown code snippets","archived":false,"fork":false,"pushed_at":"2025-04-14T18:39:16.000Z","size":141,"stargazers_count":73,"open_issues_count":2,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-14T19:50:24.624Z","etag":null,"topics":["hacktoberfest","markdown","rubocop","ruby","styleguide"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubocop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"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},"funding":{"github":["palkan","bbatsov"]}},"created_at":"2017-12-12T08:49:57.000Z","updated_at":"2025-04-14T18:39:16.000Z","dependencies_parsed_at":"2024-01-11T20:25:04.727Z","dependency_job_id":"102a8ced-2054-491e-8682-8f4994514c21","html_url":"https://github.com/rubocop/rubocop-md","commit_stats":null,"previous_names":["rubocop-hq/rubocop-md"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Frubocop-md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Frubocop-md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Frubocop-md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Frubocop-md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubocop","download_url":"https://codeload.github.com/rubocop/rubocop-md/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471060,"owners_count":22076585,"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","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":["hacktoberfest","markdown","rubocop","ruby","styleguide"],"created_at":"2024-08-06T08:01:45.067Z","updated_at":"2025-05-16T05:07:31.600Z","avatar_url":"https://github.com/rubocop.png","language":"Ruby","funding_links":["https://github.com/sponsors/palkan","https://github.com/sponsors/bbatsov"],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/rubocop-md.svg)](http://badge.fury.io/rb/rubocop-md)\n![Test](https://github.com/rubocop/rubocop-md/workflows/Test/badge.svg)\n\n# Rubocop Markdown\n\nRun Rubocop against your Markdown files to make sure that code examples follow style guidelines and have valid syntax.\n\n## Features\n\n- Analyzes code blocks within Markdown files\n- Shows correct line numbers in output\n- Preserves specified language (i.e., do not try to analyze \"\\`\\`\\`sh\")\n- **Supports autocorrect 📝**\n\nThis project was developed to keep [test-prof](https://github.com/test-prof/test-prof) guides consistent with Ruby style guide back in 2017. Since then, many popular Ruby projects adopted it, including:\n\n- [Ruby on Rails](https://github.com/rails/rails)\n- [AnyCable](https://github.com/anycable/anycable)\n- [ViewComponent](https://github.com/ViewComponent/view_component)\n- [Action Policy](https://github.com/palkan/action_policy)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"rubocop-md\"\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install rubocop-md\n\n## Usage\n\n### Command line\n\nJust require `rubocop-md` plugin in your command:\n\n```sh\nrubocop --plugin \"rubocop-md\" ./lib\n```\n\nAutocorrect works too:\n\n```sh\nrubocop --plugin \"rubocop-md\" -a ./lib\n```\n\n### Configuration\n\nCode in the documentation does not make sense to be checked for some style guidelines (eg `Style/FrozenStringLiteralComment`).\n\nWe described such rules in the [default config](config/default.yml), but if you use the same settings in your project’s `.rubocop.yml` file, `RuboCop` will override them.\n\nFortunately, `RuboCop` supports directory-level configuration and we can do the next trick.\n\nAt first, add `rubocop-md` to your main `.rubocop.yml`:\n\n```yml\n# .rubocop.yml\n\nplugins:\n  - \"rubocop-md\"\n```\n\n*Notice: additional options*\n\n```yml\n# .rubocop.yml\n\nMarkdown:\n  # Whether to run RuboCop against non-valid snippets\n  WarnInvalid: true\n  # Whether to lint codeblocks without code attributes\n  Autodetect: true\n```\n\nSecondly, create empty `.rubocop.yml` in your docs directory.\n\n```bash\n├── docs\n│   ├── .rubocop.yml\n│   ├── doc1.md\n│   ├── doc2.md\n│   └── doc3.md\n├── lib\n├── .rubocop.yml # main\n└── ...\n```\n\nThird, just run\n\n```bash\n$ rubocop\n```\n\nAlso you can add special rules in the second `.rubocop.yml`\n\n```yml\n# rubocop.yml in docs folder\n\nMetrics/LineLength:\n  Max: 100\n\nLint/Void:\n  Exclude:\n    - '*.md'\n```\n\n### But if I want to use inline disabling some directive like in classic RuboCop?\n\nYou can use this tricks\n\n````md\n# my_post.md\n\n... some markdown ...\n\n\u003cspan style=\"display:none;\"\u003e# rubocop:disable all\u003c/span\u003e\n\n```ruby\ndef my_poor_method(foo)\n  [:a, :b, :c] + [\"#{foo}\".to_sym]\nend\n```\n\nend of snippet\n\n\u003cspan style=\"display:none;\"\u003e# rubocop:enable all\u003c/span\u003e\n\n... continuation of article ...\n````\n\n## How it works?\n\n- Preprocess Markdown source into Ruby source preserving line numbers\n- Let RuboCop do its job\n- Restore Markdown from preprocessed Ruby if it has been autocorrected\n\n## Limitations\n\n- RuboCop cache is disabled for Markdown files (because cache knows nothing about preprocessing)\n- Uses naive Regexp-based approach to extract code blocks from Markdown, support only backticks-style code blocks\\*\n- No language detection included; if you do not specify language for your code blocks, you'd better turn `WarnInvalid` off (see above)\n\n\\* It should be easy to integrate a _real_ parser (e.g. [Kramdown](https://kramdown.gettalong.org)) and handle all possible syntax. Feel free to open an issue or pull request!\n\n## Development\n\nAfter checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-md.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubocop%2Frubocop-md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubocop%2Frubocop-md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubocop%2Frubocop-md/lists"}