From c90c3b15441a43f90c38205ab1664fd297b38e04 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Fri, 16 Nov 2012 16:57:39 -0700 Subject: [PATCH] Support git code syntax in live preview Add autocrlf values for Windows, Linux, and OS X. --- .gitattributes | 7 +++++++ .../frontend/public/gollum/livepreview/js/livepreview.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/.gitattributes b/.gitattributes index 57a806c2..09ab669c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,11 @@ # https://help.github.com/articles/dealing-with-line-endings +# +# For Mac & Linux +# git config --global core.autocrlf input +# +# For windows +# git config --global core.autocrlf true +# # Set default behaviour, in case users don't have core.autocrlf set. * text=auto diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js index cc32e706..57f561a8 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js @@ -298,6 +298,8 @@ var makePreviewHtml = function () { } var prevTime = new Date().getTime(); + // Handle gollum file code insertion syntax. + text = text.replace(/^[ \t]*``` ?([^:\n\r]+:[^`\n\r]+)```/gm, '``$1``'); text = md_to_html( text ); // Calculate the processing time of the HTML creation.