Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Allow all markdown files to be processed #185

Merged
merged 1 commit into from
Dec 27, 2014
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
2 changes: 1 addition & 1 deletion src/Pretzel.Logic/Templating/Context/PathExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Pretzel.Logic.Templating.Context
{
public static class PathExtensions
{
private static readonly string[] MarkdownFiles = new[] { ".md", ".mdown", ".markdown" };
private static readonly string[] MarkdownFiles = new[] { ".md", ".mkd", ".mkdn", ".mdown", ".markdown" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to the change, but this seems like a very big yak to shave 😀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!
I think that these extensions are the most used, so it is may be not necessary to add the others?
Or "mdwn" only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave it as-is. If someone wants a different extension, they can add it in a PR.

private static readonly string[] ImageFiles = new[] { ".png", ".gif", ".jpg" };

public static bool IsMarkdownFile(this string extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private string RenderContent(string file, string contents, IDictionary<string, o
try
{
var contentsWithoutHeader = contents.ExcludeHeader();
html = string.Equals(Path.GetExtension(file), ".md", StringComparison.InvariantCultureIgnoreCase)
html = Path.GetExtension(file).IsMarkdownFile()
? Markdown.Transform(contentsWithoutHeader)
: contentsWithoutHeader;

Expand Down
53 changes: 53 additions & 0 deletions src/Pretzel.Tests/Templating/Context/SiteContextGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,58 @@ public void site_context_pages_have_date_in_bag(string fileName, bool useDefault

Assert.Equal(expectedDate, actualDate);
}

[Fact]
public void site_context_generator_processes_page_markdown_mkd()
{
// arrange
fileSystem.AddFile(@"C:\TestSite\_posts\2012-01-01-SomeFile.mkd", new MockFileData(ToPageContent("# Title")));

// act
var siteContext = generator.BuildContext(@"C:\TestSite", false);

// assert
Assert.Equal("<h1>Title</h1>", siteContext.Posts[0].Content.Trim());
}

[Fact]
public void site_context_generator_processes_page_markdown_mkdn()
{
// arrange
fileSystem.AddFile(@"C:\TestSite\_posts\2012-01-01-SomeFile.mkdn", new MockFileData(ToPageContent("# Title")));

// act
var siteContext = generator.BuildContext(@"C:\TestSite", false);

// assert
Assert.Equal("<h1>Title</h1>", siteContext.Posts[0].Content.Trim());
}

[Fact]
public void site_context_generator_processes_page_markdown_mdown()
{
// arrange
fileSystem.AddFile(@"C:\TestSite\_posts\2012-01-01-SomeFile.mdown", new MockFileData(ToPageContent("# Title")));

// act
var siteContext = generator.BuildContext(@"C:\TestSite", false);

// assert
Assert.Equal("<h1>Title</h1>", siteContext.Posts[0].Content.Trim());
}

[Fact]
public void site_context_generator_processes_page_markdown_markdown()
{
// arrange
fileSystem.AddFile(@"C:\TestSite\_posts\2012-01-01-SomeFile.markdown", new MockFileData(ToPageContent("# Title")));

// act
var siteContext = generator.BuildContext(@"C:\TestSite", false);

// assert
Assert.Equal("<h1>Title</h1>", siteContext.Posts[0].Content.Trim());
}

}
}