-
Notifications
You must be signed in to change notification settings - Fork 19
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
For evaluation: Implementation of MarkdownDeep.net over Journaley. #129
Conversation
- Replaced MarkdownSharp with MarkdownDeep.net. Has better compatibility with some Markdown features that Day One supports - Added a fix for single line breaks that isn't implemented in MarkdownDeep. Note that this needs some optimization.
string formattedString = string.Format( | ||
"<style type=\"text/css\">\n<!-- Font CSS -->\n{0}\n<!-- Size CSS -->\n{1}\n<!-- Custom CSS -->\n{2}\n</style><html><body><div>{3}</div></body></html>", | ||
"<style type=\"text/css\">\n<!-- Font CSS -->\n{0}\n<!-- Size CSS -->\n{1}\n<!-- Custom CSS -->\n{2}\n</style>\n<html>\n<body>\n<div>\n{3}\n</div>\n</body>\n</html>", |
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.
Added proper line breaks for the tags.
- Transferred the fix into its own helper class, PostMarkdownParser. - Added fixes for strikethroughs and backtick code blocks (converting the <p> tagged code into <pre>). - Added a DOCTYPE on the formatted HTML string to make the HTML parsed HTML 4 strict.
@@ -97,7 +97,9 @@ | |||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | |||
</PropertyGroup> | |||
<Error Condition="!Exists('..\packages\StyleCop.MSBuild.4.7.48.2\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\StyleCop.MSBuild.4.7.48.2\build\StyleCop.MSBuild.Targets'))" /> | |||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> |
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.
Was there a particular reason to change this file?
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.
I really don't know. I think this was when I enabled Nuget Package Recovery in VS.
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.
No, you shouldn't enable that in the solution. In fact, it turns out these changes (in Journaley.Core
, Journaley
, VersionExtractor
) broke the build on my side. Please remove these lines from all the affected projects.
You should just go to Tools
-> Options...
-> NuGet Package Manager
-> General
and check both the Allow NuGet to download missing packages
and Automatically check for missing pakcages during build in Visual Studio
options. The solution should build fine after enabling these options. If not, let's troubleshoot that together later on.
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.
I'll reset my repo and I'll do this again. I'll message you if it worked with just removing the code first.
- Improved PostMarkdown function as suggested by @yyoon. - Reverted screwed up csproj files due to Nuget Package Recovery. - Modified docType string to use HTML5 DOCTYPE standard. - Minor fixes.
// 2 - stumbles upon a <pre> tag. | ||
var parseState = 0; | ||
|
||
string newLineString; |
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.
- Declare this variable when its used in line 86. This makes it easier to understand the code, because the scope of this variable is actually within the
else if (parseState == 0)
block. It is fine for the other variables likebuilder
,paragraphBuilder
, andparseState
, because their state persists over the loops. - Let's rename this to
paragraph
, because it is a better name, it comes from theparagraphBuilder
, and the namenewLineString
can be misleading because it usually refers to\r\n
or some other platform dependent newline string.
Another issue I noticed: when playing with your test file, I found that the entry area shows nested scrollbars like this: This happens because now we use the pre {
word-wrap: break-word;
} Please add this to all three css files (small, medium, large). |
Okay. That makes sense to me. |
|
||
// 0 - stumbles upon the beginning of a <p> tag/usual parsing. | ||
// 1 - stumbles upon the end of </p> tag. | ||
// 2 - skips check and just dumps the line to builder. |
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.
I think you meant to say -1 here, not 2.
The reason for those two lines is because of something like this:
Obviously it's expected like this:
Which is what GFM and Day One renders: For this kind of paragraph, that's why I added those 2 lines on this case. |
Why do I always press the first button ... But anyway, I did agree with passing Strikethrough in paragraph, which did work on my side. |
I understand why you did that, but I still think it was incorrect for a few reasons. First, it wouldn't necessarily match the opening / closing strikethrough mark pairs. ~~Line1
Line2
Line3 GitHub renders it as: ~~Line1 , because there is no closing ~~ mark at the end. However, the current code seems like it would just add the opening Second, it seems to me that it would only handle the ~~ marks that appear right after Normal text ~~strikethrough
should be applied here~~ and not here. GitHub renders it as: Normal text , but I think our previous code would probably not handle this correctly. These are the reasons why I suggested to process at the paragraph level, not at the line level. |
The code I'm doing (not commited yet) is now processing it on the paragraph level now. I switched every line process over to paragraph level. Your second example BTW, has not been rendered on Github, but it does render it on Day One and since we need to be as close to day one as possible, I might need to have a intelligent way of doing this. |
Why does the button for closing a PR is the one I always push? It's getting my nerves a bit. |
I guess space between
Normal text
Normal text ~~ strikethrough |
|
On second thought, there are problems that are going on. I'll fix this tomorrow morning. |
- Removed strikethrough support for now until we can find a way to do it properly (preferably not using Regex). - Single line breaks are now properly added. - Uses StringReader instead of a foreach loop in reading the string. - Backticked code blocks is now properly parsed into <pre> tags.
Here's the (hopefully last) implementation of PostMarkdown. I removed strikethrough support for now, because there are a lot of things to consider, but what I wanted to make sure was the other parts, especially single line breaks, are implemented. If we commit this now, with little to no changes, we'll just add the strikethrough problem as an issue and then work on it incrementally. |
- Since we are doing this upon render time, just replace the backticks into tildes instead to make it properly render HTML tags that might be used (HTML is still considered parsed despite converting the <p> tags to <pre>).
Sorry, I need to do a followup for this one. Apparently, parsing backtick fenced code blocks post markdown would not escape HTML tags. This is like similar to what I said (I think I said it) where That's why in this fix, instead of having to fight MarkdownDeep, I'll just convert the backtick fence into a tilde fence, that way it would be transformed properly as it is intended. The user's file of course is not affected by it since I only change it on UpdateWebBrowser only. I'll find a way to do this programmatically on PostMarkdown properly, but the priority here is making the single line break work. |
Looks good to me. Thanks! |
Implementation of MarkdownDeep.net over Journaley.
Replaced MarkdownSharp with MarkdownDeep.net. Has better compatibility with some Markdown features that Day One supports including Markdown Extra features (tables and footnotes for one), although there are some certain things it doesn't have. That's where fixes comes in, the most important is for single line breaks.
For more information, refer to the commits for details.