Modify

Opened 11 years ago

Last modified 11 years ago

#11107 new defect

Trac Wiki to HTML Script Fails with Links

Reported by: anonymous Owned by: coldpizza
Priority: normal Component: TracWikiToHtmlConverterScript
Severity: normal Keywords: link html formatter
Cc: Trac Release: 1.0

Description

The trac2html.py script fails to create an HTML file if any link exist in the wiki. Links of the following format fail.

LINK: http://www.google.com
ERROR:
Traceback (most recent call last):
  File "trac2html.py", line 28, in <module>
    print HtmlFormatter(env, context, wiki).generate()
UnicodeEncodeError: 'ascii' codec can't encode character u'\u200b' in position 115: ordinal not in range(128)


LINK: [wiki:SomeWikiPage Title]
ERROR:
Traceback (most recent call last):
  File "trac2html.py", line 28, in <module>
    print HtmlFormatter(env, context, wiki).generate()
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 1501, in generate
    escape_newlines)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 1283, in format
    result = re.sub(self.wikiparser.rules, self.replace, line)
  File "/usr/lib/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 1201, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 1197, in handle_match
    return internal_handler(match, fullmatch)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 591, in _lhref_formatter
    return self._make_lhref_link(match, fullmatch, rel, ns, target, label)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 626, in _make_lhref_link
    fullmatch)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/formatter.py", line 635, in _make_link
    fullmatch)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/api.py", line 392, in link_resolver
    return self._format_link(formatter, ns, target, label, False)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/api.py", line 412, in _format_link
    pagename = self._resolve_scoped_name(pagename, referrer)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1-py2.7.egg/trac/wiki/api.py", line 446, in _resolve_scoped_name
    referrer = referrer.split('/')
AttributeError: 'NoneType' object has no attribute 'split'


LINK: SomeWikiPage
ERROR: Very similar error trace as above.

Attachments (0)

Change History (1)

comment:1 Changed 11 years ago by anonymous

The code works, it's only that the resource names must be valid Wiki page names, otherwise the engine cannot create correct links.

Ie. this would throw an error:

context = Context.from_request(req, 'wikistart')

But this works perfectly:

context = Context.from_request(req, 'WikiStart')

I have a bunch of pages that I exported from Trac, and as long as I keep the names exactly as they were in Trac, the script works.

I'll be making a whole project that displays your Wikis as Trac would, with identical formatting, etc, only served from static files. I'll post the link here when it's usable.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain coldpizza.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.