Skip to content

Commit

Permalink
Allow snip arguments to contain dots.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyatom committed Nov 18, 2012
1 parent ad1f004 commit d115f7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/vanilla/snip_reference_parser.rb
Expand Up @@ -37,12 +37,11 @@ class SnipParser < Parslet::Parser
rule(:right_brace) { str("}") }

rule(:word) { match("[a-zA-Z0-9_\\-]").repeat(1) }
rule(:quotables) { word | comma | spaces }
rule(:double_quoted_string) do
dquote >> (quotables | squote).repeat(1).as(:string) >> dquote
dquote >> (dquote.absent? >> any).repeat(1).as(:string) >> dquote
end
rule(:single_quoted_string) do
squote >> (quotables | dquote).repeat(1).as(:string) >> squote
squote >> (squote.absent? >> any).repeat(1).as(:string) >> squote
end
rule(:spaced_string) { (word >> (spaces >> word).repeat).as(:string) }
rule(:string) do
Expand Down Expand Up @@ -99,4 +98,4 @@ def to_h; {@k.to_sym => @v}; end
rule(:key_value_arg_list => sequence(:x)) { x.inject({}) { |h, kv| h.merge(kv.to_h) } }
end
end
end
end
3 changes: 2 additions & 1 deletion test/core/snip_reference_parser_test.rb
Expand Up @@ -83,6 +83,7 @@
%|{s 'arg, comma'}| => {:snip => 's', :attribute => nil, :arguments => ['arg, comma']},
# %|{s "arg { open"}| => {:snip => 's', :attribute => nil, :arguments => ['arg { open']},
# %|{s "arg } close"}| => {:snip => 's', :attribute => nil, :arguments => ['arg } close']}
%|{s 'arg.with.fullstop'}| => {:snip => 's', :attribute => nil, :arguments => ['arg.with.fullstop']},
},

:html_quoting_arguments => {
Expand Down Expand Up @@ -124,4 +125,4 @@ def create_snip_from_expected(expected)
end
create_snip(attributes)
end
end
end

0 comments on commit d115f7d

Please sign in to comment.