Skip to content
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

326 warn if problemtitle differs from problemsettingsnamelanguage #329

Conversation

thorehusfeldt
Copy link
Collaborator

@thorehusfeldt thorehusfeldt commented Jan 15, 2024

For #326, compare problemtitle in problem.yaml and various {lang}.tex files.

The extraction of \problemname{foo} in problem.en.tex is handled by a new method in bin/latex.py. This is very bare-bones and would be confused by each of the following

% \problenname{No warning produced, though outcommented}
\problemname{
   foo
}

Somebody should run this on a large repository of existing problems and see how many false positive warnings it generates.

It warns if no problemname is found in the tex source, which makes the BAPCtools testsuite unhappy. Maybe that warning shouldn’t be there. On the other hand, the specification actually requires it:

https://github.com/Kattis/problem-package-format/blob/af5288b5c21d8a65ace08296ce7aecad8fdefdd2/spec/2023-07-draft.md?plain=1#L282

(and in the first line of the code!) so maybe it should be much stricter.

Copy link
Owner

@RagnarGrootKoerkamp RagnarGrootKoerkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly lgtm. Just 2 tiny things.

And indeed, would be nice if you could fix the empty problem.en.tex in tests/ so that tests pass again.

bin/problem.py Show resolved Hide resolved
bin/problem.py Outdated Show resolved Hide resolved
@thorehusfeldt
Copy link
Collaborator Author

I’ve now implemented the substring matching; looks like this:

             texname_letters = iter(texname)
                if not all(c in texname_letters for c in yamlname):
                    warn(f'Problem titles in problem.{lang}.tex ({texname})' +
                         f' and problem.yaml ({yamlname}) differ;' +
                         r' consider using \problemname{\problemyamlname}.'
                         )

Before I commit: Is this really what you want? It would accept

\problemname{A Slightly Different Problem}

when problem.yaml is

problem: { en: A Different Problem }

and similar situations, like https://open.kattis.com/problems/rationalsequence2 (which would not catch problem: { en: A Rational Sequence}. My own hunch is that markup in TeX problemtitles is less common than the above. I could be wrong.

@RagnarGrootKoerkamp
Copy link
Owner

For us we pretty much always use \problemyamlname unless the formatting is different, but maybe you're right.

We could also allow some way to disable the check, like \problemname{something different} % DISTINCTNAME. Then the check can be strict and users can simply disable the warning.

@mpsijm @mzuenni wdyt?

@thorehusfeldt
Copy link
Collaborator Author

Another idea is to disable the check as soon as texname contains \.

@RagnarGrootKoerkamp
Copy link
Owner

Oh, I like that! Feel free to implement.

@thorehusfeldt
Copy link
Collaborator Author

Can someone grep \\problemname\{^\\}(or something like that) in the full BAPC- and NWERC-library? Then we could get a better feeling for what kind of formatting actually appears in real life.

@RagnarGrootKoerkamp
Copy link
Owner

For BAPC we have:

  • \problemname{\texttt{git mv}}
  • \problemname{\texttt{apt upgrade}}

For NWERC we didn't deviate in the past 3 years.

@thorehusfeldt
Copy link
Collaborator Author

thorehusfeldt commented Jan 15, 2024

I did toy with the idea of removing matching \foo{} from \problemtitle but I don’t think this issue deserves that much attention. I think I’m done with my TODOs now.

Do note that 62a41b1 escalated warn to error, which is consistent with the specification (and now also with BAPCtools’s test suite.)

@RagnarGrootKoerkamp
Copy link
Owner

I did toy with the idea of removing matching \foo{} from \problemtitle but I don’t think this issue deserves that much attention.

Agreed.

I think I’m done with my TODOs now.

Do note that 62a41b1 escalated warn to error, which is consistent with the specification (and now also with BAPCtools’s test suite.)

👍

Thanks! Merging :)

@RagnarGrootKoerkamp RagnarGrootKoerkamp merged commit ad22bfc into master Jan 15, 2024
2 checks passed
@RagnarGrootKoerkamp RagnarGrootKoerkamp deleted the 326-warn-if-problemtitle-differs-from-problemsettingsnamelanguage branch January 15, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn if \problemtitle differs from problem.settings.name[language]
2 participants