Search in sources :

Example 1 with LinkAttributes

use of org.eclipse.mylyn.wikitext.parser.LinkAttributes in project mylyn.docs by eclipse.

the class AsciiDocDocumentBuilder method link.

@Override
public void link(Attributes attributes, String hrefOrHashName, String text) {
    assertOpenBlock();
    LinkAttributes linkAttr = new LinkAttributes();
    linkAttr.setTitle(attributes.getTitle());
    linkAttr.setHref(hrefOrHashName);
    beginSpan(SpanType.LINK, linkAttr);
    if (Strings.isNullOrEmpty(text)) {
        characters(hrefOrHashName);
    } else {
        characters(text);
    }
    endSpan();
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 2 with LinkAttributes

use of org.eclipse.mylyn.wikitext.parser.LinkAttributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testSpanLinkWithNullHref.

public void testSpanLinkWithNullHref() {
    builder.beginDocument();
    builder.characters("a ");
    LinkAttributes attributes = new LinkAttributes();
    attributes.setId("some.id");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.endSpan();
    builder.characters(" test");
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "a <anchor id=\"some.id\"></anchor> test";
    assertEquals(DOCBOOK_BEGIN + expectedContent + DOCBOOK_END, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 3 with LinkAttributes

use of org.eclipse.mylyn.wikitext.parser.LinkAttributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testLink.

public void testLink() {
    builder.beginDocument();
    builder.characters("a ");
    builder.link(new LinkAttributes(), "#foo", "link to foo");
    builder.characters(" test");
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "a <link linkend=\"foo\">link to foo</link> test";
    assertEquals(DOCBOOK_BEGIN + expectedContent + DOCBOOK_END, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 4 with LinkAttributes

use of org.eclipse.mylyn.wikitext.parser.LinkAttributes in project mylyn.docs by eclipse.

the class EventDocumentBuilderTest method link.

@Test
public void link() {
    builder.link(new LinkAttributes(), "https://example.com", "test");
    assertEvents(new LinkEvent(new LinkAttributes(), "https://example.com", "test"));
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageLinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent) LinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.LinkEvent) Test(org.junit.Test)

Example 5 with LinkAttributes

use of org.eclipse.mylyn.wikitext.parser.LinkAttributes in project mylyn.docs by eclipse.

the class HtmlDocumentBuilder2Test method testHtmlLinkWithNullHref.

public void testHtmlLinkWithNullHref() {
    // Bug 492302
    LinkAttributes attributes = new LinkAttributes();
    attributes.setId("lorem");
    builder.link(attributes, null, "");
    assertContainsPattern("<a id=\"lorem\"></a>");
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Aggregations

LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)45 Test (org.junit.Test)16 ImageAttributes (org.eclipse.mylyn.wikitext.parser.ImageAttributes)12 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)10 ImageLinkEvent (org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent)5 TableAttributes (org.eclipse.mylyn.wikitext.parser.TableAttributes)2 LinkEvent (org.eclipse.mylyn.wikitext.parser.builder.event.LinkEvent)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocument (org.eclipse.jface.text.IDocument)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 ListAttributes (org.eclipse.mylyn.wikitext.parser.ListAttributes)1 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1