[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] New "kbd" macro?

From: Kaushal Modi
Subject: Re: [O] [RFC] New "kbd" macro?
Date: Wed, 13 Sep 2017 14:03:53 +0000

On Wed, Sep 13, 2017 at 9:23 AM Nicolas Goaziou <address@hidden> wrote:

I would like to submit a new minor macro for integration within Org: the
"kbd" macro.

The "kbd" macro focuses on normalizing keybinding during export. For
example, during Texinfo export, {{{kbd(v SPC)}}} becomes

  @kbd{v @key{SPC}}

whereas in another back-end, it becomes

  v <SPC>

Can we have {{{kbd(v SPC)}}} export to below for HTML?

<kbd>v <span class="key">SPC</span></kbd>

It will be tremendously useful for blog posts. At the moment, I use this hack[1] in ox-hugo.el.
*Also stuff within angle brackets will hide in HTML if you choose to leave the export as "v <SPC>" for HTML too!*

More specifically:

  Within {{{kbd(...)}}}, the following case-sensitive keys are wrapped
  within angle brackets: SPC, RET, LFD, TAB, BS, ESC, DELETE, SHIFT,
  CTRL, META, up, down, left, right.

With an optional argument, it can wrap the key-binding within verbatim
or code markup:

  {{{kbd(v SPC,code)}}}      =>  ~v <SPC>~

  {{{kbd(v SPC,verbatim)}}}  =>  =v <SPC>=
Looks good.

Granted, this is probably only useful for Texinfo export, but defining
it as a global macro makes Org documents a bit more portable across
export back-ends.

For HTML too! :)

If there is any interest in it, I will add tests and documentation.
I attach a proof of concept.


Copying Oleh, as I believe he would also have some interest in this.

Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]