use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class TextileDocumentBuilderTest method testBulletedList.
public void testBulletedList() {
builder.beginDocument();
builder.beginBlock(BlockType.BULLETED_LIST, new Attributes());
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
builder.characters("text2");
builder.beginSpan(SpanType.BOLD, new Attributes());
builder.characters("text3");
builder.endSpan();
builder.endBlock();
emitListItem("text4");
builder.endBlock();
builder.endDocument();
String markup = out.toString();
assertEquals("* text2 **text3**\n* text4\n", markup);
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class ListBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
boolean continuation = false;
if (blockLineCount == 0) {
listState = new Stack<>();
Attributes attributes = new Attributes();
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
String typeSpec = matcher.group(2);
BlockType type = calculateType(typeSpec);
computeAttributes(attributes, type, typeSpec);
// 0-offset matches may start with the "*** " prefix.
offset = matcher.start(3);
listState.push(new ListState(1, type));
builder.beginBlock(type, attributes);
adjustLevel(type, listSpec, level);
} else {
Matcher matcher = startPattern.matcher(line);
if (!matcher.matches()) {
// FIXME: continuations not yet implemented
matcher = continuationPattern.matcher(line);
if (listState.isEmpty() || !matcher.matches()) {
setClosed(true);
return 0;
} else {
continuation = true;
// use -1 to get one whitespace character
offset = matcher.start(1) - 1;
}
} else {
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
String typeSpec = matcher.group(2);
BlockType type = calculateType(typeSpec);
offset = matcher.start(3);
adjustLevel(type, typeSpec, level);
}
}
++blockLineCount;
ListState listState = this.listState.peek();
if (!continuation && listState.openItem) {
builder.endBlock();
listState.openItem = false;
}
if (!listState.openItem) {
listState.openItem = true;
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
}
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class ParagraphBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
builder.beginBlock(BlockType.PARAGRAPH, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
TWikiLanguage textileLanguage = (TWikiLanguage) getMarkupLanguage();
for (Block block : textileLanguage.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return 0;
}
}
if (blockLineCount != 0) {
builder.lineBreak();
}
++blockLineCount;
textileLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class TextileTest method testJustifiedAlignment.
public void testJustifiedAlignment() {
Pattern pattern = Pattern.compile("h1" + Textile.REGEX_BLOCK_ATTRIBUTES + "\\. (.*)?");
Matcher matcher = pattern.matcher("h1<>. foo");
assertTrue(matcher.matches());
Attributes attributes = new Attributes();
Textile.configureAttributes(attributes, matcher, 1, true);
assertEquals("text-align: justify;", attributes.getCssStyle());
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class TextileTest method testRightPadding.
public void testRightPadding() {
Pattern pattern = Pattern.compile("h1" + Textile.REGEX_BLOCK_ATTRIBUTES + "\\. (.*)?");
Matcher matcher = pattern.matcher("h1))). foo");
assertTrue(matcher.matches());
Attributes attributes = new Attributes();
Textile.configureAttributes(attributes, matcher, 1, true);
assertEquals("padding-right: 3em;", attributes.getCssStyle());
}
Aggregations