diff --git a/src/Tools/offlinedoc/README b/src/Tools/offlinedoc/README index 216a9eb869..621fe07ef4 100644 --- a/src/Tools/offlinedoc/README +++ b/src/Tools/offlinedoc/README @@ -10,6 +10,9 @@ download and another to actually download the files. 2) run "downloadwiki.py". If connection drops, run it again, the already downloaded files will be skipped. + +2b) Dirty hack: run "fixlinks.py" to fix wrong html links + (downloadwiki.py should be fixed in the future) 3) run "buildqhelp.py" to generate freecad.qhc and freecad.qch files diff --git a/src/Tools/offlinedoc/buildqhelp.py b/src/Tools/offlinedoc/buildqhelp.py index 2d6572fa01..de90461b5d 100755 --- a/src/Tools/offlinedoc/buildqhelp.py +++ b/src/Tools/offlinedoc/buildqhelp.py @@ -103,7 +103,7 @@ def createCollProjectFile(): FreeCAD User Manual freecad-icon-64.png - freecad/freecad + freecad/freecad qthelp://org.freecad.usermanual/doc/Online_Help_Startpage.html About FreeCAD @@ -177,10 +177,17 @@ def buildtoc(): if "]*>(.*?)',line)[0].strip() link = re.findall('href="(.*?)"',line)[0].strip() + if link: + if not link.endswith(".html"): + link = link + ".html" + if link.startswith("/"): + link = link[1:] if not link: link = 'default.html' if title.startswith(" * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + +"""This script fixes links like href="/Arch_Wall" into href="/Arch_Wall.html" where needed. Dirty hack, downloadwiki.py should be fixed instead""" + +import os,re +files = [f for f in os.listdir("localwiki") if f.endswith(".html")] +for fn in files: + f = open(os.path.join("localwiki",fn)) + b = f.read() + f.close() + b = b.replace("\n","--endl--") + for href in re.findall("href=\".*?\"",b): + if (not "." in href) and (not "#" in href): + repl = href[:-1]+".html\"" + if "href=\"/" in repl: + repl = repl.replace("href=\"/","href=\"") + print(fn," : replacing",href,"with",repl) + b = b.replace(href,repl) + b = b.replace("--endl--","\n") + f = open(os.path.join("localwiki",fn),"w") + f.write(b) + f.close() +