X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.wiki.ui%2Fsrc%2Forg%2Fsimantics%2Fwiki%2Fui%2Flanguage%2FMediaWikiLanguage.java;fp=bundles%2Forg.simantics.wiki.ui%2Fsrc%2Forg%2Fsimantics%2Fwiki%2Fui%2Flanguage%2FMediaWikiLanguage.java;h=64ad653355a67b7abd4895767f908e5df76c188e;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/language/MediaWikiLanguage.java b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/language/MediaWikiLanguage.java new file mode 100644 index 000000000..64ad65335 --- /dev/null +++ b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/language/MediaWikiLanguage.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.internal.wikitext.mediawiki.core.phrase.EscapePhraseModifier; +import org.eclipse.mylyn.internal.wikitext.mediawiki.core.phrase.SimplePhraseModifier; +import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.SpanType; +import org.eclipse.mylyn.wikitext.core.parser.markup.phrase.HtmlCommentPhraseModifier; +import org.eclipse.mylyn.wikitext.core.parser.markup.phrase.LimitedHtmlEndTagPhraseModifier; +import org.eclipse.mylyn.wikitext.core.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.core.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()); + } + } +} \ No newline at end of file