3

Edit: This torture test should become irrelevant very soon, since the discrepancies between the preview and final output have been resolved on S[OFU]. Hopefully, those changes will be merged into SE soon..


no conversion to italics/bold

word*ending*, mid*word*stuff, and * with * spaces on each side. *Internal_underscores* (or _stars * like_ this) break italics, even _like _ this_ . Spaces_ must_ be__ on__ the** correct** sides. _Leading underscores is break italics/bold, like _this and _this. f'_n=g'_n is left alone.

surprising conversions to italics/bold

*word*beginning. Surrounding}symbols!are often treated as spaces, but not always: {a}{b}={c}{d} is italic, but a _ b = c _ d is not. *Only *the innermost stars* match*, unless bold in italics. _Same for underscores_ _or mixed symbols_. Insanely, you can mismatch symbols to get _italics* or bold__! f'*n=g'*n is converted (a weird difference between *'s and _'s). **internal _'s and *'s (even __'s and **s) don't break bold (note that "s) don't" wasn't converted separately, indicating some sort of greedyness). Within bold, stars or underscores can add italics. Within italics, stars or underscores can add bold! Bold*italics*bold with stars in between. Internal _'s and *'s don't thwart conversion if they're escaped.

*Leading stars and trailing stars* don't thwart conversion, and trailing underscores_ don't either.

source for "surprising conversions" section

*word*beginning. Surrounding}_symbols_!are often treated as spaces, but not 
always: {a}_{b}={c}_{d} is italic, but a _ b = c _ d is not. *Only *the 
*innermost* stars* match*, *unless **bold** in* italics. _Same _for_ 
underscores_ _or *mixed* symbols_. Insanely, you can mismatch symbols to 
get _italics* or **bold__! f'*n=g'*n is converted (a weird difference 
between *'s and _'s). **internal _'s and *'s (even __'s and **s) don't** 
break bold (note that "**s) don't**" wasn't converted separately, indicating 
some sort of greedyness). Within __bold, *stars* or _underscores_ can add 
italics__. Within _italics, **stars** or __underscores__ can add_ bold! 
**Bold****italics****bold** with stars in between. *Internal \_'s and \*'s 
don't* thwart conversion if they're escaped.

**Leading stars* and _trailing stars_* don't thwart conversion, and 
*trailing underscores*_ don't either.
flag

4 Answers

1

a

a*a*

a a

aa

a a

a

a**a**

a a

aa

a a

a a: a; a! a@ a# a$ a% a^ a& *a** a( a) a- a= a_ a+ a' a" a/ a| a, a. a; a? a\ a

a :a ;a !a @a #a $a %a ^a &a *a (a )a -a =a _*a* +a 'a "a /a |a ,a .a ;a ?a *a* a

a a: a; a! a@ a# a$ a% a^ a& a* a( a) a- a= a_ a+ a' a" a/ a| a, a. a; a? a\ a

a :a ;a !a @a #a $a %a ^a &a *a (a )a -a =a _**a** +a 'a "a /a |a ,a .a ;a ?a **a** a

link|flag
0

this is a test sentence.

this is a test sen**te**nce.

link|flag
0

X_*y* is the thing that I wanted to do

xalef

x

a*x*b

xa

x

is * * * *** ***** ******* ********* *********** a thing

is * *

what is *** that

Vakil's condition $$ is really powerful. I don't know what I'd do without $$.

"italics"

"italics"

// use the sentinel to anchor our regex so it doesn't explode
text = text.replace(/~B(.+?)~A/g,
	function(wholeMatch,m1,m2) {
		var leadingText = m1;
		var numSpaces = 4 - leadingText.length % 4;  // attacklab: g_tab_width

		// there *must* be a better way to do this:
		for (var i=0; i<numSpaces; i++) leadingText+=" ";

		return leadingText;
	}
);
link|flag
"*not italics*" and "italics" – Anton Geraschenko Dec 23 2009 at 18:16
"*not italics*" and "italics". – Anton Geraschenko Dec 23 2009 at 18:18
0

adding another answer (edited)

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.