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
Render markdown on frontend #86
Render markdown on frontend #86
Conversation
|
c757c31
to
3c218a2
Compare
Let's go ahead and move the FAQ and contest pages over to using the new approach. I think we should leave |
It looks like the syntax highlighting is different due to this change. My guess is github uses a different syntax coloring theme than what we're using by default with Here's the version where we render the markdown on the front-end: Here's the version when github renders the markdown: You can use this guide as a basic test. |
GitHub uses (Linguist)[https://github.com/github/linguist] to highlight the codes. But I dont think it would be good for us to use that, since it is a ruby lib. I guess we can use another or improve the current highlight js theme. |
@@ -150,16 +150,6 @@ function create_responsive_tables(div) { | |||
tables.addClass('table'); | |||
} | |||
|
|||
/* Change all external links to open in a new tab/window */ | |||
function create_external_links(id) { |
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.
Just for reference, this code is handled in the pskb_website/static/js/marked_settings.js file now.
Why does it matter if Github uses linguist instead of highlight js? I thought the problem was the syntax coloring not the actual language detection, which is what linguist does right? Isn't that what this file is supposed to be handling? I was under the impression that CSS file was mimicing the colors, etc. of the github syntax styling. As a sidenote, we aren't using this file anymore after you removed it from the article.html page in this commit. Maybe we can adapt it to fix this issue or remove the file altogether since it's not used? |
Exactly. Actually there were two github.css files. I stop using them because they were changing badly some html components. But it was in the TODO list to check this design issues after removing that. So, we can create/customise the github.css to fit our needs. |
The included github theme of highlightjs should be obsolete. The github-gist theme is more similar, so maybe we can use this. There is a good live demo here about the themes: https://highlightjs.org/static/demo/ I created an article for testing these:
I will work on the css now. |
Oh ok that all makes sense. Thanks for clarifying. I forgot you mentioned we'd need to update the CSS afterwards. Thanks for the highlightjs theme link, good way to test it! |
3c218a2
to
3633bde
Compare
Do we need to turn our rendered markdown as close as possible to the GitHub pages? Because now I am using https://sindresorhus.com/github-markdown-css/ and the css is very close to the GitHub's css. Also, I am using the highlight-js github-gist.css instead of the github.css theme. Now the Editor's preview, the Article page and the FAQ page are using the same JS code, the same CSS and all of them are very similar to the GitHub's. Including the font-family. Is that the objective? http://guides-dev.herokuapp.com//python/markdown-test-paulo?saved=1&status=draft |
Sounds good. The objective is to have our preview and guide pages look as On Thursday, June 16, 2016, Paulo Cheque notifications@github.com wrote:
|
fd63660
to
e586c84
Compare
Rebased to origin/master |
Looks like there is a problem with some CSS or the rendering leading to a really narrow column of text for the guide. Maybe it's an error with the guide's markdown? You can grab the raw markdown to test with here. Here's how the guide looks with our current implementation: I think this guide's text might also have newlines in it which is leading to the weird wrapping. I guess the github renderer or our previous JS on the front-end cleaned this up? Another issue is the link text is blue in the new version. Does anyone have a preference on this? Our existing CSS uses orange, which matches the rest of the design. However, maybe blue is better? I also noticed there's a lot more whitespace between the title and the guide itself when using the new renderer. I'm guessing this is just some padding in the gist CSS that we didn't have before. I think it looks better to keep the text a bit closer to the title. What do you think @paulocheque? |
c6d7533
to
421719e
Compare
Fixed! |
Nice! It looks like some of the changes are causing us to not use the Gotham font on the guides. Looks like these rules are the problem, which makes the text on the guide look different than the rest of the site. I noticed another subtle difference in the markdown parsing. For example, test this guide on the staging site with this branch. Notice the extra This issue leads to a lot of extra whitespace between columns on this guide. Finally, there still seems to be a bunch of extra left margin/padding on the guide text and code blocks, which leads to the code block and text not being left-aligned and too much whitespace on the left. New: Sorry for all the nitpicking! This is a big change, which changes the most useful feature of the entire project, so I want to test it fully. This is not an easy change so thanks so much for taking it on! |
01bcb6e
to
402869a
Compare
About the fonts, you are right, I just removed that css and it is fixed. Before, the font was the same of the GitHub's. About the line breaks, this is a cache issue. If you clean your redis cache of articles, it should be fixed automatically. Now we have to think about the deploy. We can temporarily disable the cache and deploy. After a couple of hours we can deploy again with the cache enabled again. Or we can clean the cache manually. |
The cache was part of the problem. However, there is still a difference in how the new parsing handles line breaks. I've cleared the cache on the staging server, and I still see a major difference between the rendering of this guide. Notice the article itself has some line-breaks in it, but github's rendering doesn't render these as New: Old (rendering from github.com): |
Also, here are some other CSS tweaks that we need to integrate to this PR (I don't have push access). The font-size is a little too large in the new approach. Also that diff cleans up the left padding on code blocks and the blue links. We want to keep the links orange to match the rest of the site. |
Well, I am not sure about this line endings, but if the artilcle has a line break, the renderer replace that by a This happens because we are using the So I believe that if some article has these extra line breaks, the article content should be adjusted. But I think the only way to fix that is manually. A simple test here: Paragraph 1 with a line break right now (no line breaks here) Paragraph 2 with a line break right Paragraph 3 with a line break right now (every \n is replaced by a |
Interesting. So the |
Is this a bug in the I think this is the starting point for seeing how github's API actually does this. |
…ticle view - Experimenting with ideas mentioned in pluralsight#39. This commit removes the following features: - No automatic header tags like on github.com - This is the little 'octicon link' icons that show up to the left of headers when you hover over them. - This means our headers do not have in-page anchors associated with them anymore so users cannot link to sections of a guide. - We definitely want this added back but not sure the best way to do it yet on the front-end.
…e. Stop using the rendered article html in the backend.
…/article/faq pages. Using highlight-js github-gist.css theme instead of github.css theme.
…not support this markdown syntax, but hack.guides does.
3d32fc7
to
007ab8c
Compare
There is no bug. It just a line ending convention. But the marked lib doc is wrong (https://github.com/chjj/marked#breaks), so the GitHub line ending convention is the opposite. So I guess we should disable this line ending style.
|
…'s line ending convention. All the discussion and screenshots can be found in the PR pluralsight#86
Got this all fixed and deployed. I made a few small changes. You can see the commits for details, but in short I removed all the custom font-weight and font-size from the headers and fixed a bug injected here 836b220 that was leading to an extra bit of the white background showing on the homepage. The article pages now use the header stylings that are used throughout the site and suggested by PS's designer. This is different than github.com but it makes everything match across our site. |
Awesome! |
This PR is not done yet. I have just created it to discuss about it.
I rebased your
render_markdown_on_frontend
branch to theorigin/master
. I guess we should deploy the Fixed #84 #85 first to avoid merge conflicts. I can rebase it again later.Before deploying this feature, I believe we should clean the Redis cache. I am using
rendered_text = False
, but I am not sure if this prevent some cache of html.Now, the preview and the article's page looks identical. If we need to change something in the layout, we need to use one common css file for both pages, to keep the idea.
I removed the github.css files because they were screwing the design up. But maybe some useful css, that let the design closer to the GitHub may be lost. It is not critical I think.
I believe we can remove all the backend code related to the
rendered = True
part. Is that ok? Or we are using this in another feature?I guess some js/css files can be renamed to be more understanding. For example:
editor_controller.js
instead ofeditor_utils.js
. But I believe this should be the last commit to avoid merge issues.