在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sylvainhalle/textidote开源软件地址(OpenSource Url):https://github.com/sylvainhalle/textidote开源编程语言(OpenSource Language):Java 90.6%开源软件介绍(OpenSource Introduction):TeXtidote: a correction tool for LaTeX documents and other formatsHave you ever thought of using a grammar checker on LaTeX files? If so, you probably know that the process is far from simple. Since LaTeX documents contain special commands and keywords (the so-called "markup") that are not part of the "real" text, you cannot run a grammar checker directly on these files: it cannot tell the difference between markup and text. The other option is to remove all this markup, leaving only the "clear" text; however, when a grammar tool points to a problem at a specific line in this clear text, it becomes hard to retrace that location in the original LaTeX file. TeXtidote solves this problem; it can read your original LaTeX file and perform various sanity checks on it: for example, making sure that every figure is referenced in the text, enforcing the correct capitalization of titles, etc. In addition, TeXtidote can remove markup from the file and send it to the Language Tool library, which performs a verification of both spelling and grammar in a dozen languages. What is unique to TeXtidote is that it keeps track of the relative position of words between the original and the "clean" text. This means that it can translate the messages from Language Tool back to their proper location directly in your source file. You can see the list of all the rules checked by TeXtidote at the end of this file. TeXtidote also supports spelling and grammar checking of files in the Markdown format. Getting TeXtidoteYou can either install TeXtidote by downloading it manually, or by installing it using a package. Under Debian systems: install packageUnder Debian systems (Ubuntu and derivatives), you can install TeXtidote using
The Manual downloadYou can also download the TeXtidote executable manually: this works on all operating systems. Simply make sure you have Java version 8 or later installed on your system. Then, download the latest release of TeXtidote; put the JAR in the folder of your choice. Using TeXtidoteTeXtidote is run from the command line. The TeXtidote repository contains a sample LaTeX file called example.tex. Download this file and save it to the folder where TeXtidote resides. You then have the choice of producing two types of "reports" on the contents of your file: an "HTML" report (viewable in a web browser) and a "console" report. HTML reportTo run TeXtidote and perform a basic verification of the file, run:
In Linux, if you installed TeXtidote using
Here, the
Once the process is over, switch to your favorite web browser, and open the
file As you can see, the page shows your original LaTeX source file, where some portions have been highlighted in various colors. These correspond to regions in the file where an issue was found. You can hover your mouse over these colored regions; a tooltip will show a message that describes the problem. If you don't write any filename (or write Plain reportTo run TeXtidote and display the results directly in the console, simply omit
the
TeXtidote will analyze the file like before, but produce a report that looks like this:
Each element of the list corresponds to a "warning", indicating that something in the text requires your attention. For each warning, the position in the original source file is given: LxxCyy indicates line xx, column yy. The warning is followed by a short comment describing the issue, and an excerpt from the line in question is displayed. The range of characters where the problem occurs is marked by the "^^^^" symbols below the text. Each of these warnings results from the evaluation of some "rule" on the text; an identifier of the rule in question is also shown between brackets. Single line reportAnother option to display the results directly in the console is the single line report:
Textidote will analyze the file like before, but this time the report looks like this:
Each line corresponds to a warning, and is parseable by regular expressions easily, e.g., for further processing in another tool. The file is given at the beginning of the line, followed by the position in parentheses. Then, the warning message is given, and the excerpt causing the warning is printed in double quotes (""). Note, that sometimes it may happen that a position cannot be determined. In this case, instead of LxxCyy, ? is printed. You can disable the use of color in any form of command-line output using the
Spelling, grammar and styleYou can perform further checks on spelling and grammar, by passing the
The Additionally, the
The language codes you can use are:
Using a dictionaryIf you have a list of words that you want TeXtidote to ignore when checking
spelling, you can use the
The file If you already spell checked you file using Aspell and
saved a local dictionary
(as is done for example by the
PaperShell environment),
TeXtidote can automatically load this dictionary when invoked. More
specifically, it will look for a file called
Ignoring rulesYou may want to ignore some of TeXtidote's advice. You can do so by specifying
rule IDs to ignore with the
If you want to ignore multiple rules, separate their IDs with a comma (but no space). Ignoring environmentsTeXtidote can be instructed to remove user-specified environments using the
This command will remove all text lines between Ignoring macrosThe same can be done with macros:
This command will remove all occurrences of use-defined command Replacing stringsBefore TeXtidote analyses a file, you can ask it to apply a set of find/replace operations (for example, to replace a macro by some predefined character string). You can write these patterns into a text file and pass them to the program at the command line:
Here,
Replacement rules are applied line-wise, so multiline replacements are not possible. Reading a sub-fileBy default, TeXtidote ignores everything before the TeXtidote also automatically follows sub-files that are embedded from a main document using Removing markupYou can also use TeXtidote just to remove the markup from your original LaTeX
file. This is done with the option
By default, the resulting "clean" file is printed directly at the console. To save it to a file, use a redirection:
You will see that TeXtidote performs a very aggressive deletion of LaTeX markup:
Surprisingly, the result of applying these modifications is a text that is clean and legible enough for a spelling or grammar checker to provide sensible advice. As was mentioned earlier, TeXtidote keeps a mapping between character ranges
in the "cleaned" file, and the same character ranges in the original LaTeX
document. You can get this mapping by using the
The
The first entry indicates that characters 1 to 24 in the first line of the clean file correspond to characters 5 to 28 in the first line of the original LaTeX file --and so on. This mapping can have "holes": for example, character 25 line 1 does not correspond to anything in the original file (this happens when the "cleaner" inserts new characters, or replaces characters from the original file by something else). Conversely, it is also possible that characters in the original file do not correspond to anything in the clean file (this happens when the cleaner deletes characters from the original). Character encodingsTeXtidote uses the OS default encoding when reading files (e.g.
Using a configuration fileIf you need to run TeXtidote with many command line arguments (for example:
you load a local dictionary, ignore a few rules, apply replacements, etc.), it
may become tedious to invoke the program with a long list of arguments every
time. TeXtidote can be "configured" by putting those arguments in a text
file called
As you can see, arguments can be split across multiple lines. You can then call TeXtidote without any arguments like this:
If you call TeXtidote with command line arguments, they will be merged with
whatever was found in Markdown inputTeXtidote also supports files in the Markdown format. The only difference is that rules specific to LaTeX (references to figures, citations) are not evaluated. Simply call TeXtidote with a Markdown input file instead of a LaTeX file. The format is auto-detected by looking at the file extension. However, if you pass a file through the standard input, you must tell TeXtidote that the input file is Markdown by using the command line parameter Helping TeXtidoteIt order to get the best results when using TeXtidote, it is advisable that you follow a few formatting conventions when writing your LaTeX file:
As a rule, it is advisable to first see what your text looks like using the
If you realize that a portion of LaTeX markup is not handled properly and messes up the rest of the file, you can tell TeXtidote to ignore a region using a special LaTeX comment:
The lines between <!-- textidote: ignore begin -->
This should be ignored
<!-- textidote: ignore end --> Linux shortcutsTo make using TeXtidote easier, you can create shortcuts on your system. Here are a few recommended tips. First, we recommend you create a folder called Command line shortcut(This step is not necessary if TeXtidote has been installed with
Make this file executable by typing at the command line:
(These two operations also require root privileges.) From then on, you can
invoke TeXtidote on the command line from any folder by simply typing
Desktop shortcutIf you use a desktop environment such as Gnome or Xfce, you can automate
this even further by creating a TeXtidote icon on your desktop. First,
create a file called #!/bin/bash
if [ -x /usr/bin/notify-send ]; then
err() { notify-send -a TeXtidote -i /opt/textidote/textidote-icon.svg "$*"; }
else
err() { printf "%s\n" "$*" >&2; }
fi
[ $# -lt 1 ] && err "At least one file should be provided as input" && exit
dir=$(dirname "$1")
pushd "$dir" || err "$dir does not exist" && exit
java -jar /opt/textidote/textidote.jar --check en --output html "$@" > /tmp/textidote.html
popd || exit
xdg-open /tmp/textidote.html & This script enters into the directory of the file passed as an argument, calls TeXtidote, sends the HTML report to a temporary file, and opens the default web browser to show that report. Then, on your desktop (typically in your [Desktop Entry]
Version=1.0
Type=Application
Name=TeXtidote
Comment=Check text with TeXtidote
Exec=/opt/textidote/textidote-desktop.sh %F
Icon=/opt/textidote/textidote-icon.svg
Path=
Terminal=false
StartupNotify=false This will create a new desktop shortcut; make this file executable. From then on, you can drag LaTeX files from your file manager with your mouse and drop them on the TeXtidote icon. After the analysis, the report will automatically pop up in your web browser. Voilà! Tab completionsYou can auto-complete the commands you type at the command-line using the TAB
key (as you are probably used to). If you installed TeXtidote using ZshUsers of Zsh can also enable auto-completion; in your
(Create the file if it does not exist.) You must then restart your Zsh shell for the changes to take effect. Visual Studio Code integrationUsers of Visual Studio Code can integrate TeXtidote by calling it with the Emacs integrationEmacs users can benefit from TeXtidote through flycheck. (flycheck-define-checker tex-textidote
"A LaTeX grammar/spelling checker using textidote.
See https://github.com/sylvainhalle/textidote"
:modes (latex-mode plain-tex-mode)
:command ("java" "-jar" (eval (expand-file-name "~/PATH/TO/textidote.jar"))
"--read-all"
"--output" "singleline"
"--no-color"
"--check" (eval (if ispell-current-dictionary (substring ispell-current-dictionary 0 2) "en"))
;; Try to honor local aspell dictionary and replacements if they exist
"--dict" (eval (expand-file-name "~/.aspell.en.pws"))
"--replace" (eval (expand-file-name "~/.aspell.en.prepl"))
;; Using source ensures that a single temporary file in a different dir is created
;; such that textidote won't process other files. This serves as a hacky workaround for
;; https://github.com/sylvainhalle/textidote/issues/200.
source)
:error-patterns ((warning line-start (file-name)
"(L" line "C" column "-" (or (seq "L" end-line "C" end-column) "?") "): "
(message (one-or-more (not "\""))) (one-or-more not-newline) line-end)))
(add-to-list 'flycheck-checkers 'tex-textidote) Rules checked by TeXtidoteHere is a list of the rules that are checked on your LaTeX file by TeXtidote. Each rule has a unique identifier, written between square brackets. Language ToolIn addition to all the rules below, the If the Style
Citations and references
Figures
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论