Examples of CodeColorizerFormat


Examples of org.sonar.api.web.CodeColorizerFormat

  public CodeColorizers() {
    this(Lists.<CodeColorizerFormat>newArrayList());
  }

  public String toHtml(String code, String language) {
    CodeColorizerFormat format = byLang.get(language);
    List<Tokenizer> tokenizers;
    if (format == null) {
      tokenizers = Collections.emptyList();
    } else {
      tokenizers = format.getTokenizers();
    }
    return new CodeColorizer(tokenizers).toHtml(new StringReader(code), HtmlOptions.ONLY_SYNTAX);
  }
View Full Code Here

Examples of org.sonar.api.web.CodeColorizerFormat

import static org.fest.assertions.Assertions.assertThat;

public class CodeColorizersTest {
  @Test
  public void colorize_source_code() throws Exception {
    CodeColorizerFormat format = new LiteralFormat("java");
    CodeColorizers colorizers = new CodeColorizers(Arrays.asList(format));

    String html = colorizers.toHtml("String s = \"foo\";", "java");
    assertThat(html).isEqualTo("String s = <span class=\"s\">\"foo\"</span>;");
  }
View Full Code Here

Examples of org.sonar.api.web.CodeColorizerFormat

    assertThat(html).isEqualTo("String s = <span class=\"s\">\"foo\"</span>;");
  }

  @Test
  public void do_not_fail_if_unsupported_language() throws Exception {
    CodeColorizerFormat format = new LiteralFormat("java");
    CodeColorizers colorizers = new CodeColorizers(Arrays.asList(format));

    String html = colorizers.toHtml("String s = \"foo\";", "groovy");
    assertThat(html).isEqualTo("String s = \"foo\";");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.