Hi Vincent, No, it’s not too late. WikiLinkNode contains all infos, It is the treatment of this information which is wrong. In AbstractLinkAndImagePegdownVisitor : @Overrid <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Override.java#Override>e 243 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#243> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> public void <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#>visit <http://grepcode.com/file/repo1.maven.org/maven2/org.pegdown/pegdown/1.4.1/org/pegdown/ast/Visitor.java#Visitor.visit%28org.pegdown.ast.WikiLinkNode%29>(WikiLinkNode <http://grepcode.com/file/repo1.maven.org/maven2/org.pegdown/pegdown/1.4.1/org/pegdown/ast/WikiLinkNode.java#WikiLinkNode> wikiLinkNode) 244 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#244> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> { 245 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#245> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> ResourceReference <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-api/5.4.3/org/xwiki/rendering/listener/reference/ResourceReference.java#ResourceReference> reference = this.linkResourceReferenceParser <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#AbstractLinkAndImagePegdownVisitor.0linkResourceReferenceParser>.parse <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-api/5.4.3/org/xwiki/rendering/parser/ResourceReferenceParser.java#ResourceReferenceParser.parse%28java.lang.String%29>(wikiLinkNode.getText <http://grepcode.com/file/repo1.maven.org/maven2/org.pegdown/pegdown/1.4.1/org/pegdown/ast/TextNode.java#TextNode.getText%28%29>()); 246 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#246> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> getListener <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractPegdownVisitor.java#AbstractPegdownVisitor.getListener%28%29>().beginLink <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-api/5.4.3/org/xwiki/rendering/listener/LinkListener.java#LinkListener.beginLink%28org.xwiki.rendering.listener.reference.ResourceReference%2Cboolean%2Cjava.util.Map%29>(reference, false, Collections <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/util/Collections.java#Collections.0EMPTY_MAP>.EMPTY_MAP <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/util/Collections.java#Collections.0EMPTY_MAP>); 247 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#247> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> getListener <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractPegdownVisitor.java#AbstractPegdownVisitor.getListener%28%29>().endLink <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-api/5.4.3/org/xwiki/rendering/listener/LinkListener.java#LinkListener.endLink%28org.xwiki.rendering.listener.reference.ResourceReference%2Cboolean%2Cjava.util.Map%29>(reference, false, Collections <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/util/Collections.java#Collections.0EMPTY_MAP>.EMPTY_MAP <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/util/Collections.java#Collections.0EMPTY_MAP>); 248 <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#248> <http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-rendering-syntax-markdown10/5.4.3/org/xwiki/rendering/internal/parser/markdown/AbstractLinkAndImagePegdownVisitor.java#> } Imagine we had write in markdown : [[MySpace.MyPage | my Alias]] wikiLinkNode.getText() is : "MySpace.MyPage | my Alias" I have to use regexp in order to extract MyAlias and MySpace.MyPage. (var link, var alias) After that : - I send to link variable to this.linkResourceReferenceParser.parse() - I begin Link - What I do here with “alias" variable? - I endLink Thanks Marc
On 18 Feb 2015, at 10:05, [email protected] wrote:
Hi Marc,
On 18 Feb 2015 at 09:57:53, Marc AUDEFROY ([email protected] <mailto:[email protected]>(mailto:[email protected] <mailto:[email protected]>)) wrote:
Hi all!
I would fix this issues : http://jira.xwiki.org/browse/XRENDERING-362 http://jira.xwiki.org/browse/XRENDERING-354 .
For this, I'll have to play with this classes :
- AbstractLinkAndImagePegdownVisitor : http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-re...
- AbstractPluginsPegdownVisitor : https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-syntaxe...
- XDOMGeneratorListener : http://grepcode.com/file/repo1.maven.org/maven2/org.xwiki.rendering/xwiki-re...
For resume, Pegdown, the parser engine accept the plugins in order to override the behaviour. XWiki has already added three plugins. For that, They created AbstractPluginsPegdownVisitor which inherits AbstractLinkAndImagePegdownVisitor.
For issue concerning the WikiLinks, I need override “visit(WikiLinkNode wikiLinkNode)” (into AbstractPluginsPegdownVisitor). In this method, I have to call the instance of XDOMGeneratorListener in order to create a XDOM link.
Are you sure it’s not too late in the processing? When visit(WikiLinkNode) is called the parser has already found it was a link. Is it called if you have, for example:

?
If not, then you’ll need to write a plugin that will parse this type of links before the standard MD parser parses it.
And this is where I have a problem. I understand I have to call beginLinks and endLink but I don’t understand how to sent the link and the title? It’s a bit hard to understand XDOMGeneratorListener.
The code is here actually:
getListener().beginLink(reference, false, parameters); visitChildren(expLinkNode); getListener().endLink(reference, false, parameters);
So in XWiki’s XDOM events it works like this: - send a begin link event - send the label of the link as events (the label can contain any markup!). - send an end link event
Hope it helps! -Vincent
I hope you can help me.
Thanks,
Marc