Skip to content

Conversation

@gkreitz
Copy link
Contributor

@gkreitz gkreitz commented May 16, 2025

We used to have at least 3 implementations of code that found statements for a problem, all of them inconsistent. This makes use of the new methods in statement_util to unify the implementation. That fix blew up a bit, as it touched a lot of old parts (including our latex templates).

I opted not to maintain the "0.1" version of our latex templates any longer. Support for that is now removed. It seemed broken (rendering empty pdf:s) when I tested.

This PR also continues moving from str to pathlib.Path for paths. A lot of our code deals with paths, and I think using Path throughout the code is a significant improvement.

Improves our mypy configuration to not allow missing imports. As we are heavy users of a library without type annotations (plasTeX), I also made mypy follow untyped imports. It seems like plasTeX actually has a decent number of type annotations, just that they haven't marked the package as such.

Fixes an untracked bug where verifyproblem stopped after the first problem when one listed multiple problems.
Fixes #282
Closes #310

@gkreitz gkreitz force-pushed the refactor_statement_handling branch from fb0889d to 5184cc8 Compare May 16, 2025 12:30

def convert(problem: str, options: argparse.Namespace) -> bool:
def convert(problem_root: Path, options: argparse.Namespace, statement_file: Path) -> bool:
"""Convert a Markdown statement to HTML
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should document that output will be written to current working directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will it? I'm pretty sure it'll be written to destfile.

Copy link
Contributor

@Matistjati Matistjati May 16, 2025

Choose a reason for hiding this comment

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

Right, I meant from the perspective of this code, it's the current working directory. copy_image will dump images to the working directory (destdir). When I was reading this code by itself, I missed that "we are in output directory" is a precondition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Feels like that also goes into the follow-up that deals with the other issue you raised w.r.t. copy_image.

if os.path.isfile(img_src): # already copied
return
shutil.copyfile(source_name, img_src)
shutil.copyfile(statement_dir / img_src, img_src)
Copy link
Contributor

@Matistjati Matistjati May 16, 2025

Choose a reason for hiding this comment

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

Not your fault, but does this actually work as we expect it to? When I read the spec, I don't see subfolders being disallowed. https://www.kattis.com/problem-package-format/spec/2023-07-draft.html#problem-statements
I.e., what happens if img_src points to a subfolder in statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I'll leave that for a follow-up

@gkreitz gkreitz merged commit 6e9add7 into Kattis:develop May 16, 2025
4 checks passed
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.

Support for problem_statement latex version "0.1" seems broken (and I will remove it, instead of repairing) Error if problem name is empty

2 participants