Notapplicable4now / support-tools

Automatically exported from code.google.com/p/support-tools
Apache License 2.0
0 stars 0 forks source link

WikiWords not replaced by links upon conversion to .md #124

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We've tried to migrate our project (http://code.google.com/p/address-sanitizer) 
to GitHub using the "Export to GitHub" button. For some Wiki pages, some 
WikiWords that corresponded to actual pages weren't replaced with links upon 
.md conversion (if someone's eager to reproduce that, these are for example the 
links to AsanCoverage from Flags.md).

Because the problem is also reproducible for me locally with wiki2gfm.py, which 
I suspect is used when the "Export to GitHub" button is being pressed (if this 
isn't actually so, consider this a bugreport for wiki2gfm.py, if it is, we're 
really disappointed by the quality of the migration tools).

The following patch appears to solve the problem for me. Note that it assumes 
--wikipages_list contains filenames ending with ".wiki", not WikiWords.

diff --git a/wiki_to_md/wiki2gfm.py b/wiki_to_md/wiki2gfm.py
index 8ee84ec..1f8a05a 100755
--- a/wiki_to_md/wiki2gfm.py
+++ b/wiki_to_md/wiki2gfm.py
@@ -86,14 +86,17 @@ def main(args):
     with codecs.open(parsed_args.output_file, "wU", "utf-8") as output_stream:
       # Create the master list of wiki pages assumed to exist.
       wikipages = parsed_args.wikipages_list or []
-      wikipages.append(parsed_args.input_file)
+      wikipages.append(os.path.basename(parsed_args.input_file))

       if parsed_args.wikipages_path:
-        # Add all the .wiki files in all the given paths.
         for path in parsed_args.wikipages_path:
           for f in os.listdir(path):
-            if f.endswith(".wiki"):
-              wikipages.append(f[:-len(".wiki")])
+            wikipages.append(f)
+      # Only treat .wiki files as wikipages.
+      wikipages = [f[:-len(".wiki")] for f in wikipages if f.endswith(".wiki")]
+      # Remove the duplicates, e.g. if parsed_args.input_file belongs to
+      # parsed_args.wikipages_path.
+      wikipages = list(set(wikipages))

       # Fill this will a mapping from Google Code issue
       # to GitHub issue to automate that conversion.

Original issue reported on code.google.com by gli...@google.com on 28 Aug 2015 at 1:29

GoogleCodeExporter commented 8 years ago
thanks for your information. visit me 
http://richcare.blogspot.co.id/2015/09/obat-herbal-asam-urat-alami-generik-resep
dokter-dan-kolesterol.html

Original comment by prabukra...@gmail.com on 1 Oct 2015 at 4:54