Re: [Patch] LaTeX: export nested lists

From: Jose Da Silva <digital_at_joescat.com>
Date: Sat Mar 29 2008 - 20:21:16 CET

On March 29, 2008 05:43:21 am Xun Sun wrote:
> Dear all,
>
> Currently AbiWord can only export flat (single-level) lists to LaTeX
> documents. This patch tries to extend this function to more complex
> lists. It was diff-ed against main trunk. Although it is not perfect
> and may even contain bugs, I still want to send it to the list to
> gather comments and feedback.
>
> The simple mechanism to recognize nested lists is based on their
> indentation.
>
> I have also attached a test file "List_test.abw". In AbiWord, simply
> save this file as a LaTeX document, then run latex on the LaTeX
> document, and run xdvi to preview.

Just a quick suggestion, you currently have:
+ switch (list_type) {
+ case NUMBERED_LIST:
+ m_pie->write("\\end{enumerate}\n");
+ break;
+ case BULLET_LIST:
+ m_pie->write("\\end{itemize}\n");
+ break;
+ default:
+ ;
+ }

however, this should take less space after compiling since you are only
working with 2 conditions.
+ if (list_type == NUMBERED_LIST)
+ m_pie->write("\\end{enumerate}\n");
+ else if (list_type == BULLET_LIST)
+ m_pie->write("\\end{itemize}\n");

The switch statement makes more sense if you are working with several (or
many) conditions which can be done in a lookup table type of format
because the way a switch condition works is to do something like this:
if (value < min_value) goto default;
if (value > max_value) goto default;
on (value - min_value) goto x, y, z

supposing min_value is 3 and max value is 7 then you could see something
like this:
if (value < 3) goto default;
if (value > 7) goto default;
on (value - 3) goto x, default, default, default, z

In summary, the switch statement looks nicer from a source-code point of
view, but the if statement is a bit less code in a compiled sense.

Hope this suggestion helped
Jose
Received on Sat Mar 29 20:21:40 2008

This archive was generated by hypermail 2.1.8 : Sat Mar 29 2008 - 20:21:40 CET