/** * @see #link(Attributes, String, String) */ public final void link(String hrefOrHashName, String text) { link(new LinkAttributes(), hrefOrHashName, text); }
@Override protected void emitContent(String content, boolean extended) throws IOException { if (content.matches("!.*?!")) { //$NON-NLS-1$ ConfluenceDocumentBuilder.this.emitContent(content); } else { ConfluenceDocumentBuilder.this.emitContent('"'); ConfluenceDocumentBuilder.this.emitContent(content); ConfluenceDocumentBuilder.this.emitContent('"'); } ConfluenceDocumentBuilder.this.emitContent(':'); ConfluenceDocumentBuilder.this.emitContent(attributes.getHref()); } }
private void applyLinkAttributes(Attributes attributes, String href) { applyAttributes(attributes); boolean hasTarget = false; String rel = linkRel; if (attributes instanceof LinkAttributes) { LinkAttributes linkAttributes = (LinkAttributes) attributes; if (linkAttributes.getTarget() != null) { hasTarget = true; writer.writeAttribute("target", linkAttributes.getTarget()); //$NON-NLS-1$ } if (linkAttributes.getRel() != null) { rel = rel == null ? linkAttributes.getRel() : linkAttributes.getRel() + ' ' + rel; } } if (attributes.getTitle() != null && attributes.getTitle().length() > 0) { writer.writeAttribute("title", attributes.getTitle()); //$NON-NLS-1$ } if (!hasTarget && defaultAbsoluteLinkTarget != null && href != null) { if (isExternalLink(href)) { writer.writeAttribute("target", defaultAbsoluteLinkTarget); //$NON-NLS-1$ } } if (rel != null) { writer.writeAttribute("rel", rel); //$NON-NLS-1$ } }
LinkAttributes attributes = new LinkAttributes(); attributes.setTitle(tip); attributes.setHref(href); getBuilder().beginLink(attributes, href); getMarkupLanguage().emitMarkupLine(parser, state, getStart(this), text, 0);
@Override public void emit() { String hyperlinkBoundaryText = group(1); String hyperlinkSrc = group(2 + Textile.ATTRIBUTES_GROUP_COUNT); String href = group(3 + Textile.ATTRIBUTES_GROUP_COUNT); String namedLinkUrl = ((TextileContentState) getState()).getNamedLinkUrl(href); if (namedLinkUrl != null) { href = namedLinkUrl; } if (hyperlinkBoundaryText.equals("\"")) { //$NON-NLS-1$ LinkAttributes attributes = new LinkAttributes(); attributes.setHref(href); Textile.configureAttributes(this, attributes, ATTRIBUTES_OFFSET, false); builder.beginSpan(SpanType.LINK, attributes); getMarkupLanguage().emitMarkupLine(parser, state, start(2), hyperlinkSrc, 0); builder.endSpan(); } else { final ImageAttributes attributes = new ImageAttributes(); Textile.configureAttributes(this, attributes, ATTRIBUTES_OFFSET, false); builder.imageLink(attributes, href, hyperlinkSrc); } } }
out.beginBlock(BlockType.TABLE_CELL_NORMAL, tableCellAttributes); if (previous != null) { linkAttributes = new LinkAttributes(); linkAttributes.setTitle(previous.getLabel()); if (navigationImages) { ImageAttributes imageAttributes = new ImageAttributes(); out.beginBlock(BlockType.TABLE_CELL_NORMAL, tableCellAttributes); if (!header && !rootPage) { linkAttributes = new LinkAttributes(); linkAttributes.setTitle(rootBuilder.getTitle()); if (navigationImages) { ImageAttributes imageAttributes = new ImageAttributes(); out.beginBlock(BlockType.TABLE_CELL_NORMAL, tableCellAttributes); if (next != null) { linkAttributes = new LinkAttributes(); linkAttributes.setTitle(next.getLabel()); if (navigationImages) { ImageAttributes imageAttributes = new ImageAttributes();
text = text.substring(1); Attributes attributes = new LinkAttributes(); attributes.setTitle(tip); getBuilder().link(attributes, toInternalHref(href), text); } else { LinkAttributes attributes = new LinkAttributes(); attributes.setTitle(tip); attributes.setHref(toInternalHref(href)); getBuilder().beginSpan(SpanType.LINK, attributes);
/** * Create a hyperlink whose visual representation is an image. Implementations must apply the attributes to the * image tag. For example, if the builder constructs HTML, the builder would emit * <code><a href="..."><img src="..."/></a></code>. In this case if the attributes define a css class then * the resulting HTML should look like this: <code><a href="..."><img src="..." class="..."/></a></code> * * @param attributes * the attributes of the image, which may be {@link ImageAttributes} * @param href * the url (which may be internal to the page if prefixed with a hash '#') * @param imageUrl * the url of the image, which may be relative * @see #imageLink(Attributes, Attributes, String, String) */ public final void imageLink(Attributes attributes, String href, String imageUrl) { imageLink(new LinkAttributes(), attributes, href, imageUrl); }
@Override public void beginSpan(SpanType type, Attributes attributes) { if (type == SpanType.LINK) { if (attributes instanceof LinkAttributes) { LinkAttributes linkAttributes = (LinkAttributes) attributes; if (linkAttributes.getHref() != null && !linkAttributes.getHref().startsWith("#")) { //$NON-NLS-1$ IRegion region = createRegion(); links.add(new HyperlinkDescriptor(linkAttributes.getHref(), region)); } } } } });
/** * @see #imageLink(Attributes, String, String) */ public final void imageLink(String href, String imageUrl) { imageLink(new LinkAttributes(), new ImageAttributes(), href, imageUrl); }
@Override public void beginSpan(SpanType type, Attributes attributes) { super.beginSpan(type, attributes); if (type == SpanType.LINK) { if (attributes instanceof LinkAttributes) { LinkAttributes linkAttributes = (LinkAttributes) attributes; processLink(getLocator(), linkAttributes.getHref()); } } }
@Override public void emit() { String email = group(1); builder.link(new LinkAttributes(), "mailto:" + email, email); //$NON-NLS-1$ }
@Override public void beginSpan(SpanType type, Attributes attributes) { String elementName = spanTypeToElementName.get(type); if (elementName == null) { throw new IllegalStateException(type.name()); } writer.writeStartElement(htmlNsUri, elementName); if (type == SpanType.LINK && attributes instanceof LinkAttributes) { String href = ((LinkAttributes) attributes).getHref(); emitAnchorHref(href); applyLinkAttributes(attributes, href); } else { applyAttributes(attributes); } }
@Override public void emit() { getBuilder().characters(group(1)); String linkComposite = group(2); String[] parts = linkComposite.split("\\s*\\|\\s*(?=([^\\!]*\\![^\\!]*\\!)*[^\\!]*$)"); //$NON-NLS-1$ // split on '\s*\|\s*' but make sure the | is not included inside a !..! block // see http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes/1757107#1757107 String text = parts.length > 1 ? parts[0] : null; if (text != null) { text = text.trim(); } String href = parts.length > 1 ? parts[1] : parts[0]; if (href != null) { href = href.trim(); } String tip = parts.length > 2 ? parts[2] : null; if (tip != null) { tip = tip.trim(); } if (text == null || text.length() == 0) { text = href; if (text.charAt(0) == '#') { text = text.substring(1); } } Attributes attributes = new LinkAttributes(); attributes.setTitle(tip); getBuilder().link(attributes, href, text); } }
case LINK: { LinkAttributes linkAttributes = (LinkAttributes) attributes; String href = linkAttributes.getHref(); if (href.startsWith("#")) { //$NON-NLS-1$ writer.writeStartElement("link"); //$NON-NLS-1$
LinkAttributes linkAttributes = (LinkAttributes) attributes; writer.writeStartElement("xref"); //$NON-NLS-1$ writer.writeAttribute("href", computeDitaXref(linkAttributes.getHref())); //$NON-NLS-1$