smartypants: Normalize dash replacement

The original SmartyPants comes with three dash replacement modes:

	1 =>  "--" for em-dashes; no en-dash support
	2 =>  "---" for em-dashes; "--" for en-dashes
	3 =>  "--" for em-dashes; "---" for en-dashes

Sundown now runs with number 2, because I am opinionated and I think
that the other 2 options are stupid.
This commit is contained in:
Vicent Marti 2011-07-19 19:17:00 +02:00
parent 20f58920dc
commit a580f7b2a0

View file

@ -161,16 +161,14 @@ smartypants_cb__parens(struct buf *ob, struct smartypants_data *smrt, char previ
static size_t
smartypants_cb__dash(struct buf *ob, struct smartypants_data *smrt, char previous_char, const char *text, size_t size)
{
if (size >= 2) {
if (text[1] == '-') {
BUFPUTSL(ob, "—");
return 1;
}
if (size >= 3 && text[1] == '-' && text[2] == '-') {
BUFPUTSL(ob, "—");
return 2;
}
if (word_boundary(previous_char) && word_boundary(text[1])) {
BUFPUTSL(ob, "–");
return 0;
}
if (size >= 2 && text[1] == '-') {
BUFPUTSL(ob, "–");
return 1;
}
bufputc(ob, text[0]);