Skip to content

Commit

Permalink
Fix generated_html failure when the meta line doesn't have a "content…
Browse files Browse the repository at this point in the history
…" attribute (#4628)

* Add test fixture that illustrates the failure

* Add ronn generated fixture

* Support content or value and handle nil

* Revert "Add ronn generated fixture"

This reverts commit 84428d3b9ef746ea94046ad65781ac4245d5f629.

* Revert "Add test fixture that illustrates the failure"

This reverts commit fc0da0388afc18e70baf9de328e0b6e9468276bb.
  • Loading branch information
lildude committed Aug 29, 2019
1 parent 3b7d23c commit 6027cf3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,23 +621,27 @@ def generated_html?
return false if matches.empty?
return matches.map {|x| extract_html_meta(x) }.any? do |attr|
attr["name"].to_s.downcase == 'generator' &&
attr["content"].match(/^
( org \s+ mode
| j?latex2html
| groff
| makeinfo
| texi2html
) \b
/ix)
[attr["content"], attr["value"]].any? do |cv|
!cv.nil? &&
cv.match(/^
( org \s+ mode
| j?latex2html
| groff
| makeinfo
| texi2html
| ronn
) \b
/ix)
end
end
end

# Internal: Extract a Hash of name/content pairs from an HTML <meta> tag
def extract_html_meta(match)
(match.last.sub(/\/\Z/, "").strip.scan(/
(?<=^|\s) # Check for preceding whitespace
(name|content) # Attribute names we're interested in
\s* = \s* # Key-value separator
(?<=^|\s) # Check for preceding whitespace
(name|content|value) # Attribute names we're interested in
\s* = \s* # Key-value separator
# Attribute value
( "[^"]+" # name="value"
Expand Down

0 comments on commit 6027cf3

Please sign in to comment.