diff --git a/src/Pretzel.Logic/Extensions/YamlExtensions.cs b/src/Pretzel.Logic/Extensions/YamlExtensions.cs index 9e1fe3a2b..871fb0f7b 100644 --- a/src/Pretzel.Logic/Extensions/YamlExtensions.cs +++ b/src/Pretzel.Logic/Extensions/YamlExtensions.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Text.RegularExpressions; using YamlDotNet.RepresentationModel; using System.IO; +using System.Linq; using YamlDotNet.Serialization; namespace Pretzel.Logic.Extensions @@ -107,7 +109,7 @@ public static string ExcludeHeader(this string text) if (m.Count == 0) return text; - return text.Replace(m[0].Groups[0].Value, "").Trim(); + return text.Replace(m[0].Groups[0].Value, "").TrimStart('\r', '\n').TrimEnd(); } } } diff --git a/src/Pretzel.Logic/Pretzel.Logic.csproj b/src/Pretzel.Logic/Pretzel.Logic.csproj index eea2e8c80..cfc7d56dc 100644 --- a/src/Pretzel.Logic/Pretzel.Logic.csproj +++ b/src/Pretzel.Logic/Pretzel.Logic.csproj @@ -37,6 +37,9 @@ False ..\packages\AjaxMin.5.13.5463.15282\lib\net40\AjaxMin.dll + + ..\packages\CommonMark.NET.0.8.0\lib\net40-client\CommonMark.dll + ..\packages\DotlessClientOnly.1.4.1.0\lib\dotless.ClientOnly.dll @@ -46,10 +49,6 @@ ..\packages\HtmlAgilityPack.1.4.9\lib\Net40\HtmlAgilityPack.dll - - False - ..\packages\MarkdownDeep.NET.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll - ..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll @@ -134,11 +133,6 @@ True RazorCsProject.resx - - True - True - Resources.resx - @@ -154,6 +148,11 @@ True RazorWiki.resx + + True + True + Resources.resx + @@ -198,7 +197,7 @@ ResXFileCodeGenerator Designer - Resources1.Designer.cs + Resources.Designer.cs ResXFileCodeGenerator @@ -211,6 +210,7 @@ ResXFileCodeGenerator RazorWiki.Designer.cs + Designer diff --git a/src/Pretzel.Logic/Properties/Resources1.Designer.cs b/src/Pretzel.Logic/Properties/Resources.Designer.cs similarity index 89% rename from src/Pretzel.Logic/Properties/Resources1.Designer.cs rename to src/Pretzel.Logic/Properties/Resources.Designer.cs index 7193d5993..d21091627 100644 --- a/src/Pretzel.Logic/Properties/Resources1.Designer.cs +++ b/src/Pretzel.Logic/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17372 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -60,6 +60,9 @@ internal Resources() { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap _25 { get { object obj = ResourceManager.GetObject("_25", resourceCulture); @@ -67,6 +70,9 @@ internal static System.Drawing.Bitmap _25 { } } + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// internal static System.Drawing.Icon faviconico { get { object obj = ResourceManager.GetObject("faviconico", resourceCulture); @@ -74,6 +80,9 @@ internal static System.Drawing.Icon faviconico { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap faviconpng { get { object obj = ResourceManager.GetObject("faviconpng", resourceCulture); @@ -81,6 +90,9 @@ internal static System.Drawing.Bitmap faviconpng { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap logo { get { object obj = ResourceManager.GetObject("logo", resourceCulture); @@ -128,10 +140,7 @@ internal static System.Drawing.Bitmap logo { ///li ///{ /// margin:0; - /// padding:0; - /// list-style-type:none; - ///} - ///.entry [rest of string was truncated]";. + /// padd [rest of string was truncated]";. /// internal static string Style { get { diff --git a/src/Pretzel.Logic/Resources/Liquid/FirstPost.liquid b/src/Pretzel.Logic/Resources/Liquid/FirstPost.liquid index abafcc08e..b8a3d8b87 100644 --- a/src/Pretzel.Logic/Resources/Liquid/FirstPost.liquid +++ b/src/Pretzel.Logic/Resources/Liquid/FirstPost.liquid @@ -7,4 +7,12 @@ comments: true ## Hello world... +```cs +static void Main() +{ + Console.WriteLine("Hello World!"); +} +``` + + This is my first post on the site! \ No newline at end of file diff --git a/src/Pretzel.Logic/Resources/Liquid/Index.liquid b/src/Pretzel.Logic/Resources/Liquid/Index.liquid index 365d0d8a9..6ae94c915 100644 --- a/src/Pretzel.Logic/Resources/Liquid/Index.liquid +++ b/src/Pretzel.Logic/Resources/Liquid/Index.liquid @@ -9,7 +9,6 @@ title : SiteName
{% if forloop.first and post.layout == "post" %}

{{ post.title }}

- - {{ post.content }}
Comments @@ -31,7 +29,6 @@ title : SiteName
{{ post.content }} - Comments {% endif %} diff --git a/src/Pretzel.Logic/Resources/Liquid/Layout.liquid b/src/Pretzel.Logic/Resources/Liquid/Layout.liquid index b35f77f4b..89e8b1dad 100644 --- a/src/Pretzel.Logic/Resources/Liquid/Layout.liquid +++ b/src/Pretzel.Logic/Resources/Liquid/Layout.liquid @@ -5,10 +5,10 @@ - {{ page.title }} + @@ -26,7 +26,8 @@
{{content}}
- + + \ No newline at end of file diff --git a/src/Pretzel.Logic/Resources/Liquid/Post.liquid b/src/Pretzel.Logic/Resources/Liquid/Post.liquid index 733568696..d40fd099b 100644 --- a/src/Pretzel.Logic/Resources/Liquid/Post.liquid +++ b/src/Pretzel.Logic/Resources/Liquid/Post.liquid @@ -25,7 +25,6 @@ layout: layout + \ No newline at end of file diff --git a/src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs b/src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs index 15f18eece..3a7d3af31 100644 --- a/src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs +++ b/src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs @@ -1,5 +1,4 @@ -using MarkdownDeep; -using Pretzel.Logic.Extensibility; +using Pretzel.Logic.Extensibility; using Pretzel.Logic.Extensions; using System; using System.Collections.Generic; @@ -22,7 +21,6 @@ public class SiteContextGenerator readonly Dictionary pageCache = new Dictionary(); - static readonly Markdown Markdown = new Markdown(); readonly IFileSystem fileSystem; readonly IEnumerable contentTransformers; readonly List includes = new List(); @@ -328,7 +326,7 @@ private string RenderContent(string file, string contents, IDictionary contentTransformer.Transform(current)); diff --git a/src/Pretzel.Logic/packages.config b/src/Pretzel.Logic/packages.config index c55ce2d5c..da0ea724c 100644 --- a/src/Pretzel.Logic/packages.config +++ b/src/Pretzel.Logic/packages.config @@ -1,6 +1,7 @@  + diff --git a/src/Pretzel.Tests/Templating/Context/SiteContextGeneratorTests.cs b/src/Pretzel.Tests/Templating/Context/SiteContextGeneratorTests.cs index b83c6a3d5..3d0651e0e 100644 --- a/src/Pretzel.Tests/Templating/Context/SiteContextGeneratorTests.cs +++ b/src/Pretzel.Tests/Templating/Context/SiteContextGeneratorTests.cs @@ -14,6 +14,7 @@ using Pretzel.Logic.Extensions; using System.Text; using System.Threading; +using Pretzel.Tests.Templating.Jekyll; namespace Pretzel.Tests.Templating.Context { @@ -734,7 +735,7 @@ public void page_default_values() Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("this is a post", siteContext.Pages[0].Title); Assert.Equal(DateTime.Now.Date, siteContext.Pages[0].Date.Date); - Assert.Equal("

Title

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

", siteContext.Pages[0].Content.TrimEnd()); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Pages[0].Filepath); Assert.Equal(@"C:\TestSite\SomeFile.md", siteContext.Pages[0].File); Assert.Equal(3, siteContext.Pages[0].Bag.Count); // param, excerpt, date @@ -758,7 +759,7 @@ public void page_metadata_values() Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("my title", siteContext.Pages[0].Title); Assert.Equal(new DateTime(2015, 1, 27), siteContext.Pages[0].Date); - Assert.Equal("

Title

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

", siteContext.Pages[0].Content.RemoveWhiteSpace()); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Pages[0].Filepath); Assert.Equal(@"C:\TestSite\SomeFile.md", siteContext.Pages[0].File); Assert.Equal(4, siteContext.Pages[0].Bag.Count); // title, date, param, excerpt @@ -784,7 +785,7 @@ public void page_with_date_in_title() Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("this is a post", siteContext.Pages[0].Title); Assert.Equal(new DateTime(2015, 1, 26), siteContext.Pages[0].Date); - Assert.Equal("

Title

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

", siteContext.Pages[0].Content.RemoveWhiteSpace()); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}-SomeFile.md", currentDate.Replace("/", "-")), siteContext.Pages[0].Filepath); Assert.Equal(filePath, siteContext.Pages[0].File); Assert.Equal(3, siteContext.Pages[0].Bag.Count); // param, excerpt, date @@ -807,7 +808,7 @@ public void page_with_false_date_in_title() Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("this is a post", siteContext.Pages[0].Title); Assert.Equal(DateTime.Now.Date, siteContext.Pages[0].Date.Date); - Assert.Equal("

Title

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

", siteContext.Pages[0].Content.RemoveWhiteSpace()); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}SomeFile.md", currentDate.Replace("/", "-")), siteContext.Pages[0].Filepath); Assert.Equal(filePath, siteContext.Pages[0].File); Assert.Equal(3, siteContext.Pages[0].Bag.Count); // param, excerpt, date @@ -827,7 +828,7 @@ public void post_default_values() Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("this is a post", siteContext.Posts[0].Title); Assert.Equal(DateTime.Now.Date, siteContext.Posts[0].Date.Date); - Assert.Equal("

Title

\n", siteContext.Posts[0].Content); + Assert.Equal("

Title

", siteContext.Posts[0].Content.RemoveWhiteSpace()); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Posts[0].Filepath); Assert.Equal(@"C:\TestSite\_posts\SomeFile.md", siteContext.Posts[0].File); Assert.Equal(3, siteContext.Posts[0].Bag.Count); // param, excerpt, date @@ -851,7 +852,7 @@ public void post_metadata_values() Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("my title", siteContext.Posts[0].Title); Assert.Equal(new DateTime(2015, 1, 27), siteContext.Posts[0].Date); - Assert.Equal("

Title

\n", siteContext.Posts[0].Content); + Assert.Equal("

Title

", siteContext.Posts[0].Content.RemoveWhiteSpace()); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Posts[0].Filepath); Assert.Equal(@"C:\TestSite\_posts\SomeFile.md", siteContext.Posts[0].File); Assert.Equal(4, siteContext.Posts[0].Bag.Count); // title, date, param, excerpt @@ -903,7 +904,7 @@ public void post_with_date_in_title() Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("this is a post", siteContext.Posts[0].Title); Assert.Equal(new DateTime(2015, 1, 26), siteContext.Posts[0].Date); - Assert.Equal("

Title

\n", siteContext.Posts[0].Content); + Assert.Equal("

Title

", siteContext.Posts[0].Content.RemoveWhiteSpace()); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}\SomeFile.md", currentDate.Replace("/", "\\")), siteContext.Posts[0].Filepath); Assert.Equal(filePath, siteContext.Posts[0].File); Assert.Equal(3, siteContext.Posts[0].Bag.Count); // param, excerpt, date @@ -926,7 +927,7 @@ public void post_with_false_date_in_title() Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("this is a post", siteContext.Posts[0].Title); Assert.Equal(DateTime.Now.Date, siteContext.Posts[0].Date.Date); - Assert.Equal("

Title

\n", siteContext.Posts[0].Content); + Assert.Equal("

Title

", siteContext.Posts[0].Content.RemoveWhiteSpace()); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}SomeFile.md", currentDate.Replace("/", "\\")), siteContext.Posts[0].Filepath); Assert.Equal(filePath, siteContext.Posts[0].File); Assert.Equal(3, siteContext.Posts[0].Bag.Count); // param, excerpt, date @@ -1058,7 +1059,7 @@ public void render_with_ContentTransformer_should_transform_content() Assert.Equal(1, siteContext.Pages.Count); - Assert.Equal("

Title

\n

bar

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

bar

", siteContext.Pages[0].Content.RemoveWhiteSpace()); } [Fact] @@ -1132,7 +1133,7 @@ public void file_with_1_ioexception_on_ReadAllText_is_processed() // assert Assert.Equal(1, siteContext.Pages.Count); - Assert.Equal("

Title

\n", siteContext.Pages[0].Content); + Assert.Equal("

Title

", siteContext.Pages[0].Content.RemoveWhiteSpace()); // Check if the temp file have been deleted fileSubstitute.Received().Delete(filePath); } diff --git a/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs b/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs index e42cdaff5..a92c26a0e 100644 --- a/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs +++ b/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs @@ -1184,7 +1184,7 @@ public void The_Output_Should_Have_The_Comments_Value() public class When_A_Page_Has_A_Valid_Include_Value : BakingEnvironment { - const string PageContents = "---\r\ntest: value\r\n---#{{ page.title }}\r\n{% include foobar.html %}"; + const string PageContents = "---\r\ntest: value\r\n---# {{ page.title }}\r\n{% include foobar.html %}"; const string IncludePageContents = "foo {{ page.test }} bar"; const string ExpectedfileContents = "

My Web Site

foo value bar

"; @@ -1220,7 +1220,7 @@ public void Does_Not_Copy_Include_To_Output() public class When_A_Page_Has_A_Non_Existing_Include_Value : BakingEnvironment { - const string PageContents = "---\r\ntest: value\r\n---#{{ page.title }}\r\n{% include foobar.html %}"; + const string PageContents = "---\r\ntest: value\r\n---# {{ page.title }}\r\n{% include foobar.html %}"; const string ExpectedfileContents = "

My Web Site

"; public override LiquidEngine Given() @@ -1248,7 +1248,7 @@ public void The_File_Has_Not_The_Include_Value() public class When_A_Page_Has_A_Permalink_Without_FileName : BakingEnvironment { - const string PageContents = "---\r\npermalink: /pages/\r\n---#{{ page.title }}"; + const string PageContents = "---\r\npermalink: /pages/\r\n---# {{ page.title }}"; const string ExpectedfileContents = "

My Web Site

"; public override LiquidEngine Given() @@ -1367,5 +1367,33 @@ public void Layout_With_Bad_Header_Should_Not_Throw_Exception() Assert.Equal(Context.Posts[0].Categories.First(), "mycategory"); } } + + public class Given_Page_Has_Code_Block : BakingEnvironment + { + const string PageContents = "---\r\n layout: nil \r\n---\r\n\r\n```cs\r\nMy code1\r\nMy code2\r\n```\r\n"; + const string ExpectedfileContents = "
My code1My code2
"; + + public override LiquidEngine Given() + { + var engine = new LiquidEngine(); + engine.Initialize(); + return engine; + } + + public override void When() + { + FileSystem.AddFile(@"C:\website\index.md", new MockFileData(PageContents)); + var generator = new SiteContextGenerator(FileSystem, Enumerable.Empty()); + var context = generator.BuildContext(@"C:\website\", false); + Subject.FileSystem = FileSystem; + Subject.Process(context); + } + + [Fact] + public void The_Filter_And_Block_Have_Been_Correctly_Interpreted() + { + Assert.Equal(ExpectedfileContents, FileSystem.File.ReadAllText(@"C:\website\_site\index.html").RemoveWhiteSpace()); + } + } } } \ No newline at end of file diff --git a/src/Pretzel.Tests/Templating/Razor/RazorEngineTests.cs b/src/Pretzel.Tests/Templating/Razor/RazorEngineTests.cs index 2bde62e6f..6e58413ca 100644 --- a/src/Pretzel.Tests/Templating/Razor/RazorEngineTests.cs +++ b/src/Pretzel.Tests/Templating/Razor/RazorEngineTests.cs @@ -220,8 +220,8 @@ public class When_Paginate_Razor : BakingEnvironment const string TemplateContents = "@model Pretzel.Logic.Templating.Context.PageContext \r\n@Raw(Model.Content)"; const string PostContents = "---\r\n layout: default \r\n title: 'Post'\r\n---\r\n

Post{0}

"; const string IndexContents = "---\r\n layout: default \r\n paginate: 2 \r\n paginate_link: /blog/page:page/index.html \r\n---\r\n @model Pretzel.Logic.Templating.Context.PageContext \r\n @foreach(var post in Model.Paginator.Posts) { @Raw(post.Content) }"; - const string ExpectedfileContents = "

Post{0}

Post{1}

"; - const string ExpectedLastFileContents = "

Post{0}

"; + const string ExpectedFileContents = "

Post{0}

Post{1}

"; + const string ExpectedLastFileContents = "

Post{0}

"; public override RazorSiteEngine Given() { @@ -247,13 +247,13 @@ public override void When() [Fact] public void Posts_Properly_Paginated() { - Assert.Equal(String.Format(ExpectedfileContents, 7, 6), + Assert.Equal(String.Format(ExpectedFileContents, 7, 6), FileSystem.File.ReadAllText(@"C:\website\_site\index.html").RemoveWhiteSpace()); - Assert.Equal(String.Format(ExpectedfileContents, 5, 4), + Assert.Equal(String.Format(ExpectedFileContents, 5, 4), FileSystem.File.ReadAllText(@"C:\website\_site\blog\page2\index.html").RemoveWhiteSpace()); - Assert.Equal(String.Format(ExpectedfileContents, 3, 2), + Assert.Equal(String.Format(ExpectedFileContents, 3, 2), FileSystem.File.ReadAllText(@"C:\website\_site\blog\page3\index.html").RemoveWhiteSpace()); Assert.Equal(String.Format(ExpectedLastFileContents, 1),