Community
Participate
Working Groups
When wikitext is transformed to eclipse help using the standalone ant task, wiki links are translated to references to the link name without appending ".html". A an example - the input: See [details] for more information. Is transformed to: See <a href="<<HELPROOT>>/details">details</a> Minimal support for wiki links, just needs to output: See <a href="<<HELPROOT>>/details">details</a>
Adding Dave Carver, who (from the newsgroup) is running into the same issue.
(In reply to comment #0) Typo > Minimal support for wiki links, just needs to output: > > See <a href="<<HELPROOT>>/details">details</a> Should have been See <a href="<<HELPROOT>>/details.html">details</a>
(In reply to comment #2) > (In reply to comment #0) > Typo > > Minimal support for wiki links, just needs to output: > > > > See <a href="<<HELPROOT>>/details">details</a> > > Should have been > See <a href="<<HELPROOT>>/details.html">details</a> Correct I ended up having to override a the emitAnchorHref() method to append the .html to the end of the links. So I extended HtmlDocumentBuilder and did my own implementation (really a hack). Here is the relevant code below: @Override protected void emitAnchorHref(String href) { writer.writeAttribute("href", makeUrlAbsolute(href)); //$NON-NLS-1$ } private static final Pattern ABSOLUTE_URL_PATTERN = Pattern.compile("[a-zA-Z]{3,8}://?.*"); //$NON-NLS-1$ protected String makeUrlAbsolute(String url) { if (ABSOLUTE_URL_PATTERN.matcher(url).matches()) { return url; } if (url.startsWith("#")) { //$NON-NLS-1$ return url; } if (url.endsWith(".jpg") || url.endsWith(".png") || url.endsWith(".gif") || url.endsWith(".JPG") || url.endsWith(".PNG") || url.endsWith(".GIF")) { return url; } String absoluteUrl = url + ".html"; return absoluteUrl; } Now as I said it is a hack.
I need this one fixed.
things to consider: # do we do this for all relative links without file extensions or just for links referencing files that are being transformed by the current Ant task? # this should be handled correctly in the case of generation to single or multiple files (@multipleOutputFiles@ option on Ant task) # does the implementation result in the same output when transforming source files individually as when transforming multiple source files together in a single fileset?
Created attachment 232007 [details] mylyn/context/zip
Thanks for your input David, I just sat down to take a second stab at this one :-) (In reply to comment #5) > things to consider: > # do we do this for all relative links without file extensions or just for > links referencing files that are being transformed by the current Ant task? I believe all relative links. Maybe test that the source files (with wiki markup) actually exists? > # this should be handled correctly in the case of generation to single or > multiple files (@multipleOutputFiles@ option on Ant task) Maybe not the same issue, rather an improvement to @multipleOutputFiles@. But definitely yes. > # does the implementation result in the same output when transforming source > files individually as when transforming multiple source files together in a > single fileset? Yes, that was my intention. I see no reason why it should not. I noticed I broke a lot of markup language specific tests when doing my first attempt (it appears that tests are for some reason not executed locally during maven build). So I'm investigating those.
I see at least most of the tests I broke expect links to be unchanged. This I think is only true if the document is still on a wiki. I this case we're handling a file based wiki, a concept that seem to be missing. I start to think that there should be some way of detecting a file based wiki and only do the link transformation if this is the case. Or it could be left to the user and we could simply add an option to the Ant tasks. Lastly it would be cool if we could augment the Wiki preview browser to produce proper links between e.g. *.textile pages. So a link to @foo@ would render as a link to @foo.textile@ _and_ open in the Wiki editor (not in the browser). However that is another issue.
I have some work going on at https://git.eclipse.org/r/#/c/13578/
The solution now looks like this: * Added flag to HtmlDocumentBuilder indicating whether or not such transformation of links should be done. * The flag is enabled when markup is converted to HTML using one of the purposed Ant tasks. It will also handle generation to multiple destination files. * Links that are relative and does not have a file suffix are transformed. Links to anchors in other files are also handled.
David, unless you have any objections I would like merge the proposed change set into master.
Torkild, I'd like to complete the code review before it gets merged. I'll try to get to it this week.
(In reply to comment #12) > Torkild, I'd like to complete the code review before it gets merged. I'll try > to get to it this week. Great! Thanks David.
Closed as part of backlog clean-up. Please re-open if you'd like to see this revisited, perhaps with a contribution.
Work is ongoing. See https://git.eclipse.org/r/#/c/13578/
Fixed in https://git.eclipse.org/r/#/c/13578/