Consecutive unordered and ordered lists.
Mark Henderson Linton
marklinton at mac.com
Wed Dec 22 09:35:14 EST 2004
I'm sorry if I'm being a pest about this, but I just wanted to clean up
my solution a little bit. I came up with a more general way of solving
the problem that did not involve having two nearly identical routines.
Now there is a single routine that you call twice, once passing it the
ordered list marker, then again passing it the unordered list marker.
Note: For some reason it seems important to do the ordered lists first.
Please find below the output from 'diff -u' that can be used with the
'patch' command to incorporate the change. I hereby release these
modifications under the terms of a BSD-style open source license.
sub _DoLists {
+ my $text = shift;
+ my $marker_ul = qr/[*+-]/;
+ my $marker_ol = qr/\d+[.]/;
+
+ $text = _DoGenericLists($marker_ol, $text);
+ $text = _DoGenericLists($marker_ul, $text);
+
+ return $text;
+}
+
+
+sub _DoGenericLists {
#
# Form HTML ordered (numbered) and unordered (bulleted) lists.
#
+ my $marker = shift;
my $text = shift;
my $less_than_tab = $g_tab_width - 1;
# Re-usable patterns to match list item bullets and number
markers:
my $marker_ul = qr/[*+-]/;
my $marker_ol = qr/\d+[.]/;
- my $marker_any = qr/(?:$marker_ul|$marker_ol)/;
+ my $marker_any = qr/(?:$marker)/;
# Re-usable pattern to match any entirel ul or ol list:
my $whole_list = qr{
On Dec 21, 2004, at 9:17 PM, Mark Henderson Linton wrote:
> I played a little bit with this and if you make two new routines,
> nearly identical to _DoLists, called _DoOrderedLists and
> _DoUnorderedLists, where the only difference is that $marker_any only
> includes $marker_ol in the former and $marker_ul in the latter, and
> call them like this:
>
> sub _DoLists {
> my $text = shift;
>
> $text = _DoOrderedLists($text);
> $text = _DoUnorderedLists($text);
>
> return $text;
> }
>
> The code then behaves as expected.
>
> On Dec 18, 2004, at 9:53 PM, Mark Henderson Linton wrote:
>
>> Greetings,
>>
>> I believe there is a problem in the _DoLists subroutine involving the
>> use of $marker_any to determine when a list ends. If you have an
>> ordered list following an unordered list, the routine will
>> incorrectly match the end of the second, ordered list as the end of
>> the first, unordered list, resulting in a single unordered list.
>>
>> Place the following into the Dingus:
>>
>> ====
>>
>> # Yorkshire Pudding
>>
>> * 2 cups all-purpose flour
>> * 1 teaspoon coarse salt
>> * Freshly ground pepper
>> * 4 large eggs
>> * 3 to 3 1/2 cups whole milk
>> * 6 to 8 tablespoons drippings from roasting pan, vegetable oil, or
>> lard
>>
>> 1. In a large bowl, combine flour, salt, and pepper. Make a well in
>> the center, and add eggs and one-quarter of the milk. Using a whisk,
>> combine eggs and milk, then incorporate flour; begin with the inner
>> rim of the well. Continue whisking until a smooth, stiff batter
>> forms. Stir in half of the remaining milk. Cover with plastic wrap
>> and let stand at room temperature for 30 minutes.
>>
>> 2. Heat oven to 400 degrees. Place 12 3/4-cup capacity muffin tins in
>> oven until very hot, about 5 minutes.
>>
>> 3. Stir enough of the remaining milk into the batter until it is the
>> consistency of heavy cream. Transfer 1 to 2 teaspoons of drippings
>> into each muffin tin. Pour batter in the muffin tins, filling them
>> about one-third full; the batter should sizzle in the hot drippings.
>> Return to oven and bake until puffed, browned, and crisp, 25 to 30
>> minutes. Yorkshire pudding is best served fresh from the oven, but it
>> can be kept warm in a low oven for about 15 minutes.
>>
>> ====
>>
>> The following code will result:
>>
>> ====
>>
>> <h1>Yorkshire Pudding</h1>
>>
>> <ul>
>> <li>2 cups all-purpose flour</li>
>> <li>1 teaspoon coarse salt</li>
>> <li>Freshly ground pepper</li>
>> <li>4 large eggs</li>
>> <li>3 to 3 1/2 cups whole milk</li>
>> <li><p>6 to 8 tablespoons drippings from roasting pan, vegetable oil,
>> or lard</p></li>
>> <li><p>In a large bowl, combine flour, salt, and pepper. Make a well
>> in the center, and add eggs and one-quarter of the milk. Using a
>> whisk, combine eggs and milk, then incorporate flour; begin with the
>> inner rim of the well. Continue whisking until a smooth, stiff batter
>> forms. Stir in half of the remaining milk. Cover with plastic wrap
>> and let stand at room temperature for 30 minutes.</p></li>
>> <li><p>Heat oven to 400 degrees. Place 12 3/4-cup capacity muffin
>> tins in oven until very hot, about 5 minutes.</p></li>
>> <li><p>Stir enough of the remaining milk into the batter until it is
>> the consistency of heavy cream. Transfer 1 to 2 teaspoons of
>> drippings into each muffin tin. Pour batter in the muffin tins,
>> filling them about one-third full; the batter should sizzle in the
>> hot drippings. Return to oven and bake until puffed, browned, and
>> crisp, 25 to 30 minutes. Yorkshire pudding is best served fresh from
>> the oven, but it can be kept warm in a low oven for about 15
>> minutes.</p></li>
>> </ul>
>>
>> ====
>>
>> This is the code that was expected:
>>
>> ====
>>
>> <h1>Yorkshire Pudding</h1>
>>
>> <ul>
>> <li>2 cups all-purpose flour</li>
>> <li>1 teaspoon coarse salt</li>
>> <li>Freshly ground pepper</li>
>> <li>4 large eggs</li>
>> <li>3 to 3 1/2 cups whole milk</li>
>> <li>6 to 8 tablespoons drippings from roasting pan, vegetable oil, or
>> lard</li>
>> </ul>
>>
>> <ol>
>> <li><p>In a large bowl, combine flour, salt, and pepper. Make a well
>> in the center, and add eggs and one-quarter of the milk. Using a
>> whisk, combine eggs and milk, then incorporate flour; begin with the
>> inner rim of the well. Continue whisking until a smooth, stiff batter
>> forms. Stir in half of the remaining milk. Cover with plastic wrap
>> and let stand at room temperature for 30 minutes.</p></li>
>> <li><p>Heat oven to 400 degrees. Place 12 3/4-cup capacity muffin
>> tins in oven until very hot, about 5 minutes.</p></li>
>> <li><p>Stir enough of the remaining milk into the batter until it is
>> the consistency of heavy cream. Transfer 1 to 2 teaspoons of
>> drippings into each muffin tin. Pour batter in the muffin tins,
>> filling them about one-third full; the batter should sizzle in the
>> hot drippings. Return to oven and bake until puffed, browned, and
>> crisp, 25 to 30 minutes. Yorkshire pudding is best served fresh from
>> the oven, but it can be kept warm in a low oven for about 15
>> minutes.</p></li>
>> </ol>
>>
>> ====
>>
>> Any suggestions?
>>
>> Sincerely,
>> Mark Linton
>> --
>> If there is a 50-50 chance that something can go wrong, then 9 times
>> out of ten it will. -- Paul Harvey News, 1979
>>
>> _______________________________________________
>> Markdown-discuss mailing list
>> Markdown-discuss at six.pairlist.net
>> http://six.pairlist.net/mailman/listinfo/markdown-discuss
>>
>>
> Sincerely,
> Mark Linton
> --
> One advantage of fuzzy project objectives is that they let you avoid
> the embarrassment of estimating the corresponding costs. -- Third Rule
> of Project Management
>
> _______________________________________________
> Markdown-discuss mailing list
> Markdown-discuss at six.pairlist.net
> http://six.pairlist.net/mailman/listinfo/markdown-discuss
>
>
Sincerely,
Mark Linton
--
Time is like money, the less we have of it to spare the further we make
it go. -- Josh Billings
More information about the Markdown-Discuss
mailing list