Example #1
0
 public void ReplaceEncoding(MarkdownReplacementArgs args, Match match)
 {
     if (match.Success)
     {
         ReplaceEncoding(match.Index, match.Index + match.Length, match.Scanner, match.Matches, args);
     }
     else
     {
         args.Output.Append(match.Text);
     }
 }
Example #2
0
        public void Transform(MarkdownReplacementArgs args, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            var scanner = new StringScanner(text);
            var match   = Match(scanner);

            if (match.Success)
            {
                ReplaceEncoding(0, text.Length, scanner, match.Matches, args);
                return;
            }
            args.Output.Append(text);
        }
Example #3
0
        public void Transform(MarkdownReplacementArgs args, StringScanner scanner, int index, int length)
        {
            if (length <= 0)
            {
                return;
            }
            var text  = scanner.Value;
            var match = Match(new StringScanner(text, index, length));

            if (match.Success)
            {
                ReplaceEncoding(index, index + length, scanner, match.Matches, args);
                return;
            }
            args.Output.Append(text, index, length);
        }
Example #4
0
        public string Transform(string markdown)
        {
            var match = Match(markdown);

            if (match.Success)
            {
                var args = new MarkdownReplacementArgs
                {
                    Output   = new StringBuilder(markdown.Length),
                    Grammar  = this,
                    Encoding = encoding
                };
                Transform(match, args);
                return(args.Output.ToString());
            }
            return(markdown);
        }
Example #5
0
        public void Transform(Match match, MarkdownReplacementArgs args)
        {
            var reference = new ReferenceSection();

            foreach (var refMatch in match.Find(reference.Name))
            {
                reference.AddReference(refMatch, args);
            }

            var count = match.Matches.Count;

            for (int i = 0; i < count; i++)
            {
                var section     = match.Matches[i];
                var replacement = replacements.GetReplacement(section.Name);
                replacement.Transform(section, args);
            }
        }
Example #6
0
 public void Transform(MarkdownReplacementArgs args, Match match, int indexOffset, int lengthOffset)
 {
     Transform(args, (StringScanner)match.Scanner, match.Index + indexOffset, match.Length + lengthOffset);
 }
Example #7
0
 public void Transform(MarkdownReplacementArgs args, Match match)
 {
     Transform(args, (StringScanner)match.Scanner, match.Index, match.Length);
 }
Example #8
0
        public void ReplaceEncoding(int index, int end, Scanner scanner, MatchCollection matches, MarkdownReplacementArgs args)
        {
            int last  = index;
            var count = matches.Count;

            for (int i = 0; i < count; i++)
            {
                var replacementMatch = matches[i];
                var replacement      = replacements.GetReplacement(replacementMatch.Name);

                if (replacementMatch.Index > last)
                {
                    args.Output.Append(scanner.Substring(last, replacementMatch.Index - last));
                }
                last = replacementMatch.Index + replacementMatch.Length;

                replacement.Transform(replacementMatch, args);
            }
            if (last < end)
            {
                args.Output.Append(scanner.Substring(last, end - last));
            }
        }
Example #9
0
        public void TransformReplacement(Match match, MarkdownReplacementArgs args)
        {
            var replacement = replacements.GetReplacement(match.Name);

            replacement.Transform(match, args);
        }
		public string Transform(string markdown)
		{
			var match = Match(markdown);
			if (match.Success)
			{
				var args = new MarkdownReplacementArgs
				{
					Output = new StringBuilder(markdown.Length),
					Grammar = this,
					Encoding = encoding
				};
				Transform(match, args);
				return args.Output.ToString();
			}
			return markdown;
		}
		public void TransformReplacement(Match match, MarkdownReplacementArgs args)
		{
			var replacement = replacements.GetReplacement(match.Name);
			replacement.Transform(match, args);
		}
		public void Transform(Match match, MarkdownReplacementArgs args)
		{
			var reference = new ReferenceSection();
			foreach (var refMatch in match.Find(reference.Name))
			{
				reference.AddReference(refMatch, args);
			}

			var count = match.Matches.Count;
			for (int i = 0; i < count; i++)
			{
				var section = match.Matches[i];
				var replacement = replacements.GetReplacement(section.Name);
				replacement.Transform(section, args);
			}
		}