This repository was archived by the owner on Sep 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
add a hackish script to convert the wiki to creole #13
Open
jedie
wants to merge
4
commits into
trentm:master
Choose a base branch
from
jedie:creole
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,23 @@ See this blog post giving example usage: <http://trentm.com/2012/03/google-code- | |
| # wiki conversion | ||
|
|
||
| - <http://code.google.com/p/support/wiki/WikiSyntax> | ||
|
|
||
|
|
||
| # convert google wiki to creole | ||
|
|
||
| install, e.g.: | ||
| ``` | ||
| ~$ virtualenv --python=python2 wikiconvert | ||
| ~$ cd wikiconvert/ | ||
| ~/wikiconvert$ source bin/activate | ||
| (wikiconvert)~/wikiconvert$ git clone [email protected]:jedie/googlecode2github.git | ||
| (wikiconvert)~/wikiconvert$ pip install python-creole markdown | ||
| ``` | ||
|
|
||
| usage, e.g: | ||
| ``` | ||
| ~$ cd wikiconvert/ | ||
| ~/wikiconvert$ source bin/activate | ||
| (wikiconvert)~/wikiconvert$ cd googlecode2github | ||
| (wikiconvert)~/wikiconvert$ python googlecode2github.py username/project /path/to/wiki /path/to/new_wiki | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| """ | ||
| Usage: | ||
| python2 /path/to/wiki2creole.py PROJID SRCDIR DSTDIR | ||
|
|
||
| where "PROJID" is the github project id, e.g. "trentm/python-markdown2", | ||
| "SRCDIR" is a Google Code project wiki Subversion working copy dir and | ||
| "DSTDIR" is the git clone dir of the git project's wiki. | ||
| """ | ||
|
|
||
| __version__ = "1.0.0" | ||
|
|
||
| import sys | ||
| import os | ||
| import glob | ||
| import codecs | ||
|
|
||
| import markdown | ||
| from creole import html2creole | ||
|
|
||
| from wikiconvert import log | ||
| from wikiconvert import convert_file as wiki2markdown | ||
|
|
||
|
|
||
| def convert_dir(proj_id, src_dir, dst_dir): | ||
| if not os.path.isdir(dst_dir): | ||
| log("Create %r..." % dst_dir) | ||
| os.makedirs(dst_dir) | ||
|
|
||
| if os.path.isfile(src_dir): | ||
| wiki2creole(proj_id, src_dir, dst_dir) | ||
| else: | ||
| for f in glob.glob(os.path.join(src_dir, "*.wiki")): | ||
| wiki2creole(proj_id, f, dst_dir) | ||
|
|
||
|
|
||
|
|
||
| def wiki2creole(proj_id, src_path, dst_dir): | ||
| log("\nConvert %r..." % src_path) | ||
|
|
||
| gh_page_name, md_file_path = wiki2markdown(proj_id, src_path, dst_dir) | ||
|
|
||
| with codecs.open(md_file_path, 'r', 'utf-8') as f: | ||
| md_content = f.read() | ||
|
|
||
| html = markdown.markdown(md_content) | ||
| html=html.replace("<pre><code>", "\n<pre>\n") | ||
| html=html.replace("</code></pre>", "</pre>\n") | ||
|
|
||
| creole_content = html2creole(html) | ||
|
|
||
| creole_path = os.path.join(dst_dir, gh_page_name+".creole") | ||
| log("write %r..." % creole_path) | ||
| with codecs.open(creole_path, 'w', 'utf-8') as f: | ||
| f.write(creole_content) | ||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| if len(sys.argv) != 4: | ||
| print __doc__ | ||
| sys.exit(1) | ||
| convert_dir(sys.argv[1], sys.argv[2], sys.argv[3]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That example should show running wik2creole.py right?
What is creole? Is it related to Google Code or GitHub at all?
Cheers,
Trent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, wiki2creole.py should be used ;)
Creole is a markup: https://en.wikipedia.org/wiki/Creole_(markup) and http://www.wikicreole.org/
You can use it in github wiki ;)