Package br.com.caelum.tubaina.chunk

Examples of br.com.caelum.tubaina.chunk.CodeChunk


  @Test
  public void codeTagWithFileNameWithLanguageAndLabel() throws Exception {
    String options = "java filename=src/Main2.java label=javacode1";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);

    assertTrue(output.startsWith("\\tubainaCodeLabel{javacode1}\n"));
    assertPygmentsRan(output);
  }
View Full Code Here


  @Test
  public void javascriptLangBug() throws Exception {
    String options = "javascript";
    String code = "writeTotal(3.14159);";
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);

    assertFalse(output.contains("javascript"));
    assertPygmentsRan(output);
  }
View Full Code Here

 
  @Test
  public void shouldUseDescription() throws Exception {
    String options = "java label=javacode1 \"description here\"";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);
    assertTrue(output.contains("\\tubainaCodeLabel{javacode1}{description here}"));
  }
View Full Code Here

 
  @Test
  public void testName() throws Exception {
    String options = "php options='startinline=true'";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);
    System.out.println(output);
  }
View Full Code Here

      SimpleIndentator indentator = new SimpleIndentator(4);
    int maxLineLength = Utilities.maxLineLength(indentator.indent(content)) - Utilities.getMinIndent(indentator.indent(content));
    if (maxLineLength > TubainaBuilder.getCodeLength())
      throw new TubainaException ("Chapter " + ChapterBuilder.getChaptersCount() +
                    "  -  Code has " + maxLineLength + " columns out of " + TubainaBuilder.getCodeLength() + ":\n\n" + content);
    return new CodeChunk(content, options);
  }
View Full Code Here

  @Test
  public void notNumberedGenericCode() {
    String code = "public static void main(String[] args) {\n" + "    String name = \"Gabriel\";\n"
        + "    System.out.println(\"Hello, \" + name);\n" + "}";
    CodeChunk chunk = new CodeChunk(code, "");
    String result = getContent(chunk);
    Assert.assertEquals("<pre ><div class=\"highlight\">" +
              "<pre>public static void main(String[] args) {" +
              "\n    String name = &quot;Gabriel&quot;;" +
              "\n    System.out.println(&quot;Hello, &quot; + name);" +
View Full Code Here

  @Test
  public void numberedGenericCode() {
    String code = "public static void main(String[] args) {\n" + "    String name = \"Gabriel\";\n"
        + "    System.out.println(\"Hello, \" + name);\n" + "}";
    CodeChunk chunk = new CodeChunk(code, "#");
    String result = getContent(chunk);
    Assert.assertEquals("<pre ><div class=\"highlight\">" +
              "<pre><span class=\"lineno\">1</span> " +
              "public static void main(String[] args) {" +
              "\n<span class=\"lineno\">2</span> " +
View Full Code Here

        GistResult result = retriever.retrieve(gistId, "");
       
        String content = result.getContent();
        String language = result.getLanguage();
       
        CodeChunk codeChunk = new CodeChunk(content, language + codeOptions);
    return code.parse(codeChunk);
    }
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.chunk.CodeChunk

Copyright © 2018 www.massapicom. 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.