[Wikitext-l] So, a better algorithm for apostrophes?

Jared Williams jared.williams1 at ntlworld.com
Wed Nov 28 02:25:01 UTC 2007


 

> -----Original Message-----
> From: wikitext-l-bounces at lists.wikimedia.org 
> [mailto:wikitext-l-bounces at lists.wikimedia.org] On Behalf Of 
> Steve Bennett
> Sent: 28 November 2007 01:39
> To: Wikitext-l
> Subject: [Wikitext-l] So, a better algorithm for apostrophes?
> 
> How about this:
> 
> Word'''word -> always apostrophe+italics
> Word''''word -> always apostrophe+bold
> 
> Advantages:
> * French and Italian examples work correctly all the time
> * You can parse it with single-token lookahead.
> * No need to count matched/mismatched bold/italics
> * Broken wikitext at the end of the line does not interfere with
> correct wikitext at the start of the line
> * Simpler to understand than the current rule.
> 
> Disadvantages:
> * You lose the ability to easily apply bold mid-word.
> * The ambiguity will arise more often, so more people will have to
> know that ''' is not always bold. Not that it's always bold at the
> moment, but you know...
> 
> Thoughts?
> 
> Steve

I create a DOM tree as it parses, which eliminates advantages 2 & 3.

2, It just creates elements as it goes, and corrects any erroneously made
assumptions

Eg Seeing '''''five'''          it creates <b><i>five  then seeing the '''
realises it needs to rewrite to <i><b>five</b>.

3, When hit a newline, only have to see if still within <b> & <i> elements.

Jared 







More information about the Wikitext-l mailing list