From: Reinhold Kainhofer Date: Sun, 23 Sep 2007 08:39:49 +0000 (+0200) Subject: MusicXML: Correctly convert instrument names with line breaks X-Git-Tag: release/2.11.35-1~100 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=27b5b5a23e97816a7e08796bd3d35bdc958bb563;p=lilypond.git MusicXML: Correctly convert instrument names with line breaks Convert line breaks in instrument names to \markup \columns {\line {..} \line {..}} Also add regression test file. Signed-off-by: Reinhold Kainhofer --- diff --git a/python/musicexp.py b/python/musicexp.py index 9c6e2341f3..504cdf139a 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -6,8 +6,17 @@ import re from rational import Rational -def escape_output_string (input_string): - return "\"" + string.replace (input_string, "\"", "\\\"") + "\"" +def escape_instrument_string (input_string): + retstring = string.replace (input_string, "\"", "\\\"") + if re.match ('.*\n.*', retstring): + strings = retstring.split ('\r\n') + retstring = "\\markup { \\column { " + for s in strings: + retstring += "\\line {\"" + s + "\"} " + retstring += "} }" + else: + retstring = "\"" + retstring + "\"" + return retstring class Output_stack_element: def __init__ (self): @@ -949,11 +958,11 @@ class StaffGroup: printer.newline () if self.stafftype and self.instrument_name: printer.dump ("\\set %s.instrumentName = %s" % (self.stafftype, - escape_output_string (self.instrument_name))) + escape_instrument_string (self.instrument_name))) printer.newline () if self.stafftype and self.short_instrument_name: printer.dump ("\\set %s.shortInstrumentName = %s\n" % (self.stafftype, - escape_output_string (self.short_instrument_name))) + escape_instrument_string (self.short_instrument_name))) printer.newline () self.print_ly_contents (printer) printer.newline ()