Skip to content

Moved MarkdownOut files to the XML project #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\MarkdownOut\MarkdownOut.csproj" />
<Folder Include="MarkdownOut\" />
</ItemGroup>

</Project>
8 changes: 1 addition & 7 deletions XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuidelineXmlToMD", "GuidelineXmlToMD.csproj", "{D9C7CC15-01DB-46FE-922A-6EB41CE1759B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownOut", "..\MarkdownOut\MarkdownOut.csproj", "{FCAD1B53-2C32-4790-96B8-98AAE7027637}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GuidelineXmlToMD", "GuidelineXmlToMD.csproj", "{D9C7CC15-01DB-46FE-922A-6EB41CE1759B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,10 +15,6 @@ Global
{D9C7CC15-01DB-46FE-922A-6EB41CE1759B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9C7CC15-01DB-46FE-922A-6EB41CE1759B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9C7CC15-01DB-46FE-922A-6EB41CE1759B}.Release|Any CPU.Build.0 = Release|Any CPU
{FCAD1B53-2C32-4790-96B8-98AAE7027637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCAD1B53-2C32-4790-96B8-98AAE7027637}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCAD1B53-2C32-4790-96B8-98AAE7027637}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCAD1B53-2C32-4790-96B8-98AAE7027637}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
36 changes: 36 additions & 0 deletions XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace MarkdownOut {

/// <summary>
/// A container for extension methods related to Markdown styling and formatting.
/// </summary>
public static class MdExtensions {

/// <summary>
/// Styles one or more substrings of the provided string using the specified
/// <see cref="MdStyle"/>.
/// </summary>
/// <param name="str">The string containing the substring to style.</param>
/// <param name="substring">The substring to style.</param>
/// <param name="style">The Markdown style to apply.</param>
/// <param name="firstOnly">
/// If true, only the first occurrence of the substring is styled; otherwise, all
/// occurrences of the substring are styled.
/// </param>
/// <returns>
/// The selectively styled string. If <paramref name="str"/> does not contain any
/// occurrences of <paramref name="substring"/>, it is returned unchanged.
/// </returns>
public static string StyleSubstring(this string str, string substring, MdStyle style,
bool firstOnly = false) {
if (!firstOnly) {
return str.Replace(substring, MdText.Style(substring, style));
}
int pos = str.IndexOf(substring);
if (pos < 0) {
return str;
}
return str.Substring(0, pos) + MdText.Style(substring, style)
+ str.Substring(pos + substring.Length);
}
}
}
65 changes: 65 additions & 0 deletions XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace MarkdownOut {

/// <summary>
/// Specifies a Markdown format to apply to a line or block of text. Formats are applied with a
/// prefix string and, unlike Markdown styles (see <see cref="MdStyle"/>), cannot be selectively
/// applied to substrings.
/// </summary>
public enum MdFormat {

/// <summary>
/// No text format.
/// </summary>
None,

/// <summary>
/// Heading 1 text format (inserts the string <c>"# "</c> in front of text).
/// </summary>
Heading1,

/// <summary>
/// Heading 2 text format (inserts the string <c>"## "</c> in front of text).
/// </summary>
Heading2,

/// <summary>
/// Heading 3 text format (inserts the string <c>"### "</c> in front of text).
/// </summary>
Heading3,

/// <summary>
/// Heading 4 text format (inserts the string <c>"#### "</c> in front of text).
/// </summary>
Heading4,

/// <summary>
/// Heading 5 text format (inserts the string <c>"##### "</c> in front of text).
/// </summary>
Heading5,

/// <summary>
/// Heading 6 text format (inserts the string <c>"###### "</c> in front of text).
/// </summary>
Heading6,

/// <summary>
/// Quote text format (inserts the string <c>"> "</c> in front of text).
/// </summary>
Quote,

/// <summary>
/// Unordered list item text format (inserts the string <c>"- "</c> in front of text).
/// </summary>
UnorderedListItem,

/// <summary>
/// Ordered list item text format (inserts the string <c>"1. "</c> in front of text).
/// </summary>
OrderedListItem,

/// <summary>
/// Creates a link to the heading that matches text to write (formats the text as [Foo](#foo)).
/// </summary>
InternalLink,
}
}
40 changes: 40 additions & 0 deletions XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace MarkdownOut {

/// <summary>
/// Specifies a Markdown style to apply to a string of text. Styles are applied by wrapping text
/// with a special string on each side and can be selectively applied to substrings.
/// </summary>
public enum MdStyle {

/// <summary>
/// No text styling.
/// </summary>
None,

/// <summary>
/// Italic text styling (surrounds text with a single <c>*</c> character on each side).
/// </summary>
Italic,

/// <summary>
/// Bold text styling (surrounds text with two <c>*</c> characters on each side).
/// </summary>
Bold,

/// <summary>
/// Bold italic text styling (surrounds text with three <c>*</c> characters on each side).
/// </summary>
BoldItalic,

/// <summary>
/// Code text styling (surrounds text with a single <c>`</c> character on each side).
/// </summary>
Code,

/// <summary>
/// Strike-through text styling (surrounds text with two <c>~</c> characters on each side).
/// This style may not be supported by all Markdown parsers.
/// </summary>
StrikeThrough,
}
}
Loading