Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word count only analyses LaTeX files #862

Merged
merged 2 commits into from Apr 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace
import nl.rubensten.texifyidea.TexifyIcons
import nl.rubensten.texifyidea.file.LatexFileType
import nl.rubensten.texifyidea.psi.*
import nl.rubensten.texifyidea.util.*
import java.util.regex.Pattern
Expand All @@ -33,7 +34,7 @@ open class WordCountAction : AnAction(
"\\usepackage", "\\documentclass", "\\label", "\\linespread", "\\ref", "\\cite", "\\eqref", "\\nameref",
"\\autoref", "\\fullref", "\\pageref", "\\newcounter", "\\newcommand", "\\renewcommand",
"\\setcounter", "\\resizebox", "\\includegraphics", "\\include", "\\input", "\\refstepcounter",
"\\counterwithins", "\\RequirePackage"
"\\counterwithins", "\\RequirePackage", "\\bibliography", "\\bibliographystyle"
)

/**
Expand Down Expand Up @@ -103,6 +104,7 @@ open class WordCountAction : AnAction(
*/
private fun countWords(baseFile: PsiFile): Pair<Int, Int> {
val fileSet = baseFile.referencedFileSet()
.filter { it.fileType == LatexFileType }
val allNormalText = fileSet.flatMap { it.childrenOfType(LatexNormalText::class) }

val bibliographies = baseFile.childrenOfType(LatexEnvironment::class)
Expand Down