LexPl has asked for the wisdom of the Perl Monks concerning the following question:
I have got lists with two types of list markers, namely numeric (1., 2., 3., etc.) and alphabetic "a)", "b)", "c)", etc. or "aa)", "bb)", "cc)", etc. I want to check whether each item of a list is numbered subsequently according to its list marker type.
This means in numeric lists a subsequent item should be numbered as n+1 plus a dot, where n is the number in the current item's term and n+1 would be the number in its parent::item/following-sibling::*[1]/self::item/term.
In alphabetic lists the parent::item/following-sibling::*[1]/self::item/term should contain the next letter(s) in alphabetical order from the current item/term plus a closing parenthesis. So for example after "b)" would follow "c)" and after "cc)" would follow "dd)".
I do not want to change the numbering, but just check and document the errors found and ideally their locations.
The input format would look like this:
<list>
<item>
<term>1.</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>3.</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>4.</term>
<para>jhjhjh hjkjkjkj</para>
</item>
</list>
Or:
<list>
<item>
<term>a)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>b)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>d)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
</list>
Or:
<list>
<item>
<term>aa)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>cc)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
<item>
<term>dd)</term>
<para>jhjhjh hjkjkjkj</para>
</item>
</list>
These input samples deliberately contain errors that should be detected and located.
Please note that in the samples I had to use <para> instead of <p>, but in the Perl script, it should be <p>-elements.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check numbering of list items
by Corion (Patriarch) on Dec 09, 2024 at 13:02 UTC | |
by LexPl (Beadle) on Dec 09, 2024 at 13:33 UTC | |
by Corion (Patriarch) on Dec 09, 2024 at 13:51 UTC | |
|
Re: Check numbering of list items
by tybalt89 (Monsignor) on Dec 09, 2024 at 16:35 UTC |