public Link(InlineElement[] linkText, string destination, string title, ParserConfig config) : base(config) { Children = linkText; Destination = InlineElementUtils.UrlEncode(InlineText.HandleEscapeAndHtmlEntity(RemoveAngleBrackets(destination))); Title = title == null ? null : InlineText.HandleEscapeAndHtmlEntity(RemoveQuotes(title)); }
/// <summary> /// Initializes a new instance of <see cref="LinkReferenceDefinition"/> /// with link label ,destination, title. /// </summary> /// <param name="label"></param> /// <param name="destination"></param> /// <param name="title"></param> /// <param name="elem"></param> /// <param name="config">Configuration of the parser.</param> internal LinkReferenceDefinition(string label, string destination, string title, UnknownElement elem, ParserConfig config) : base(config) { Label = GetSimpleName(label?.Trim(whiteSpaceChars) ?? throw new ArgumentNullException(nameof(title))); Destination = InlineElementUtils.UrlEncode(InlineText.HandleEscapeAndHtmlEntity( destination ?? throw new ArgumentNullException(nameof(destination)))); Title = title == null ? null : InlineText.HandleEscapeAndHtmlEntity(title); warnings.AddRange(elem?.Warnings ?? new List <string>()); }
/// <summary> /// Adds a line of string to this <see cref="FencedCodeBlock"/>. /// </summary> /// <param name="line">A single line to add to this element.</param> /// <param name="lazy">Whether <paramref name="line"/> is lazy continuation.</param> /// <param name="currentIndent">The indent count of <paramref name="line"/>.</param> /// <returns> /// Returns <c>AddLineResult.Consumed</c> except when <paramref name="line"/> /// contains the close fence. /// </returns> internal override AddLineResult AddLine(string line, bool lazy, int currentIndent) { if (lazy && line.GetIndentNum(currentIndent) >= 0) { throw new InvalidBlockFormatException(BlockElementType.CodeBlock); } if (!initialized) // When the first line is specified { Match match = openFenceRegex.Match(line); if (!match.Success) // When the first line does not contain open fence. { throw new InvalidBlockFormatException(BlockElementType.CodeBlock); } string fence = match.Groups["fence"].Value; fenceLength = fence.Length; fenceChar = fence[0]; indentNum = match.Groups["indent"].Length; if (match.Groups["info"].Success) { infoString = InlineText.HandleEscapeAndHtmlEntity(match.Groups["info"].Value); } initialized = true; return(AddLineResult.Consumed); } Match closeMatch = closeFenceRegex.Match(line); if (!closeMatch.Success) { contents.Add(RemoveIndent(line, indentNum, currentIndent)); return(AddLineResult.Consumed); } string closeFence = closeMatch.Groups["fence"].Value; if (closeFence[0] == fenceChar && closeFence.Length >= fenceLength) { closed = true; return(AddLineResult.Consumed | AddLineResult.NeedClose); } contents.Add(RemoveIndent(line, indentNum, currentIndent)); return(AddLineResult.Consumed); }