Search in sources :

Example 11 with LinkAttributes

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

the class TextileDocumentBuilderTest method testSpanLinkWithNullHref.

public void testSpanLinkWithNullHref() {
    builder.beginDocument();
    builder.characters("a ");
    builder.beginSpan(SpanType.LINK, new LinkAttributes());
    builder.characters("link text");
    builder.endSpan();
    builder.characters(" test");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("a \"link text\": test\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 12 with LinkAttributes

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

the class TextileDocumentBuilderTest method testParagraphWithLink.

public void testParagraphWithLink() {
    builder.beginDocument();
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    builder.characters("text\n\nmore text ");
    final LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("http://example.com/foo+bar/baz.gif");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.characters("baz");
    builder.endSpan();
    builder.characters(" test");
    builder.endBlock();
    builder.endDocument();
    String markup = out.toString();
    assertEquals("text more text \"baz\":http://example.com/foo+bar/baz.gif test\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes)

Example 13 with LinkAttributes

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

the class MarkdownDocumentBuilder 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);
    characters(text);
    endSpan();
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes)

Example 14 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanNoHref.

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

Example 15 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanWithSurroundingItalics.

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

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