# # A little function to add html markup around emacs commands found in text. # def markup_emacs(text) # defuns are put between () # TODO nested defuns text.gsub!(/(\([^\)]+\))/, '\1') # keyboard strokes # -> M-x some-defun # -> and other combo's key = '(?:<[^&]+>|\w\b|[^\s\w])' stroke = "(?:[CMSs]-)+#{key}" text.gsub!(/\b(M-x \S+|#{stroke}(?: (?:#{stroke}|#{key}))*)/, '\1') text end