Search in sources :

Example 1 with ImageAttributes

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

the class AsciiDocDocumentBuilderTest method testImageLinkWithImageAttributes.

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

Example 2 with ImageAttributes

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

the class AsciiDocDocumentBuilderTest method testImageImplicitParagraph.

@Test
public void testImageImplicitParagraph() {
    builder.beginDocument();
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    builder.characters("Below is an image:");
    builder.endBlock();
    builder.image(new ImageAttributes(), "/path/to/img.jpg");
    builder.endDocument();
    assertMarkup("Below is an image:\n\nimage:/path/to/img.jpg[]\n\n");
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) Test(org.junit.Test)

Example 3 with ImageAttributes

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

the class AsciiDocDocumentBuilderTest method testImageWithTitle.

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

Example 4 with ImageAttributes

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

the class AsciiDocDocumentBuilder method computeImage.

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

Example 5 with ImageAttributes

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

the class XslfoDocumentBuilderTest method testImageWithWidthInPct.

public void testImageWithWidthInPct() {
    ImageAttributes attributes = new ImageAttributes();
    attributes.setWidth(10);
    attributes.setWidthPercentage(true);
    builder.image(attributes, "some/image.png");
    String generatedContent = out.toString();
    assertTrue(generatedContent.contains("width=\"10%\""));
}
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