Hi folks,
I'm trying to choose a good text markup language (e.g. markdown, restructured text etc). I want it to be able to deal with nested numbered lists. So something like this:
# Dog # Kitten # Fish # Goldfish # Haddock # Elephant
would produce something like this:
1. Dog 2. Kitten 3. Fish 3.1. Goldfish 3.2. Haddock 4. Elephant
Anyone know a text format that would fit the bill?
Many thanks, Richard
Hi Richard,
maybe I miss the point. What about LaTeX?
\begin{enumerate} \item{Dog} \item{Kitten} \item{Fish} \begin{enumerate} \item{Goldfish} \item{Haddock} \end{enumerate} \item{Elephant} \end{enumerate}
in a LaTeX document would do the trick.
Luzie
On Mon, Oct 04, 2010 at 01:55:07PM +0100, Richard Parsons wrote:
Hi folks,
I'm trying to choose a good text markup language (e.g. markdown, restructured text etc). I want it to be able to deal with nested numbered lists. So something like this:
# Dog # Kitten # Fish # Goldfish # Haddock # Elephant
would produce something like this:
- Dog
- Kitten
- Fish
3.1. Goldfish 3.2. Haddock 4. Elephant
Anyone know a text format that would fit the bill?
Many thanks, Richard
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
[It seems I accidentally sent this reply only to Richard. This time I'm bouncing also to the ALUG list, for anyone else's interest. Sorry.]
On 04-Oct-10 12:55:07, Richard Parsons wrote:
Hi folks, I'm trying to choose a good text markup language (e.g. markdown, restructured text etc). I want it to be able to deal with nested numbered lists. So something like this:
# Dog # Kitten # Fish # Goldfish # Haddock # Elephant
would produce something like this:
- Dog
- Kitten
- Fish
3.1. Goldfish 3.2. Haddock 4. Elephant
Anyone know a text format that would fit the bill?
Many thanks, Richard
Although the required input would be a bit more complicated than your "# Dog" etc., you could use 'groff' (a fully fledged markup language) with an appropriate macro package. For instance, in the 'ms' macro package, the macro ".NH k" produces the next "numbered header" at level k (k=1 like your 1,2,3; k=2 like your 3.1,3.2; etc.).
Hence the following (pasted into the command line):
groff -Tascii -ms << EOT .nr PD 0 .de @SH .. .LP .NH 1 Dog .LP .NH 1 Kitten .LP .NH 1 Fish .LP .NH 2 Goldfish .LP .NH 2 Haddock .LP .NH 1 Elephant .LP EOT
produces the following output to screen:
1. Dog 2. Kitten 3. Fish 3.1. Goldfish 3.2. Haddock 4. Elephant
which is exactly what you gave.
NOTES: The "1. ", "2. ", "3. ", "3.1. ", "3.2. ", "4. " are what ".NH 1" and ".NH 2" produce. These do not generate a line break, so are immediately followed by text on subsequent input lines, unless that text is preceded by a markup which generates a line-break.
The ".de SH//.." is needed here to undefine the macro ".SH" which is called by ".NH", and would produce undesired side-effects in the case of your example. Part of its function is then replaced by an explicit ".LP" (begin a left-justified paragraph) in the input, so that the next numbered line nbegins on a new line.
The ".nr PD 0" sets the number register "PD" (paragraph drop, i.e. vertical space inserted before a new paragraph) to 0.
Hoping this helps. (There's a lot more to groff, and a lot more to learn about using it, if you're not familiar with it). There are also facilities for numbered lists in some other macro packages in groff.
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) ted.harding@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 04-Oct-10 Time: 14:54:08 ------------------------------ XFMail ------------------------------
-------------------------------------------------------------------- E-Mail: (Ted Harding) ted.harding@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 04-Oct-10 Time: 17:17:08 ------------------------------ XFMail ------------------------------