Created
February 8, 2018 06:38
-
-
Save nhh/c23ce213bec05541b303e13f8ef43df1 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 Markdown | |
module Fixer | |
# Since gsub returns a replaced string, we can chain the methods together | |
# without yielding the module itself | |
def self.fix_all(markdown) | |
markdown.gsub('title', '"title"') | |
.gsub('hr', 'hhr') | |
.gsub('\r\n', '\n') | |
.gsub('tags', 't a g s') | |
end | |
def self.add_quotes_to_title(markdown) | |
markdown.gsub('title', '"title"') | |
end | |
def self.modify_hr_tags(markdown) | |
markdown.gsub('hr', 'hhr') | |
end | |
def self.convert_newlines(markdown) | |
markdown.gsub('\r\n', '\n') | |
end | |
def self.split_tags(markdown) | |
markdown.gsub('tags', 't a g s') | |
end | |
end | |
end | |
# Usage: | |
Markdown::Fixer.fix_all('title hr tags\r\n') | |
# returns: "title" hhr t a g s\n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment