Search in sources :

Example 11 with ImageAttributes

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

the class MarkdownDocumentBuilderTest method testImageLinkWithLinkAttributes.

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

Example 12 with ImageAttributes

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

the class MarkdownDocumentBuilderTest method testImageLinkWithImageAttributes.

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("[![Alt text](/path/to/img.jpg \"Optional title\")](http://example.net/)\n\n");
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 13 with ImageAttributes

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

the class MarkdownDocumentBuilderTest method testImageWithTitle.

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("![Alt text](/path/to/img.jpg \"Optional title\")\n\n");
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 14 with ImageAttributes

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

the class MarkdownDocumentBuilderTest method testImage.

public void testImage() {
    builder.beginDocument();
    builder.image(new ImageAttributes(), "/path/to/img.jpg");
    builder.endDocument();
    assertMarkup("![](/path/to/img.jpg)\n\n");
}
Also used : ImageAttributes(org.eclipse.mylyn.wikitext.parser.ImageAttributes)

Example 15 with ImageAttributes

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

the class SimplifiedHtmlDocumentBuilder method image.

@Override
public void image(Attributes attributes, String url) {
    // $NON-NLS-1$
    writer.writeEmptyElement(getHtmlNsUri(), "img");
    // $NON-NLS-1$
    writer.writeAttribute("src", makeUrlAbsolute(url));
    if (attributes instanceof ImageAttributes) {
        ImageAttributes imageAttributes = (ImageAttributes) attributes;
        writer.writeAttribute(getHtmlNsUri(), "alt", Objects.firstNonNull(imageAttributes.getAlt(), ""));
        if (imageAttributes.getTitle() != null) {
            writer.writeAttribute(getHtmlNsUri(), "title", imageAttributes.getTitle());
        }
    }
}
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