private void handleLineInDefaultState(String line) throws IOException { /* Does line end with a \begin or \end which is unclosed */ if (line.endsWith(BEGIN)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - BEGIN.length())); parsingState = ParsingState.BEGIN_DECLARATION; } else if (line.endsWith(END)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - END.length())); parsingState = ParsingState.END_DECLARATION; } else { handleLineFragmentInDefaultState(line); } }
/** * Creates a new indenter that will output to {@link #outputWriter}. This will have * default properties set and will compact blank lines by default. * * @param outputWriter */ public LaTeXIndenter(final Writer outputWriter) { this.outputWriter = outputWriter; this.indentWidth = DEFAULT_INDENT_WIDTH; this.maxIndentLevel = DEFAULT_MAX_INDENT_LEVEL; this.compactingBlankLines = true; /* Initialise parsing state */ reset(); }
/** * Indents the TeX read from the given inputReader, sending the results to * {@link #outputWriter}. The inputReader will be closed afterwards; the * {@link #outputWriter} is left open so the caller should arrange to * flush or close it as required. */ public void run(Reader inputReader) throws IOException { /* Reset state */ reset(); /* Ensure input is buffered */ BufferedReader reader; if (inputReader instanceof BufferedReader) { reader = (BufferedReader) inputReader; } else { reader = new BufferedReader(inputReader); } /* Now read line-by-line */ String line; try { while ((line=reader.readLine())!=null) { handleLine(line); } } finally { inputReader.close(); } }
indentLevel--; createIndent(indentLevel);
handleLineInDefaultState(line); handleLineInDefaultState(line); handleLineInDefaultState(BEGIN + line); handleLineInDefaultState(END + line);
/** * Indents the TeX read from the given inputReader, sending the results to * {@link #outputWriter}. The inputReader will be closed afterwards; the * {@link #outputWriter} is left open so the caller should arrange to * flush or close it as required. */ public void run(Reader inputReader) throws IOException { /* Reset state */ reset(); /* Ensure input is buffered */ BufferedReader reader; if (inputReader instanceof BufferedReader) { reader = (BufferedReader) inputReader; } else { reader = new BufferedReader(inputReader); } /* Now read line-by-line */ String line; try { while ((line=reader.readLine())!=null) { handleLine(line); } } finally { inputReader.close(); } }
indentLevel--; createIndent(indentLevel);
handleLineInDefaultState(line); handleLineInDefaultState(line); handleLineInDefaultState(BEGIN + line); handleLineInDefaultState(END + line);
/** * Indents the TeX read from the given inputReader, sending the results to * {@link #outputWriter}. The inputReader will be closed afterwards; the * {@link #outputWriter} is left open so the caller should arrange to * flush or close it as required. */ public void run(Reader inputReader) throws IOException { /* Reset state */ reset(); /* Ensure input is buffered */ BufferedReader reader; if (inputReader instanceof BufferedReader) { reader = (BufferedReader) inputReader; } else { reader = new BufferedReader(inputReader); } /* Now read line-by-line */ String line; try { while ((line=reader.readLine())!=null) { handleLine(line); } } finally { inputReader.close(); } }
/** * Creates a new indenter that will output to {@link #outputWriter}. This will have * default properties set and will compact blank lines by default. * * @param outputWriter */ public LaTeXIndenter(final Writer outputWriter) { this.outputWriter = outputWriter; this.indentWidth = DEFAULT_INDENT_WIDTH; this.maxIndentLevel = DEFAULT_MAX_INDENT_LEVEL; this.compactingBlankLines = true; /* Initialise parsing state */ reset(); }
private void handleLineInDefaultState(String line) throws IOException { /* Does line end with a \begin or \end which is unclosed */ if (line.endsWith(BEGIN)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - BEGIN.length())); parsingState = ParsingState.BEGIN_DECLARATION; } else if (line.endsWith(END)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - END.length())); parsingState = ParsingState.END_DECLARATION; } else { handleLineFragmentInDefaultState(line); } }
indentLevel--; createIndent(indentLevel);
handleLineInDefaultState(line); handleLineInDefaultState(line); handleLineInDefaultState(BEGIN + line); handleLineInDefaultState(END + line);
/** * Creates a new indenter that will output to {@link #outputWriter}. This will have * default properties set and will compact blank lines by default. * * @param outputWriter */ public LaTeXIndenter(final Writer outputWriter) { this.outputWriter = outputWriter; this.indentWidth = DEFAULT_INDENT_WIDTH; this.maxIndentLevel = DEFAULT_MAX_INDENT_LEVEL; this.compactingBlankLines = true; /* Initialise parsing state */ reset(); }
private void handleLineInDefaultState(String line) throws IOException { /* Does line end with a \begin or \end which is unclosed */ if (line.endsWith(BEGIN)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - BEGIN.length())); parsingState = ParsingState.BEGIN_DECLARATION; } else if (line.endsWith(END)) { handleLineFragmentInDefaultState(line.substring(0, line.length() - END.length())); parsingState = ParsingState.END_DECLARATION; } else { handleLineFragmentInDefaultState(line); } }