/// <summary> /// Writes the provided output to the file, followed by a Markdown paragraph break to /// terminate the line and start a new paragraph. /// </summary> /// <param name="output">The output to write.</param> /// <param name="style">The optional Markdown style to apply.</param> /// <param name="format">The optional Markdown format to apply.</param> /// <param name="useMdLineBreaks"> /// If true, when the text is cleansed, all newlines will be replaced by Markdown line /// breaks to maintain the assumed intended line breaks in the text; otherwise, the text's /// newlines will not parsed as line breaks by Markdown parsers. /// </param> public void WriteLine(object output, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, bool useMdLineBreaks = true, int numNewLines = 2) { string text = MdText.StyleAndFormat(output, style, format); _Stream.Write(MdText.Cleanse(text, useMdLineBreaks) + MakeParagraphLineBreak(numNewLines)); }
/// <summary> /// Formats the provided text using the specified <see cref="MdFormat"/>. If styling is also /// desired, use the <see cref="StyleAndFormat"/> method or style the text first; formatting /// text and then styling it produces output that may not parse correctly. /// </summary> /// <param name="text">The text to format.</param> /// <param name="format">The Markdown format to apply.</param> /// <returns>The formatted string.</returns> /// <exception cref="System.ArgumentException">The format is not recognized.</exception> public static string Format(object text, MdFormat format) { string prefix; switch (format) { case MdFormat.None: prefix = string.Empty; break; case MdFormat.Heading1: prefix = Heading1Prefix; break; case MdFormat.Heading2: prefix = Heading2Prefix; break; case MdFormat.Heading3: prefix = Heading3Prefix; break; case MdFormat.Heading4: prefix = Heading4Prefix; break; case MdFormat.Heading5: prefix = Heading5Prefix; break; case MdFormat.Heading6: prefix = Heading6Prefix; break; case MdFormat.Quote: prefix = QuotePrefix; break; case MdFormat.UnorderedListItem: prefix = UnorderedListItemPrefix; break; case MdFormat.OrderedListItem: prefix = OrderedListItemPrefix; break; #pragma warning disable CA1308 // Normalize strings to uppercase case MdFormat.InternalLink: prefix = ""; text = $"[{text}](#{RemoveInvalidMDLinkCharacters(text).ToLowerInvariant()})"; break; #pragma warning restore CA1308 // Normalize strings to uppercase default: throw new ArgumentException("The format is not recognized."); } return(prefix + text); }
/// <summary> /// Writes the provided output to the file. /// </summary> /// <param name="output">The output to write.</param> /// <param name="style">The optional Markdown style to apply.</param> /// <param name="format">The optional Markdown format to apply.</param> /// <param name="useMdLineBreaks"> /// If true, when the text is cleansed, all newlines will be replaced by Markdown line /// breaks to maintain the assumed intended line breaks in the text; otherwise, the text's /// newlines will not parsed as line breaks by Markdown parsers. /// </param> public void Write(object output, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, bool useMdLineBreaks = true) { string text = MdText.StyleAndFormat(output, style, format); _Stream.Write(MdText.Cleanse(text, useMdLineBreaks)); }
/// <summary> /// Formats the provided text using the specified <see cref="MdFormat"/>. If styling is also /// desired, use the <see cref="StyleAndFormat"/> method or style the text first; formatting /// text and then styling it produces output that may not parse correctly. /// </summary> /// <param name="text">The text to format.</param> /// <param name="format">The Markdown format to apply.</param> /// <returns>The formatted string.</returns> /// <exception cref="System.ArgumentException">The format is not recognized.</exception> public static string Format(object text, MdFormat format) { string prefix; switch (format) { case MdFormat.None: prefix = String.Empty; break; case MdFormat.Heading1: prefix = Heading1Prefix; break; case MdFormat.Heading2: prefix = Heading2Prefix; break; case MdFormat.Heading3: prefix = Heading3Prefix; break; case MdFormat.Heading4: prefix = Heading4Prefix; break; case MdFormat.Heading5: prefix = Heading5Prefix; break; case MdFormat.Heading6: prefix = Heading6Prefix; break; case MdFormat.Quote: prefix = QuotePrefix; break; case MdFormat.UnorderedListItem: prefix = UnorderedListItemPrefix; break; case MdFormat.OrderedListItem: prefix = OrderedListItemPrefix; break; default: throw new ArgumentException("The format is not recognized."); } return(prefix + text); }
/// <summary> /// Writes the provided output to the file using the /// <see cref="MdFormat.UnorderedListItem"/> format, followed by a Markdown paragraph break /// to terminate the list item. /// </summary> /// <param name="output">The output to write.</param> /// <param name="listIndent"> /// The optional indent of the list item (0 adds no indent, 1 adds a single indentation to /// create a sublist, etc). Negative values are ignored. /// </param> /// <param name="style">The optional Markdown style to apply.</param> /// <param name="format">The optional Markdown format to apply.</param> /// </param> public void WriteUnorderedListItem(object output, int listIndent = 0, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, int numNewLines = 1) { string text = MdText.Format(output, format); text = MdText.StyleAndFormat(text, style, MdFormat.UnorderedListItem); text = MdText.Indent(text, listIndent); _Stream.Write(MdText.Cleanse(text, true) + MakeParagraphLineBreak(numNewLines)); }
///<summary>ウディタ情報をファイル出力</summary> public void Output() { AddBlankAppMesWhenHasAlreadyAppMes(); MdFormat format = new MdFormat(); if (woditerInfoStr.CEvStrs != null) { CreateOutputStrsCEv(woditerInfoStr.CEvStrs, format); } if (woditerInfoStr.CDBStrs != null) { CreateOutputStrsDB(woditerInfoStr.CDBStrs, WoditerInfo.WoditerInfoCategory.CDB, format); } if (woditerInfoStr.UDBStrs != null) { CreateOutputStrsDB(woditerInfoStr.UDBStrs, WoditerInfo.WoditerInfoCategory.UDB, format); } if (woditerInfoStr.SDBStrs != null) { CreateOutputStrsDB(woditerInfoStr.SDBStrs, WoditerInfo.WoditerInfoCategory.SDB, format); } if (woditerInfoStr.MapDataStrs.Count != 0) { CreateOutputStrsMap(woditerInfoStr.MapDataStrs, format); } if (woditerInfoStr.MapTreeStr != null) { CreateOutputStrsMapTree(woditerInfoStr.MapTreeStr, format); } if (woditerInfoStr.TileMgrStr != null) { CreateOutputStrsTileSet(woditerInfoStr.TileMgrStr, format); } }
/// <summary> /// Styles then formats the provided text using the specified <see cref="MdStyle"/> and /// <see cref="MdFormat"/>. /// </summary> /// <param name="text">The text to format and style.</param> /// <param name="style">The Markdown style to apply.</param> /// <param name="format">The Markdown format to apply.</param> /// <returns>The formatted and styled string.</returns> public static string StyleAndFormat(object text, MdStyle style, MdFormat format) { return Format(Style(text, style), format); }
/// <summary> /// Formats the provided text using the specified <see cref="MdFormat"/>. If styling is also /// desired, use the <see cref="StyleAndFormat"/> method or style the text first; formatting /// text and then styling it produces output that may not parse correctly. /// </summary> /// <param name="text">The text to format.</param> /// <param name="format">The Markdown format to apply.</param> /// <returns>The formatted string.</returns> /// <exception cref="System.ArgumentException">The format is not recognized.</exception> public static string Format(object text, MdFormat format) { string prefix; switch (format) { case MdFormat.None: prefix = String.Empty; break; case MdFormat.Heading1: prefix = Heading1Prefix; break; case MdFormat.Heading2: prefix = Heading2Prefix; break; case MdFormat.Heading3: prefix = Heading3Prefix; break; case MdFormat.Heading4: prefix = Heading4Prefix; break; case MdFormat.Heading5: prefix = Heading5Prefix; break; case MdFormat.Heading6: prefix = Heading6Prefix; break; case MdFormat.Quote: prefix = QuotePrefix; break; case MdFormat.UnorderedListItem: prefix = UnorderedListItemPrefix; break; case MdFormat.OrderedListItem: prefix = OrderedListItemPrefix; break; default: throw new ArgumentException("The format is not recognized."); } return prefix + text; }
/// <summary> /// Writes the provided output to the file, followed by a Markdown paragraph break to /// terminate the line and start a new paragraph. /// </summary> /// <param name="output">The output to write.</param> /// <param name="style">The optional Markdown style to apply.</param> /// <param name="format">The optional Markdown format to apply.</param> /// <param name="useMdLineBreaks"> /// If true, when the text is cleansed, all newlines will be replaced by Markdown line /// breaks to maintain the assumed intended line breaks in the text; otherwise, the text's /// newlines will not parsed as line breaks by Markdown parsers. /// </param> public void WriteLine(object output, MdStyle style = MdStyle.None, MdFormat format = MdFormat.None, bool useMdLineBreaks = true) { string text = MdText.StyleAndFormat(output, style, format); stream.Write(MdText.Cleanse(text, useMdLineBreaks) + MdText.ParagraphBreak); }
/// <summary> /// Styles then formats the provided text using the specified <see cref="MdStyle"/> and /// <see cref="MdFormat"/>. /// </summary> /// <param name="text">The text to format and style.</param> /// <param name="style">The Markdown style to apply.</param> /// <param name="format">The Markdown format to apply.</param> /// <returns>The formatted and styled string.</returns> public static string StyleAndFormat(object text, MdStyle style, MdFormat format) { return(Format(Style(text, style), format)); }