Search in sources :

Example 16 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanNoText.

@Test
public void linkSpanNoText() {
    builder.beginDocument();
    builder.characters("prefix ");
    LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("http://example.com/target");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.endSpan();
    builder.characters(" suffix");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("prefix [http://example.com/target] suffix\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Test(org.junit.Test)

Example 17 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpan.

@Test
public void linkSpan() {
    builder.beginDocument();
    builder.characters("prefix ");
    LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("http://example.com/target");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.characters("test");
    builder.endSpan();
    builder.characters(" suffix");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("prefix [test | http://example.com/target] suffix\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Test(org.junit.Test)

Example 18 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanWithTitle.

@Test
public void linkSpanWithTitle() {
    builder.beginDocument();
    builder.characters("prefix ");
    LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("http://example.com/target");
    attributes.setTitle("Title Words");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.characters("test");
    builder.endSpan();
    builder.characters(" suffix");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("prefix [test | http://example.com/target | Title Words] suffix\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Test(org.junit.Test)

Example 19 with LinkAttributes

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

the class MarkdownDocumentBuilderTest method testLinkWithTitle.

public void testLinkWithTitle() {
    builder.beginDocument();
    builder.characters("This is ");
    LinkAttributes attr = new LinkAttributes();
    attr.setTitle("Title");
    builder.link(attr, "http://example.com/", "an example");
    builder.characters(" inline link.");
    builder.endDocument();
    assertMarkup("This is [an example](http://example.com/ \"Title\") inline link.\n\n");
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 20 with LinkAttributes

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

the class MarkdownDocumentBuilderTest method testImageLinkWithLinkAttributes.

public void testImageLinkWithLinkAttributes() {
    builder.beginDocument();
    LinkAttributes linkAttr = new LinkAttributes();
    linkAttr.setTitle("Optional link title");
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.setAlt("Alt text");
    imageAttr.setTitle("Optional image title");
    builder.imageLink(linkAttr, imageAttr, "http://example.net/", "/path/to/img.jpg");
    builder.endDocument();
    assertMarkup("[![Alt text](/path/to/img.jpg \"Optional image title\")](http://example.net/ \"Optional link title\")\n\n");
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

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