use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class HeadingBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
if (offset == 0) {
// 0-offset matches may start with the "hn. " prefix.
level = Integer.parseInt(matcher.group(1));
Textile.configureAttributes(attributes, matcher, 2, true);
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
}
if (attributes.getId() == null) {
// $NON-NLS-1$
attributes.setId(state.getIdGenerator().newId("h" + level, line.substring(offset)));
}
builder.beginHeading(level, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
if (blockLineCount != 0) {
// $NON-NLS-1$
getMarkupLanguage().emitMarkupText(getParser(), state, "\n");
}
++blockLineCount;
getMarkupLanguage().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) {
nestedStartOffset = -1;
nestedLineNumber = -1;
if (blockLineCount == 0) {
Attributes attributes = new Attributes();
builder.beginBlock(BlockType.PARAGRAPH, attributes);
}
if (markupLanguage.isEmptyLine(line)) {
setClosed(true);
return 0;
}
MediaWikiLanguage dialect = (MediaWikiLanguage) getMarkupLanguage();
// paragraphs can have nested lists and other things
for (Block block : dialect.getParagraphBreakingBlocks()) {
if (block.canStart(line, offset)) {
setClosed(true);
return offset;
}
}
nestedStartOffset = calculateNestedStartOffset(line, offset);
if (nestedStartOffset != -1) {
nestedLineNumber = getState().getLineNumber();
}
++blockLineCount;
if (testPreformattedBlocks && offset == 0 && line.length() > 0 && line.charAt(0) == ' ') {
// a preformatted block.
setClosed(true);
return 0;
}
if (blockLineCount != 1 && nestedStartOffset == -1 && lastLineNumber != getState().getLineNumber()) {
// note: normally newlines don't automatically convert to line breaks
if (newlinesCauseLineBreak) {
builder.lineBreak();
} else {
// $NON-NLS-1$
builder.characters("\n");
}
}
if (nestedStartOffset > 0) {
line = line.substring(0, nestedStartOffset);
}
if (nestedStartOffset != offset) {
dialect.emitMarkupLine(getParser(), state, line, offset);
}
lastLineNumber = getState().getLineNumber();
return nestedStartOffset;
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class AttributesTest method testClone.
@Test
public void testClone() {
Attributes original = new Attributes("1", "class", "style", "lang");
Attributes copy = original.clone();
assertNotNull(copy);
assertEquals(original.getId(), copy.getId());
assertEquals(original.getCssClass(), copy.getCssClass());
assertEquals(original.getCssStyle(), copy.getCssStyle());
assertEquals(original.getLanguage(), copy.getLanguage());
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class HtmlDocumentBuilderTest method buildBasicDocument.
protected void buildBasicDocument() {
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
builder.characters("test");
builder.endBlock();
builder.endDocument();
}
use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.
the class HtmlDocumentBuilderTest method cssClassesAreAppliedToNestedElements.
@Test
public void cssClassesAreAppliedToNestedElements() {
Attributes attributes = new Attributes();
attributes.setCssClass("aclass");
builder.setEmitAsDocument(false);
builder.beginDocument();
builder.beginBlock(BlockType.CODE, attributes);
builder.characters("content");
builder.endBlock();
builder.endDocument();
assertEquals("<pre class=\"aclass\"><code class=\"aclass\">content</code></pre>", out.toString());
}
Aggregations