shanxp / asciidoc

Automatically exported from code.google.com/p/asciidoc
GNU General Public License v2.0
0 stars 0 forks source link

Add menu macro to identify a menu reference or menu selection #18

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
A very common need for computer-related documentation is to reference a menu or 
menu selection in a UI. These references are often styled in the output to 
appear the way they do in the UI. Without proper semantics in an AsciiDoc 
document, it's not possible to identify this information in the output.

I propose adding an inline menu macro that recognizes the following syntax:

menu:File[]
menu:File[Close]
menu:File[New,Message]

The target slot is the name of the menu. The last attribute is the name of the 
menu item. Any attribute preceding the last attribute is assumed to be a 
submenu.

In the docbook backend, the menu is mapped to <guimenu>, the submenu to 
<guisubmenu> and the menu item to <guimenuitem>. A selection is wrapped in 
<menuchoice>.

<guimenu>File</guimenu>
<menuchoice>
  <guimenu>File</guimenu>
  <guimenuitem>Close</guimenuitem>
</menuchoice>
<menuchoice>
  <guimenu>File</guimenu>
  <guisubmenu>New</guisubmenu>
  <guimenuitem>Message</guimenuitem>
</menuchoice>

In the html backend, these element names become class names on <span> elements.

I've included an implementation and a page that shows examples in a gist:

https://gist.github.com/mojavelinux/4736691

Original issue reported on code.google.com by dan.j.allen on 8 Feb 2013 at 5:19

GoogleCodeExporter commented 8 years ago
We could also consider recognizing the shorthand format:

File>Close
File>New>Message

Original comment by dan.j.allen on 8 Feb 2013 at 5:20

GoogleCodeExporter commented 8 years ago
I realized that my shorthand would break down if the menu or menu item included 
a space. I handled this case by allowing the first or last entries to be quoted 
to enclose the text.

For example:

"Main Menu">Utilities>"Gnome Terminal"

Original comment by dan.j.allen on 8 Feb 2013 at 6:32

GoogleCodeExporter commented 8 years ago
Oh yeah, if you leave off the target, then it's assumed to be a top-level menu 
item.

menu:[Save]

Original comment by dan.j.allen on 8 Feb 2013 at 6:44