Search in sources :

Example 21 with ImageAttributes

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

the class AsciiDocDocumentBuilderTest method testImageNoUrl.

@Test
public void testImageNoUrl() {
    builder.beginDocument();
    ImageAttributes attr = new ImageAttributes();
    attr.setAlt("Alt text");
    attr.setTitle("Optional title");
    builder.image(attr, null);
    builder.endDocument();
    assertMarkup("image:[Alt text, title=\"Optional title\"]\n\n");
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) Test(org.junit.Test)

Example 22 with ImageAttributes

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

the class TextileDocumentBuilderTest method testImageNoUrl.

public void testImageNoUrl() {
    builder.beginDocument();
    builder.characters("a ");
    builder.image(new ImageAttributes(), null);
    builder.characters(" test");
    builder.endDocument();
    String markup = out.toString();
    assertEquals("a test\n\n", markup);
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 23 with ImageAttributes

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

the class TextileDocumentBuilderTest method testImageLink.

public void testImageLink() {
    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)

Example 24 with ImageAttributes

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

the class TextileDocumentBuilderTest method testImage.

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

Example 25 with ImageAttributes

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

the class MarkdownDocumentBuilder method computeImage.

private String computeImage(Attributes attributes, String url) {
    // ![](/path/to/img.jpg) or
    // ![alt text](path/to/img.jpg "title")
    // $NON-NLS-1$
    String altText = "";
    // $NON-NLS-1$
    String title = "";
    if (attributes instanceof ImageAttributes) {
        ImageAttributes imageAttr = (ImageAttributes) attributes;
        altText = Strings.nullToEmpty(imageAttr.getAlt());
    }
    if (!Strings.isNullOrEmpty(attributes.getTitle())) {
        // $NON-NLS-1$
        title = " \"" + attributes.getTitle() + '"';
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    return "![" + altText + "](" + Strings.nullToEmpty(url) + title + ')';
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Aggregations

ImageAttributes (org.eclipse.mylyn.wikitext.parser.ImageAttributes)38 Test (org.junit.Test)17 LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)10 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)3 ImageLinkEvent (org.eclipse.mylyn.wikitext.parser.builder.event.ImageLinkEvent)3 ImageEvent (org.eclipse.mylyn.wikitext.parser.builder.event.ImageEvent)2 Align (org.eclipse.mylyn.wikitext.parser.ImageAttributes.Align)1 TableAttributes (org.eclipse.mylyn.wikitext.parser.TableAttributes)1 TableCellAttributes (org.eclipse.mylyn.wikitext.parser.TableCellAttributes)1