Handle smart quotes

This commit is contained in:
Matthias Neeracher 2008-08-16 20:42:59 +00:00
parent cb57ba9a67
commit 1e0ac13e12

View File

@ -187,7 +187,7 @@ def parseLilypond
INFILE.each do |line| INFILE.each do |line|
line.chomp!.sub!(/%.*/, "") line.chomp!.sub!(/%.*/, "")
line.gsub!(/\\breve/, "1*8/4") line.gsub!(/\\breve/, "1*8/4")
line.scan(%r$\G\s*(\{|\}|\(|\)|\||=|~|<<|>>|--|#'|#\(|##t|##f|\\\w+|\".*?\"|\w[-+^\w\d.',:*/?!]+|.)$) do |token| line.scan(%r$\G\s*(\{|\}|\(|\)|\||=|~|<<|>>|--|#'|#\(|##t|##f|\\\w+|\".*?\"|(\w|'|`)[-+^\w\d.'`,:*/?!]+|.)$) do |token|
tokens.push(token[0]) tokens.push(token[0])
end end
end end
@ -349,7 +349,13 @@ def parseLilypond
p [$1, lyricFlags] if $DEBUG p [$1, lyricFlags] if $DEBUG
lyrics.push [$1, lyricFlags] lyrics.push [$1, lyricFlags]
lyricFlags = 0 lyricFlags = 0
elsif token =~ /^\w.*/ elsif token =~ /^(\w|'|`).*/
#
# Handle smart quotes
#
token.gsub!(/``/, "\xE2\x80\x9C");
token.gsub!(/''/, "\xE2\x80\x9D");
token.gsub!(/'/, "\xE2\x80\x99");
p [token, lyricFlags] if $DEBUG p [token, lyricFlags] if $DEBUG
lyrics.push [token, lyricFlags] lyrics.push [token, lyricFlags]
lyricFlags = 0 lyricFlags = 0