Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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'})
Add Comment
Please, Sign In to add comment