Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting for an unknown icon #4584

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ def self.citation_library
@CITATION_LIBRARY
end

@JEKYLL_CONFIG = nil

def self.jekyll_config
if @JEKYLL_CONFIG.nil?
# Load
@JEKYLL_CONFIG = YAML.load_file('_config.yml')
end
@JEKYLL_CONFIG
end

def self.check_bad_cite(contents)
find_matching_texts(contents, /{%\s*cite\s+([^%]*)\s*%}/i)
.map do |idx, _text, selected|
Expand All @@ -332,6 +342,24 @@ def self.check_bad_cite(contents)
end
end

def self.check_bad_icon(contents)
find_matching_texts(contents, /{%\s*icon\s+([^%]*)\s*%}/i)
.map do |idx, _text, selected|
icon_key = selected[1].strip
if jekyll_config['icon-tag'][icon_key].nil?
ReviewDogEmitter.error(
path: @path,
idx: idx,
match_start: selected.begin(0),
match_end: selected.end(0),
replacement: nil,
message: "The icon (#{icon_key}) could not be found, please add it to _config.yml.",
code: 'GTN:033'
)
end
end
end

def self.non_existent_snippet(contents)
find_matching_texts(contents, /{%\s*snippet\s+([^ ]*)/i)
.reject do |_idx, _text, selected|
Expand Down Expand Up @@ -719,6 +747,7 @@ def self.fix_md(contents)
*new_more_accessible_boxes_agenda(contents),
*no_target_blank(contents),
*check_bad_link(contents),
*check_bad_icon(contents),
*check_looks_like_heading(contents),
*check_bad_tag(contents),
*check_useless_box_prefix(contents),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ To use this system, you need to take care of a few things:

- Do **not** use hands-on boxes for segments that should be executed (code needs to be left aligned!)
- Do **not** use snippets
- Do **not** use icons `{% raw %}{% icon X %}{% endraw %}`
- Do **not** use icons `{% raw %}{% icon galaxy-eye %}{% endraw %}`
- Do not use a terminal or prompt character (that would be included in the execution.)
- Avoid including output when you can, it doesn't render nicely especially when the cells will become runnable.

Expand Down
Loading