1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 08:30:06 +02:00

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;
      }
This commit is contained in:
martynshaw99 2014-08-27 00:43:32 +00:00
parent eccaf30646
commit 07f1c22c38

View File

@ -22,6 +22,7 @@
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/statusbr.h> #include <wx/statusbr.h>
#include <wx/regex.h>
#include "../FileNames.h" #include "../FileNames.h"
#include "LinkingHtmlWindow.h" #include "LinkingHtmlWindow.h"
@ -245,23 +246,47 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
releasePageName = PageName; releasePageName = PageName;
anchor = wxT(""); anchor = wxT("");
} }
// This bit of code replicates the name transformations performed by the // The wiki pages are transformed to static HTML by
// clean_filename routine in scripts/mw2html_audacity/mw2html.py // scripts/mw2html_audacity/mw2html.py
// there is a special case for transforming the front page // The name is first transformed to lower case, then all
// (Main_Page => index.html) // '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")) if (releasePageName == wxT("Main_Page"))
{ {
// FIXME: Needs to be outside /man/ directory for release manual.
releasePageName = wxT("index") + HelpSystem::ReleaseSuffix + anchor; 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 else
{ // for any other name {
releasePageName.Replace(wxT("%%"), wxT("_"), true); // Change to lower case.
releasePageName.Replace(wxT("%25"), wxT("_"), true); releasePageName = releasePageName.Lower();
releasePageName.Replace(wxT("%"), wxT("_"), true); wxRegEx re;
releasePageName.Replace(wxT("-"), wxT("_"), true); // replace 'special characters' with underscores.
releasePageName.Replace(wxT("__"), wxT("_"), true); // RFC 2396 defines the characters a-z, A-Z, 0-9 and ".-_" as "always safe"
releasePageName.Replace(wxT("_."), wxT("."), true); // mw2html also replaces "-" with "_" so replace that too.
releasePageName = releasePageName.Lower()+HelpSystem::ReleaseSuffix + anchor; 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(); localHelpPage = wxFileName(FileNames::HtmlHelpDir()+wxT("/man/"), releasePageName).GetFullPath();