-
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
Message generation by the basic LaTeX filter #180
Comments
This is exactly what I intended in #177 (see my comment there). But I will stick to your separation of the issues. Now to this one. I do not yet understand how all the code works together. Anyway I will put some thought here
Although I wrote ‘empty string’ above, I think it would be nice if some kind of mark is written to the output in case it produces extra errors. This could be made optional. Also, it is helpful in plain text output to have these. One could also think about removing all LT errors which report a misspelled |
Thank you for the thoughts!
Yes, this is roughly the plan. (But
See first point.
This would then be done "automatically" by
Yes, I was already thinking about these points, too. There are some subtle interdepencies to be taken into account. |
Thank you for all the answers. I already played a little with this idea yesterday:
It should also work pretty well without too many modifications to the code. Here is a quick sketch. Don’t take it too seriously, but it already yields reasonable results. I can put more effort into this next week. Just let me know. In the end you know the code a lot better. The mockup class ErrorToken(TextToken):
def __init__(self, pos, txt, id, short_msg, msg, pos_fix=True):
super().__init__(pos, txt)
self.error = {
'offset': 0,
'length': 1,
'context': {
'text': 'sometext',
'offset': 0,
'length': 1,
},
'rule': {'id': id, 'category': {'name': 'YY_LATEX_ERROR'}},
'message': msg,
'replacements': [],
} In def get_txt_pos_err(toks):
txt = ''
pos = []
errors = []
for t in toks:
txt += t.txt
if type(t) is defs.ErrorToken:
error = t.error
error['offset'] = len(pos)
errors.append(error)
if t.pos_fix:
pos += [t.pos] * len(t.txt)
else:
pos += list(range(t.pos, t.pos + len(t.txt)))
return txt, pos, errors And also output the error Too also support errors for nested calls (i.e. So far, this obviously only works for certain settings (e.g. no multilanguage) but the changes should be straight forward. EDIT: By the way, this would show you errors of nested |
This is in principle the scheme I'm also thinking about. As you also point out, there are quite some things to consider, if one wants to achieve a solution of good quality. In part, this is also due to the "not so tidy" internal structure of the software. So, if you need a quick solution for your application, then you are of course free to modify the tool for your needs. On the other hand, this is a hobby project, and I would like to "hack" the core parts on my own. (I see an effort of more than a few days. In other words, I'd like to slow down.) By the way, 'token' is a technical term in compiler building. It is perhaps misplaced for the messages between the core LaTeX filter and an application like |
Sure. I just don’t want to open issues and expect that you solve them. There is also really no need to hurry. Have fun hacking!
I don’t know compiler building at all. But I called it |
Currently, the basic filter
yalafi
provides the plain text and a map for character positions. In order to indicate certain problems as LaTeX-related errors, a special mark has to be inserted in the plain text that then is detected by the proofreading software.We should add a third "channel" between
yalafi
andyalafi.shell
with complete messages that can be inserted just as currently for option --single-letters (which is implemented inyalafi.shell
). When using the base filteryalafi
in isolation, one could save these messages in a JSON file.We first need to resolve issue #169.
A first application could be direct injection of LaTeX-related problems (cf. issue #177), then we could shift processing of option --single-letters and --equation-punctuation to core
yalafi
, and finally we perhaps could generate better messages for problems in displayed equations (for instance, issue #158).In all cases, we would not need to insert special marks (or repeated words) to be found by the proofreading program, any more.
The text was updated successfully, but these errors were encountered: