-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use rubocop template api to extract markdown code blocks
- Loading branch information
Showing
6 changed files
with
130 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Markdown | ||
# Used by RuboCop to get parsed ruby from markdown | ||
class RubyExtractor | ||
# According to Linguist. mdx was dropped but is being kept for backwards compatibility. | ||
# See https://github.com/github-linguist/linguist/blob/8c380f360ce00b95fa08d14ce0ebccd481af1b33/lib/linguist/languages.yml#L4088-L4098 | ||
# Keep in sync with config/default.yml | ||
MARKDOWN_EXTENSIONS = %w[ | ||
.md | ||
.livemd | ||
.markdown | ||
.mdown | ||
.mdwn | ||
.mdx | ||
.mkd | ||
.mkdn | ||
.mkdown | ||
.ronn | ||
.scd | ||
.workbook | ||
].freeze | ||
|
||
class << self | ||
def call(processed_source) | ||
new(processed_source).call | ||
end | ||
end | ||
|
||
def initialize(processed_source) | ||
@processed_source = processed_source | ||
end | ||
|
||
def call | ||
return unless markdown_file? | ||
|
||
Preprocess.new(@processed_source).call | ||
end | ||
|
||
private | ||
|
||
def markdown_file? | ||
MARKDOWN_EXTENSIONS.include?(File.extname(@processed_source.path || "")) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.