use of org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage in project mylyn.docs by eclipse.
the class FastMarkupPartitionerTest method testConfluenceColor3.
public void testConfluenceColor3() {
IDocument document = new Document();
FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
partitioner.setMarkupLanguage(new ConfluenceLanguage());
document.set("views to help SOA development. These includes [SOA Services Explorer](in green) for the list of all available SOA services,\n[Types Explorer](in {color:#0000ff}blue{color}) for searching and browsing all available ");
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
partitioner.computePartitioning(0, document.getLength(), false);
}
use of org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage in project mylyn.docs by eclipse.
the class ExtendedQuoteBlock method handleBlockContent.
@Override
protected void handleBlockContent(String content) {
if (nestedBlock == null) {
ConfluenceLanguage markupLanguage = (ConfluenceLanguage) getMarkupLanguage();
for (Block block : markupLanguage.getNestedBlocks()) {
if (block.canStart(content, 0)) {
nestedBlock = block.clone();
nestedBlock.setParser(getParser());
nestedBlock.setState(getState());
if (paraOpen) {
// para
builder.endBlock();
paraOpen = false;
paraLine = 0;
}
break;
}
}
}
if (nestedBlock != null) {
int lineOffset = nestedBlock.processLine(content, 0);
if (nestedBlock.isClosed()) {
nestedBlock = null;
}
if (lineOffset < content.length() && lineOffset >= 0) {
if (nestedBlock != null) {
// $NON-NLS-1$
throw new IllegalStateException("if a block does not fully process a line then it must be closed");
}
content = content.substring(lineOffset);
} else {
return;
}
}
if (blockLineCount == 1 && content.length() == 0) {
return;
}
if (blockLineCount > 1 && paraOpen && getMarkupLanguage().isEmptyLine(content)) {
// para
builder.endBlock();
paraOpen = false;
paraLine = 0;
return;
}
if (!paraOpen) {
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
paraOpen = true;
}
if (paraLine != 0) {
builder.lineBreak();
}
++paraLine;
getMarkupLanguage().emitMarkupLine(getParser(), state, content, 0);
}
use of org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage in project mylyn.docs by eclipse.
the class TableOfContentsBlock method processLineContent.
@Override
public int processLineContent(String line, int offset) {
if (blockLineNumber++ > 0) {
setClosed(true);
return 0;
}
if (!getMarkupLanguage().isFilterGenerativeContents()) {
String options = matcher.group(1);
setOptions(options);
OutlineParser outlineParser = new OutlineParser(new ConfluenceLanguage());
OutlineItem rootItem = outlineParser.parse(state.getMarkupContent());
emitToc(rootItem);
}
setClosed(true);
return matcher.start(2);
}
use of org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage 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;
}
++blockLineCount;
ConfluenceLanguage markupLanguage = (ConfluenceLanguage) getMarkupLanguage();
// however we cause them to end the paragraph rather than being nested.
if (paragraphBreakingBlockMatches(markupLanguage, line, offset)) {
setClosed(true);
return 0;
}
Matcher blockStartMatcher = confluenceBlockStart.matcher(line);
if (offset > 0) {
blockStartMatcher.region(offset, line.length());
}
if (blockStartMatcher.find()) {
int end = blockStartMatcher.start();
if (end > offset) {
markupLanguage.emitMarkupLine(getParser(), state, offset, line.substring(offset, end), 0);
}
setClosed(true);
return end;
}
if (blockLineCount > 1) {
builder.lineBreak();
}
markupLanguage.emitMarkupLine(getParser(), state, line, offset);
return -1;
}
use of org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage in project mylyn.docs by eclipse.
the class FastMarkupPartitionerTest method testConfluenceColor2.
public void testConfluenceColor2() {
IDocument document = new Document();
FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
partitioner.setMarkupLanguage(new ConfluenceLanguage());
document.set("{color:blue}\n{tip}\ntip\n{tip}\ntext\n{note}\nnote\n{note}\n");
// ...........0123456789012.345678.9012.345678.90123.4567890.12345.6789012.
// .....................10..........20..........30.........40..........50..
//
// MarkupPartition(type=PARAGRAPH,offset=19,length=10,end=29) cannot start before partition
// MarkupPartition(type=PARAGRAPH,offset=29,length=5,end=34).
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
//
// expect:
//
// MarkupPartition(type=DIV,offset=0,length=13,end=13)
// MarkupPartition(type=TIP,offset=13,length=6,end=19)
// MarkupPartition(type=PARAGRAPH,offset=19,length=10,end=29)
// MarkupPartition(type=PARAGRAPH,offset=29,length=5,end=34)
// MarkupPartition(type=NOTE,offset=34,length=7,end=41)
// MarkupPartition(type=PARAGRAPH,offset=41,length=12,end=53)
int[][] expected = new int[][] { //
{ 0, 13 }, //
{ 13, 6 }, //
{ 19, 10 }, //
{ 29, 5 }, //
{ 34, 7 }, //
{ 41, 12 } };
ITypedRegion[] partitioning = partitioner.computePartitioning(0, document.getLength(), false);
assertPartitioningAsExpected(expected, partitioning);
}
Aggregations