First of all, thank you very much for this script. It helped me a lot.
I just stumbled over a small bug when using it. If the manuscript starts with a \section (as can be common in certain fields) the first line detection in count_main_text_words_detex breaks giving an output of 0 words for the main text.
The proposed change compares the line by checking if the text as generated by detex can be found in the tex file.
There could still be cases where this method breaks, but at least in my cases, it worked.
First of all, thank you very much for this script. It helped me a lot. I just stumbled over a small bug when using it. If the manuscript starts with a \section (as can be common in certain fields) the first line detection in count_main_text_words_detex breaks giving an output of 0 words for the main text. The proposed change compares the line by checking if the text as generated by detex can be found in the tex file. There could still be cases where this method breaks, but at least in my cases, it worked.