Search in sources :

Example 31 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanWithAdjacentSpans.

@Test
public void linkSpanWithAdjacentSpans() {
    builder.beginDocument();
    builder.beginSpan(SpanType.BOLD, new Attributes());
    builder.characters("bold");
    builder.endSpan();
    LinkAttributes attributes = new LinkAttributes();
    attributes.setHref("http://example.com/target");
    builder.beginSpan(SpanType.LINK, attributes);
    builder.characters("test");
    builder.endSpan();
    builder.beginSpan(SpanType.ITALIC, new Attributes());
    builder.characters("italic");
    builder.endSpan();
    builder.endDocument();
    String markup = out.toString();
    assertEquals("*bold*[test | http://example.com/target]_italic_\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) Test(org.junit.Test)

Example 32 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method linkSpanWithSpecialCharacters.

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

Example 33 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method paragraphWithLink.

@Test
public void paragraphWithLink() {
    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) Test(org.junit.Test)

Example 34 with LinkAttributes

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

the class ConfluenceDocumentBuilderTest method imageLink.

@Test
public void imageLink() {
    builder.beginDocument();
    builder.characters("a ");
    builder.imageLink(new LinkAttributes(), new ImageAttributes(), "#foo", "fooImage.png");
    builder.characters(" test");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("a !fooImage.png!:#foo test\n\n", markup);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) Test(org.junit.Test)

Example 35 with LinkAttributes

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

the class DocBookDocumentBuilderTest method testLinkWithNullHref.

public void testLinkWithNullHref() {
    builder.beginDocument();
    builder.characters("a ");
    LinkAttributes attributes = new LinkAttributes();
    attributes.setId("some.id");
    builder.link(attributes, null, null);
    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)

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