Sha256: d0e13a59f89f5189c0a96c796d23652b09bd6203abe0ff929ed2aa01a6c0d421
Contents?: true
Size: 810 Bytes
Versions: 2
Compression:
Stored size: 810 Bytes
Contents
require 'kramdown' require 'kramdown/parser/kramdown' require 'pygments' class Kramdown::Parser::Slider < Kramdown::Parser::Kramdown def initialize(source, options) super @block_parsers.unshift(:syntax_tag) @block_parsers.unshift(:slide_tag) end def parse_syntax_tag match = /^```(\w+)\n(.*)\n```$/m.match(@src.matched) @src.pos += @src.matched_size code = Pygments.highlight(match[2], :lexer => match[1], :options => { :encoding => 'utf-8' }) @tree.children << Element.new(:raw, code) end def parse_slide_tag @src.pos += @src.matched_size @tree.children << Element.new(:raw, '</section><section class="slide">') end define_parser(:slide_tag, /^!SLIDE\w*$/, '') define_parser(:syntax_tag, /^``` ?([^\r\n]+)?\r?\n(.+?)\r?\n```\r?$/m, '') end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slider-0.2 | lib/slider/markdown.rb |
slider-0.1 | lib/slider/markdown.rb |