From 07f1c22c38709d9cc546cddecb9680f37d7a267a Mon Sep 17 00:00:00 2001 From: martynshaw99 Date: Wed, 27 Aug 2014 00:43:32 +0000 Subject: [PATCH] Steve's patch committed, for the quick release of 2.0.6, but noting my concerns here that it does not mirror what mw2html.py does and a pointer to a better solution may be stuff like while( (p=releasePageName.Find(wxT("__"))) != wxNOT_FOUND ) { wxString left = releasePageName.Left(p); wxString right = releasePageName.Mid(p+2); releasePageName = left + wxT("_") + right; } --- src/widgets/HelpSystem.cpp | 49 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index 1bb17fd23..a1cca7961 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "../FileNames.h" #include "LinkingHtmlWindow.h" @@ -245,23 +246,47 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent, releasePageName = PageName; anchor = wxT(""); } - // This bit of code replicates the name transformations performed by the - // clean_filename routine in scripts/mw2html_audacity/mw2html.py - // there is a special case for transforming the front page - // (Main_Page => index.html) + // The wiki pages are transformed to static HTML by + // scripts/mw2html_audacity/mw2html.py + // The name is first transformed to lower case, then all + // 'special characters' are replaced by underscores. Spaces are + // transformed to "+". + // + // The transformations are handled in mw2html by first applying + // 'urllib.parse.quote_plus' (escape chars that are not in "always safe" list) + // then replacing escape characters (%xx and %25xx) with underscores, + // and finally removing duplicate / redundant underscores. + // + // The front page and 'quick_help' are treated as special cases and placed in + // the root of the help directory rather than the "/man/" sub-directory. if (releasePageName == wxT("Main_Page")) { + // FIXME: Needs to be outside /man/ directory for release manual. releasePageName = wxT("index") + HelpSystem::ReleaseSuffix + anchor; } + else if (releasePageName == wxT("Quick_Help")) + { + // FIXME: Needs to be outside /man/ directory for release manual. + releasePageName = wxT("quick_help") + HelpSystem::ReleaseSuffix + anchor; + } else - { // for any other name - releasePageName.Replace(wxT("%%"), wxT("_"), true); - releasePageName.Replace(wxT("%25"), wxT("_"), true); - releasePageName.Replace(wxT("%"), wxT("_"), true); - releasePageName.Replace(wxT("-"), wxT("_"), true); - releasePageName.Replace(wxT("__"), wxT("_"), true); - releasePageName.Replace(wxT("_."), wxT("."), true); - releasePageName = releasePageName.Lower()+HelpSystem::ReleaseSuffix + anchor; + { + // Change to lower case. + releasePageName = releasePageName.Lower(); + wxRegEx re; + // replace 'special characters' with underscores. + // RFC 2396 defines the characters a-z, A-Z, 0-9 and ".-_" as "always safe" + // mw2html also replaces "-" with "_" so replace that too. + re.Compile(wxT("[^[:alnum:] . [:space:]]")); + re.ReplaceAll(&releasePageName, (wxT("_"))); + // Replace spaces with "+" + releasePageName.Replace(wxT(" "), wxT("+"), true); + // Reduce multiple underscores to single underscores + releasePageName.Replace(wxT("__"), wxT("_"), true); + // Replace "_." with "." + releasePageName.Replace(wxT("_."), wxT("."), true); + // Concatenate file name with file extension and anchor. + releasePageName = releasePageName + HelpSystem::ReleaseSuffix + anchor; } localHelpPage = wxFileName(FileNames::HtmlHelpDir()+wxT("/man/"), releasePageName).GetFullPath();