use of org.eclipse.mylyn.wikitext.parser.ListAttributes in project mylyn.docs by eclipse.
the class ListBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
ListAttributes attributes = new ListAttributes();
String spaces = matcher.group(1);
String listSpec = matcher.group(2);
String numericListSpec = matcher.group(3);
if (numericListSpec != null && !"1".equals(numericListSpec)) {
// $NON-NLS-1$
attributes.setStart(numericListSpec);
}
int level = calculateLevel(spaces);
BlockType type = listSpec == null ? BlockType.NUMERIC_LIST : BlockType.BULLETED_LIST;
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
listState.push(new ListState(level, spaces.length(), offset, type));
builder.beginBlock(type, attributes);
} else {
ListAttributes attributes = new ListAttributes();
Matcher matcher = startPattern.matcher(line);
if (!matcher.matches()) {
Matcher nextLineMatcher = nextLinePattern.matcher(line);
ListState listState = this.listState.peek();
if (listState.openItem && nextLineMatcher.matches()) {
String spaces = nextLineMatcher.group(1);
if (spaces.length() > 0 && spaces.length() >= listState.numSpaces && spaces.length() <= listState.lineRemainderStart) {
++blockLineCount;
offset = nextLineMatcher.start(2) - 1;
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
}
setClosed(true);
return 0;
}
String spaces = matcher.group(1);
String listSpec = matcher.group(2);
String numericListSpec = matcher.group(3);
if (numericListSpec != null && !"1".equals(numericListSpec)) {
// $NON-NLS-1$
attributes.setStart(numericListSpec);
}
int level = calculateLevel(spaces);
BlockType type = listSpec == null ? BlockType.NUMERIC_LIST : BlockType.BULLETED_LIST;
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
for (ListState listState = this.listState.peek(); listState.level != level || listState.type != type; listState = this.listState.peek()) {
if (listState.level > level || (listState.level == level && listState.type != type)) {
closeOne();
if (this.listState.isEmpty()) {
this.listState.push(new ListState(1, spaces.length(), offset, type));
builder.beginBlock(type, attributes);
}
} else {
this.listState.push(new ListState(level, spaces.length(), offset, type));
builder.beginBlock(type, attributes);
}
}
}
++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;
}
use of org.eclipse.mylyn.wikitext.parser.ListAttributes in project mylyn.docs by eclipse.
the class DocBookDocumentBuilderTest method testOrderedListLoweralphaType.
public void testOrderedListLoweralphaType() {
builder.beginDocument();
ListAttributes listAttributes = new ListAttributes();
listAttributes.setCssStyle("list-style-type: lower-alpha;");
builder.beginBlock(BlockType.NUMERIC_LIST, listAttributes);
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
builder.characters("item");
// LI
builder.endBlock();
// OL
builder.endBlock();
builder.endDocument();
String docbook = out.toString();
String expectedContent = "<orderedlist numeration=\"loweralpha\"><listitem><para>item</para></listitem></orderedlist>";
assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
use of org.eclipse.mylyn.wikitext.parser.ListAttributes in project mylyn.docs by eclipse.
the class HtmlDocumentBuilderTest method assertListStyle.
private void assertListStyle(String listStyleType) {
setup();
ListAttributes attributes = new ListAttributes();
attributes.setCssStyle(String.format("list-style-type: %s;", listStyleType));
builder.setEmitAsDocument(false);
builder.beginDocument();
builder.beginBlock(BlockType.NUMERIC_LIST, attributes);
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
builder.characters("first");
builder.endBlock();
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
builder.characters("second");
builder.endBlock();
builder.endBlock();
builder.endDocument();
assertEquals("<ol style=\"list-style-type: " + listStyleType + ";\"><li>first</li><li>second</li></ol>", out.toString());
}
Aggregations