protected final void initializeBlocks() { addStandardBlocks(blocks, paragraphBreakingBlocks); // extensions addBlockExtensions(blocks, paragraphBreakingBlocks); if (configuration != null) { configuration.addBlockExtensions(blocks, paragraphBreakingBlocks); } // ~extensions blocks.add(createParagraphBlock()); // ORDER DEPENDENCY: this must come last }
protected final void initializePhraseModifiers() { addStandardPhraseModifiers(phraseModifierSyntax); addPhraseModifierExtensions(phraseModifierSyntax); if (configuration != null) { configuration.addPhraseModifierExtensions(phraseModifierSyntax); } }
protected final void initializeTokens() { addStandardTokens(tokenSyntax); addTokenExtensions(tokenSyntax); if (configuration != null) { configuration.addTokenExtensions(tokenSyntax); } }
public void addBlockExtensions(List<Block> blocks, List<Block> paragraphBreakingBlocks) { for (Block block : getBlocks()) { blocks.add(computeInsertPosition(block), block); if (isParagraphBreaking(block)) { paragraphBreakingBlocks.add(block); } } }
@Override protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) { // IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!! boolean escapingHtml = configuration == null ? false : configuration.isEscapingHtmlAndXml(); phraseModifierSyntax.add(new AutoLinkSwitchPhraseModifier()); if (!escapingHtml) { phraseModifierSyntax.add(new HtmlStartTagPhraseModifier()); phraseModifierSyntax.add(new HtmlEndTagPhraseModifier()); } phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\{\\}\\[\\]])|^)(?:", 0); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("*", SpanType.BOLD)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("__", new SpanType[] { SpanType.BOLD, SpanType.ITALIC })); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("_", SpanType.ITALIC)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("==", new SpanType[] { SpanType.BOLD, SpanType.MONOSPACE })); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("=", SpanType.MONOSPACE)); //$NON-NLS-1$ phraseModifierSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$ literalPhraseModifierSyntax.add(new HtmlStartTagPhraseModifier()); literalPhraseModifierSyntax.add(new HtmlEndTagPhraseModifier()); }
@Override protected void addStandardTokens(PatternBasedSyntax tokenSyntax) { // IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!! tokenSyntax.add(new BangEscapeToken()); tokenSyntax.add(new LineBreakToken()); tokenSyntax.beginGroup("(?:(?<=[\\s\\.\\\"'?!;:\\)\\(\\{\\}\\[\\]-])|^)(?:", 0); // always starts at the start of a line or after a non-word character excluding '!' and '-' //$NON-NLS-1$ tokenSyntax.add(new RevisionLogReplacementToken()); tokenSyntax.add(new ChangesetLinkReplacementToken()); tokenSyntax.add(new HyperlinkReplacementToken()); tokenSyntax.add(new ImpliedHyperlinkReplacementToken()); tokenSyntax.add(new TicketAttachmentLinkReplacementToken()); tokenSyntax.add(new TicketLinkReplacementToken()); tokenSyntax.add(new ReportLinkReplacementToken()); tokenSyntax.add(new MilestoneLinkReplacementToken()); tokenSyntax.add(new SourceLinkReplacementToken()); tokenSyntax.add(new WikiLinkReplacementToken()); if (configuration == null || configuration.isWikiWordLinking() == null || configuration.isWikiWordLinking()) { tokenSyntax.add(new WikiWordReplacementToken()); } tokenSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$ }
@Override protected void addStandardTokens(PatternBasedSyntax tokenSyntax) { tokenSyntax.add(new EntityReferenceReplacementToken("(tm)", "#8482")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new EntityReferenceReplacementToken("(TM)", "#8482")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new EntityReferenceReplacementToken("(c)", "#169")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new EntityReferenceReplacementToken("(C)", "#169")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new EntityReferenceReplacementToken("(r)", "#174")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new EntityReferenceReplacementToken("(R)", "#174")); //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new FootnoteReferenceReplacementToken()); if (configuration == null || !configuration.isOptimizeForRepositoryUsage()) { ResourceBundle res = ResourceBundle.getBundle(BUNDLE_NAME, configuration == null || configuration.getLocale() == null ? Locale.ENGLISH : configuration.getLocale()); tokenSyntax.add(new EntityWrappingReplacementToken( "\"", res.getString("quote_left"), res.getString("quote_right"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tokenSyntax.add(new EntityWrappingReplacementToken( "'", res.getString("singlequote_left"), res.getString("singlequote_right"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=\\w)(')(?=\\w))", "#8217")); // apostrophe //$NON-NLS-1$ //$NON-NLS-2$ } tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(--)(?=\\s\\w))", "#8212")); // emdash //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=\\w\\s)(-)(?=\\s\\w))", "#8211")); // endash //$NON-NLS-1$ //$NON-NLS-2$ tokenSyntax.add(new PatternEntityReferenceReplacementToken("(?:(?<=\\d\\s)(x)(?=\\s\\d))", "#215")); // mul //$NON-NLS-1$ //$NON-NLS-2$ if (configuration == null || !configuration.isOptimizeForRepositoryUsage()) { tokenSyntax.add(new AcronymReplacementToken()); } }
/** * Indicate if newlines in the markup must cause a line break. If false, then the default markup language behaviour * should be observed. The default is false. */ public void addPhraseModifierExtensions(PatternBasedSyntax phraseModifierSyntax) { for (PatternBasedElement element : getPhraseModifiers()) { phraseModifierSyntax.add(element); } }
@Override public MarkupLanguage clone() { MarkupLanguage markupLanguage; try { markupLanguage = getClass().newInstance(); } catch (Exception e) { throw new IllegalStateException(e); } markupLanguage.setName(name); markupLanguage.internalLinkPattern = internalLinkPattern; markupLanguage.enableMacros = enableMacros; markupLanguage.configuration = configuration == null ? null : configuration.clone(); return markupLanguage; }
@Override protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) { boolean escapingHtml = configuration == null ? false : configuration.isEscapingHtmlAndXml(); phraseModifierSyntax.add(new HtmlEndTagPhraseModifier(escapingHtml)); phraseModifierSyntax.add(new HtmlStartTagPhraseModifier(escapingHtml)); phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\{\\}\\[\\]])|^)(?:", 0); //$NON-NLS-1$ phraseModifierSyntax.add(new EscapeTextilePhraseModifier()); phraseModifierSyntax.add(new SimpleTextilePhraseModifier("**", SpanType.BOLD, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("??", SpanType.CITATION, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("__", SpanType.ITALIC, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("_", SpanType.EMPHASIS, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("*", SpanType.STRONG, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("+", SpanType.INSERTED, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("~", SpanType.SUBSCRIPT, Mode.NORMAL)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("^", SpanType.SUPERSCRIPT, Mode.NORMAL)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("@", SpanType.CODE, Mode.SPECIAL)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("%", SpanType.SPAN, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimpleTextilePhraseModifier("-", SpanType.DELETED, Mode.NESTING)); //$NON-NLS-1$ phraseModifierSyntax.add(new ImageTextilePhraseModifier()); phraseModifierSyntax.add(new HyperlinkPhraseModifier()); // hyperlinks are actually a phrase modifier see bug 283093 phraseModifierSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$ }
@Override protected void addStandardTokens(PatternBasedSyntax tokenSyntax) { // IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!! tokenSyntax.add(new BangEscapeToken()); tokenSyntax.add(new LineBreakToken()); tokenSyntax.beginGroup("(?:(?<=[\\s\\.\\\"'?!;:\\)\\(\\{\\}\\[\\]-])|^)(?:", 0); // always starts at the start of a line or after a non-word character excluding '!' and '-' //$NON-NLS-1$ tokenSyntax.add(new MacroReplacementToken()); tokenSyntax.add(new RevisionLogReplacementToken()); tokenSyntax.add(new ChangesetLinkReplacementToken()); tokenSyntax.add(new HyperlinkReplacementToken()); tokenSyntax.add(new ImpliedHyperlinkReplacementToken()); tokenSyntax.add(new TicketAttachmentLinkReplacementToken()); tokenSyntax.add(new TicketLinkReplacementToken()); tokenSyntax.add(new ReportLinkReplacementToken()); tokenSyntax.add(new MilestoneLinkReplacementToken()); tokenSyntax.add(new SourceLinkReplacementToken()); tokenSyntax.add(new WikiLinkReplacementToken()); if (configuration == null || configuration.isWikiWordLinking() == null || configuration.isWikiWordLinking()) { tokenSyntax.add(new WikiWordReplacementToken()); } tokenSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$ }
public void addTokenExtensions(PatternBasedSyntax tokenSyntax) { for (PatternBasedElement element : getPhraseModifiers()) { tokenSyntax.add(element); } }