Browse Source

Fix multi-line captures

master
Graham Littlewood 4 years ago
parent
commit
c0a9d990f9
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      src/commands/cmd_macro.rs

+ 8
- 4
src/commands/cmd_macro.rs View File

@@ -10,7 +10,7 @@ extern crate serde_json;
use serde_json::Result;

extern crate regex;
use regex::{Regex, Match};
use regex::{Regex, RegexBuilder, Match};

use core::option::Option;
use std::collections::HashMap;
@@ -88,8 +88,12 @@ impl CmdMacro {
let macros: HashMap<u64, HashMap<String, String>> = serde_json::from_reader(reader).unwrap_or(HashMap::<u64, HashMap<String, String>>::new());
return CmdMacro {
format:
Regex::new(r#"^!macro\s+([A-Za-z0-9]+|"[^\s]+"|'[^\s]+')(?:\s+([A-Za-z0-9]+|"[^\s]+"|'[^\s]+')\s+(.+))?"#)
.unwrap(),
RegexBuilder::new(r#"^!macro\s+([A-Za-z0-9]+|"[^\s]+"|'[^\s]+')(?:\s+([A-Za-z0-9]+|"[^\s]+"|'[^\s]+')\s+(.+))?"#)
.multi_line(true)
.dot_matches_new_line(true)
.case_insensitive(true)
.build()
.unwrap(),
macros: macros,
};
}
@@ -148,7 +152,7 @@ impl CmdMacro {
}

fn save_json(&self) {
let mut file = OpenOptions::new()
let file = OpenOptions::new()
.write(true)
.open(MACRO_PATH)
.unwrap();