Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#
# 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!(/(\([^\)]+\))/, '<code>\1</code>')
# keyboard strokes
# -> M-x some-defun
# -> and other combo's
key = '(?:&lt;[^&]+&gt;|\w\b|[^\s\w])'
stroke = "(?:[CMSs]-)+#{key}"
text.gsub!(/\b(M-x \S+|#{stroke}(?: (?:#{stroke}|#{key}))*)/, '<kbd>\1</kbd>')
text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.