Esempio n. 1
0
        /// <summary>
        /// Parses the specified textWithSubstitutes with source markup (according to set start and end tags) as preperation
        /// for getting subtitles and references texts.
        /// </summary>
        /// <param name="substitute">Substitute that replaces the source markdown.</param>
        private void Parse(IInteractiveSourceSubstitute substitute)
        {
            if (substitute == null)
            {
                return;
            }

            var pattern = new Regex(HtmlStartTag + ".+?" + HtmlEndTag);
            var match   = pattern.Match(TextWithSubstitutes);

            int index = 0;

            while (match.Success)
            {
                string oldText = match.Value;
                string srcText = oldText;
                srcText = srcText.Replace(HtmlStartTag, string.Empty);
                srcText = srcText.Replace(HtmlEndTag, string.Empty);

                string sub = substitute.NextSubstitute();

                Sources.Add(new Source(srcText, match.Index, sub, index));

                // replace footnote markup with substitute
                TextWithSubstitutes = TextWithSubstitutes.Replace(oldText, sub);
                match = pattern.Match(TextWithSubstitutes); // working with new textWithSubstitutes to get correct start index
                index++;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a parser for the specified textWithSubstitutes with source markup.
        /// </summary>
        /// <param name="textWithSubstitutes">TextWithSubstitutes to parse.</param>
        /// <param name="substitute">Substitute that replaces the source markdown.</param>
        public InteractiveSourcesParser(string textWithSubstitutes, IInteractiveSourceSubstitute substitute)
        {
            Sources             = new List <Source>();
            TextWithSubstitutes = textWithSubstitutes;

            Parse(substitute);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a parser for the specified textWithSubstitutes with source markup.
 /// </summary>
 /// <param name="substitute">Substitute that replaces the source markdown.</param>
 public InteractiveSourcesParser(IInteractiveSourceSubstitute substitute)
 {
     this.substitute = substitute;
 }