org.fife.ui.rsyntaxtextarea.folding.LatexFoldParser Maven / Gradle / Ivy
The newest version!
/*
* 04/24/2012
*
* LatexFoldParser.java - Fold parser for LaTeX.
*
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package org.fife.ui.rsyntaxtextarea.folding;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import javax.swing.text.BadLocationException;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.Token;
/**
* A fold parser for LaTeX documents. This is likely incomplete and/or not
* quite right; feedback is appreciated.
*
* @author Robert Futrell
* @version 1.0
*/
public class LatexFoldParser implements FoldParser {
private static final char[] BEGIN = "\\begin".toCharArray();
private static final char[] END = "\\end".toCharArray();
/**
* {@inheritDoc}
*/
public List getFolds(RSyntaxTextArea textArea) {
List folds = new ArrayList();
Stack expectedStack = new Stack();
Fold currentFold = null;
int lineCount = textArea.getLineCount();
try {
for (int line=0; line