EinarAndreas / TeXcount

TeXcount
9 stars 1 forks source link

`newcounter` not supported in option file #2

Open joel-coffman opened 3 years ago

joel-coffman commented 3 years ago

Consider the following example (from the documentation):

\documentclass{article}

\begin{document}

%TC:newcounter fwords Words in footnotes
%TC:newcounter footnote Number of footnotes
%TC:macro \footnote [fwords]
%TC:macroword \footnote [footnote]
Each footnote\footnote{Words in footnotes will be counted separately.} will be counted.

\end{document}

texcount reports the following:

Encoding: ascii
Words in text: 5
Words in headers: 0
Words outside text (captions, etc.): 0
Number of headers: 0
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 0
Words in footnotes: 7
Number of footnotes: 1

These same TC commands do not work correctly when in an option file. More specifically, consider the following option file:

%newcounter fwords Words in footnotes
%newcounter footnote Number of footnotes
%macro \footnote [fwords]
%macroword \footnote [footnote]

texcount -opt=<path-to-prior-file> reports the following:

Invalid TC option: newcounter fwords Words in footnotes

I'm guessing that this parsing failure is a bug unless there's another way to define new counters in an option file?

EinarAndreas commented 3 years ago

I'm afraid the implementation of the option file parsing is very lacking, and only supports a subset of the TeXcount instructions.

Fixing this is on my TODO list, but I don't have much time for TeXcount and the TODO list is starting to get long, so I don't want to make any promise as to when I can get around to fixing this.

An alternative which bypasses this problem is to place these TC commands in a separate tex file and either include it in the TeX document (requires -merge to ensure the file is processed immediately), or run TeXcount on both the options file and the document (eg texcount tcoptions.tex document.tex). Neither of these solutions are ideal, so I really should fix this as there have been more requests for it.

joel-coffman commented 3 years ago

Thanks for the response, and I understand completely regarding other priorities. If I had any familiarity with Perl, I'd work on a patch myself.

I appreciate the suggested workarounds – I'll give them a shot to see if they're feasible in my workflow.