-
-
Save sevenseacat/82b646eaaa2416d9122c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
require 'asciidoctor' | |
def asciidoctor(text) | |
Asciidoctor.convert(text) | |
end | |
require 'coderay' | |
def coderay(text) | |
#I tried data-lang="( ... etc) since the browser output does that. | |
text.gsub(/\<code( lang="(.+?)")?\>(.+?)\<\/code\>/m) do | |
CodeRay.scan($3, $2).div(line_numbers: :table)#, :css => :class) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="listingblock"> | |
<div class="content"> | |
<pre class="highlight"> | |
<code class="language-ruby" data-lang="ruby"> | |
ORDERED_LIST_KEYWORDS = { | |
'loweralpha' => 'a', | |
'lowerroman' => 'i', | |
'upperalpha' => 'A', | |
'upperroman' => 'I' | |
#'lowergreek' => 'a' | |
#'arabic' => '1' | |
#'decimal' => '1' | |
} | |
</code> | |
</pre> | |
</div> | |
</div> | |
note: the browser should have applied various classes for syntax highlighting, but it is absent. | |
If it's coderay's job to apply them, coderay is failing to do so. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/data displayed in show.html.slim | |
:coderay-linenums-mode: inline | |
:source-highlighter: coderay | |
:coderay-css: class | |
[source,ruby,linenums] | |
---- | |
ORDERED_LIST_KEYWORDS = { | |
'loweralpha' => 'a', | |
'lowerroman' => 'i', | |
'upperalpha' => 'A', | |
'upperroman' => 'I' | |
#'lowergreek' => 'a' | |
#'arabic' => '1' | |
#'decimal' => '1' | |
} | |
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/articles - show.html.slim | |
== coderay(asciidoctor(@article.content)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment