@Test public void renderWikiLinkWithNoFollow() { WikiLinkNode node = new WikiLinkNode("foo | nofollow"); Rendering rendering = renderer.render(node); assertEquals("foo", rendering.href); assertEquals("foo", rendering.text); assertTrue(rendering.attributes.contains(Attribute.NO_FOLLOW)); }
@Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri; boolean noFollow = false; if (text.startsWith("#")) { text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); } else { uri = StringUtils.substringBefore(text, " ").trim(); text = StringUtils.substringAfter(text, " "); String params = StringUtils.substringAfter(text, "|").trim(); text = StringUtils.substringBefore(text, "|"); if (uri.startsWith("=")) { if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; }
DocumentrLinkRenderer extends LinkRenderer { @Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri; boolean noFollow = false; if (text.startsWith("#")) { text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); } else { uri = StringUtils.substringBefore(text, " ").trim(); text = StringUtils.substringAfter(text, " "); String params = StringUtils.substringAfter(text, "|").trim(); text = StringUtils.substringBefore(text, "|"); if (uri.startsWith("=")) { if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; } }
DocumentrLinkRenderer extends LinkRenderer { @Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri; boolean noFollow = false; if (text.startsWith("#")) { text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); } else { uri = StringUtils.substringBefore(text, " ").trim(); text = StringUtils.substringAfter(text, " "); String params = StringUtils.substringAfter(text, "|").trim(); text = StringUtils.substringBefore(text, "|"); if (uri.startsWith("=")) { if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; } DocumentrLinkRenderer(HtmlSerializerContext context); }
DocumentrLinkRenderer extends LinkRenderer { @Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri; boolean noFollow = false; if (text.startsWith("#")) { text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); } else { uri = StringUtils.substringBefore(text, " ").trim(); text = StringUtils.substringAfter(text, " "); String params = StringUtils.substringAfter(text, "|").trim(); text = StringUtils.substringBefore(text, "|"); if (uri.startsWith("=")) { if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; } DocumentrLinkRenderer(HtmlSerializerContext context); @Override Rendering render(WikiLinkNode node); @Override Rendering render(ExpLinkNode node, String text); }
DocumentrLinkRenderer extends LinkRenderer { @Override public Rendering render(WikiLinkNode node) { String text = node.getText(); String uri; boolean noFollow = false; if (text.startsWith("#")) { text = text.substring(1).trim(); uri = "#" + Util.simplifyForUrl(text); } else { uri = StringUtils.substringBefore(text, " ").trim(); text = StringUtils.substringAfter(text, " "); String params = StringUtils.substringAfter(text, "|").trim(); text = StringUtils.substringBefore(text, "|"); if (uri.startsWith("=")) { if (StringUtils.isBlank(text)) { text = uri.substring(1); } uri = context.getAttachmentUri(uri.substring(1)); } else { if (StringUtils.isBlank(text)) { text = uri; } } text = text.trim(); if (params.equalsIgnoreCase("nofollow")) { noFollow = true; } } Rendering rendering = new Rendering(uri, text); if (noFollow) { rendering.withAttribute(Attribute.NO_FOLLOW); } return rendering; } DocumentrLinkRenderer(HtmlSerializerContext context); @Override Rendering render(WikiLinkNode node); @Override Rendering render(ExpLinkNode node, String text);  }