Refactor private method `HighlightBlock#parse_options` (#6822)
Merge pull request 6822
This commit is contained in:
parent
822d020086
commit
cd513da07e
|
@ -65,23 +65,24 @@ MSG
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
OPTIONS_REGEX = %r!(?:\w="[^"]*"|\w=\w|\w)+!
|
||||||
|
|
||||||
def parse_options(input)
|
def parse_options(input)
|
||||||
options = {}
|
options = {}
|
||||||
unless input.empty?
|
return options if input.empty?
|
||||||
|
|
||||||
# Split along 3 possible forms -- key="<quoted list>", key=value, or key
|
# Split along 3 possible forms -- key="<quoted list>", key=value, or key
|
||||||
input.scan(%r!(?:\w="[^"]*"|\w=\w|\w)+!) do |opt|
|
input.scan(OPTIONS_REGEX) do |opt|
|
||||||
key, value = opt.split("=")
|
key, value = opt.split("=")
|
||||||
# If a quoted list, convert to array
|
# If a quoted list, convert to array
|
||||||
if value && value.include?("\"")
|
if value && value.include?('"')
|
||||||
value.delete!('"')
|
value.delete!('"')
|
||||||
value = value.split
|
value = value.split
|
||||||
end
|
end
|
||||||
options[key.to_sym] = value || true
|
options[key.to_sym] = value || true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if options.key?(:linenos) && options[:linenos] == true
|
options[:linenos] = "inline" if options[:linenos] == true
|
||||||
options[:linenos] = "inline"
|
|
||||||
end
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue