Search in sources :

Example 1 with ConfluenceLanguage

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);
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with ConfluenceLanguage

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);
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 3 with ConfluenceLanguage

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);
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 4 with ConfluenceLanguage

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;
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) Matcher(java.util.regex.Matcher) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes)

Example 5 with ConfluenceLanguage

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);
}
Also used : ConfluenceLanguage(org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage) ITypedRegion(org.eclipse.jface.text.ITypedRegion) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

ConfluenceLanguage (org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage)8 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 ITypedRegion (org.eclipse.jface.text.ITypedRegion)2 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)2 Matcher (java.util.regex.Matcher)1 Block (org.eclipse.mylyn.wikitext.parser.markup.Block)1 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)1 OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)1