use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType in project mylyn.docs by eclipse.
the class ListBlock method handleItem.
private void handleItem(String text, Matcher itemStartMatcher) {
if (blockLineCount == 0) {
// start list block
BlockType blockType = itemStartMatcher.group(1) != null ? BlockType.BULLETED_LIST : BlockType.NUMERIC_LIST;
builder.beginBlock(blockType, new Attributes());
// start item
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
} else {
if (nestedBlock != null) {
nestedBlock.setClosed(true);
nestedBlock = null;
} else {
// end list item
builder.endBlock();
}
// start item
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
}
int contentStart = itemStartMatcher.start(3);
thisIndentation = contentStart;
getMarkupLanguage().emitMarkupLine(getParser(), getState(), text, contentStart);
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType 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<ListState>();
Attributes attributes = new Attributes();
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
if (type == BlockType.BULLETED_LIST && "-".equals(listSpec)) {
// $NON-NLS-1$
// $NON-NLS-1$
attributes.setCssStyle("list-style: square");
}
// 0-offset matches may start with the "*** " prefix.
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
listState.push(new ListState(1, type));
builder.beginBlock(type, attributes);
adjustLevel(listSpec, level, type);
} else {
Matcher matcher = LIST_PATTERN.matcher(line);
if (!matcher.matches()) {
boolean empty = offset == 0 && markupLanguage.isEmptyLine(line);
boolean breaking = ParagraphBlock.paragraphBreakingBlockMatches(getMarkupLanguage(), line, offset);
if (empty || breaking) {
setClosed(true);
return 0;
} else {
continuation = true;
}
} else {
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
adjustLevel(listSpec, level, type);
}
}
++blockLineCount;
ListState listState = this.listState.peek();
if (listState.openItem) {
if (continuation) {
builder.lineBreak();
} else {
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.DocumentBuilder.BlockType in project mylyn.docs by eclipse.
the class BlockStrategiesTest method lists.
@Test
public void lists() {
for (BlockType listType : new BlockType[] { BlockType.BULLETED_LIST, BlockType.NUMERIC_LIST }) {
BlockStrategies strategies = new BlockStrategies(Sets.newHashSet(listType));
assertSupported(strategies, listType);
assertSupported(strategies, BlockType.LIST_ITEM);
}
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType in project mylyn.docs by eclipse.
the class BlockStrategiesTest method createNonEmpty.
@Test
public void createNonEmpty() {
BlockStrategies strategies = new BlockStrategies(Sets.newHashSet(BlockType.PARAGRAPH, BlockType.CODE));
assertSupported(strategies, BlockType.PARAGRAPH);
assertSupported(strategies, BlockType.CODE);
for (BlockType blockType : BlockType.values()) {
assertNotNull(strategies.getStrategy(blockType, new Attributes()));
}
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType in project mylyn.docs by eclipse.
the class ListBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
listState = new Stack<ListState>();
Attributes attributes = new Attributes();
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
// 0-offset matches may start with the "*** " prefix.
Textile.configureAttributes(attributes, matcher, 2, true);
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
listState.push(new ListState(1, type));
builder.beginBlock(type, attributes);
adjustLevel(matcher, level, type);
} else {
Matcher matcher = startPattern.matcher(line);
if (!matcher.matches()) {
setClosed(true);
return 0;
}
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
adjustLevel(matcher, level, type);
}
++blockLineCount;
ListState listState = this.listState.peek();
if (listState.openItem) {
builder.endBlock();
}
listState.openItem = true;
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
Aggregations