/// <summary> /// Writes the serialization of the node guided by the formatter to the /// given stream. /// </summary> /// <param name="markup">The markup node to format.</param> /// <param name="stream">The output stream to use.</param> public static async Task ToHtmlAsync(this IMarkupFormattable markup, Stream stream) { using (var writer = new StreamWriter(stream)) { await markup.ToHtmlAsync(writer).ConfigureAwait(false); } }
/// <summary> /// Uses the <see cref="DiffMarkupFormatter"/> to generate a HTML markup string /// from a <see cref="IMarkupFormattable"/> <paramref name="markupFormattable"/>. /// The generated HTML markup will NOT include the internal Blazor attributes /// added to elements. /// </summary> public static string ToDiffMarkup(this IMarkupFormattable markupFormattable) { if (markupFormattable is null) { throw new ArgumentNullException(nameof(markupFormattable)); } using var sw = new StringWriter(); markupFormattable.ToHtml(sw, new DiffMarkupFormatter()); return(sw.ToString()); }
/// <summary> /// Returns the serialization of the node guided by the formatter. /// </summary> /// <param name="markup">The markup node to format.</param> /// <param name="formatter">The formatter to use.</param> /// <returns>The source code snippet.</returns> public static String ToHtml(this IMarkupFormattable markup, IMarkupFormatter formatter) { var sb = StringBuilderPool.Obtain(); using (var writer = new StringWriter(sb)) { markup.ToHtml(writer, formatter); } return(sb.ToPool()); }
/// <summary> /// Uses the <see cref="PrettyMarkupFormatter"/> to generate a HTML markup /// from a <see cref="IMarkupFormattable"/> <paramref name="markupFormattable"/>. /// </summary> public static string ToMarkup(this IMarkupFormattable markupFormattable) { if (markupFormattable is null) { throw new ArgumentNullException(nameof(markupFormattable)); } using var sw = new StringWriter(); var formatter = new PrettyMarkupFormatter() { NewLine = Environment.NewLine, Indentation = " " }; markupFormattable.ToHtml(sw, formatter); return(sw.ToString()); }
public static string ToHtml(this IMarkupFormattable value) { return(value.ToHtml(new AngleSharp.Html.MinifyMarkupFormatter())); }
/// <summary> /// Creates an instance of the <see cref="HtmlEqualException"/> type. /// </summary> public HtmlEqualException(IEnumerable <IDiff> diffs, IMarkupFormattable expected, IMarkupFormattable actual, string?userMessage) : base(PrintHtml(expected), PrintHtml(actual), CreateUserMessage(diffs, userMessage), "Expected HTML", "Actual HTML") { }
/// <summary> /// Returns the (complete) HTML markup representation of the node. /// </summary> /// <param name="markup">The markup node to format.</param> /// <returns>The source code snippet.</returns> public static String ToHtml(this IMarkupFormattable markup) { return(markup.ToHtml(HtmlMarkupFormatter.Instance)); }
/// <summary> /// Returns the (complete) HTML markup representation of the node. /// </summary> /// <param name="markup">The markup node to format.</param> /// <returns>The source code snippet.</returns> public static String ToHtml(this IMarkupFormattable markup) => markup.ToHtml(HtmlMarkupFormatter.Instance);
/// <summary> /// Writes the serialization of the node guided by the formatter. /// </summary> /// <param name="markup">The markup node to format.</param> /// <param name="writer">The output target of the serialization.</param> public static Task ToHtmlAsync(this IMarkupFormattable markup, TextWriter writer) => writer.WriteAsync(markup.ToHtml());
/// <summary> /// Returns a prettified serialization of the node guided by the /// PrettyMarkupFormatter with the default options. /// </summary> /// <param name="markup">The markup node to format.</param> /// <returns>The source code snippet.</returns> public static String Prettify(this IMarkupFormattable markup) => markup.ToHtml(new PrettyMarkupFormatter());
/// <summary> /// Returns a minified serialization of the node guided by the /// MinifyMarkupFormatter with the default options. /// </summary> /// <param name="markup">The markup node to format.</param> /// <returns>The source code snippet.</returns> public static String Minify(this IMarkupFormattable markup) => markup.ToHtml(new MinifyMarkupFormatter());
/// <summary> /// Writes the serialization of the node guided by the formatter. /// </summary> /// <param name="markup">The markup node to format.</param> /// <param name="writer">The output target of the serialization.</param> public static void ToHtml(this IMarkupFormattable markup, TextWriter writer) => markup.ToHtml(writer, HtmlMarkupFormatter.Instance);
public static string ToText(this IMarkupFormattable markup) => markup.ToHtml(new TextFormatter()).Trim(' ').Trim('\t').Trim('\n');
public static string PrintHtml(this IMarkupFormattable nodes) => nodes.ToDiffMarkup() + Environment.NewLine;