-
Notifications
You must be signed in to change notification settings - Fork 162
Conversation
Now code blocks are highlighting with prettify
This is awesome, I think this syntax works with both liquid and razor.
For the last one, if you haven't the time I will look into it.
@shiftkey, @JakeGinnivan, what do you think? |
return text.Replace(m[0].Groups[0].Value, "").Trim(); | ||
text = text.Replace(m[0].Groups[0].Value, ""); | ||
var lines = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None).ToList(); | ||
while (lines.Any() && string.IsNullOrWhiteSpace(lines.First())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be done in a more LINQ-friendly way?
var nonEmptyLine = lines.Where(x => !String.IsNullOrWhiteSpace(x));
return String.Join(Environment.NewLine, nonEmptyLines).TrimEnd();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't remove empty line in the middle of the text. My while
removes only first empty lines. So, SkipWhile
is needed. I will fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, 👍 to SkipWhile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (commit 0e5338f)
For reference, this is how Jekyll does it:
A couple of quick thoughts on the proposed syntax (contrasting against the above sample):
That feels so much friendlier than needing to wrapp the language name in
|
@laedit, @shiftkey, thank you for feedback. I will try to add suport of differenet syntax for declare code blocks. About highlighters: I suggest to use some predefine set of highlighters and choose it in the config like in the following line: highlighter: prettyify What kind of additional highlighters is needed? |
There is a problem with the MarkdownDeep library. The issue about support for backtick fenced code blocks have been fixed only at 24 Feb 2014. But the current NuGet version of the library (0.5) is obsolete (last updated at August 20, 2012). So, it is impossible to implement nice support of markdown codeblocks with this version. I suggest switching the project to CommonMark.NET for markdown processing. Advantages:
What do you think? |
Also I suggest using of CommonMark Spec 0.17 without specific highlighter. For example, lines
will transform in
It is the HTML5 convention for code element. Prettify supports it. Next, a pretzel user can add any highlighter yourself. What do you think? |
I'd totally be down for switching over to a more modern Markdown library |
That is a great idea! |
It seems that prettify always need the |
Yes, but you can add this class with one jQuery line. So, it is not a problem. |
Good point. |
Done. |
In that case we can use highlightjs which does not require JQuery. For the plugins it is a bit more complicated :) |
Ok, then I just will change |
Done. |
Any updates? |
Sorry, I haven't got the time to merge it. |
Now code blocks are highlighting with prettify