Problems in using java-regex-tokenizer in Universal Wiki Converter

Deleted user May 22, 2014

We want to convert a Trac wiki (with > 3.600 pages) to Confluence by using the UWC. One of the problems we have is that the Trac wiki users have used the Include macro in Trac. I have tried to adapt the Trac properties so that the Include macro is translated to the include-page macro in Confluence. I have tried the following line:

Trac.0770-include_links.java-regex-tokenizer=\[\[Include\(([^\]]+)\)\]\]{replace-with}{include:$1}

As a result I get for the following simple source page:

Here another include: [[Include(a/a-1)]]

The following page in Confluence:

<p>Here another include: <ac:link><ri:page ri:content-title="a-1)" /></ac:link></p>

Has anyone any idea what is going wrong here? Is there such a thing as issue tracker for UWC? I did not find anything usefull here: https://bitbucket.org/appfusions/universal-wiki-converter

2 answers

1 accepted

0 votes
Answer accepted
Deleted user May 23, 2014

Here comes the solution to my own question:

  • The Regexpression was not correct. See below, I had used a \] instead of \) for closing the URL, so no match fit.
  • Second, which I did not saw at the beginning: The order of the rules is essential. Not mentioned in the question above was the rule about double-bracket-replacement, which matched for includes as well.

So here is the correct rule:

Trac.0655-include_links.java-regex-tokenizer=\[\[Include\(([^\)]+)\)\]\]{replace-with}{include:$1}
Trac.0660-doublebracket-links.java-regex=\[{2}([^\]]+)\]{2}{replace-with}[$1]

So first, in the first line, the group was defined as ([^)]+), which means: match everything that is not a closing parantheses (not: bracket), and take that as the URL.

Second, define the rule before the doublebracket-links rule, so it can be replaced before.

The solution is not yet complete, because hierarchical page names ( like Include(a/a-1) ) should be replaced by the leaf of the hierarchy (here: a-1), so I have to adapt the regular expression, that I find the last title in the hierarchy.

Deleted user May 25, 2014

See my question on stackoverflow to the problem of a regexpression that replaces the wiki title.

0 votes
Deleted user May 23, 2014

Looks like I have done it wrong in the regexpression, I wanted to match [[Include(a/a-1)]], but my match goes up to the closing first bracket. So no match at all, and the replacement will not work. Have to check that in the office next week, though.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events