-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Vastly improved backtick code blocks and added support for Textile
2. Refactored Octopress filters into Liquid filters and pre/post render filters (using post_filters plugin) 3. Added methods to raw plugin to prevent Markdown and Textile from parsing blocks 4. Updated render partial to invoke the pre_render method of post_filters 5. Moved Rubypants filter out of default.html into Octopress post_render filters 6. Added raw's safe_wrapper method to codeblock and include_code filters
- Loading branch information
Showing
7 changed files
with
107 additions
and
55 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require './plugins/pygments_code' | ||
|
||
module BacktickCodeBlock | ||
include HighlightCode | ||
AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+)\s*(.+)?/i | ||
LangCaption = /([^\s]+)\s*(.+)?/i | ||
def render_code_block(input) | ||
@caption = nil | ||
@lang = nil | ||
@url = nil | ||
@title = nil | ||
input.gsub /^`{3} *([^\n]+)?\n(.+?)\n`{3}/m do | ||
options = $1 | ||
str = $2 | ||
|
||
if options =~ AllOptions | ||
@lang = $1 | ||
@caption = "<figcaption><span>#{$2}</span><a href='#{$3}'>#{$4 || 'link'}</a></figcaption>" | ||
elsif options =~ LangCaption | ||
@lang = $1 | ||
@caption = "<figcaption><span>#{$2}</span></figcaption>" | ||
end | ||
|
||
if str.match(/\A {4}/) | ||
str = str.gsub /^ {4}/, '' | ||
end | ||
if @lang.nil? || @lang == 'plain' | ||
code = tableize_code(str.gsub('<','<').gsub('>','>')) | ||
"<figure role=code>#{@caption}#{code}</figure>" | ||
else | ||
if @lang.include? "-raw" | ||
raw = "``` #{@lang.sub('-raw', '')}\n" | ||
raw += str | ||
raw += "\n```\n" | ||
else | ||
code = highlight(str, @lang) | ||
"<figure role=code>#{@caption}#{code}</figure>" | ||
end | ||
end | ||
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
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
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
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
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