lib/gherkin/token_matcher.rb in cucumber-gherkin-9.2.0 vs lib/gherkin/token_matcher.rb in cucumber-gherkin-10.0.0
- old
+ new
@@ -78,11 +78,11 @@
def match_DocStringSeparator(token)
if @active_doc_string_separator.nil?
# open
_match_DocStringSeparator(token, '"""', true) ||
- _match_DocStringSeparator(token, '```', true)
+ _match_DocStringSeparator(token, '```', true)
else
# close
_match_DocStringSeparator(token, @active_doc_string_separator, false)
end
end
@@ -116,14 +116,14 @@
true
end
def match_StepLine(token)
keywords = @dialect.given_keywords +
- @dialect.when_keywords +
- @dialect.then_keywords +
- @dialect.and_keywords +
- @dialect.but_keywords
+ @dialect.when_keywords +
+ @dialect.then_keywords +
+ @dialect.and_keywords +
+ @dialect.but_keywords
keyword = keywords.detect { |k| token.line.start_with?(k) }
return false unless keyword
@@ -150,20 +150,26 @@
title = token.line.get_rest_trimmed(keyword.length + ':'.length)
set_token_matched(token, token_type, title, keyword)
true
end
- def set_token_matched(token, matched_type, text=nil, keyword=nil, indent=nil, items=[])
+ def set_token_matched(token, matched_type, text = nil, keyword = nil, indent = nil, items = [])
token.matched_type = matched_type
token.matched_text = text && text.chomp
token.matched_keyword = keyword
token.matched_indent = indent || (token.line && token.line.indent) || 0
token.matched_items = items
token.location[:column] = token.matched_indent + 1
token.matched_gherkin_dialect = @dialect_name
end
def unescape_docstring(text)
- @active_doc_string_separator ? text.gsub("\\\"\\\"\\\"", "\"\"\"") : text
+ if @active_doc_string_separator == "\"\"\""
+ text.gsub("\\\"\\\"\\\"", "\"\"\"")
+ elsif @active_doc_string_separator == "```"
+ text.gsub("\\`\\`\\`", "```")
+ else
+ text
+ end
end
end
end