Examples of CodeChunk


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

  public Chunk createChunk(String options, String content) {
    int maxLineLenght = Utilities.maxLineLength(content) - Utilities.getMinIndent(content);
    if(maxLineLenght >Tubaina.MAX_LINE_LENGTH)
      throw new TubainaException ("Chapter " + Chapter.getChaptersCount() +
                    "  -  Code has " + maxLineLenght + " columns:\n\n" + content);
    return new CodeChunk(content, options);
  }
View Full Code Here

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

  public Chunk createChunk(String options, String content) {
    int maxLineLenght = Utilities.maxLineLength(content) - Utilities.getMinIndent(content);
    if(maxLineLenght >Tubaina.MAX_LINE_LENGTH)
      throw new TubainaException ("Chapter " + Chapter.getChaptersCount() +
                    "  -  Code has " + maxLineLenght + " columns:\n\n" + content);
    return new CodeChunk(content, options);
  }
View Full Code Here

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

  @Test
  public void plainJavaCode() throws Exception {
    String options = "java";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(code, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(code), eq(options), eq(false), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  @Test
  public void javaCodeWithNumberedLines() throws Exception {
    String options = "java #";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(code, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(code), eq("java"), eq(true), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  public void plainRubyCode() throws Exception {
    String options = "ruby";
    String rubyCode = "@name = \"Gabriel\"\n" + "puts \"Hello, \" + name";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(rubyCode, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(rubyCode), eq("ruby"), eq(false), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  public void noLanguageDefinedIsTreatedAsText() throws Exception {
    String options = "";
    String noParticularLanguage = "Some text explaining some new bizarre\n" + "syntax in a very code alike way";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(noParticularLanguage, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(noParticularLanguage), eq("text"), eq(false), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  public void noLanguageDefinedIsTreatedAsTextEvenWhenItIsNumbered() throws Exception {
    String options = "#";
    String noParticularLanguage = "Some text explaining some new bizarre\n" + "syntax in a very code alike way";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(noParticularLanguage, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(noParticularLanguage), eq("text"), eq(true), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  public void shouldNotConsiderLabelAsLanguage() throws Exception {
    String options = "label=world";
    String noParticularLanguage = "Some code";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(noParticularLanguage, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(noParticularLanguage), eq("text"), eq(false), eq(emptyList), Mockito.anyString());
  }
View Full Code Here

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

  public void shouldConsiderLineHighlightOption() throws Exception {
    String options = "h=1,2";
    String noParticularLanguage = "Some code";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(noParticularLanguage, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(noParticularLanguage), eq("text"), eq(false), eq(Arrays.asList(1, 2)), Mockito.anyString());
  }
View Full Code Here

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

  public void shouldConsiderPygmentsOptions() throws Exception {
    String options = "label=somelabel options=\'startinline=true\'";
    String noParticularLanguage = "Some code";
    SyntaxHighlighter htmlCodeHighlighter = mock(SyntaxHighlighter.class);
    HtmlAndKindleCodeTag codeTag = new HtmlAndKindleCodeTag(htmlCodeHighlighter);
    CodeChunk chunk = new CodeChunk(noParticularLanguage, options);
    codeTag.parse(chunk);
    verify(htmlCodeHighlighter).highlight(eq(noParticularLanguage), eq("text"), eq(false), eq(emptyList), eq("startinline=true"));
  }
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.