Hi John,
The www-post script has another bug with link rewriting: For the snippets 
pages, it checks and replaces links using the regexp:
       r'href="(?:\.\./)?lilypond(|-internals|-learning|-program)'
Unfortunately, "lilypond-snippets-big-page.html" also matches this regexp, so 
internal links in the snippets pages are also rewritten to point to 
Documentation/user/!

Attached is a patch to fix this: I have to explicity add -snippets to the 
regexp and can only later on exclude those matches in a replacement function.

Okay to push to master?

Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: [EMAIL PROTECTED], http://reinhold.kainhofer.com/
 * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
 * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
 * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/
From 4c385f9bce569879457fc822f5d0c5f3b3c54120 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <[EMAIL PROTECTED]>
Date: Sun, 10 Aug 2008 14:23:49 +0200
Subject: [PATCH 1/1] Fix link-rewriting for snippets

Since the user_ref_re checks for lilypond(|...), it will also
match lilypond-snippets and thus also rewrite snippets links from
snippet pages, breaking those links.

The workaround is to explicitly match lilypond-snippets and
then exclude those matches in a replacement function.
---
 buildscripts/add_html_footer.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/buildscripts/add_html_footer.py b/buildscripts/add_html_footer.py
index a1c81f3..48beb36 100644
--- a/buildscripts/add_html_footer.py
+++ b/buildscripts/add_html_footer.py
@@ -93,8 +93,18 @@ def source_links_replace (m, source_val):
 
 splitted_docs_re = re.compile ('(input/lsr/out-www/lilypond-snippets|Documentation/user/out-www/(lilypond|music-glossary|lilypond-program|lilypond-learning))/')
 
+# since lilypond-snippet also matches lilypond, I have to exclude the snippets 
+# later on in the replacement function from path rewriting. For this, I explicitly
+# match the snippets, too, otherwise I would have not way to detect them.
 snippets_ref_re = re.compile (r'href="(\.\./)?lilypond-snippets')
-user_ref_re = re.compile (r'href="(?:\.\./)?lilypond(|-internals|-learning|-program)')
+user_ref_re = re.compile (r'href="(?:\.\./)?lilypond(-internals|-learning|-program|-snippets|)')
+
+# If we are in the snippets dir, don't rewrite links to snippets!
+def hack_links_from_snippets (m):
+    if m.group(1) == '-snippets':
+        return m.group(0);
+    else:
+        return 'href="source/Documentation/user/lilypond'+m.group(1);
 
 ## Windows does not support symlinks.
 # This function avoids creating symlinks for splitted HTML manuals
@@ -108,7 +118,7 @@ def hack_urls (s, prefix):
     if 'user/out-www/lilypond' in 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)
+        s = user_ref_re.sub (hack_links_from_snippets, s)
 
     source_path = os.path.join (os.path.dirname (prefix), 'source')
     if not os.path.islink (source_path):
-- 
1.5.4.3

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to