diff --git a/private_includes/book/toc_include.ily b/private_includes/book/toc_include.ily index 2ff802e..b872527 100644 --- a/private_includes/book/toc_include.ily +++ b/private_includes/book/toc_include.ily @@ -61,20 +61,9 @@ ;; We insert index items sorted from the beginning on and do ;; not sort them later - this saves pretty much computing time (insert-alphabetical-sorted! (list label markup-symbol textoptions - ;; this crazy hack is necessary because lilypond depends on guile 1.8 atm - ;; and so the cool unicode conversion functions cannot be used (ly:string-substitute " " "" - (ly:string-substitute "…" "" - (ly:string-substitute "Č" "C" - (ly:string-substitute "Đ" "D" - (ly:string-substitute "Š" "S" - (ly:string-substitute "Т" "T" - (ly:string-substitute "Ä" "Ae" - (ly:string-substitute "ä" "ae" - (ly:string-substitute "Ö" "O" - (ly:string-substitute "ö" "oe" - (ly:string-substitute "Ü" "U" - (ly:string-substitute "ü" "ue" sorttext))))))))))))) + (ly:string-substitute "." "" + (transliterate-de sorttext)))) index-item-list)) (make-music 'EventChord 'page-marker #t diff --git a/private_includes/book/transliteration.ily b/private_includes/book/transliteration.ily new file mode 100644 index 0000000..3df1668 --- /dev/null +++ b/private_includes/book/transliteration.ily @@ -0,0 +1,65 @@ +#(define (transliterate-de str) + "Gesamte Transliteration: entfernt Diakritika, ersetzt Sonderzeichen, ergibt ASCII-String." + + (define (remove-diacritics s) + (string-join + (map (lambda (ch) + (let ((code (char->integer ch))) + ;; Unicode-Bereich 0300–036F = Combining Diacritical Marks + (if (and (>= code #x0300) (<= code #x036F)) + "" + (string ch)))) + (string->list (string-normalize-nfkd s))) + "")) + + (define transliteration-table + '( + ;; Deutsche Umlaute & ß + ("ä" . "ae") ("ö" . "oe") ("ü" . "ue") + ("Ä" . "Ae") ("Ö" . "Oe") ("Ü" . "Ue") + ("ß" . "ss") + + ;; Balkan & mitteleuropäische Sonderzeichen + ("Č" . "C") ("č" . "c") + ("Š" . "S") ("š" . "s") + ("Ž" . "Z") ("ž" . "z") + ("Đ" . "D") ("đ" . "d") + ("Ł" . "L") ("ł" . "l") + ("Ø" . "O") ("ø" . "o") + ("Æ" . "Ae") ("æ" . "ae") + ("Œ" . "Oe") ("œ" . "oe") + + ;; Kyrillische Buchstaben mit lateinischen Pendants + ("А" . "A") ("а" . "a") + ("Б" . "B") ("б" . "b") + ("В" . "V") ("в" . "v") + ("Г" . "G") ("г" . "g") + ("Д" . "D") ("д" . "d") + ("Е" . "E") ("е" . "e") + ("З" . "Z") ("з" . "z") + ("И" . "I") ("и" . "i") + ("К" . "K") ("к" . "k") + ("Л" . "L") ("л" . "l") + ("М" . "M") ("м" . "m") + ("Н" . "N") ("н" . "n") + ("О" . "O") ("о" . "o") + ("П" . "P") ("п" . "p") + ("Р" . "R") ("р" . "r") + ("С" . "S") ("с" . "s") + ("Т" . "T") ("т" . "t") + ("У" . "U") ("у" . "u") + ("Ф" . "F") ("ф" . "f") + ("Х" . "Kh") ("х" . "kh") + ("Ц" . "Ts") ("ц" . "ts") + ("Ч" . "Ch") ("ч" . "ch") + ("Ш" . "Sh") ("ш" . "sh") + ("Щ" . "Sch") ("щ" . "sch") + ("Я" . "Ja") ("я" . "ja") + ("Ю" . "Ju") ("ю" . "ju") + ("Й" . "J") ("й" . "j") + )) + + (remove-diacritics + (fold (lambda (pair acc) + (ly:string-substitute (car pair) (cdr pair) acc)) + str transliteration-table))) diff --git a/public_includes/book_top.ily b/public_includes/book_top.ily index 2dd0529..59d9891 100644 --- a/public_includes/book_top.ily +++ b/public_includes/book_top.ily @@ -1,3 +1,4 @@ \include "../private_includes/book/book_include.ily" +\include "../private_includes/book/transliteration.ily" \include "../private_includes/book/toc_include.ily" \include "../private_includes/book/appendix.ily" \ No newline at end of file