Skip to content

Commit

Permalink
Let XMLScanner extend HTMLScanner to support type lookup on XML
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakknutsen committed Mar 23, 2014
1 parent ca09a78 commit 1d7a172
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jboss.forge.addon.text.highlight.scanner.PlainScanner;
import org.jboss.forge.addon.text.highlight.scanner.PropertiesScanner;
import org.jboss.forge.addon.text.highlight.scanner.SQLScanner;
import org.jboss.forge.addon.text.highlight.scanner.XMLScanner;
import org.jboss.forge.addon.text.highlight.scanner.YAMLScanner;

public class Syntax
Expand All @@ -28,6 +29,7 @@ public static void builtIns()
Scanner.Factory.registrer(PlainScanner.class);
Scanner.Factory.registrer(JavaScanner.class);
Scanner.Factory.registrer(HTMLScanner.class);
Scanner.Factory.registrer(XMLScanner.class);
Scanner.Factory.registrer(CSSScanner.class);
Scanner.Factory.registrer(JavaScriptScanner.class);
Scanner.Factory.registrer(JSONScanner.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public enum State
.add(EVENT_ATTRIBUTES, EmbeddedType.script)
.add(new String[] { "style" }, EmbeddedType.style);

public static final Type TYPE = new Type("HTML", "\\.(html|htm|xhtml|xml|cfc|cfm|tmproj|xaml)$");
public static final Type TYPE = new Type("HTML", "\\.(html|htm|xhtml)$");

@Override
public Type getType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jboss.forge.addon.text.highlight.scanner;


public class XMLScanner extends HTMLScanner {

public static final Type TYPE = new Type("XML", "\\.(xml|cfc|cfm|tmproj|xaml)$");

@Override
public Type getType() {
return TYPE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,4 @@ public void shoulMatchHTMLTPuthTagsExample() throws Exception
{
assertMatchExample(Builder.create(), "html", "tputh.in.html");
}

@Test
public void shoulMatchXMLDTDExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "dtd.in.xml");
}

@Test
@Ignore
// Some issue with new_line in output, revisit
public void shoulMatchXMLKateExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "kate.in.xml");
}

@Test
public void shoulMatchXMLXAMLExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "xaml.in.xml");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jboss.forge.addon.text.highlight.scanner;

import org.jboss.forge.addon.text.highlight.Syntax.Builder;
import org.junit.Ignore;
import org.junit.Test;

public class XMLScannerTestCase extends AbstractScannerTestCase
{
@Test
public void shoulMatchXMLDTDExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "dtd.in.xml");
}

@Test
@Ignore
// Some issue with new_line in output, revisit
public void shoulMatchXMLKateExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "kate.in.xml");
}

@Test
public void shoulMatchXMLXAMLExample() throws Exception
{
assertMatchExample(Builder.create(), "xml", "xaml.in.xml");
}
}

0 comments on commit 1d7a172

Please sign in to comment.