Last active
February 8, 2018 07:18
-
-
Save nhh/7d7bc14cfa7a8f134f5290f2c1f40ca5 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 | |
def self.fix(markdown, pattern=@fix_all_pattern) | |
pattern.map do |key, value| | |
markdown.gsub!(key.to_s, value.to_s) | |
end | |
markdown | |
end | |
@fix_all_pattern = { | |
'title': '"title"', | |
'hr': 'hhr', | |
'\r\n': '\n', | |
'tags': 't a g s' | |
} | |
end | |
end | |
# Usage: | |
# returns: "title" hhr t a g s\n | |
Markdown::Fixer.fix('title hr tags\r\n') | |
# Provide a custom pattern: | |
# returns: title hr tags\n | |
Markdown::Fixer.fix('title hr tags\r\n', {'\r\n': '\n'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment