Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Sep 14, 2015 · 0 comments
Open

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

GoogleCodeExporter opened this issue Sep 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 28 Aug 2015 at 1:29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant