refine the String class then just chaining methods at fix_all
classMarkdownFixer<Struct.new(:markdown)usingModule.new{refine(String)dodefadd_quotes_to_titlegsub('title','"title"')enddefadd_quotes_to_publishedgsub("\r\npublished: ","\"\r\npublished: ")end# This turns --- into ------- after the first two,# because --- messes with front matterdefmodify_hr_tagsgsub(/^---/).with_index{|m,i|i>1?"#{m}-----":m}enddefconvert_newlinegsub("\r\n","\n")enddefmodify_tagsgsub(/\ntags:.*\n/)do|tags|tags.split(" #").join(",").gsub("#","").gsub(":,",": ")endendend}deffix_allmarkdown.add_quotes_to_title.modify_hr_tags.convert_newline.add_quotes_to_title.add_quotes_to_published.moidfy_tagsendend
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
refine the String class then just chaining methods at fix_all