The codex-converter is aid tool for WordPress Codex migrator or translater. It automatically converts Codex article written by MediaWiki format to specified format.
For example, Codex article
==Title==
This is example article.
* List1
* List2
will be converted to HelpHub article by Codex to HelpHub converter.
<h2>Title</h2>
<p>This is example article.</p>
<ul>
<li>List1</li>
<li>List2</li>
</ul>
Current codex-converter package includes two type of converter:
- HelpHub
- Japanese Codex (Beta)
Codex to HelpHub:
http://unofficialtokyo.com/codex-converter
Codex Translator Aid Tool (Beta):
http://unofficialtokyo.com/codex-translater-aid
- Click center button for demo.
- Cut and Paste the Codex text into the left box and click center button.
- Refer "TODO" that requires post production (ex. Image paste).
- Code is always assumed as PHP. Adjust the line [code lang=php].
- Check whole contents. This program is not complete converter.
You can convert on your local computer.
Codex to HelpHub:
php command-codextohelphub.php -i <input_file> -o <output_file>
Refer codex-converter.log. To change log file name or log level, edit class-logger.php direct.
codex-converter uses own Logger class only for a removal of external library dependency. That has the same interface with log4php with limitations.
- Not ussing log-config.xml. To change log file name or log level, edit class-logger.php direct.
- Terrible performance when LOGGERLEVEL_TRACE is set for long Codex article. Use only for debug or consider to use log4php.
You should use log4php if it is possible.
To use log4php
- replace require_once in class-codex.php
- rename sample-log-config.xml to log-config.xml
Codex to HelpHub:
<pre>
tag or line begin with space character is always converted to[code language="php"]
.
Codex Translater Aid Tool (Beta):
- Japanse support only.
- Some functions are not implemented yet such as automatic retrieve function by URL specification. Refer ToDo.
README.md readme (This file)
testrun.bat (Windows) phpunit test kicker
run.bat (Windows) command line HelpHub launcher
src/
class-codex.php Codex class (main)
interface-converter.php Interface of Converter
ws-codex-converter.php receiver
class-logger.php Own poor Logger
class-result.php Output result keeper
class-util.php Utility handles line type
codex-converter.css stylesheet
loader.gif animated loader
sample-functions.php sample functions.php (part of)
sample-log-config.xml sample log4php configuration file
(codex-converter.log) (not included) log file
// --- Codex to HelpHub ---
page-codextohelphub.php Page Template
codex-converter.js invoker
codextohelphub.html standalone web page (test purpose)
command-codextohelphub.php command line interface
helphub
class-helphub-converter.php Converter class (main logic)
// ---Codex Translator Aid ---
page-codextranslatoraid.php Page Template
codex-translator-aid.js invoker
codextranslatoraid.html standalone web page (test purpose)
jacodex
class-jacodex-converter.php Converter class (main logic)
tests/
CodexHelpHubTest.php phpunit test for Codex to HelpHub
CodexJaCodexTest.php phpunit test for Codex Translator Aid
(others) test files
(others_expected) expected results
Codex to HelpHub Deployment steps are as following. Codex Translator Aid tool is the same except file name.
- Copy every files under the codex-converter/src including sub-directory to Web Server. In this scenario, let's assume files are copied to htdocs/ws-codex-converter.
- Edit
TARGET_URL
incodex-converter.js
to point the ws-codex-converter.php. For example, it isvar TARGET_URL = 'ws-codex-converter.php';
orvar TARGET_URL = '/ws-codex-converter/ws-codex-converter.php';
- Access http://(your-host)/ws-codex-converter/codextohelphub.html
- Even Custom Page Template, first try above "Web Application" step for confirmation.
NOTE: Specify absolute path toTARGET_URL
incodex-converter.js
as the first step, if you get error "XMLHttpRequest : 404, textStatus : error, errorThrown : undefined". - Copy following files to your theme directory
- page-codextohelphub.php
- sample-functions.php
- codex-converter.css
- codex-converter.js
- loader.gif
It assumes phpunit can be invoked.
- testrun
- testrun test01 (or test02, test03, ...)
For test case details, refer tests/CodexHelpHubTest.php.
If you want to create your own converter, follow below steps:
- Define your converter symbol (ex. KoCodex)
- Create subdirectory and class file with lower characters of converter symbol (ex. kocodex/class-kocodex-converter.php)
- Implements interface-converter.php. Refer helphub/ or jacodex/. (ex. KoCodexConverter class)
- Instantiate Codex class with the converter symbol.
$codex_to = new Codex( 'KoCodex' );
$output_data = $codex_to->convert( $input_data );
- URL input support. It will get the contents and last modifier information.
- Transferred DevHub page support. In this case, it will get last - 1 revision from Codex and inform it translator.
- Other language support as sample.
Akira Tachibana (http://unofficialtokyo.com)
- Add span id to h1 - h2 tag
- Fix: Link included space and special characters
- Fix: No __TOC__
convert()
handles string input/output.- Line types handling routines were moved to new
Util
class. TESTRUN
takes filter options.- Fix:
**
sub list support (#9) - Fix: multiple spaces only lines are not converted to code anymore.
- <nowiki> support
- fixed Windows batch file extension
- Release of Codex to Help Hub
- Beta of Codex Translator Aid
- Early drop