-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YaLafi to handle LaTeX syntax (recognize begin/end of environments) #239
Comments
Thank you for opening this issue. To add these packages to YaLafi, you would basically need to implement a python version of them. How to do that is sketched here (see also here). However, I don’t think that is needed in your case. If a command (call it In your case I would suggest to use
Now YaLafi should check both languages simultaneously. If you really want to check only one language at a time, one would at least need to implement an Feel free to ask further questions if something is still unclear. I have also not explicitly tested the above. PS: You can use ```latex
\documentclass{scrartcl}
...
``` |
Hello Torik42, If for the given file (minimal example in "samplefiles.zip" in my last comment), all comments and all German parts would be stripped out, this would be ok for me. The attachment "samplefiles-filtered.zip" in this comment contains two samples of what I would expect as a result from the filters and what then can be handed over to LanguageTool. Is this something what YaLafi already can handle, or do I have to wait till you or one of the other contributors implemented this new issue? I really appreciate this work and if you need a beta tester, please let me know. |
My initial suggestion was to check both languages simultaneously, by just setting the language in each of your two environment. Indeed, YaLafi can handle You can use the following python code saved as from yalafi.defs import Environ, InitModule
require_packages = []
def init_module(parser, options, position):
parms = parser.parms
macros_latex = ''
macros_python = []
environments = [
Environ(parms, 'de', remove=True, add_pars=False),
]
return InitModule(macros_latex=macros_latex, macros_python=macros_python,
environments=environments) It will remove the Since YaLafi does not know the Alternatively, you can check both languages simultaneously. For that hide the preamble from YaLafi using: %%% LT-SKIP-BEGIN
…
%%% LT-SKIP-END Then, use the following saved as from yalafi.defs import Environ, InitModule
require_packages = []
def init_module(parser, options, position):
parms = parser.parms
macros_latex = ''
macros_python = []
environments = [
Environ(parms, 'en', remove=False, repl=r'\selectlanguage{english}', add_pars=False),
Environ(parms, 'de', remove=False, repl=r'\selectlanguage{ngerman}', add_pars=False),
]
return InitModule(macros_latex=macros_latex, macros_python=macros_python,
environments=environments) and call YaLafi with \newcommand{\LTadd}[1]{}
\LTadd{\usepackage[english,ngerman]{babel}}
\LTadd{\newcommand{\deen}[2]{{\selectlanguage{ngerman}#1} {\selectlanguage{english}#2}}} to your preamble so that YaLafi loads Edit: Fix missing bracket. |
You could probably also skip the last part and put the commands within macros_latex = '''
\usepackage[english,ngerman]{babel}}
\newcommand{\deen}[2]{{\selectlanguage{ngerman}#1} {\selectlanguage{english}#2}}
'''
within `auto.py`. |
Hello Torik42, thanks a lot for your last answer. (1) By using en.py as additional package, the following YaLafi command worked very well. This now ignored everything in the "de" environments:
And the same worked independently when wished to ignore the "en" environments. (2) I modified your suggestion to substitute \iftoggle in all tex files with a newcommand \deen (since YaLafi does not know the ifthen package). It was easier to do something similar only once in the document header:
See the attached minimal sample "m-language-switch.tex" in the zip file. Thanks again for your great help. These changes reduced the number of "problems" found by LanguageTool We recently had a discussion about language checks of LaTeX documents at DANTE. If you would like to give an introduction to YaLafi please let me know. You could write to my email address directly. |
I am glad that it worked.
If you want to keep the
If you want to remove more comment environments, you can – for now – just add more Environ(parms, 'environment_to_be_ignored', remove=True, add_pars=False), statements to |
Hello Torik42,
Thanks again for your help. |
That was my fault. As initially written, it should be
|
PS: Could you please answer my DANTE question above. I'd like to remove my email address again. |
I'd like to check a larger document. The according LaTeX sources (several tex files are included in the main document) contain many comments and the main document has a switch at the beginning so that from the same sources both a German and an English version of the PDF can be created. See the attached minimal example, where \begin{en} ... \end{en} is such an environment, which is only handled by LaTeX if the English language is selected. A second way to control the languages apart is \iftoggle{en} (also see the minimal example).
However, I still get way too many false positives because it also reads the comments and the switched off language, and sends them to LanguageTool.
For the minimal example, here is the call to YaLafi and the output (on a Ubuntu bash terminal):
How can I make the packages "comment", "ifthen" and "etoolbox" be known to YaLafi?
In addition to the minimal example "main_two_languages.tex", I attached the output (the file "t1.html"): 15 lines of text are output there, with only one line needed: the one with the misspelled word "misspellingx" in line 56.
If I just missed an option YaLafi already has or if you need more information, please send me a message. Thanks a lot.
PS: Concerning the minimal example: As GitHub said, "tex" and "html" are not supported as file types for an attachment, the two sample files are in the attached zip file.
samplefiles.zip
The text was updated successfully, but these errors were encountered: