Search in sources :

Example 36 with ImageAttributes

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

the class ConfluenceDocumentBuilder method writeImageAttributes.

private void writeImageAttributes(Attributes attributes) throws IOException {
    if (attributes instanceof ImageAttributes) {
        ImageAttributes imageAttributes = (ImageAttributes) attributes;
        String attributeMarkup = "";
        if (!Strings.isNullOrEmpty(imageAttributes.getAlt())) {
            attributeMarkup = "alt=\"" + imageAttributes.getAlt() + "\"";
        }
        if (!Strings.isNullOrEmpty(imageAttributes.getTitle())) {
            if (!attributeMarkup.isEmpty()) {
                attributeMarkup += ",";
            }
            attributeMarkup += "title=\"" + imageAttributes.getTitle() + "\"";
        }
        if (!attributeMarkup.isEmpty()) {
            currentBlock.write('|');
            currentBlock.write(attributeMarkup);
        }
    }
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 37 with ImageAttributes

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

the class Image method emit.

@Override
public void emit(DocumentBuilder builder) {
    ImageAttributes attributes = new ImageAttributes();
    attributes.setTitle(title);
    List<Inline> contents = getContents();
    if (!contents.isEmpty()) {
        attributes.setAlt(InlineParser.toStringContent(contents));
    }
    builder.image(attributes, src);
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 38 with ImageAttributes

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

the class MultiplexingDocumentBuilderTest method image.

@Test
public void image() {
    multiplexer.image(new ImageAttributes(), "http://example.com/foo.png");
    assertEvents(new ImageEvent(new ImageAttributes(), "http://example.com/foo.png"));
}
Also used : ImageEvent(org.eclipse.mylyn.wikitext.parser.builder.event.ImageEvent) ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes) Test(org.junit.Test)

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