# HG changeset patch # User ali # Date 1381824964 -3600 # Node ID ad92d11d59b812c1599d942452371f734742993f # Parent 783eff3047bc0827c354408c4d666ee0523d48e4 Fix bug #27: Don't treat [1] as a standalone 1 diff -r 783eff3047bc -r ad92d11d59b8 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sat Oct 05 21:37:31 2013 +0100 +++ b/bookloupe/bookloupe.c Tue Oct 15 09:16:04 2013 +0100 @@ -2951,7 +2951,24 @@ for (;!g_unichar_isdigit(g_utf8_get_char(*ptr)) && !g_unichar_isalpha(g_utf8_get_char(*ptr)) && **ptr;*ptr=g_utf8_next_char(*ptr)) - ; + { + /* Handle exceptions for footnote markers like [1] */ + if (g_utf8_get_char(*ptr)=='[') + { + g_string_append_c(word,'['); + s=g_utf8_next_char(*ptr); + for (;g_unichar_isdigit(g_utf8_get_char(s));s=g_utf8_next_char(s)) + g_string_append_unichar(word,g_utf8_get_char(s)); + if (g_utf8_get_char(s)==']') + { + g_string_append_c(word,']'); + *ptr=g_utf8_next_char(s); + return g_string_free(word,FALSE); + } + else + g_string_truncate(word,0); + } + } /* * Use a look-ahead to handle exceptions for numbers like 1,000 and 1.35. * Especially yucky is the case of L1,000 diff -r 783eff3047bc -r ad92d11d59b8 test/bookloupe/Makefile.am --- a/test/bookloupe/Makefile.am Sat Oct 05 21:37:31 2013 +0100 +++ b/test/bookloupe/Makefile.am Tue Oct 15 09:16:04 2013 +0100 @@ -1,6 +1,6 @@ TESTS_ENVIRONMENT=BOOKLOUPE=../../bookloupe/bookloupe ../harness/loupe-test TESTS=non-ascii.tst long-line.tst curved-single-quotes.tst curved-quotes.tst \ runfox-quotes.tst curved-genitives.tst multi-line-illustration.tst \ - emdash.tst + emdash.tst footnote-marker.tst dist_pkgdata_DATA=$(TESTS) diff -r 783eff3047bc -r ad92d11d59b8 test/bookloupe/footnote-marker.tst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bookloupe/footnote-marker.tst Tue Oct 15 09:16:04 2013 +0100 @@ -0,0 +1,31 @@ +**************** INPUT **************** +Among these was the Buddha Amitabha, the Buddha of Boundless Light,[1] +who had made a wondrous vow in virtue of which a blessed future of +righteousness and joy in the Western Paradise was secured for all who +put their trust in him. Carried into China, this devotion acquired +great popularity, and centuries later it passed into Japan. There, +while Europe was sending its warriors to win back from the Crescent the +city of the Cross, while Bernard and Francis and Dominic were awakening +new enthusiasm for the monastic {17} life, two famous teachers, Honen +(1133-1212) and Shin-ran (1173-1262), developed the doctrine of +"salvation by faith." Honen was the only son of a military chief who +died of a wound inflicted by an enemy. On his deathbed he enjoined the +boy never to seek revenge, and bade him become a monk for the spiritual +enlightenment both of his father and his father's foe. So the lad +passed in due time into one of the great Buddhist monasteries on mount +Hiei. Long years of laborious study followed, till in 1175 he reached +the conviction that faith in Amida[2] was the true way of salvation. A +deep sense of human sinfulness and the belief in an All-Merciful +Deliverer were the essential elements of his religion. Three emperors +became his pupils, and his life, compiled by imperial order after his +death, resembles that of a mediaeval Christian saint. Visions of Amida +and of the holy teachers of the past were vouchsafed to him. He +preached--like another St. Francis--to the serpents and the birds. His +person was mysteriously transfigured, and a wondrous light filled his +dwelling. + + +[1] Also called Amitayus, the Buddha of Boundless Life. + +[2] The Japanese form of the Sanskrit Amitabha. +**************** EXPECTED ****************