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

Code block support #206

Merged
merged 8 commits into from
Feb 15, 2015
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
6 changes: 4 additions & 2 deletions src/Pretzel.Logic/Extensions/YamlExtensions.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
}
}
}
20 changes: 10 additions & 10 deletions src/Pretzel.Logic/Pretzel.Logic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\AjaxMin.5.13.5463.15282\lib\net40\AjaxMin.dll</HintPath>
</Reference>
<Reference Include="CommonMark">
<HintPath>..\packages\CommonMark.NET.0.8.0\lib\net40-client\CommonMark.dll</HintPath>
</Reference>
<Reference Include="dotless.ClientOnly">
<HintPath>..\packages\DotlessClientOnly.1.4.1.0\lib\dotless.ClientOnly.dll</HintPath>
</Reference>
Expand All @@ -46,10 +49,6 @@
<Reference Include="HtmlAgilityPack">
<HintPath>..\packages\HtmlAgilityPack.1.4.9\lib\Net40\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="MarkdownDeep, Version=1.5.4615.26275, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MarkdownDeep.NET.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll</HintPath>
</Reference>
<Reference Include="NDesk.Options">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -134,11 +133,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>RazorCsProject.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Resources\Liquid\Sitemap.liquid" />
<None Include="Resources\RazorAzure\Shim.cs" />
<None Include="Resources\RazorCsProject\Category_cs" />
Expand All @@ -154,6 +148,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>RazorWiki.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="SanityCheck.cs" />
<Compile Include="Templating\Context\Category.cs" />
<Compile Include="Templating\Context\NonProcessedPage.cs" />
Expand Down Expand Up @@ -198,7 +197,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources1.Designer.cs</LastGenOutput>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\RazorAzure.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand All @@ -211,6 +210,7 @@
<EmbeddedResource Include="Properties\RazorWiki.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>RazorWiki.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/Pretzel.Logic/Resources/Liquid/FirstPost.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ comments: true

## Hello world...

```cs
static void Main()
{
Console.WriteLine("Hello World!");
}
```


This is my first post on the site!
3 changes: 0 additions & 3 deletions src/Pretzel.Logic/Resources/Liquid/Index.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ title : SiteName
<div class="idea">
{% if forloop.first and post.layout == "post" %}
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1>

<div class="postdate">{{ post.date | date: "%e %B, %Y" }}
<ul>
{% for tag in post.tags %}
<li><a href="/tag/{{ tag }}">{{ tag }}</a></li>
{% endfor %}
</ul>
</div>

{{ post.content }}
<br />
<a href="{{ post.url}}#disqus_thread">Comments</a>
Expand All @@ -31,7 +29,6 @@ title : SiteName
</ul>
</div>
{{ post.content }}

<a href="{{ post.url }}#disqus_thread">Comments</a>
{% endif %}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/Pretzel.Logic/Resources/Liquid/Layout.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="/rss.xml" type="application/rss+xml" rel="alternate" title="Blog Feed" />
<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Blog Feed" />

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>{{ page.title }}</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/8.4/styles/default.min.css">
<link rel="shortcut icon" href="/img/favicon.ico" />
</head>
<body>
Expand All @@ -26,7 +26,8 @@
<div id="content">
{{content}}
</div>

</div>
<script src="//cdn.jsdelivr.net/highlight.js/8.4/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>
1 change: 0 additions & 1 deletion src/Pretzel.Logic/Resources/Liquid/Post.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ layout: layout
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'NAME'; // required: replace example with your forum shortname

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
Expand Down
2 changes: 0 additions & 2 deletions src/Pretzel.Logic/Resources/Liquid/Rss.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ layout: nil
<language>en-au</language>
<pubDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
<lastBuildDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>

{% for post in site.posts %}
<item>
<title>{{ post.title | xml_escape }}</title>
Expand All @@ -22,6 +21,5 @@ layout: nil
<description>{{ post.content | xml_escape }}</description>
</item>
{% endfor %}

</channel>
</rss>
2 changes: 0 additions & 2 deletions src/Pretzel.Logic/Resources/Liquid/Sitemap.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ layout: nil
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- Generated with pretzel -->

{% for post in site.posts %}
<url>
<loc>http://domain{{ post.url }}</loc>
Expand All @@ -27,5 +26,4 @@ layout: nil
</url>
{% endif %}
{% endfor %}

</urlset>
9 changes: 9 additions & 0 deletions src/Pretzel.Logic/Resources/Razor/FirstPost.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ comments: true

## Hello world...

Code:

```cs
static void Main()
{
Console.WriteLine("Hello World!");
}
```

This is my first post on the site!
2 changes: 0 additions & 2 deletions src/Pretzel.Logic/Resources/Razor/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ title : SiteName
@if (i == 0 && post.Layout == "post")
{
<h1><a href="@post.Url">@post.Title</a></h1>

<div class="postdate">@post.Date.ToString("d MMM, yyyy")
<ul>
@foreach(var tag in post.Tags)
Expand All @@ -41,7 +40,6 @@ title : SiteName
</ul>
</div>
@Raw(post.Content)

<a href="@post.Url#disqus_thread">Comments</a>
}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/Pretzel.Logic/Resources/Razor/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="/rss.xml" type="application/rss+xml" rel="alternate" title="Blog Feed" />
<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Blog Feed" />

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>@Model.Title</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/8.4/styles/default.min.css">
<link rel="shortcut icon" href="/img/favicon.ico" />
</head>
<body>
Expand All @@ -28,7 +28,8 @@
<div id="content">
@Raw(Model.Content)
</div>

</div>
<script src="//cdn.jsdelivr.net/highlight.js/8.4/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>
6 changes: 2 additions & 4 deletions src/Pretzel.Logic/Templating/Context/SiteContextGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MarkdownDeep;
using Pretzel.Logic.Extensibility;
using Pretzel.Logic.Extensibility;
using Pretzel.Logic.Extensions;
using System;
using System.Collections.Generic;
Expand All @@ -22,7 +21,6 @@ public class SiteContextGenerator


readonly Dictionary<string, Page> pageCache = new Dictionary<string, Page>();
static readonly Markdown Markdown = new Markdown();
readonly IFileSystem fileSystem;
readonly IEnumerable<IContentTransform> contentTransformers;
readonly List<string> includes = new List<string>();
Expand Down Expand Up @@ -328,7 +326,7 @@ private string RenderContent(string file, string contents, IDictionary<string, o
var contentsWithoutHeader = contents.ExcludeHeader();

html = Path.GetExtension(file).IsMarkdownFile()
? Markdown.Transform(contentsWithoutHeader)
? CommonMark.CommonMarkConverter.Convert(contentsWithoutHeader).Trim()
: contentsWithoutHeader;

html = contentTransformers.Aggregate(html, (current, contentTransformer) => contentTransformer.Transform(current));
Expand Down
1 change: 1 addition & 0 deletions src/Pretzel.Logic/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AjaxMin" version="5.13.5463.15282" targetFramework="net40" />
<package id="CommonMark.NET" version="0.8.0" targetFramework="net40" />
<package id="DotlessClientOnly" version="1.4.1.0" targetFramework="net40" />
<package id="DotLiquid" version="1.8.0" targetFramework="net40" />
<package id="HtmlAgilityPack" version="1.4.9" targetFramework="net40" />
Expand Down
Loading