/******************************************************************************* * Copyright (c) 2007, 2010 Association for Decentralized Information Management * in Industry THTH ry. * 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.wiki.ui.language; import org.eclipse.mylyn.wikitext.mediawiki.internal.phrase.EscapePhraseModifier; import org.eclipse.mylyn.wikitext.mediawiki.internal.phrase.SimplePhraseModifier; import org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType; import org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlCommentPhraseModifier; import org.eclipse.mylyn.wikitext.parser.markup.phrase.LimitedHtmlEndTagPhraseModifier; import org.eclipse.mylyn.wikitext.parser.markup.phrase.LimitedHtmlStartTagPhraseModifier; /** * A markup language for MediaWiki Wikitext markup, which is the wiki format used by several other major sites. * * @author David Green * @since 1.0 */ @SuppressWarnings("restriction") public class MediaWikiLanguage extends org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage { public MediaWikiLanguage() { super(); } @Override protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) { phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\{\\}\\[\\]])|^)(?:", 0); //$NON-NLS-1$ phraseModifierSyntax.add(new EscapePhraseModifier()); phraseModifierSyntax.add(new SimplePhraseModifier("'''''", new SpanType[] { SpanType.BOLD, SpanType.ITALIC }, //$NON-NLS-1$ true)); phraseModifierSyntax.add(new SimplePhraseModifier("'''", SpanType.BOLD, true)); //$NON-NLS-1$ phraseModifierSyntax.add(new SimplePhraseModifier("''", SpanType.ITALIC, true)); //$NON-NLS-1$ phraseModifierSyntax.endGroup(")(?=\\W|$)", 0); //$NON-NLS-1$ boolean escapingHtml = configuration == null ? false : configuration.isEscapingHtmlAndXml(); if (!escapingHtml) { String[] allowedHtmlTags = new String[] { // HANDLED BY LineBreakToken "
", // HANDLED BY LineBreakToken "
", "b", "big", "blockquote", "caption", "center", "cite", "code", "dd", "del", "div", "dl", "dt", "em", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ "font", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "ins", "li", "ol", "p", "pre", "rb", "rp", "rt", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ "ruby", "s", "small", "span", "strike", "strong", "sub", "sup", "table", "td", "th", "tr", "tt", "u", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ "ul", "var", //$NON-NLS-1$ //$NON-NLS-2$ "applet", "object", "embed" }; phraseModifierSyntax.add(new LimitedHtmlEndTagPhraseModifier(allowedHtmlTags)); phraseModifierSyntax.add(new LimitedHtmlStartTagPhraseModifier(allowedHtmlTags)); phraseModifierSyntax.add(new HtmlCommentPhraseModifier()); } } }