summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-06-22 03:00:55 +0000
committerNorbert Preining <norbert@preining.info>2021-06-22 03:00:55 +0000
commit2a49c67eee870febe71143a093f3c304e0033153 (patch)
treec9806df7138b04732008e0f3ed8aaae00fc2da1b /support
parente5ca43f7439d850f4193a932455792429cff61eb (diff)
CTAN sync 202106220300
Diffstat (limited to 'support')
-rw-r--r--support/optexcount/LICENSE21
-rw-r--r--support/optexcount/README.md5
-rw-r--r--support/optexcount/doc/optexcount-doc.pdfbin0 -> 27286 bytes
-rw-r--r--support/optexcount/doc/optexcount-doc.tex71
-rw-r--r--support/optexcount/optexcount.py49
-rw-r--r--support/optexcount/src/color_print.py29
-rw-r--r--support/optexcount/src/counter.py466
-rw-r--r--support/optexcount/src/header.py27
-rw-r--r--support/optexcount/src/keywords.py48
-rw-r--r--support/optexcount/src/word_iterator.py112
-rw-r--r--support/optexcount/tests/final_bird.pngbin0 -> 1350 bytes
-rw-r--r--support/optexcount/tests/main_test.tex146
-rw-r--r--support/optexcount/tests/test-01.tex39
-rw-r--r--support/optexcount/tests/test-02.tex41
-rw-r--r--support/optexcount/tests/test-03.tex33
-rw-r--r--support/optexcount/tests/test-04.tex55
-rw-r--r--support/optexcount/tests/test-05.tex28
-rw-r--r--support/optexcount/tests/test-06.tex31
-rw-r--r--support/optexcount/tests/test-07.tex35
19 files changed, 1236 insertions, 0 deletions
diff --git a/support/optexcount/LICENSE b/support/optexcount/LICENSE
new file mode 100644
index 0000000000..d8ed525c9c
--- /dev/null
+++ b/support/optexcount/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Richard Hartmann
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/support/optexcount/README.md b/support/optexcount/README.md
new file mode 100644
index 0000000000..ebfcea5b53
--- /dev/null
+++ b/support/optexcount/README.md
@@ -0,0 +1,5 @@
+# OpTeXcount
+
+What is OpTeXcount? It is a basic python script that analyzes OpTeX source code and counts words in specific categories. For more information about this tool read `optexcount-doc.pdf`.
+### How to use it?
+Run: `python3 optexcount.py filename [-verbose] [-set-verbchar=verb-char]`, where `filename` is the name of our OpTeX code file. What does the optional argument `-verbose`? It prints the entire source code with colored words according to their categories. `-set-verbchar=verb-char` sets the implicit inline verbatim character to `verb-char`
diff --git a/support/optexcount/doc/optexcount-doc.pdf b/support/optexcount/doc/optexcount-doc.pdf
new file mode 100644
index 0000000000..bc85ab1d62
--- /dev/null
+++ b/support/optexcount/doc/optexcount-doc.pdf
Binary files differ
diff --git a/support/optexcount/doc/optexcount-doc.tex b/support/optexcount/doc/optexcount-doc.tex
new file mode 100644
index 0000000000..0e10fa2b90
--- /dev/null
+++ b/support/optexcount/doc/optexcount-doc.tex
@@ -0,0 +1,71 @@
+
+\fontfam[Termes]
+\margins/1 a4 (3,3,3,3)cm
+\typosize[11/13.5]
+\verbchar`
+
+\def\title{\OpTeX count}
+\def\desc{Python script for counting words in \OpTeX/ documents}
+\def\version{Version 1.0}
+\def\author{Richard Hartmann}
+
+\def\maketitle {\vbox to 9\baselineskip{
+ \parindent=0pt
+ \leftskip=0pt plus 1fill \rightskip=0pt plus 1fill
+ {\parskip=14pt \typoscale[2000/]\bf \title \par}
+ {\parskip=19pt \typoscale[1200/]\desc \par}
+ {\parskip=10pt \version \par}
+ {\parskip=10pt \it \author \par}
+ {\parskip=8pt \the\day.\,\the\month.\,\the\year \par}
+}}
+
+\maketitle
+
+
+\sec Functionality and Usage
+
+\OpTeX count is a basic python utility that analyzes \OpTeX source code. It is inspired by already existing \TeX count for \LaTeX. The functionality is really lightweight and basic.
+It counts words and other elements of \OpTeX/ document and sorts them out into individual categories. These categories are inspired by \TeX count.
+
+\begitems
+\typosize[11.5/16]
+\style N \bf
+* Regular text words count
+* Header words count
+* Caption words count
+* Header count
+* Figures/Tables count
+* Inline formulae
+* Displayed math formulae
+\enditems
+
+Regular text words are words that occur in the main text. Header words are introduced using these particular keywords: {\Blue `\tit`}, {\Blue `\chap`}, {\Blue `\sec`} and {\Blue `\secc`}. Caption words take into account captions of tables and figures, i.e., {\Blue `\caption/t`} and {\Blue `\caption/f`}, footnotes({\Blue `\fnote`} or {\Blue `\fnotetext`}) and marginal notes({\Blue `\mnote`}). Header count is the number of all headers in our document. Figures/Tables count counts all tables and figures which occur in the document. Inline formulae are introduced using {\Blue `$`\dots`$`} and displayed formulae are introduced using {\Blue `$$`\dots`$$`}.
+
+If there is a verbatim text in some category, its words are counted too.
+
+Alongside above mentioned statistics, all individual sections are printed separately with particular word counts.
+
+To get this utility running, Python3 has to be installed. Then user can run this utility by command:
+
+\begtt
+python3 optexcount.py optex-filename
+\endtt
+
+User can also use two optional specifiers: {\Blue `-verbose`} and {\Blue `-set-verbchar=verb-char`}. When the utility is ran in {\Blue `-verbose`} mode, the source code is printed on the screen with colored words, so he can easily see, what is considered as text word, header word, caption word or keyword. User can specify(using {\Blue `-set-verbchar=verb-char`} specifier) implicit verbatim inline character. This can be useful when the specific verbatim character is used in the file but not explicitely set in the file. The situation may occur for example when user wants to count words in file, that is read by different main file. The verbatim character is set in the main file, but not in the file we want to analyze.
+
+\sec A Brief Implementation Description
+
+\OpTeX count uses regular expressions to separate individual words, to identify keywords, brackets, math formulae etc. These preprocessed words are sequentially loaded into counter that decides how to treat with the word.
+
+If some specific keyword occurs, that is not known by this utility, it is skipped. Problem may occur, if an unknown keyword has got some arguments, the utility could count these arguments as individual words. Therefore, most common keywords with arguments are listed in `src/keywords.py`, so the utility can load successfully these arguments. If there is some important keyword missing, feel free to modify this file, to add this keyword\dots
+
+In case of some keyword, that is important for the utility to identify, for example {\Blue `\sec`} or {\Blue `\fnote`}, special handler routine is ran, to manage this particular keyword. The place, from which we process the word also determines the category of the word, in what color should be this word highlighted in {\Blue `-verbose`} mode etc.
+
+
+\sec Utility Limitations
+
+The results are pretty precise when the most basic \OpTeX/ constructions are used. As It has been already mentioned above, it is really basic and lightweight utility. When user uses some more advanced \TeX constructions, problems may occur, and the counts may be imprecise. It doesn't take into account macro expansion, self defined rules etc\dots When using this utility, a valid \OpTeX/ source code should be passed. If the file contains some errors(for example unterminated inline verbatim), utility terminates the process and won't provide much information about the problem. This utility only works with one particular file so it doesn't count included files as well.
+
+Beside above mentioned limitations of this utility, it could be very useful for the analysis of basic \OpTeX/ documents(such as the exemplary document {\Blue `tests/main_test.tex`}).
+
+\bye
diff --git a/support/optexcount/optexcount.py b/support/optexcount/optexcount.py
new file mode 100644
index 0000000000..1dd40e0c4b
--- /dev/null
+++ b/support/optexcount/optexcount.py
@@ -0,0 +1,49 @@
+"""
+The main file for entire optexcount utility
+Author: Richard Hartmann
+Version: 1.0
+"""
+
+
+import sys
+import os.path
+import src.counter
+
+
+def main():
+ if len(sys.argv) < 2 and len(sys.argv) > 4:
+ print("Usage: python3 " + sys.argv[0] + " path-to-file [-verbose] [-set-verbchar=verbatim-character]")
+ elif not os.path.isfile(sys.argv[1]):
+ print(sys.argv[1] + " Invalid filename!")
+ elif len(sys.argv) == 3 and sys.argv[2] != "-verbose" and sys.argv[2][0:-1] != "-set-verbchar=":
+ print(sys.argv[2] + " Invalid specifier!")
+ print("Usage: python3 " + sys.argv[0] + " path-to-file [-verbose] [-set-verbchar=verbatim-character]")
+ elif len(sys.argv) == 4 and sys.argv[2] != "-verbose" and sys.argv[3][0:-1] != "-set-verbchar=":
+ if sys.argv[2] != "-verbose":
+ print(sys.argv[2] + " Invalid specifier!")
+ if sys.argv[3][0:-1] != "-set-verbchar=":
+ print(sys.argv[3] + " Invalid specifier!")
+ print("Usage: python3 + " + sys.argv[0] + " path-to-file [-verbose] [-set-verbchar=verbatim-character]")
+ else:
+ verb_char = None
+ verbose_mode = False
+ if len(sys.argv) == 4:
+ verbose_mode = True
+ verb_char = sys.argv[3][-1]
+ elif len(sys.argv) == 3:
+ if sys.argv[2] == "-verbose":
+ verbose_mode = True
+ else:
+ verb_char = sys.argv[2][-1]
+ try:
+ c = src.counter.Counter(sys.argv[1], verbose_mode, verb_char)
+ c.run()
+ c.print_result()
+ except Exception as err:
+ print()
+ print("Problem occurred!")
+ print(err)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/support/optexcount/src/color_print.py b/support/optexcount/src/color_print.py
new file mode 100644
index 0000000000..6ae62facac
--- /dev/null
+++ b/support/optexcount/src/color_print.py
@@ -0,0 +1,29 @@
+class Printer:
+ """
+ Class for printing string with specific color
+ Color list: blue, green, cyan, red, white
+ """
+ def __init__(self):
+ self.__BLUE = '\033[1;34;48m'
+ self.__GREEN = '\033[1;32;48m'
+ self.__CYAN = '\033[1;36;48m'
+ self.__RED = '\033[1;31;48m'
+ self.__TERM = '\033[1;37;0m'
+
+ def print_c(self, text, color):
+ print(color + text + self.__TERM, end='')
+
+ def blue(self, text):
+ self.print_c(text, self.__BLUE)
+
+ def green(self, text):
+ self.print_c(text, self.__GREEN)
+
+ def cyan(self, text):
+ self.print_c(text, self.__CYAN)
+
+ def red(self, text):
+ self.print_c(text, self.__RED)
+
+ def white(self, text):
+ print(text, end='')
diff --git a/support/optexcount/src/counter.py b/support/optexcount/src/counter.py
new file mode 100644
index 0000000000..e666e6788d
--- /dev/null
+++ b/support/optexcount/src/counter.py
@@ -0,0 +1,466 @@
+import src.keywords as kw
+import src.word_iterator as wi
+import src.header as hd
+import src.color_print as cp
+
+
+class Counter:
+ """
+ Class that analyzes a source code and counts word counts
+ """
+
+ def __init__(self, filename, color_print=False, verb_char=None):
+ self.word_iter = wi.WordIterator(filename) # source of words that will be analyzed
+ if verb_char is not None:
+ self.word_iter.add_separator(verb_char)
+ self.verb_char = verb_char # used for inline verbatim text
+ self.color_print = color_print # input text will be printed(with colors)
+ self.printer = cp.Printer()
+ self.regular_words_count = 0
+ self.header_words_count = 0
+ self.caption_words_count = 0
+ self.figure_float_count = 0
+ self.math_inline_count = 0
+ self.math_count = 0
+ self.all_headers = []
+ """
+ Three possible types of __context:
+ 1) regular-text (implicit)
+ 2) headers
+ 3) captions
+ """
+ self.__context = "regular-text"
+
+ def run(self):
+ """
+ Main method of the class
+ Loads all words and initializes the analysis
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "\\bye":
+ self.__process_word(pair)
+ pair = self.word_iter.read()
+ if pair is not None:
+ self.print_keyword(pair)
+ self.print_irrelevant_word(("", "\n"))
+
+ def print_result(self):
+ """
+ Generates formatted output of the counter
+ """
+ print("Text words summary: " + str(self.regular_words_count))
+ print("Header words summary: " + str(self.header_words_count))
+ print("Caption and notes words summary: " + str(self.caption_words_count))
+ print("Headers summary: " + str(len(self.all_headers)))
+ print("Figure/float count: " + str(self.figure_float_count))
+ print("Inline math formulae count: " + str(self.math_inline_count))
+ print("Math formulae count: " + str(self.math_count))
+ print("Subcounts: (header-words-count + text-words-count + caption-words-count)")
+ for header in self.all_headers:
+ print(header)
+
+ def print_counted_word(self, pair):
+ """
+ Prints word that was counted. The color depends on category of the word.
+ """
+ if not self.color_print:
+ return
+ if self.__context == "regular-text":
+ self.printer.blue(pair[0]+pair[1])
+ elif self.__context == "header":
+ self.printer.cyan(pair[0]+pair[1])
+ elif self.__context == "caption":
+ self.printer.green(pair[0]+pair[1])
+
+ def print_keyword(self, pair):
+ """
+ Prints keyword - word with red color
+ """
+ if not self.color_print:
+ return
+ self.printer.red(pair[0]+pair[1])
+
+ def print_irrelevant_word(self, pair):
+ """
+ Prints words that wasn't counted and are not important for our functionality, like commentary words etc...
+ """
+ if not self.color_print:
+ return
+ self.printer.white(pair[0]+pair[1])
+
+ def __process_word(self, pair):
+ """
+ Decides how to treat with word from argument
+ """
+ if len(pair[0]) == 0 or pair[0] == "\n": # empty word or newline
+ self.print_irrelevant_word(pair)
+ elif pair[0] == "%":
+ self.print_irrelevant_word(pair)
+ self.__skip_commentary()
+ elif pair[0] == "{":
+ self.print_irrelevant_word(pair)
+ self.__load_curly_brackets()
+ elif pair[0] == "$":
+ self.print_keyword(pair)
+ self.__load_inline_formulae()
+ elif pair[0] == "$$":
+ self.print_keyword(pair)
+ self.__load_formulae()
+ elif self.verb_char is not None and pair[0] == self.verb_char:
+ self.print_keyword(pair)
+ self.__load_verbatim(self.verb_char)
+ elif self.__is_keyword(pair[0]):
+ self.__process_keyword(pair)
+ else:
+ self.__process_text_word(pair)
+
+ def __process_keyword(self, pair):
+ """
+ Treats with keywords.
+ Calls action on known keywords that are important for the counter
+ If keyword is unknown it is skipped
+ """
+ word, arg = self.__split_keyword(pair[0])
+ self.print_keyword((word, ''))
+ if arg is None:
+ self.print_irrelevant_word(('', pair[1]))
+ else:
+ self.print_irrelevant_word((arg, pair[1]))
+ if word == '\\tit':
+ self.all_headers.append(hd.Header("title"))
+ self.__load_header()
+ elif word == '\\chap':
+ self.all_headers.append(hd.Header("chapter"))
+ self.__skip_brackets("[", "]")
+ self.__load_header()
+ elif word == '\\sec':
+ self.all_headers.append(hd.Header("section"))
+ self.__skip_brackets("[", "]")
+ self.__load_header()
+ elif word == '\\secc':
+ self.all_headers.append(hd.Header("subsection"))
+ self.__skip_brackets("[", "]")
+ self.__load_header()
+ elif word == '\\begitems':
+ self.__load_list()
+ elif word == '\\caption':
+ self.__skip_brackets("[", "]")
+ self.__load_caption()
+ elif word == '\\fnote' or word == '\\fnotetext' or word == '\\mnote':
+ self.__load_footnote()
+ elif word in kw.keywords_list:
+ if word in kw.floats_keywords:
+ self.figure_float_count += 1
+ self.__read_arguments(word)
+ elif word == '\\begtt':
+ self.__skip_commentary()
+ self.__load_verbatim()
+ elif word == '\\verbchar' or word == '\\activettchar': # keywords with same functionality
+ self.__set_verb_char(word, arg, pair[1])
+ elif word == '\\code':
+ self.__load_code_verbatim()
+ elif word in kw.logos:
+ self.__load_logo(word, arg, pair[1])
+ else:
+ pass # skip unknown keywords
+
+ def __process_text_word(self, pair):
+ """
+ Increases word counts based on the word location - word context
+ """
+ # word with only one character that is not alphanumeric won't be counted as word
+ if len(pair[0]) == 0:
+ self.print_irrelevant_word(pair)
+ elif len(pair[0]) == 1 and not pair[0].isalnum():
+ self.print_irrelevant_word(pair)
+ elif self.__context == "regular-text":
+ self.print_counted_word(pair)
+ self.regular_words_count += 1
+ if len(self.all_headers):
+ self.all_headers[-1].add_text_word()
+ elif self.__context == "header":
+ self.print_counted_word(pair)
+ self.header_words_count += 1
+ self.all_headers[-1].add_header_word(pair[0])
+ elif self.__context == "caption":
+ self.print_counted_word(pair)
+ self.caption_words_count += 1
+ if len(self.all_headers):
+ self.all_headers[-1].add_caption_word()
+
+ @staticmethod
+ def __is_keyword(word):
+ """
+ Decides whether word is keyword or not
+ """
+ if len(word) >= 3:
+ if word[0] == '\\' and word[1].isalpha() and word[2].isalpha():
+ return True
+ return False
+
+ @staticmethod
+ def __split_keyword(word):
+ """
+ Splits word to two part - keyword and its argument
+ For example:
+ '\verbchar"' will be splitted into pair: '\verbchar', '"'
+ """
+ for i in range(1, len(word)):
+ if not word[i].isalpha():
+ return word[:i], word[i:]
+ return word, None
+
+ def __load_header(self):
+ """
+ Loads header
+ It reads the source code until new line occurs.
+ In case of ^^J at the end of the line it reads until next new line occurs.
+ """
+ orig_context = self.__context
+ self.__context = 'header'
+ pair = self.word_iter.read()
+ skip_new_line = False
+ while pair is not None and pair[0] != "\\bye":
+ if not len(pair[0]):
+ self.print_irrelevant_word(pair)
+ elif pair[0] == "\n":
+ self.print_irrelevant_word(pair)
+ if not skip_new_line:
+ self.__context = orig_context
+ return
+ skip_new_line = False
+ elif pair[0] == "^^J":
+ self.print_irrelevant_word(pair)
+ skip_new_line = True
+ else:
+ self.__process_word(pair)
+ skip_new_line = False
+ pair = self.word_iter.read()
+ self.__context = orig_context
+ if pair is not None:
+ self.__process_keyword(pair)
+
+ def __load_list(self):
+ """
+ Loads list - words that are surrounded by '\begitems' and '\enditems'
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "\\enditems":
+ if pair[0] != "*":
+ self.__process_word(pair)
+ else:
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ if pair is None:
+ raise Exception("No list ending found - \\enditems")
+ else:
+ self.print_keyword(pair)
+
+ def __load_caption(self):
+ """
+ Loads caption - words until EOL
+ """
+ orig_context = self.__context
+ self.__context = 'caption'
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "\\bye":
+ if pair[0] == "\n":
+ self.print_irrelevant_word(pair)
+ self.__context = orig_context
+ return
+ else:
+ self.__process_word(pair)
+ pair = self.word_iter.read()
+ self.__context = orig_context
+ if pair is not None:
+ self.print_keyword(pair)
+
+ def __load_footnote(self):
+ """
+ Loads footnote(block in curly brackets)
+ """
+ orig_context = self.__context
+ self.__context = 'caption'
+ pair = self.word_iter.read()
+ if pair is None:
+ raise Exception("No opening curly bracket found!")
+ while len(pair[0]) == 0 or pair[0].isspace():
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ if pair[0] != "{":
+ self.__context = orig_context
+ self.word_iter.push_back(pair)
+ return
+ self.print_irrelevant_word(pair)
+ self.__load_curly_brackets()
+ self.__context = orig_context
+
+ def __load_formulae(self):
+ """
+ Loads math formulae($$ as separator)
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "$$":
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ if pair is None:
+ raise Exception("No end of math formulae found!")
+ else:
+ self.print_keyword(pair)
+ self.math_count += 1
+
+ def __load_inline_formulae(self):
+ """
+ Loads inline math formulae($ as separator)
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "$":
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ self.math_inline_count += 1
+ if pair is None:
+ raise Exception("No end of inline math formulae found!")
+ else:
+ self.print_keyword(pair)
+
+ def __load_verbatim(self, ending="\\endtt", keyword_print=True):
+ """
+ Reads words until ending(param) word occurs.
+ These words are processed as regular word(not keywords etc...)
+ """
+ pair = self.word_iter.read()
+ while pair is not None and ending != pair[0]:
+ self.__process_text_word(pair)
+ pair = self.word_iter.read()
+ if pair is None:
+ raise Exception("Verbatim text not terminated!")
+ else:
+ if keyword_print:
+ self.print_keyword(pair)
+ else:
+ self.print_irrelevant_word(pair)
+
+ def __load_code_verbatim(self):
+ """
+ In case of verbatim using "\code" keyword
+ """
+ pair = self.word_iter.read()
+ while len(pair[0]) == 0 or pair[0].isspace():
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ if pair[0] != "{":
+ raise Exception("\\Code must be followed be opening curly bracket('{')!")
+ self.print_irrelevant_word(pair)
+ self.__load_verbatim("}", False)
+
+ def __load_logo(self, logo, arg, sep):
+ """
+ Checks whether logo keyword is followed by slash etc...
+ """
+ if arg != '/' or len(sep) > 0:
+ pass
+ elif self.__context == "regular-text":
+ self.regular_words_count += 1
+ if len(self.all_headers):
+ self.all_headers[-1].add_text_word()
+ elif self.__context == "header":
+ self.header_words_count += 1
+ self.all_headers[-1].add_header_word(logo)
+ elif self.__context == "caption":
+ self.caption_words_count += 1
+ if len(self.all_headers):
+ self.all_headers[-1].add_caption_word()
+
+ def __set_verb_char(self, word, arg, sep):
+ """
+ Loads new character for inline verbatim
+ """
+ if arg is not None and len(arg) == 1:
+ self.verb_char = arg
+ self.word_iter.add_separator(arg)
+ elif arg is None and sep == '':
+ pair = self.word_iter.read()
+ if len(pair[0]) != 1:
+ raise Exception("Invalid use of " + word)
+ else:
+ self.print_irrelevant_word(pair)
+ self.verb_char = pair[0]
+ self.word_iter.add_separator(pair[0])
+ else:
+ raise Exception("Invalid use of " + word)
+
+ def __read_arguments(self, word):
+ """
+ Loads from keywords file what arguments has got particular keyword from argument
+ These arguments are skipped - not important for our purpose
+ """
+ params = kw.keywords_list[word]
+ for p in params:
+ if p == "O":
+ pass # this case is managed by '__process_keyword' method
+ elif p == "W":
+ self.__obligatory_argument()
+ elif p == "S":
+ self.__skip_brackets("[", "]")
+ elif p == "P":
+ self.__skip_brackets("(", ")")
+ elif p == "C":
+ self.__skip_brackets("{", "}")
+ else: # unknown specifier - no argument expected
+ pass
+
+ def __obligatory_argument(self):
+ """
+ Just reads another word. In case of the end of source file Exception is thrown
+ """
+ pair = self.word_iter.read()
+ if pair is None or pair[0] == "\\bye":
+ raise Exception("No obligatory argument found")
+ self.print_irrelevant_word(pair)
+ return pair
+
+ def __load_curly_brackets(self):
+ """
+ Loads block of source code in curly brackets
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "}":
+ self.__process_word(pair)
+ pair = self.word_iter.read()
+ if pair is None:
+ raise Exception("No closing bracket ('}') found.")
+ else:
+ self.print_irrelevant_word(pair)
+
+ def __skip_brackets(self, opening, closing):
+ """
+ Skips block of source code in brackets opening-closing
+ """
+ pair = self.word_iter.read()
+ bracket_count = 0
+ while True:
+ if pair is None:
+ raise Exception("No closing bracket ('" + closing + "') found.")
+ elif pair[0] == opening:
+ bracket_count += 1
+ self.print_irrelevant_word(pair)
+ elif pair[0] == closing:
+ bracket_count -= 1
+ self.print_irrelevant_word(pair)
+ if bracket_count <= 0:
+ if pair[0] != closing:
+ self.word_iter.push_back(pair)
+ break
+ elif pair[0] != opening and pair[0] != closing:
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+
+ def __skip_commentary(self):
+ """
+ Skips entire line
+ """
+ pair = self.word_iter.read()
+ while pair is not None and pair[0] != "\n":
+ self.print_irrelevant_word(pair)
+ pair = self.word_iter.read()
+ self.print_irrelevant_word(pair)
diff --git a/support/optexcount/src/header.py b/support/optexcount/src/header.py
new file mode 100644
index 0000000000..e6e4b2e0ce
--- /dev/null
+++ b/support/optexcount/src/header.py
@@ -0,0 +1,27 @@
+class Header:
+ """
+ Class represents header (all types - title, chapter, section, subsection) and its word counts
+ """
+ def __init__(self, header_type):
+ self.type = header_type # title, chapter, section, subsection
+ self.words = []
+ self.header_count = 0
+ self.text_count = 0
+ self.caption_count = 0
+
+ def add_header_word(self, word):
+ self.words.append(word)
+ self.header_count += 1
+
+ def add_text_word(self):
+ self.text_count += 1
+
+ def add_caption_word(self):
+ self.caption_count += 1
+
+ def __str__(self):
+ result = " " + self.type + " ("
+ result += str(self.header_count) + " + " + str(self.text_count) + " + " + str(self.caption_count) + ")"
+ for word in self.words:
+ result += " " + word
+ return result
diff --git a/support/optexcount/src/keywords.py b/support/optexcount/src/keywords.py
new file mode 100644
index 0000000000..e8604d751b
--- /dev/null
+++ b/support/optexcount/src/keywords.py
@@ -0,0 +1,48 @@
+"""
+List of known keywords that has got some arguments
+"O" - strOke argument
+"W" - argument Without brackets
+"S" - argument in Square brackets
+"P" - argument in Parentheses
+"C" - argument in Curly brackets
+"""
+keywords_list = {
+ "\\ii": ["W", "W"],
+ "\\label": ["S"],
+ "\\ref": ["S"],
+ "\\pgref": ["S"],
+ "\\caption": ["0"],
+ "\\begmulti": ["W"],
+ "\\cite": ["S"],
+ "\\rcite": ["S"],
+ "\\bib": ["S"],
+ "\\usebib": ["O", "P", "W"],
+ "\\load": ["S"],
+ "\\fontfam": ["S"],
+ "\\typosize": ["S"],
+ "\\typoscale": ["S"],
+ "\\thefontsize": ["S"],
+ "\\thefontscale": ["S"],
+ "\\inspic": ["W"],
+ "\\table": ["C", "C"],
+ "\\hyperlinks": ["C", "C"],
+ "\\outlines": ["C"],
+ "\\magscale": ["S"],
+ "\\margins": ["O", "W", "P", "W"],
+ "\\style": ["W"],
+ "\\url": ["C"],
+ "\\loadmath": ["C"],
+ "\\everytt": ["C"],
+ "\\eqmark": ["S"]
+}
+
+"""
+List of keywords that introduce some floats, we want to be counted in section table/floats/figures
+Pay attention! This keyword MUST be introduced in keyword_list too, otherwise it won't count words properly!
+"""
+floats_keywords = ["\\table", "\\inspic"]
+
+"""
+List of keywords of logos
+"""
+logos = ["\\TeX", "\\OpTeX", "\\LuaTeX", "\\XeTeX", "\\OPmac", "\\CS", "\\csplain"] \ No newline at end of file
diff --git a/support/optexcount/src/word_iterator.py b/support/optexcount/src/word_iterator.py
new file mode 100644
index 0000000000..f68eacbc62
--- /dev/null
+++ b/support/optexcount/src/word_iterator.py
@@ -0,0 +1,112 @@
+import re
+
+
+class WordIterator:
+ """
+ A basic wrapper for sequential reading of words from file
+ """
+
+ def __init__(self, filename):
+ self.filename = filename
+ self.word_queue = []
+ self.line_payload = 50 # how many lines will be loaded into the queue at one time
+ self.__lines_count = sum(1 for line in open(filename))
+ self.__load_line = 1 # index of first line which haven't been already loaded into the queue
+ self.__separators = []
+
+ def read(self):
+ """
+ Returns first word from file that wasn't already read by this particular object.
+ Return value format: (word, separator)
+ When all words had been read, it returns None
+ """
+ if len(self.word_queue) == 0:
+ self.__load_payload()
+ if len(self.word_queue) == 0:
+ return None
+ else:
+ return self.word_queue.pop(0)
+
+ def push_back(self, word):
+ """
+ Pushes word from argument into the first position of the queue
+ In case we already read a word but we want to re-read it again
+ """
+ self.word_queue = [word] + self.word_queue
+
+ def add_separator(self, sep):
+ """
+ All words will be separated with sep separator
+ """
+ if sep in self.__separators:
+ return
+ self.__separators.append(sep)
+ new_queue = []
+ regex_arg = re.compile('(' + sep + ')')
+ for word, sep in self.word_queue:
+ new_word = re.sub(regex_arg, r' \1 ', word)
+ new_words = new_word.split(' ')
+ new_queue += self.__make_pairs(word + sep, new_words)
+ self.word_queue = new_queue
+
+ def __load_payload(self):
+ """
+ Loads words from input file into the queue
+ Format of words: (word, separator)
+ """
+ index = 0
+ with open(self.filename, 'r') as file:
+ for line in file:
+ index += 1
+ if index < self.__load_line:
+ continue
+ elif index < self.__load_line + self.line_payload:
+ self.word_queue += self.__parse_words(line)
+ if index >= self.__lines_count:
+ index += 1
+ else:
+ break
+ self.__load_line = index
+
+ def __parse_words(self, line):
+ """
+ Parses a line passed by argument using regular expressions.
+ It separates each word on the line and stores it into list.
+ returns list of tuples (word, separator between word and next word)
+ """
+ orig_line = line
+ if line == "\n" or line == "\r\n":
+ return self.__make_pairs(orig_line, [line])
+ # All non escape occurrences of some characters are seperated to be a single 'word'
+ line = re.sub(r'(?<!\\)(?:\\\\)*([{}\[\]()%])', r' \1 ', line)
+ # $$ and $ are separated from the text to be a single 'word'
+ line = re.sub(r'(?<!\\)(?:\\\\)*((\$\$)|(\$))', r' \1 ', line)
+ # All escaped alphabetic characters are separated from the previous word
+ line = re.sub(r'(?<!\\)(\\\\)*(\\)([A-Za-z])', r'\1 \2\3', line)
+ # Non escaped character ~ is replaced with space
+ line = re.sub(r'(?<!\\)(?:\\\\)*(~)', r' \1 ', line)
+ # Iterate through every separator and put spaces around them
+ for sep in self.__separators:
+ line = re.sub('(' + sep + ')', r' \1 ', line)
+ words_on_line = re.split(r'\s+', line)
+ # At the end of every nonempty line newline character is placed
+ words_on_line.append("\n")
+ return self.__make_pairs(orig_line, words_on_line)
+
+ @staticmethod
+ def __make_pairs(orig_line, words):
+ """
+ Generates list of tuples (word, separator between the word and the next word in list)
+ """
+ pairs = []
+ read_index = 0
+ for i in range(len(words)):
+ if i + 1 >= len(words):
+ start = orig_line[read_index:].find(words[i]) + len(words[i]) + read_index
+ pairs.append((words[i], orig_line[start:]))
+ else:
+ start = orig_line[read_index:].find(words[i]) + len(words[i]) + read_index
+ end = orig_line[start:].find(words[i+1]) + start
+ pairs.append((words[i], orig_line[start: end]))
+ read_index = end
+ return pairs
diff --git a/support/optexcount/tests/final_bird.png b/support/optexcount/tests/final_bird.png
new file mode 100644
index 0000000000..889d3d12d3
--- /dev/null
+++ b/support/optexcount/tests/final_bird.png
Binary files differ
diff --git a/support/optexcount/tests/main_test.tex b/support/optexcount/tests/main_test.tex
new file mode 100644
index 0000000000..77a79f8a76
--- /dev/null
+++ b/support/optexcount/tests/main_test.tex
@@ -0,0 +1,146 @@
+% This optex source code is partialy copied from http://petr.olsak.net/tat/priklad-optex.tex
+% text words: 221
+% header words: 15
+% caption words: 14
+
+
+\chyph % české vzory dělení slov
+\fontfam[Schola] % fontová rodina TeXGyre Schola
+\margins/1 a4 (3,3,3,3)cm % okraje 3cm ze všech stran pro stranu A4
+\typosize[11/13] % velikost písma 11pt na 13pt řádkování
+\activettchar" % znak " bude ohraničovat řádkový verbatim
+\hyperlinks\Blue\Green % interní odkazy modré, webové odkazy zelené
+\outlines0 % klikací obsah po straně PDF prohlížeče
+
+\def\center{\noindent\hfil} % zkratka pro centrování
+
+\tit Ukázka \OpTeX u
+
+\sec Základní struktura
+
+Dokument se skládá z odstavců (ve zdrojovém textu jsou odděleny prázdnými řádky)
+a dále z kapitol, sekcí a podsekcí.
+
+\secc Výčty
+
+V textu můžeme používat výčty:
+
+\begitems
+* první
+* druhý
+\enditems
+
+
+Někdy mohou být výčty vnořeny:
+
+\begitems
+* První
+* Druhý.
+ \begitems \style a
+ * Podproblém,
+ * ještě jeden podproblém,
+ * poslední podproblém.
+ \enditems
+* Třetí.
+* Poslední.
+\enditems
+
+
+\secc Vyznačování
+
+Text můžeme zdůraznit {\it kurzívou}, nebo {\bf tučně}.
+
+\secc[poznamky] Poznámky
+
+Poznámka pod čarou\fnote{Vypadá takto.} je automaticky číslovaná.
+Může jich být více\fnote{Druhá poznámka.}.
+
+
+\sec[dalsi] Další sekce
+
+\secc Verbatim text
+
+Vložíme {\it verbatim text}, tedy text \uv{tak jak je} bez interpretace
+\TeX{}em:
+
+Výčet:
+\begtt
+\begitems
+* První
+* Druhý.
+\enditems
+\endtt
+
+Kromě toho je možné psát "#kusy {kódů}" přímo v textu odstavce.
+
+\secc Obrázky
+
+Obrázky se do odborného textu obvykle vkládají včetně popisku.
+
+\midinsert \label[ptacek]
+ \center \picw=7cm \inspic final_bird.png
+ \medskip
+ \caption/f Hlavní textura hry Flappy Bird
+\endinsert
+
+
+\secc Odkazy
+
+Na automaticky číslované objekty je možné odkazovat. Ve zdrojovém dokumentu
+je třeba použít {\it lejblík} v místě cíle a stejný lejblík v místě odkazu.
+Odkazy vypadají například takto: viz sekci~\ref[dalsi] na
+straně~\pgref[dalsi], dále v podsekci~\ref[poznamky] je zmínka o poznámkách
+pod čarou a rovnice~\ref[rce] na straně~\pgref[rce] uvádí zajímavou
+matematickou myšlenku. Každý jistě poznal, že na obrázku~\ref[ptacek] se
+nachází karikatura ptáčka.
+
+Vnější odkazy směřují obvykle na webové stránky,
+např.~\url{http://petr.olsak.net/opmac.html}.
+
+\secc Tabulky
+
+Na tabulky se používá "\hbox" / "\vbox" aritmetika.
+
+\bigskip
+\center\table{||l|cc||}{\crl \tskip.5ex
+ & \multispan2 \hfil počet \qquad\hfil\vrule\kern\vvkern\vrule\strut\cr
+ makro & řádků kódu & stran dokumentace \crli \tskip.5ex
+ plain & 1241 & 100 \cr
+ OPmac & 1600 & 19 \crli \tskip.5ex
+ \LaTeX{} (jádro) & 8000 & 240 \cr
+ hyperref & 24773 & 423 \cr
+ color + graphics & 2469 & 81 \crli \tskip.5ex
+ Ti{\it k}Z & 1\,634\,882 & 726 \crli \tskip.5ex
+ Con\TeX{}t & 1\,155\,673 & 547 \crl
+ }
+\nobreak\medskip
+\caption/t Makra a jejich rámcový rozsah
+\bigskip
+
+V tabulce ve zdrojovém textu je jednak záhlaví s pravidlem, jak mají být
+formátována jednotlivá pole tabulky, a dále data oddělená od sebe smluvenými
+oddělovači.
+
+\secc Matematika
+
+V řádku se píše matematika mezi dolary: $a^2+b^2=c^2$. Nebo je možno sestavit
+samostatnou rovnici obklopenou dvojicí dolarů:
+
+\label[rce]
+$$
+ \int x^\alpha {\rm d}x = \cases {
+ x^{\alpha+1} \over \alpha+1 & pro $\alpha\not=-1$ \cr \noalign{\medskip}
+ \ln x & pro $\alpha=-1 $
+ }
+ \eqmark
+$$
+Vzorce se zapisují zhruba tak, jak bychom je anglicky přečetli.
+
+
+
+$$
+ {\bbchar A} = \pmatrix{ a & b & c \cr d & e & f \cr g & h & i}.
+$$
+Toť na úvod vše.
+
+\bye
diff --git a/support/optexcount/tests/test-01.tex b/support/optexcount/tests/test-01.tex
new file mode 100644
index 0000000000..fc19d0db3e
--- /dev/null
+++ b/support/optexcount/tests/test-01.tex
@@ -0,0 +1,39 @@
+% Basic test source code of optex.
+% Test of text and header counts
+% Correct counts:
+% text count - 50
+% header count - 35
+
+
+\chyph
+\fontfam[Schola]\typosize[11/13]
+
+\tit Pouze a jen pouze ukazkovy nadpis
+
+Tento text neni zarazen do zadneho bloku
+
+\secc Je mozne udelat podparagraf rovnou?
+
+To zjistime...
+
+\sec Nase prvni sekce
+
+Dokument se skládá z odstavců (ve zdrojovém textu jsou odděleny prázdnými řádky)
+a dále z kapitol, sekcí a podsekcí.
+
+\secc Nejaky text
+
+A toto je nejaky text.
+Co dale?
+
+\chap KILL BILL Chapter one
+
+\secc Tento nadpis je pouzit pro vyzkouseni velice dlouheho nadpisu.\nl Pojdme tento nadpis jeste prodlouzit.
+
+Lorem ipsum dolor sit amet.
+
+\secc Poznámky
+
+Jedna dve tri ctyri, 5 sest sedm osm devet deset
+
+\bye
diff --git a/support/optexcount/tests/test-02.tex b/support/optexcount/tests/test-02.tex
new file mode 100644
index 0000000000..10987b98ea
--- /dev/null
+++ b/support/optexcount/tests/test-02.tex
@@ -0,0 +1,41 @@
+% Basic test source code of optex.
+% Test of text and header counts
+% Same as first test but with multiple lines header
+% Correct counts:
+% text count - 50
+% header count - 35
+
+
+\chyph
+\fontfam[Schola]\typosize[11/13]
+
+\tit Pouze a jen pouze ukazkovy nadpis
+
+Tento text neni zarazen do zadneho bloku
+
+\secc Je mozne udelat podparagraf rovnou?
+
+To zjistime...
+
+\sec Nase prvni sekce
+
+Dokument se skládá z odstavců (ve zdrojovém textu jsou odděleny prázdnými řádky)
+a dále z kapitol, sekcí a podsekcí.
+
+\secc Nejaky text
+
+A toto je nejaky text.
+Co dale?
+
+\chap KILL BILL Chapter one
+
+\secc Tento nadpis je pouzit pro ^^J
+vyzkouseni velice dlouheho nadpisu.\nl Pojdme tento nadpis jeste prodlouzit.
+
+Lorem ipsum dolor sit amet.
+
+\secc Poznámky
+
+Jedna dve tri ctyri, 5 sest sedm osm devet deset
+
+\bye
diff --git a/support/optexcount/tests/test-03.tex b/support/optexcount/tests/test-03.tex
new file mode 100644
index 0000000000..438db664b9
--- /dev/null
+++ b/support/optexcount/tests/test-03.tex
@@ -0,0 +1,33 @@
+% Correct counts
+% text count - 26
+% header count - 7
+
+\chyph
+\fontfam[Schola]
+
+\tit Zkouska listů
+
+\sec Nejaky nadpis s nejakum textem
+
+\begitems \style i
+* Odrazka prvni
+* Co dale?
+* Neco jineho:
+\begitems
+\begitems
+* Jedna dve
+* Honza jde
+\enditems
+* Jedna dve
+* Honza jde
+\enditems
+* Nese pytel mouky
+\enditems
+
+\begitems
+* Prvni odrazka
+* Druha * A rovnou dalsi odrazka
+* Posledni odrazka
+\enditems
+
+\bye
diff --git a/support/optexcount/tests/test-04.tex b/support/optexcount/tests/test-04.tex
new file mode 100644
index 0000000000..3fbdd9a4f0
--- /dev/null
+++ b/support/optexcount/tests/test-04.tex
@@ -0,0 +1,55 @@
+% Correct counts
+% text count - 31
+% header count - 8
+% caption count - 5
+
+\chyph
+\fontfam[Schola]
+
+\tit Zkouska listů
+
+Uvodni slovo k nasemu souboru
+
+\chap[Znacka na prvni kapitolu]Kapitolka
+
+\sec [Znacka na prvni sekci] Nejaky nadpis s nejakum textem
+
+\begitems \style i
+* Odrazka prvni
+* Co dale?
+* Neco jineho:
+\begitems
+\begitems
+* Jedna dve
+* Honza jde
+\enditems
+* Jedna dve
+* Honza jde
+\enditems
+* Nese pytel mouky
+\enditems
+
+\begitems
+* Prvni odrazka
+* Druha * A rovnou dalsi odrazka
+* Posledni odrazka
+\enditems
+
+% Table copied from http://petr.olsak.net/tat/priklad-optex.tex
+\bigskip
+\center\table{||l|cc||}{\crl \tskip.5ex
+ & \multispan2 \hfil počet \qquad\hfil\vrule\kern\vvkern\vrule\strut\cr
+ makro & řádků kódu & stran dokumentace \crli \tskip.5ex
+ plain & 1241 & 100 \cr
+ OPmac & 1600 & 19 \crli \tskip.5ex
+ \LaTeX{} (jádro) & 8000 & 240 \cr
+ hyperref & 24773 & 423 \cr
+ color + graphics & 2469 & 81 \crli \tskip.5ex
+ Ti{\it k}Z & 1\,634\,882 & 726 \crli \tskip.5ex
+ Con\TeX{}t & 1\,155\,673 & 547 \crl
+}
+\nobreak\medskip
+\caption/t Makra a jejich rámcový rozsah
+\bigskip
+
+\bye
diff --git a/support/optexcount/tests/test-05.tex b/support/optexcount/tests/test-05.tex
new file mode 100644
index 0000000000..5f88f0f11c
--- /dev/null
+++ b/support/optexcount/tests/test-05.tex
@@ -0,0 +1,28 @@
+% Correct counts
+% text count - 11
+% header count - 13
+% caption count - 13
+
+\chyph
+\fontfam[Schola]
+
+\tit Zkouska různých popisků
+
+Uvodni slovo k nasemu souboru
+
+\sec [Znacka na prvni sekci] Nejaky nadpis s nejakum textem
+
+Tady se nachazi {\it nejaký {\bf zvýrazněný \it textík }}
+
+\secc Zobrazení nějakého obrázku s popiskem
+
+\midinsert \label[ptacek]
+ \noindent\hfil \picw=9cm \inspic final_bird.png
+ \medskip
+ \caption/f Toto je oficiální grafika ptáčka hry {\bf Flappy bird}.
+\endinsert
+
+\noindent\hfil\table{||c|c|c|c|c|c||}{\crl 1 & 2 & 3 & 5 & 8 & 13 \crl}
+\bigskip\caption/t [Propracovaná tabulka] Čísla jakožto součet dvou předchozích.
+
+\bye
diff --git a/support/optexcount/tests/test-06.tex b/support/optexcount/tests/test-06.tex
new file mode 100644
index 0000000000..132193735a
--- /dev/null
+++ b/support/optexcount/tests/test-06.tex
@@ -0,0 +1,31 @@
+% Correct counts
+% text count - 15
+% header count - 13
+% caption count - 23
+
+\chyph
+\fontfam[Schola]
+
+\tit Zkouska různých popisků
+
+Uvodni slovo k nasemu souboru
+
+\sec [Znacka na prvni sekci] Nejaky nadpis s nejakum textem
+
+Tady se nachazi \fnote{Nějaká poznámka pod čarou}{\it nejaký {\bf zvýrazněný \it textík }}
+
+\secc Zobrazení nějakého obrázku s popiskem
+
+Rychle vložíme nějaký text \mnote{Další poznámečka}
+
+\midinsert \label[ptacek]
+ \noindent\hfil \picw=9cm \inspic final_bird.png
+ \medskip
+ \caption/f Toto je oficiální grafika ptáčka hry {\bf Flappy bird}\fnotemark1
+\endinsert
+\fnotetext{Tato hra již nedostupná}.
+
+\noindent\hfil\table{||c|c|c|c|c|c||}{\crl 1 & 2 & 3 & 5 & 8 & 13 \crl}
+\bigskip\caption/t [Propracovaná tabulka] Čísla jakožto součet dvou předchozích.
+
+\bye \ No newline at end of file
diff --git a/support/optexcount/tests/test-07.tex b/support/optexcount/tests/test-07.tex
new file mode 100644
index 0000000000..dafc96ffea
--- /dev/null
+++ b/support/optexcount/tests/test-07.tex
@@ -0,0 +1,35 @@
+% Correct counts
+% text count - 34
+% header count - 4
+% caption count - 11
+
+\chyph
+\fontfam[Schola]
+\margins/1 a4 (3,3,3,3)cm
+\typosize[11/13]
+\activettchar`
+\hyperlinks\Blue\Green
+\outlines0
+
+\tit Matematika
+
+Matematika v řádku: $a^2+b^2=c^2$. Další způsob:
+
+\label[Nějaká matice]
+$$
+ {\bbchar C} = \pmatrix{ x & 0 & 0 \cr 0 & y & 0 \cr 0 & 0 & z}, kde \; x, y, z \neq 0
+$$
+
+\chap[Kusy kódu] Zkouška základního verbatimu
+
+\begtt
+Tady je pořádný verbatim text.
+Zde mohu klidně psát klíčová slova jako \tit nebo \begtt a nikomu to nevadí.
+\endtt
+\fnote{Toto krásně funguje, že?}
+
+A co se stane, když uděláme `verbatim text` takto inline?
+
+\fnote{Nic, neboť `\activettchar` nebo `\verbchar` krásně fungují.}
+
+\bye