class GstKitchen::Feed::ShownotesRenderer
Constants
- TWITTER_HANDLE_PATTER
Public Instance Methods
preprocess(full_document)
click to toggle source
# File lib/gst-kitchen/feed.rb, line 9 def preprocess(full_document) return full_document if full_document.nil? # Duplicate the string so we don't alter the original, then call to_str # to cast it back to a String instead of a SafeBuffer. This is required # for gsub calls to work as we need them to. full_document = full_document.dup.to_str # Extract pre blocks so they are not altered # from http://github.github.com/github-flavored-markdown/ extractions = {} full_document.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}m) do |match| md5 = Digest::MD5.hexdigest(match) extractions[md5] = match "{gfm-extraction-#{md5}}" end full_document = parse(full_document) # Insert pre block extractions full_document.gsub!(/\{gfm-extraction-(\h{32})\}/) do extractions[$1] end return full_document end
Private Instance Methods
parse(document)
click to toggle source
# File lib/gst-kitchen/feed.rb, line 38 def parse(document) parse_twitter_handle(document) return document end
parse_twitter_handle(document)
click to toggle source
# File lib/gst-kitchen/feed.rb, line 44 def parse_twitter_handle(document) document.gsub!(TWITTER_HANDLE_PATTER, '\1[@\2](https://twitter.com/\2)') end