From 69f359fe0220ccde89ab5efb4200008c22d7ae81 Mon Sep 17 00:00:00 2001 From: Waldo Jaquith Date: Wed, 12 Jun 2013 14:57:44 -0400 Subject: [PATCH] Determine whether we're starting a list of Roman numerals Per #1. This is a lazy solution, but it's also very achievable, so it has that going for it. --- subsection-identifier.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/subsection-identifier.php b/subsection-identifier.php index c3629e1..ae8d40d 100644 --- a/subsection-identifier.php +++ b/subsection-identifier.php @@ -105,6 +105,25 @@ function parse() { continue; } + + /* + * If the section fragment is a Roman numeral "i", but the matched prefix candidate + * is alphabetic, then let's skip this prefix candidate and continue to iterate, + * knowing that we'll get to the Roman numeral prefix candidate soon. We ignore the + * last character, since that could potentially be the first character of the text + * (as opposed to the prefix), and is definitely not the text of our prefix (it + * could be a containing parenthesis, but we're not concerned about that now). We're + * trying to avoid actually matching an "i" if the text is, for example: + * + * "a. in the meaning of..." + */ + if (strpos(substr($section_fragment, 0, -2), 'i')) + { + if ($prefix_members[0] == 'a') + { + continue; + } + } /* * Great, we've successfully made a match -- we now know that this is the beginning