public override Node parse(BlockParser parser) { var childLines = parseChildLines(parser); // The Markdown tests expect a trailing newline. childLines.Add(""); var escaped = Utils.escapeHtml(childLines.@join("\n")); return(new Element("pre", new List <Node>() { Element.text("code", escaped) })); }
public override Node parse(BlockParser parser) { // Get the syntax identifier, if there is one. var match = pattern.Match(parser.current); var endBlock = match.Groups[1].Value; var infoString = match.Groups[2].Value; var childLines = parseChildLines(parser, endBlock); // The Markdown tests expect a trailing newline. childLines.Add(""); var text = childLines.join('\n'); if (parser.document.encodeHtml) { // Escape the code. text = Utils.escapeHtml(text); } var code = Element.text("code", text); // the info-string should be trimmed // http://spec.commonmark.org/0.22/#example-100 infoString = infoString.Trim(); if (infoString.isNotEmpty()) { // only use the first word in the syntax // http://spec.commonmark.org/0.22/#example-100 infoString = infoString.Split(' ').first(); code.attributes["class"] = "language-" + infoString; } var element = new Element("pre", new List <Node>() { code }); return(element); }