I have a series of string manipulation, I realize this with the following code. I want it to be more elegant and readable such as str.sub_heading().sub_codeblock()..., how could I rewrite my code?def sub_heading(str)  str.gsub!(/^(#+)\w+/) {|m|  m.gsub(#, =)}  str.gsub!(/^(=+)(.+)/, '\1 \2 \1')enddef sub_codeblock(str)  str.gsub!(/```(.+\n)((.|\n)+)```/,  '{{{#!text_pygments \1\2}}}')enddef sub_inlinecode(str)  str.gsub!(/`(.+)`/, '{{{\1}}}')enddef sub_bold(str)  str.gsub!(/([^\w]|^)\*\*\w[\w\s\d\-_']*\*\*([^\w]|$)/) {|m|  m.gsub(**, ''')}enddef sub_italic(str)  str.gsub!(/([^*]|^)\*\w[\w\s\d\-_']*\*([^*]|$)/) {|m|  m.gsub(*, '')}enddef sub_link(str)  str.gsub!(/\[\[(.+)\|(.+)\]\]/, '[[\2|\1]]')endsub_heading(inputdata)sub_codeblock(inputdata)sub_inlinecode(inputdata)sub_bold(inputdata)sub_italic(inputdata)sub_link(inputdata)
Simplify series of string manipulations in Ruby
ruby;strings