mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 11:01:56 +02:00
Count abstract environment in preamble (#28458)
GitOrigin-RevId: 7a69b2cef6e7570e6324ecbd7b6cd3ff61f3cf67
This commit is contained in:
@@ -159,6 +159,9 @@ export const countWordsInFile = (
|
||||
iterateNode(nodeRef, 'header')
|
||||
return false
|
||||
},
|
||||
$Environment(nodeRef) {
|
||||
return handleEnvironment(nodeRef)
|
||||
},
|
||||
})
|
||||
|
||||
const bodyMatcher = NodeType.match<
|
||||
@@ -220,27 +223,7 @@ export const countWordsInFile = (
|
||||
return false
|
||||
},
|
||||
$Environment(nodeRef) {
|
||||
const envNameNode = nodeRef.node
|
||||
.getChild('BeginEnv')
|
||||
?.getChild('EnvNameGroup')
|
||||
?.getChild('EnvName')
|
||||
|
||||
if (envNameNode) {
|
||||
const envName = content
|
||||
?.substring(envNameNode.from, envNameNode.to)
|
||||
.replace(/\*$/, '')
|
||||
|
||||
if (envName === 'abstract') {
|
||||
data.headers++
|
||||
|
||||
const contentNode = nodeRef.node.getChild('Content')
|
||||
if (contentNode) {
|
||||
iterateNode(contentNode, 'abstract')
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
return handleEnvironment(nodeRef)
|
||||
},
|
||||
BeginEnv() {
|
||||
return false // ignore text in \begin arguments
|
||||
@@ -315,6 +298,30 @@ export const countWordsInFile = (
|
||||
}
|
||||
}
|
||||
|
||||
const handleEnvironment = (nodeRef: SyntaxNodeRef) => {
|
||||
const envNameNode = nodeRef.node
|
||||
.getChild('BeginEnv')
|
||||
?.getChild('EnvNameGroup')
|
||||
?.getChild('EnvName')
|
||||
|
||||
if (envNameNode) {
|
||||
const envName = content
|
||||
?.substring(envNameNode.from, envNameNode.to)
|
||||
.replace(/\*$/, '')
|
||||
|
||||
if (envName === 'abstract') {
|
||||
data.headers++
|
||||
|
||||
const contentNode = nodeRef.node.getChild('Content')
|
||||
if (contentNode) {
|
||||
iterateNode(contentNode, 'abstract')
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tree.iterate({
|
||||
from: 0,
|
||||
to: preambleExtent.to,
|
||||
|
||||
Reference in New Issue
Block a user