Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
add syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
jess committed Feb 13, 2014
1 parent 870aada commit 00dcf08
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/post_helper.rb
Expand Up @@ -15,6 +15,6 @@ def post_summary_html(post)
end

def post_content_html(post)
RDiscount.new(render(:inline => post.content)).to_html.html_safe
MarkdownService.new.render(post.content).html_safe
end
end
15 changes: 15 additions & 0 deletions app/models/markdown_service.rb
@@ -0,0 +1,15 @@
require 'rouge/plugins/redcarpet'

class MarkdownService
class HTMLWithRouge < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet # yep, that's it.
end

def initialize
@markdown = ::Redcarpet::Markdown.new(HTMLWithRouge, :fenced_code_blocks => true)
end

def render(text)
@markdown.render(text)
end
end
3 changes: 2 additions & 1 deletion lib/postmarkdown/engine.rb
Expand Up @@ -2,7 +2,8 @@ module Postmarkdown
require 'postmarkdown'
require 'rails'
require 'gravtastic'
require 'rdiscount'
require 'redcarpet'
require 'rouge'
require 'nokogiri'
require 'action_view'
require 'haml'
Expand Down
3 changes: 2 additions & 1 deletion postmarkdown.gemspec
Expand Up @@ -25,8 +25,9 @@ Gem::Specification.new do |s|
s.add_dependency 'haml', ['>= 3.1', '< 5']
s.add_dependency 'gravtastic'
s.add_dependency 'nokogiri'
s.add_dependency 'rdiscount'
s.add_dependency 'redcarpet'
s.add_dependency 'kaminari'
s.add_dependency 'rouge'

s.add_development_dependency 'appraisal'
s.add_development_dependency 'rspec-rails', '~> 2.8'
Expand Down
61 changes: 61 additions & 0 deletions vendor/assets/stylesheets/github.css
@@ -0,0 +1,61 @@
.hll { background-color: #ffffcc }
.c { color: #999988; font-style: italic } /* Comment */
.err { color: #a61717; background-color: #e3d2d2 } /* Error */
.k { color: #000000; font-weight: normal } /* Keyword */
.o { color: #000000; font-weight: normal } /* Operator */
.cm { color: #999988; font-style: italic } /* Comment.Multiline */
.cp { color: #999999; font-weight: normal; font-style: italic } /* Comment.Preproc */
.c1 { color: #999988; font-style: italic } /* Comment.Single */
.cs { color: #999999; font-weight: normal; font-style: italic } /* Comment.Special */
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.ge { color: #000000; font-style: italic } /* Generic.Emph */
.gr { color: #aa0000 } /* Generic.Error */
.gh { color: #999999 } /* Generic.Heading */
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #555555 } /* Generic.Prompt */
.gs { font-weight: normal } /* Generic.Strong */
.gu { color: #aaaaaa } /* Generic.Subheading */
.gt { color: #aa0000 } /* Generic.Traceback */
.kc { color: #000000; font-weight: normal } /* Keyword.Constant */
.kd { color: #000000; font-weight: normal } /* Keyword.Declaration */
.kn { color: #000000; font-weight: normal } /* Keyword.Namespace */
.kp { color: #000000; font-weight: normal } /* Keyword.Pseudo */
.kr { color: #000000; font-weight: normal } /* Keyword.Reserved */
.kt { color: #445588; font-weight: normal } /* Keyword.Type */
.m { color: #009999 } /* Literal.Number */
.s { color: #d01040 } /* Literal.String */
.na { color: #008080 } /* Name.Attribute */
.nb { color: #0086B3 } /* Name.Builtin */
.nc { color: #445588; font-weight: normal } /* Name.Class */
.no { color: #008080 } /* Name.Constant */
.nd { color: #3c5d5d; font-weight: normal } /* Name.Decorator */
.ni { color: #800080 } /* Name.Entity */
.ne { color: #990000; font-weight: normal } /* Name.Exception */
.nf { color: #990000; font-weight: normal } /* Name.Function */
.nl { color: #990000; font-weight: normal } /* Name.Label */
.nn { color: #555555 } /* Name.Namespace */
.nt { color: #000080 } /* Name.Tag */
.nv { color: #008080 } /* Name.Variable */
.ow { color: #000000; font-weight: normal } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #009999 } /* Literal.Number.Float */
.mh { color: #009999 } /* Literal.Number.Hex */
.mi { color: #009999 } /* Literal.Number.Integer */
.mo { color: #009999 } /* Literal.Number.Oct */
.sb { color: #d01040 } /* Literal.String.Backtick */
.sc { color: #d01040 } /* Literal.String.Char */
.sd { color: #d01040 } /* Literal.String.Doc */
.s2 { color: #d01040 } /* Literal.String.Double */
.se { color: #d01040 } /* Literal.String.Escape */
.sh { color: #d01040 } /* Literal.String.Heredoc */
.si { color: #d01040 } /* Literal.String.Interpol */
.sx { color: #d01040 } /* Literal.String.Other */
.sr { color: #009926 } /* Literal.String.Regex */
.s1 { color: #d01040 } /* Literal.String.Single */
.ss { color: #990073 } /* Literal.String.Symbol */
.bp { color: #999999 } /* Name.Builtin.Pseudo */
.vc { color: #008080 } /* Name.Variable.Class */
.vg { color: #008080 } /* Name.Variable.Global */
.vi { color: #008080 } /* Name.Variable.Instance */
.il { color: #009999 } /* Literal.Number.Integer.Long */

0 comments on commit 00dcf08

Please sign in to comment.