Skip to content

Commit

Permalink
Store a list of prefixes, in order
Browse files Browse the repository at this point in the history
This is a step towards solving issue #1, which requires stateful
knowledge of the ordinal values of prefixes.
  • Loading branch information
waldoj committed Jun 12, 2013
1 parent 794f61b commit 392452e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions subsection-identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ function parse()
* parentheses or followed by a period and a space. We pair that with a list of all possible
* characters that can appear within that range, which we use to verify the match.
*/
$prefix_candidates = array ('/[A-Z]{1,2}\. /',
'/[0-9]{1,2}\. /',
'/[a-z]{1,2}\. /',
'/\([0-9]{1,2}\) /',
'/\([a-z]{1,2}\) /',
'/\((xvi[1,4})\) /');

$prefix_candidates = array (
'/[0-9]{1,2}\. /' => range(1, 99),
'/\([0-9]{1,2}\) /' => range(1, 99),
'/[a-z]{1,2}\. /' => range('a', 'z'),
'/\([a-z]{1,2}\) /' => range('a', 'z'),
'/[A-Z]{1,2}\. /' => range('A', 'Z'),
'/\([A-Z]{1,2}\) /' => range('a', 'z'),
'/([xvi]{1,4})\. /' => array('i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi', 'xii', 'xiii', 'xiv', 'xv', 'xvi', 'xvii', 'xviii', 'xix', 'xx'),
'/\(([xvi]{1,4})\) /' => array('i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi', 'xii', 'xiii', 'xiv', 'xv', 'xvi', 'xvii', 'xviii', 'xix', 'xx')
);

/*
* Establish a blank prefix structure. We'll build this up and continually modify it to keep
* track of our current complete section number as we iterate through the text.
Expand Down

0 comments on commit 392452e

Please sign in to comment.