]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/postprocess_html.py
Merge master into nested-bookparts
[lilypond.git] / buildscripts / postprocess_html.py
index ebea89c01b6ba72b4a3902107157616d7e911a45..e94da797559b224694a7caae817408310f9b0d4d 100644 (file)
@@ -99,6 +99,9 @@ snippets_ref_re = re.compile (r'href="(\.\./)?lilypond-snippets')
 user_ref_re = re.compile ('href="(?:\.\./)?lilypond\
 (-internals|-learning|-program|(?!-snippets))')
 
+docindex_link_re = re.compile (r'href="index.html"')
+
+
 ## Windows does not support symlinks.
 # This function avoids creating symlinks for splitted HTML manuals
 # Get rid of symlinks in GNUmakefile.in (local-WWW-post)
@@ -112,6 +115,18 @@ def hack_urls (s, prefix):
         s = snippets_ref_re.sub ('href="source/input/lsr/lilypond-snippets', s)
     elif 'input/lsr' in prefix:
         s = user_ref_re.sub ('href="source/Documentation/user/lilypond\\1', s)
+    
+    # we also need to replace in the lsr, which is already processed above!
+    if 'input/' in prefix or 'Documentation/topdocs' in prefix:
+        # fix the link from the regtest, lsr and topdoc pages to the doc index 
+        # (rewrite prefix to obtain the relative path of the doc index page)
+        rel_link = re.sub (r'out-www/.*$', '', prefix)
+        rel_link = re.sub (r'[^/]*/', '../', rel_link)
+        if 'input/regression' in prefix:
+            indexfile = "Documentation/devel"
+        else:
+            indexfile = "index"
+        s = docindex_link_re.sub ('href="' + rel_link + indexfile + '.html\"', s)
 
     source_path = os.path.join (os.path.dirname (prefix), 'source')
     if not os.path.islink (source_path):
@@ -123,9 +138,16 @@ body_tag_re = re.compile ('(?i)<body([^>]*)>')
 html_tag_re = re.compile ('(?i)<html>')
 doctype_re = re.compile ('(?i)<!DOCTYPE')
 doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n'
-css_re = re.compile ('(?i)<link rel="stylesheet" type="text/css" ([^>]*)href="[^">]*?lilypond.css"([^>]*)>')
+css_re = re.compile ('(?i)<link rel="stylesheet" type="text/css" ([^>]*)href="[^">]*?lilypond.*\.css"([^>]*)>')
 end_head_tag_re = re.compile ('(?i)</head>')
-css_link = '<link rel="stylesheet" type="text/css" href="%sDocumentation/lilypond.css">\n'
+css_link = """    <link rel="stylesheet" type="text/css" title="Patrick McCarty's design" href="%(rel)sDocumentation/lilypond-mccarty.css">
+    <link rel="alternate stylesheet" type="text/css" href="%(rel)sDocumentation/lilypond.css" title="Andrew Hawryluk's design">
+    <link rel="alternate stylesheet" type="text/css" href="%(rel)sDocumentation/lilypond-blue.css" title="Kurt Kroon's blue design">
+    <!--[if lte IE 7]>
+    <link href="%(rel)sDocumentation/lilypond-ie-fixes.css" rel="stylesheet" type="text/css">
+    <![endif]-->
+"""
+
 
 def add_header (s, prefix):
     """Add header (<body>, doctype and CSS)"""
@@ -144,7 +166,7 @@ def add_header (s, prefix):
 
         if css_re.search (s) == None:
             depth = (prefix.count ('/') - 1) * '../'
-            s = end_head_tag_re.sub ((css_link % depth) + '</head>', s)
+            s = end_head_tag_re.sub ((css_link % {'rel': depth}) + '</head>', s)
     return s
 
 title_tag_re = re.compile ('.*?<title>(.*?)</title>', re.DOTALL)