|
@@ -111,6 +111,18 @@ module.exports = CompileManager =
|
|
|
}
|
|
}
|
|
|
return results
|
|
return results
|
|
|
|
|
|
|
|
|
|
+ wordcount: (project_id, file_name, callback = (error, pdfPositions) ->) ->
|
|
|
|
|
+ logger.log project_id:project_id, file_name:file_name, "running wordcount"
|
|
|
|
|
+ file_path = "$COMPILE_DIR/" + file_name
|
|
|
|
|
+ command = [ "texcount", '-inc', file_path, "-out=" + file_path + ".wc"]
|
|
|
|
|
+ directory = Path.join(Settings.path.compilesDir, project_id)
|
|
|
|
|
+ timeout = 10 * 1000
|
|
|
|
|
+
|
|
|
|
|
+ CommandRunner.run project_id, command, directory, timeout, (error) ->
|
|
|
|
|
+ return callback(error) if error?
|
|
|
|
|
+ stdout = fs.readFileSync(directory + "/" + file_name + ".wc", "utf-8")
|
|
|
|
|
+ callback null, CompileManager._parseWordcountFromOutput(stdout)
|
|
|
|
|
+
|
|
|
_parseWordcountFromOutput: (output) ->
|
|
_parseWordcountFromOutput: (output) ->
|
|
|
results = {
|
|
results = {
|
|
|
encode: ""
|
|
encode: ""
|
|
@@ -140,16 +152,4 @@ module.exports = CompileManager =
|
|
|
results['mathInline'] = parseInt(info, 10)
|
|
results['mathInline'] = parseInt(info, 10)
|
|
|
if data.indexOf("displayed") > -1
|
|
if data.indexOf("displayed") > -1
|
|
|
results['mathDisplay'] = parseInt(info, 10)
|
|
results['mathDisplay'] = parseInt(info, 10)
|
|
|
-
|
|
|
|
|
return results
|
|
return results
|
|
|
-
|
|
|
|
|
- wordcount: (project_id, file_name, callback = (error, pdfPositions) ->) ->
|
|
|
|
|
- file_path = "$COMPILE_DIR/" + file_name
|
|
|
|
|
- command = [ "texcount", file_path, "-out=" + file_path + ".wc"]
|
|
|
|
|
- directory = Path.join(Settings.path.compilesDir, project_id)
|
|
|
|
|
- timeout = 10 * 1000
|
|
|
|
|
-
|
|
|
|
|
- CommandRunner.run project_id, command, directory, timeout, (error) ->
|
|
|
|
|
- return callback(error) if error?
|
|
|
|
|
- stdout = fs.readFileSync(directory + "/" + file_name + ".wc", "utf-8")
|
|
|
|
|
- callback null, CompileManager._parseWordcountFromOutput(stdout)
|
|
|