summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-08-17 16:11:53 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-08-17 16:11:53 +0300
commitad4a97d83528b00e76435d3d2674ff05a44bd398 (patch)
treeb2a85bcc5cd8d65a1f9c84b1b8e8e68ee3a748ff
parentf566ec604f8753f869119389072a023cd4909e7f (diff)
downloadwikitrans-ad4a97d83528b00e76435d3d2674ff05a44bd398.tar.gz
wikitrans-ad4a97d83528b00e76435d3d2674ff05a44bd398.tar.bz2
Fix the default html_base. Update docs.
-rw-r--r--README.rst11
-rwxr-xr-xbin/wikitrans10
-rw-r--r--testdata/headings.html2
-rw-r--r--wikitrans/wiki2html.py25
-rw-r--r--wikitrans/wiki2texi.py14
-rw-r--r--wikitrans/wiki2text.py14
-rw-r--r--wikitrans/wikimarkup.py25
7 files changed, 62 insertions, 39 deletions
diff --git a/README.rst b/README.rst
index c25c58f..b6863bc 100644
--- a/README.rst
+++ b/README.rst
@@ -31,3 +31,3 @@ html_base = *url*
Base URL for cross-references. Default is
- ``http://%(lang)s.wiktionary.org/wiki/``.
+ ``http://%(lang)s.wikipedia.org/wiki/``.
image_base = *url*
@@ -63,3 +63,6 @@ Translate material from wiktionary to plain text form. This is
supposed to provide a wiktionary-specific form of
-``TextWikiMarkup``. Currently both classes are entirely equivalent.
+``TextWikiMarkup``. Currently, this class differs from
+``TextWikiMarkup`` only in that the default value for ``html_base``
+is ``http://%(lang)s.wikipedia.org/wiki/``.
+
@@ -117,3 +120,5 @@ Translate material from wiktionary to HTML form. This is
supposed to provide a wiktionary-specific form of
-``HtmlWikiMarkup``. Currently both classes are equivalent.
+``HtmlWikiMarkup``. Currently both classes are equivalent, except that
+the default value for ``html_base`` in ``HtmlWiktionaryMarkup``
+is ``http://%(lang)s.wikipedia.org/wiki/``.
diff --git a/bin/wikitrans b/bin/wikitrans
index adf779d..e9ab81f 100755
--- a/bin/wikitrans
+++ b/bin/wikitrans
@@ -143,3 +143,11 @@ Otherwise, ARG is name of the file to read wiki material from.
if options.base_url:
- options.kwdict['text'] = getwiki(options.base_url + '/wiki/Special:Export/' + args[0])
+ options.kwdict['text'] = getwiki(options.base_url
+ + '/wiki/Special:Export/' + args[0])
+ m = re.match('(?:.+://)(.+?)\.(wik(?:ipedia|tionary))\.org',
+ options.base_url)
+ if m:
+ options.lang = m.group(1)
+ options.kwdict['html_base'] = options.base_url + '/wiki/'
+ if m.group(2) == 'wiktionary':
+ options.itype = 'wiktionary'
elif args[0] == '-':
diff --git a/testdata/headings.html b/testdata/headings.html
index de9c9c3..bf02987 100644
--- a/testdata/headings.html
+++ b/testdata/headings.html
@@ -4,3 +4,3 @@
sections. The Wiki software can automatically
-generate a <a href="http://en.wiktionary.org/wiki/table%20of%20contents">table of contents</a> from them.</p>
+generate a <a href="http://en.wikipedia.org/wiki/table%20of%20contents">table of contents</a> from them.</p>
<h3>Subsection</h3>
diff --git a/wikitrans/wiki2html.py b/wikitrans/wiki2html.py
index ce65bae..fc6b142 100644
--- a/wikitrans/wiki2html.py
+++ b/wikitrans/wiki2html.py
@@ -221,22 +221,7 @@ class HtmlWikiMarkup(WikiMarkup):
- Arguments:
+ HtmlWikiMarkup([filename=FILE],[file=FD],[text=STRING],[lang=CODE],
+ [html_base=URL],[image_base=URL],[media_base=URL])
- filename=FILE
- Read Wiki material from the file named FILE.
- file=FD
- Read Wiki material from file object FD.
- text=STRING
- Read Wiki material from STRING.
- lang=CODE
- Specifies source language. Default is 'en'. This variable can be
- referred to as '%(lang)s' in the keyword arguments below.
- html_base=URL
- Base URL for cross-references. Default is
- 'http://%(lang)s.wiktionary.org/wiki/'
- image_base=URL
- Base URL for images. Default is
- 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf'
- media_base=URL
- Base URL for media files. Default is
- 'http://www.mediawiki.org/xml/export-0.3'
+ The arguments have the same meaning as in the WikiMarkup constructor.
+
"""
@@ -320 +305,3 @@ class HtmlWiktionaryMarkup(HtmlWikiMarkup):
"""
+
+ html_base='http://%(lang)s.wiktionary.org/wiki/'
diff --git a/wikitrans/wiki2texi.py b/wikitrans/wiki2texi.py
index d9e5f52..55dffe2 100644
--- a/wikitrans/wiki2texi.py
+++ b/wikitrans/wiki2texi.py
@@ -313,10 +313,10 @@ class TexiWikiMarkup(WikiMarkup):
- Arguments:
+ TexiWikiMarkup([filename=FILE],[file=FD],[text=STRING],[lang=CODE],
+ [html_base=URL],[image_base=URL],[media_base=URL],
+ [sectioning_model=MODEL],[sectioning_start=N])
- filename=FILE
- Read Wiki material from the file named FILE.
- file=FD
- Read Wiki material from file object FD.
- text=STRING
- Read Wiki material from STRING.
+ For a discussion of generic arguments, see the constructor of
+ the WikiMarkup class.
+
+ Additional arguments:
diff --git a/wikitrans/wiki2text.py b/wikitrans/wiki2text.py
index 1fbc61b..88e7610 100644
--- a/wikitrans/wiki2text.py
+++ b/wikitrans/wiki2text.py
@@ -249,10 +249,9 @@ class TextWikiMarkup(WikiMarkup):
- Arguments:
+ TextWikiMarkup([filename=FILE],[file=FD],[text=STRING],[lang=CODE],
+ [html_base=URL],[image_base=URL],[media_base=URL],
+ [width=N],[show_urls=False])
- filename=FILE
- Read Wiki material from the file named FILE.
- file=FD
- Read Wiki material from file object FD.
- text=STRING
- Read Wiki material from STRING.
+ Most arguments have the same meaning as in the WikiMarkup constructor.
+
+ Class-specific arguments:
@@ -347,2 +346,3 @@ class TextWiktionaryMarkup(TextWikiMarkup):
+ html_base='http://%(lang)s.wiktionary.org/wiki/'
diff --git a/wikitrans/wikimarkup.py b/wikitrans/wikimarkup.py
index 77c3b30..a3e17d5 100644
--- a/wikitrans/wikimarkup.py
+++ b/wikitrans/wikimarkup.py
@@ -954,3 +954,3 @@ class WikiMarkup(WikiMarkupParser):
lang = 'en'
- html_base = 'http://%(lang)s.wiktionary.org/wiki/'
+ html_base = 'http://%(lang)s.wikipedia.org/wiki/'
image_base = 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf'
@@ -959,2 +959,25 @@ class WikiMarkup(WikiMarkupParser):
def __init__(self, *args, **keywords):
+ """Create a WikiMarkup object.
+
+ Arguments:
+
+ filename=FILE
+ Read Wiki material from the file named FILE.
+ file=FD
+ Read Wiki material from file object FD.
+ text=STRING
+ Read Wiki material from STRING.
+ lang=CODE
+ Specifies source language. Default is 'en'. This variable can be
+ referred to as '%(lang)s' in the keyword arguments below.
+ html_base=URL
+ Base URL for cross-references. Default is
+ 'http://%(lang)s.wikipedia.org/wiki/'
+ image_base=URL
+ Base URL for images. Default is
+ 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf'
+ media_base=URL
+ Base URL for media files. Default is
+ 'http://www.mediawiki.org/xml/export-0.3'
+ """
for kw in keywords:

Return to:

Send suggestions and report system problems to the System administrator.