Fix bug #27: Don't treat [1] as a standalone 1
authorali <ali@juiblex.co.uk>
Tue Oct 15 09:16:04 2013 +0100 (2013-10-15)
changeset 100ad92d11d59b8
parent 99 783eff3047bc
child 101 f44c530f80da
Fix bug #27: Don't treat [1] as a standalone 1
bookloupe/bookloupe.c
test/bookloupe/Makefile.am
test/bookloupe/footnote-marker.tst
     1.1 --- a/bookloupe/bookloupe.c	Sat Oct 05 21:37:31 2013 +0100
     1.2 +++ b/bookloupe/bookloupe.c	Tue Oct 15 09:16:04 2013 +0100
     1.3 @@ -2951,7 +2951,24 @@
     1.4      for (;!g_unichar_isdigit(g_utf8_get_char(*ptr)) &&
     1.5        !g_unichar_isalpha(g_utf8_get_char(*ptr)) &&
     1.6        **ptr;*ptr=g_utf8_next_char(*ptr))
     1.7 -	;
     1.8 +    {
     1.9 +	/* Handle exceptions for footnote markers like [1] */
    1.10 +	if (g_utf8_get_char(*ptr)=='[')
    1.11 +	{
    1.12 +	    g_string_append_c(word,'[');
    1.13 +	    s=g_utf8_next_char(*ptr);
    1.14 +	    for (;g_unichar_isdigit(g_utf8_get_char(s));s=g_utf8_next_char(s))
    1.15 +		g_string_append_unichar(word,g_utf8_get_char(s));
    1.16 +	    if (g_utf8_get_char(s)==']')
    1.17 +	    {
    1.18 +		g_string_append_c(word,']');
    1.19 +		*ptr=g_utf8_next_char(s);
    1.20 +		return g_string_free(word,FALSE);
    1.21 +	    }
    1.22 +	    else
    1.23 +		g_string_truncate(word,0);
    1.24 +	}
    1.25 +    }
    1.26      /*
    1.27       * Use a look-ahead to handle exceptions for numbers like 1,000 and 1.35.
    1.28       * Especially yucky is the case of L1,000
     2.1 --- a/test/bookloupe/Makefile.am	Sat Oct 05 21:37:31 2013 +0100
     2.2 +++ b/test/bookloupe/Makefile.am	Tue Oct 15 09:16:04 2013 +0100
     2.3 @@ -1,6 +1,6 @@
     2.4  TESTS_ENVIRONMENT=BOOKLOUPE=../../bookloupe/bookloupe ../harness/loupe-test
     2.5  TESTS=non-ascii.tst long-line.tst curved-single-quotes.tst curved-quotes.tst \
     2.6  	runfox-quotes.tst curved-genitives.tst multi-line-illustration.tst \
     2.7 -	emdash.tst
     2.8 +	emdash.tst footnote-marker.tst
     2.9  
    2.10  dist_pkgdata_DATA=$(TESTS)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/bookloupe/footnote-marker.tst	Tue Oct 15 09:16:04 2013 +0100
     3.3 @@ -0,0 +1,31 @@
     3.4 +**************** INPUT ****************
     3.5 +Among these was the Buddha Amitabha, the Buddha of Boundless Light,[1]
     3.6 +who had made a wondrous vow in virtue of which a blessed future of
     3.7 +righteousness and joy in the Western Paradise was secured for all who
     3.8 +put their trust in him.  Carried into China, this devotion acquired
     3.9 +great popularity, and centuries later it passed into Japan.  There,
    3.10 +while Europe was sending its warriors to win back from the Crescent the
    3.11 +city of the Cross, while Bernard and Francis and Dominic were awakening
    3.12 +new enthusiasm for the monastic {17} life, two famous teachers, Honen
    3.13 +(1133-1212) and Shin-ran (1173-1262), developed the doctrine of
    3.14 +"salvation by faith."  Honen was the only son of a military chief who
    3.15 +died of a wound inflicted by an enemy.  On his deathbed he enjoined the
    3.16 +boy never to seek revenge, and bade him become a monk for the spiritual
    3.17 +enlightenment both of his father and his father's foe.  So the lad
    3.18 +passed in due time into one of the great Buddhist monasteries on mount
    3.19 +Hiei.  Long years of laborious study followed, till in 1175 he reached
    3.20 +the conviction that faith in Amida[2] was the true way of salvation.  A
    3.21 +deep sense of human sinfulness and the belief in an All-Merciful
    3.22 +Deliverer were the essential elements of his religion.  Three emperors
    3.23 +became his pupils, and his life, compiled by imperial order after his
    3.24 +death, resembles that of a mediaeval Christian saint.  Visions of Amida
    3.25 +and of the holy teachers of the past were vouchsafed to him.  He
    3.26 +preached--like another St. Francis--to the serpents and the birds.  His
    3.27 +person was mysteriously transfigured, and a wondrous light filled his
    3.28 +dwelling.
    3.29 +
    3.30 +
    3.31 +[1] Also called Amitayus, the Buddha of Boundless Life.
    3.32 +
    3.33 +[2] The Japanese form of the Sanskrit Amitabha.
    3.34 +**************** EXPECTED ****************