private static string ProcessExcerpt(Regex pattern, string text, TransformationData data, Dictionary <string, ExcerptInfo> excerptsInfos, PreprocessedTextLocationMap map) { var changes = new List <PreprocessingTextChange>(); text = pattern.Replace(text, match => ParseExcerpt(match, excerptsInfos, data, changes)); map.ApplyChanges(changes); return(text); }
public static string Replace(Regex pattern, string text, MatchEvaluator evaluator, PreprocessedTextLocationMap locationMap, List <PreprocessingTextChange> changesDone = null) { if (locationMap == null && changesDone == null) { return(pattern.Replace(text, evaluator)); } var changes = changesDone ?? new List <PreprocessingTextChange>(); var output = pattern.Replace(text, m => PreprocessingTextChange.MatchEvaluatorWithTextChangeEmitWrapper(m, evaluator, changes)); if (locationMap != null) { locationMap.ApplyChanges(changes); } return(output); }