Search in sources :

Example 11 with Block

use of org.eclipse.mylyn.wikitext.parser.markup.Block 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();
        if (offset == 0) {
            // 0-offset matches may start with the "p. " prefix.
            Matcher matcher = startPattern.matcher(line);
            if (matcher.matches()) {
                Textile.configureAttributes(attributes, matcher, 1, true);
                offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
            } else {
                if (line.charAt(0) == ' ') {
                    offset = 1;
                    if (enableUnwrapped) {
                        unwrapped = true;
                    }
                }
            }
        }
        if (!unwrapped) {
            builder.beginBlock(BlockType.PARAGRAPH, attributes);
        }
    }
    if (markupLanguage.isEmptyLine(line)) {
        setClosed(true);
        return 0;
    }
    TextileLanguage textileLanguage = (TextileLanguage) getMarkupLanguage();
    // however we cause them to end the paragraph rather than being nested.
    for (Block block : textileLanguage.getParagraphBreakingBlocks()) {
        if (block.canStart(line, offset)) {
            setClosed(true);
            return offset;
        }
    }
    if (blockLineCount != 0) {
        if (unwrapped) {
            // $NON-NLS-1$
            builder.characters("\n");
        } else {
            builder.lineBreak();
        }
    }
    ++blockLineCount;
    textileLanguage.emitMarkupLine(getParser(), state, line, offset);
    return -1;
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) Matcher(java.util.regex.Matcher) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Aggregations

Block (org.eclipse.mylyn.wikitext.parser.markup.Block)11 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)8 Matcher (java.util.regex.Matcher)1 ConfluenceLanguage (org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage)1 CreoleLanguage (org.eclipse.mylyn.wikitext.creole.CreoleLanguage)1 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)1 BehaviorSwitchBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.BehaviorSwitchBlock)1 CommentBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.CommentBlock)1 EscapeBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.EscapeBlock)1 HeadingBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.HeadingBlock)1 ListBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.ListBlock)1 ParagraphBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.ParagraphBlock)1 PreformattedBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.PreformattedBlock)1 SourceBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.SourceBlock)1 TableBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableBlock)1 TableOfContentsBlock (org.eclipse.mylyn.wikitext.mediawiki.internal.block.TableOfContentsBlock)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)1 TracWikiLanguage (org.eclipse.mylyn.wikitext.tracwiki.TracWikiLanguage)1 TWikiLanguage (org.eclipse.mylyn.wikitext.twiki.TWikiLanguage)1