Ejemplo n.º 1
0
        public static void AddChangesToBounds(
            PreprocessedTextLocationMap map,
            List <PreprocessingTextChange> changes,
            PreprocessedData data,
            PreprocessedTextType type)
        {
            if (data == null)
            {
                return;
            }

            foreach (var change in changes)
            {
                if (change.RemoveCharsCount == 0)
                {
                    continue;
                }

                var start = change.Index;
                var end   = change.Index + change.RemoveCharsCount - 1;

                if (map != null)
                {
                    start = map.GetOriginalPosition(start, PositionRounding.Up);
                    end   = map.GetOriginalPosition(end, PositionRounding.Down);
                }

                data.PreprocessedTextBounds.Add(
                    new PreprocessedTextBound(
                        type, start, end));
            }
        }
        public string ParseExcerpts(string text, TransformationData data, PreprocessedTextLocationMap map)
        {
            var excerptInfos = new Dictionary <string, ExcerptInfo>();

            text = ProcessExcerpt(ExcerptBlock, text, data, excerptInfos, map);
            text = ProcessExcerpt(ExcerptInline, text, data, excerptInfos, map);

            foreach (var excerptInfo in excerptInfos)
            {
                AddExcerpt(data, excerptInfo.Value, excerptInfo.Key);
            }

            AddExcerpt(data, new ExcerptInfo(map.GetOriginalPosition(0, PositionRounding.Down), 0, text), "");

            return(text);
        }