Skip to content

Instantly share code, notes, and snippets.

@naoty
Last active January 4, 2016 16:19
Show Gist options
  • Select an option

  • Save naoty/8646605 to your computer and use it in GitHub Desktop.

Select an option

Save naoty/8646605 to your computer and use it in GitHub Desktop.
paragraph parse sample
require "redcarpet"
require "pathname"
require "cgi"
class MyRenderer < Redcarpet::Render::HTML
def paragraph(text)
if text =~ /^\s?\[.+\]\s?$/
puts "parses:"
lines = text.split("\n")
lines.each do |line|
puts "\t#{CGI.unescapeHTML(line)}"
end
""
else
%(<p>#{text}</p>)
end
end
end
markdown = Redcarpet::Markdown.new(MyRenderer)
content = Pathname.new("./sample.md").read
markdown.render(content)
# Paths for my project on GitHub

[/] <-> [/naoty] <-> [/naoty/graphdown]
[/] <-> [/naoty/graphdown]
[/] <-> [/search] -> [/naoty/graphdown]
[/] <-> [/notifications] -> [/naoty/graphdown]

This text should not be parsed.

[sample link](http://example.com)

# Sign in and Sign out on GitHub

[/] -[POST /logout]-> [/]
[/] -> [/login] -[POST /session]-> [/]

This text should not be parsed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment