diff options
Diffstat (limited to 'org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java')
-rw-r--r-- | org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java b/org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java index a9d0122b4..9f001ed9f 100644 --- a/org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java +++ b/org.eclipse.mylyn.wikitext.markdown.core/src/org/eclipse/mylyn/internal/wikitext/markdown/core/block/InlineHtmlBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Stefan Seelmann and others. + * Copyright (c) 2012, 2013 Stefan Seelmann and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,32 +11,38 @@ package org.eclipse.mylyn.internal.wikitext.markdown.core.block; -import org.eclipse.mylyn.wikitext.core.parser.markup.Block; +import java.util.regex.Pattern; + +import org.eclipse.mylyn.internal.wikitext.markdown.core.token.AutomaticLinkReplacementToken; /** * Markdown inline HTML. * * @author Stefan Seelmann */ -public class InlineHtmlBlock extends Block { - - @Override - public boolean canStart(String line, int lineOffset) { - return line.startsWith("<"); //$NON-NLS-1$ - } - - @Override - protected int processLineContent(String line, int offset) { - // empty line: start new block - if (markupLanguage.isEmptyLine(line)) { - setClosed(true); - return 0; - } - - builder.charactersUnescaped(line); - builder.characters("\n"); //$NON-NLS-1$ - - return -1; - } +public class InlineHtmlBlock extends NestableBlock { + + private static final Pattern AUTOMATIC_LINK_PATTERN = Pattern.compile(AutomaticLinkReplacementToken.AUTOMATIC_LINK_REGEX); + + @Override + public boolean canStart(String line, int lineOffset) { + return line.substring(lineOffset).trim().startsWith("<") && !AUTOMATIC_LINK_PATTERN.matcher(line).matches(); //$NON-NLS-1$ + } + + @Override + protected int processLineContent(String line, int offset) { + String text = line.substring(offset); + + // empty line: start new block + if (markupLanguage.isEmptyLine(text)) { + setClosed(true); + return offset; + } + + builder.charactersUnescaped(text); + builder.characters("\n"); //$NON-NLS-1$ + + return -1; + } } |