Search in sources :

Example 36 with LinkAttributes

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

the class DocBookDocumentBuilderTest method testSpanLink.

public void testSpanLink() {
    builder.beginDocument();
    builder.beginBlock(BlockType.DIV, new Attributes());
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("#test1234");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.beginSpan(SpanType.EMPHASIS, new Attributes());
    builder.characters("link text");
    builder.endSpan();
    builder.endSpan();
    // PARAGRAPH
    builder.endBlock();
    // DIV
    builder.endBlock();
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "<para><link linkend=\"test1234\"><emphasis>link text</emphasis></link></para>";
    assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes)

Example 37 with LinkAttributes

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

the class EventDocumentBuilderTest method imageLink.

@Test
public void imageLink() {
    builder.imageLink(new LinkAttributes(), new ImageAttributes(), "https://example.com", "http://example.com/foo.png");
    assertEvents(new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "https://example.com", "http://example.com/foo.png"));
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) ImageLinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent) Test(org.junit.Test)

Example 38 with LinkAttributes

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

the class DocBookDocumentBuilderTest method testExternalLink.

public void testExternalLink() {
    builder.beginDocument();
    builder.characters("an ");
    builder.link(new LinkAttributes(), "http://example.com", "external link");
    builder.characters(" test");
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "an <ulink url=\"http://example.com\">external link</ulink> test";
    assertEquals(DOCBOOK_BEGIN + expectedContent + DOCBOOK_END, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 39 with LinkAttributes

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

the class ImageLinkEventTest method equals.

@Test
public void equals() {
    assertEquality(new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com", "http://example.com/img.png"), new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com", "http://example.com/img.png"));
    assertInequality(new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com", "http://example.com/img.png"), new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com", "http://example.com/img2.png"));
    assertInequality(new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com", "http://example.com/img.png"), new ImageLinkEvent(new LinkAttributes(), new ImageAttributes(), "http://example.com/2", "http://example.com/img.png"));
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) ImageLinkEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent) Test(org.junit.Test)

Example 40 with LinkAttributes

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

the class ConfluenceDocumentBuilder method link.

@Override
public void link(Attributes attributes, String hrefOrHashName, String text) {
    assertOpenBlock();
    LinkAttributes linkAttributes = new LinkAttributes();
    linkAttributes.setTitle(attributes.getTitle());
    linkAttributes.setHref(hrefOrHashName);
    beginSpan(SpanType.LINK, linkAttributes);
    characters(text);
    endSpan();
}
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