Skip to content

Commit 8f35cf0

Browse files
committed
updated readme
1 parent f224973 commit 8f35cf0

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

tex_misc/check_silly.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
from typing import List
3+
import os
4+
import argparse
5+
6+
7+
class SillyChecker:
8+
def __init__(self, file_path):
9+
if os.path.exists(file_path):
10+
with open(file_path, "r") as reader:
11+
self.contents: List[str] = reader.readlines()
12+
if len(self.contents) < 0:
13+
raise ValueError("File has no content")
14+
self.__process_lines()
15+
else:
16+
raise FileNotFoundError
17+
18+
def __is_comment(self, line: str) -> bool:
19+
return line.startswith("%")
20+
21+
def check_words_count(self, line: str, look_for: str, ref_word: str, reason: str = None):
22+
if look_for in line:
23+
if not line.count(look_for) == line.count(ref_word):
24+
print("Check for {} issues in line: {} ".format(ref_word, line))
25+
if reason:
26+
print(reason)
27+
28+
def __process_lines(self):
29+
for line in self.contents:
30+
if len(line) < 1 or self.__is_comment(line):
31+
continue
32+
else:
33+
self.check_words_count(line, "\cite{", "~\cite{", "~ before cite")
34+
self.check_words_count(line, "\ref{", "~\ref{", "~ before ref")
35+
self.check_words_count(line, ", that ", " that ", "no , before that")
36+
self.check_words_count(line, " which ", ", which ", "comma before which")
37+
38+
39+
if __name__ == "__main__":
40+
parser = argparse.ArgumentParser("Process tex file to check for \
41+
~ before ref, cite, and for checking that and which.")
42+
parser.add_argument("path")
43+
args = parser.parse_args()
44+
SillyChecker(args.path)
45+

tex_misc/readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Line Breaker
2+
3+
checks for silly issues, like not using ~before \cite and \ref
4+
not using , before which, or using , before that.

0 commit comments

Comments
 (0)