re.sub ('<', '<',
re.sub ('&', '&', s)))
-def split_options (option_string):
- if option_string:
- if global_options.format == HTML:
- options = re.findall('[\w\.-:]+(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|\S+))?',option_string)
- for i in range(len(options)):
- options[i] = re.sub('^([^=]+=\s*)(?P<q>["\'])(.*)(?P=q)','\g<1>\g<3>',options[i])
- return options
- else:
- return re.split (format_res[global_options.format]['option_sep'],
- option_string)
- return []
-
-def set_default_options (source):
- global default_ly_options
- if not default_ly_options.has_key (LINE_WIDTH):
- if global_options.format == LATEX:
+ texinfo_lang_re = re.compile ('(?m)^@documentlanguage (.*?)( |$)')
+def set_default_options (source, default_ly_options, format):
+ if LINE_WIDTH not in default_ly_options:
+ if format == LATEX:
textwidth = get_latex_textwidth (source)
- default_ly_options[LINE_WIDTH] = \
- '''%.0f\\pt''' % textwidth
- elif global_options.format == TEXINFO:
+ default_ly_options[LINE_WIDTH] = '%.0f\\pt' % textwidth
+ elif format == TEXINFO:
+ m = texinfo_lang_re.search (source)
+ if m and not m.group (1).startswith ('en'):
+ default_ly_options[LANG] = m.group (1)
+ else:
+ default_ly_options[LANG] = ''
- for (k, v) in texinfo_line_widths.items ():
+ for regex in texinfo_line_widths:
# FIXME: @layout is usually not in
# chunk #0:
#
progress ('\n')
return do_file (name)
- include_chunks = [process_include (c) for c in chunks
- if is_derived_class (c.__class__, Include_snippet)]
+ include_chunks = map (process_include,
- filter (lambda x: isinstance (x, IncludeSnippet),
- chunks))
++ filter (lambda x: isinstance (x, IncludeSnippet),
++ chunks))
- return chunks + reduce (operator.add, include_chunks, [])
+ return chunks + reduce (lambda x, y: x + y, include_chunks, [])
- except Compile_error:
+ except CompileError:
os.chdir (original_dir)
progress (_ ("Removing `%s'") % output_filename)
progress ('\n')