Use generic matcher on unsupported extensions, and include base string delimiters for it

This commit is contained in:
Rijnard van Tonder 2019-04-12 00:11:35 -04:00
parent 2a9d98b17b
commit d2b23cd217
3 changed files with 18 additions and 2 deletions

View File

@ -7,7 +7,10 @@ module Syntax = struct
; ("[", "]")
]
let escapable_string_literals = []
let escapable_string_literals =
[ {|"|}
; {|'|}
]
let escape_char =
'\\'

View File

@ -368,7 +368,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
in
let matcher =
let default = (module Matchers.C : Matchers.Matcher) in
let default = (module Matchers.Generic : Matchers.Matcher) in
match file_extensions with
| None | Some [] -> default
| Some (hd::_) ->

View File

@ -74,6 +74,19 @@ let%expect_test "with_rewrite_rule" =
|> print_string;
[%expect_exact {|hello|}]
let%expect_test "generic_matcher" =
let source = {|\footnote{\small \url{https://github.com}}|} in
let match_template = {|\footnote{\small :[1]}|} in
let rewrite_template = {|\footnote{\scriptsize :[1]}|} in
let command_args =
Format.sprintf "-stdin '%s' '%s' -f .generic" match_template rewrite_template
in
let command = Format.sprintf "%s %s" binary_path command_args in
read_source_from_stdin command source
|> print_string;
[%expect_exact {|\footnote{\scriptsize \url{https://github.com}}|}]
let%expect_test "json_output_option" =
let source = "a X c a Y c" in
let match_template = "a :[1] c" in