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");
}
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");
}
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");
}
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();
}
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%\""));
}
Aggregations