Package br.com.caelum.tubaina

Examples of br.com.caelum.tubaina.TubainaException


  public Chunk createChunk(String options, String content) {
      //TODO: use the real tab size, it may be different depending of which parseType is being used
      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


        }
      } else { // close tag found
        if (!stack.isEmpty() && stack.peek().equalsIgnoreCase(matcher.group(4))) {
          stack.pop();
        } else {
          throw new TubainaException("Tag " + matcher.group(4) + " closed unproperly");
        }
      }
    }

    if (!stack.isEmpty()) {
      throw new TubainaException("There is(are) unclosed tag(s) : " + stack.toString());
    }

    if (chunkStart < 0) { // if item was not found
      throw new TubainaException("There is no item inside a list tag on chapter " + ChapterBuilder.getChaptersCount());
      // chunks.add(new ParagraphChunk(text));
      // return "";
    }
    String textBefore = text.substring(0, chunkStart - 1).trim();
    if (textBefore.length() > 0) {
      throw new TubainaException("There is some inside a list tag, but outside an item on chapter "
          + ChapterBuilder.getChaptersCount());
      // chunks.add(new ParagraphChunk(textBefore));
    }

    if (chunkEnd < 0) {
View Full Code Here

public class XmlTag implements Tag<XmlChunk> {

  private static final String MESSAGE = "[xml] Tag is deprecated and can't be used anymore. Use [code xml] instead";

  public XmlTag(Indentator indentator) {
    throw new TubainaException(MESSAGE);
  }
View Full Code Here

    throw new TubainaException(MESSAGE);
  }
 
  @Override
  public String parse(XmlChunk chunk) {
    throw new TubainaException(MESSAGE);
  }
View Full Code Here

  @Override
  public Chunk createChunk(String options, String content) {
    int maxLineLength = Utilities.maxLineLength(content) - Utilities.getMinIndent(content);
    if(maxLineLength >TubainaBuilder.getCodeLength())
      throw new TubainaException ("Chapter " + ChapterBuilder.getChaptersCount() +
          "  -  Code has " + maxLineLength + " columns out of " + TubainaBuilder.getCodeLength() + ":\n\n" + content)
    return new XmlChunk(options, content);
  }
View Full Code Here

    try {
      PrintStream stream = new PrintStream(new FileOutputStream(new File("todo.log"), true));
      stream.println("<==========================================================>");
      stream.println(chunk.getContent().trim());
    } catch (FileNotFoundException e) {
      throw new TubainaException("File could not be read", e);
    }
    return "";
  }
View Full Code Here

  @Override
  public String parse(ImageChunk chunk) {
      Pattern label = Pattern.compile("(?s)(?i)label=(\\w+)?");
        Matcher labelMatcher = label.matcher(chunk.getOptions());
        if (labelMatcher.matches()) {
            throw new TubainaException("Image labels are not yet supported for html output");
        }
     
    return template.parse(chunk, false);
  }
View Full Code Here

    public TubainaHtmlDir createTubainaDir(File bookRoot) {
        try {
            File templateIncludes = new File(templateDir, "includes/");
            if (!templateIncludes.exists()) {
                throw new TubainaException("Could not find includes dir at: " + templateIncludes.getAbsolutePath() + ".");
            }
            NotFileFilter excludingVersionControlFiles = new NotFileFilter(new NameFileFilter(Arrays.asList("CVS", ".svn", ".git")));
            FileUtilities.copyDirectoryToDirectory(templateIncludes, bookRoot, excludingVersionControlFiles);
        } catch (IOException e) {
            throw new TubainaException("Error while copying template files", e);
        }
       
        return new TubainaHtmlDir(bookRoot, templateDir, resourceManipulatorFactory);
    }
View Full Code Here

    private void configureFreemarker() {
        freeMarkerConfig = new Configuration();
        try {
            freeMarkerConfig.setDirectoryForTemplateLoading(templateDir);
        } catch (IOException e) {
            throw new TubainaException("Couldn't load freemarker template for Kindle HTML mode", e);
        }
        freeMarkerConfig.setObjectWrapper(new BeansWrapper());
    }
View Full Code Here

    File file = new File(currentFolder, "index.html");
    try {
      IOUtils.write(bookContent, new PrintStream(file, "UTF-8"));
      return this;
    } catch (IOException e) {
      throw new TubainaException("Couldn't create index.html in " + currentFolder);
    }
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.TubainaException

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.