pml-lang / pml-companion

Java source code of the 'PML Companion (PMLC)'
https://www.pml-lang.dev
GNU General Public License v2.0
22 stars 1 forks source link

Add Inline Node for <kbd> HTML Tag #25

Open tajmone opened 3 years ago

tajmone commented 3 years ago

It would be useful to have an inline node for keystrokes, to generate the <kbd> HTML tag.

Possible node tags: [key or just [k.

Example:

[k Ctrl] [k Shift] [k Z]

which would be rendered as:

Ctrl Shift Z

with HTML code:

<kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>Z</kbd>

(see below for an alternative node syntax)

Note that in the above example I've inserted spaces between the keys, but many people don't, while others insert the + symbol:

[k Ctrl][k Shift][k Z]

[k Ctrl]+[k Shift]+[k Z]

rendered as:

CtrlShiftZ

Ctrl+Shift+Z

... it's a matter of personal taste, but it should be kept into account in the implementation.

Multi-Keys Node

Also, not how Asciidoctor implements it via the Keyboard Macro:

kbd:[Ctrl+Shift+Z]

(rendered as: Ctrl+Shift+Z)

It's smart because it uses just one keyword to handle multiple keys, using + as a separator (two pluses + + will produce the + key).

So PML could also do that, and instead of the above proposed implementation, could instead:

[k Ctrl+Shift+Z]

CSS Styling

For some nice styling of the keys via ready-to-us CSS stylesheets, see:

IMO, the first link offers the best CSS effects for keys, and also provided different styles.

The second on is beautiful looking, but maybe not so practical for inline styling (keys are too big).

pml-lang commented 3 years ago

inline node for keystrokes

Yes, that's one more of the nodes to add soon (after the new parser is ready). Thanks.

A first syntax that comes to mind:

single key:
[key Z]

key combination:
[key Ctrl,Shift,Z]      // no space and no + between
[key Ctrl, Shift, Z]    // space between
[key Ctrl+Shift+Z]      // + between

Needs more thought before implementing. Suggestions are very welcome.

Thanks a lot for the useful links too.