Ejemplo n.º 1
0
        private string DeleteMarks(RenderingRule rule, string rawText)
        {
            var selection    = rule.GetSelection(rawText);
            var renderedText = rawText.Replace(selection, rule.Selector.Start, rule.Selector.GetLength());

            return(renderedText);
        }
Ejemplo n.º 2
0
        public string RenderWithPriority(RenderingRule rule, string rawText)
        {
            string renderedText;

            var selection        = rule.GetSelection(rawText);
            var intersectedRules = RenderingRules.Where(r => IntersectedWithRenderedRule(selection, r)).ToList();

            if (intersectedRules.Any())
            {
                foreach (var r in intersectedRules)
                {
                    rule.Selector.Start += r.OpeningTag.Length - 1;
                }

                return(DeleteMarks(rule, rawText));
            }

            if (IntersectedWithHigherPriorityRule(rule))
            {
                var oldEndOfSelection   = rule.Selector.End;
                var oldStartOfSelection = rule.Selector.Start;
                renderedText = DeleteMarks(rule, rawText);
                MoveIntersectedStarts(rule, oldStartOfSelection, oldEndOfSelection);
                return(renderedText);
            }

            renderedText = Render(rule, rawText);
            rule.Selector.ResetSelection();
            return(renderedText);
        }
Ejemplo n.º 3
0
        private string Render(RenderingRule rule, string rawText)
        {
            var selection      = rule.GetSelection(rawText);
            var tagedSelection = String.Concat(rule.OpeningTag, selection, rule.ClosingTag);
            var renderedText   = rawText.Replace(tagedSelection, rule.Selector.Start, rule.Selector.GetLength());

            return(renderedText);
        }