Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

parse verbatim sections

  • Loading branch information...
commit 087a06010dc880de40013ab5f2c22c55ad081b72 1 parent 8768baf
@moritz authored
Showing with 12 additions and 0 deletions.
  1. +8 −0 lib/Mowyw/Grammar.pm
  2. +4 −0 t/parse.t
View
8 lib/Mowyw/Grammar.pm
@@ -23,6 +23,14 @@ token command:sym<comment> { <sym> [ <!before '%]'> .]* }
token command:sym<include> { <sym> <.ws> <arg> }
rule command:sym<setvar> { <sym> <name> '='? <slurpy_arg> }
rule command:sym<readvar> { <sym> <name> }
+regex command:sym<verbatim> {
+ <sym>
+ <.ws> '%]' :
+ (.*?) '[%'
+ <.ws> 'endverbatim'
+ <.ws> <?before '%]'>
+ # the final %] is parsed by token directive
+}
# vim: ft=perl6
View
4 t/parse.t
@@ -16,6 +16,10 @@ my @samples =
[1, '[% setvar foo = bar baz %]', 'setvar with optional ='],
[1, '[% readvar foo %]', 'readvar'],
[0, '[% readvar %]', 'readvar neads a var name'],
+ [1, '[% verbatim %] foo %] blubb [% [% endverbatim %]',
+ 'verbatim'],
+ [0, '[% verbatim %] foo %] blubb [%',
+ 'open-ended verbatim'],
;
Please sign in to comment.
Something went wrong with that request. Please try again.