@jutge.org/toolkit 4.2.6 → 4.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +133 -3
  2. package/assets/latex/root-pdf.tpl.tex +29 -0
  3. package/assets/latex/root-text.tpl.tex +34 -0
  4. package/assets/problems/demo/demo.pbm/README.md +24 -0
  5. package/assets/problems/demo/demo.pbm/award.html +1 -0
  6. package/assets/problems/demo/demo.pbm/award.png +0 -0
  7. package/assets/problems/demo/demo.pbm/campanar.png +0 -0
  8. package/assets/problems/demo/demo.pbm/handler.yml +2 -0
  9. package/assets/problems/demo/demo.pbm/jutge.png +0 -0
  10. package/assets/problems/demo/demo.pbm/jutge.svg +27 -0
  11. package/assets/problems/demo/demo.pbm/problem.en.tex +276 -0
  12. package/assets/problems/demo/demo.pbm/problem.en.yml +3 -0
  13. package/assets/problems/demo/demo.pbm/sample-1.inp +1 -0
  14. package/assets/problems/demo/demo.pbm/sample-2.inp +1 -0
  15. package/assets/problems/demo/demo.pbm/solution.py +5 -0
  16. package/assets/sty/{judgeit.sty → jutge.sty} +20 -16
  17. package/dist/index.js +529 -545
  18. package/docs/getting-started-guide.md +27 -254
  19. package/docs/install-linux.md +107 -0
  20. package/docs/install-macos.md +111 -0
  21. package/docs/install-windows.md +99 -0
  22. package/docs/problem-anatomy.md +4 -0
  23. package/package.json +10 -4
  24. package/toolkit/ask.ts +1 -1
  25. package/toolkit/convert.ts +72 -0
  26. package/toolkit/index.ts +2 -0
  27. /package/assets/sty/{judgeit.ca.sty → jutge.ca.sty} +0 -0
  28. /package/assets/sty/{judgeit.de.sty → jutge.de.sty} +0 -0
  29. /package/assets/sty/{judgeit.en.sty → jutge.en.sty} +0 -0
  30. /package/assets/sty/{judgeit.es.sty → jutge.es.sty} +0 -0
  31. /package/assets/sty/{judgeit.fr.sty → jutge.fr.sty} +0 -0
@@ -30,6 +30,8 @@ There are four types of problems in Jutge.org:
30
30
 
31
31
  - **Graphic problems**: Similar to standard problems but involve graphical output to file `output.png` rather than standard output, typically (but not necessarily) solved using Python's graphical libraries.
32
32
 
33
+ -- **Circuit problems**: A subtype of problems where users must implement digital circuits using the Verilog programming language. These problems use formal verification techniques and do not need test cases for evaluation. These are not covered in this document.
34
+
33
35
  - **Games**: Problems where users must implement an AI to play a game against other users or predefined strategies. These problems often involve turn-based gameplay and require users to implement specific functions to decide their moves. These are not covered in this document.
34
36
 
35
37
  - **Quizzes**: Problems where users must answer multiple-choice questions. These are not covered in this document.
@@ -236,6 +238,8 @@ There are also optional arguments that may be used:
236
238
 
237
239
  - `func_name`: Name of the function requested in case the problem only asks for a function (this must be used along with `source_modifier: no_main`).
238
240
 
241
+ - `hide_html`: If set to `1`, the statement will not be shown in HTML in the Jutge.org website; use it sparingly.
242
+
239
243
  - `invisible_main`: If set to `1`, the `main.cc` file will not be provided to users. This is used by problems that do not require writing a `main` function.
240
244
 
241
245
  - `presentation_error`: If set to `1` (by default), the PE (Presentation Error) verdict will be enabled. Otherwise, the verdict will be WA (Wrong Answer) if the files are not identical.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jutge.org/toolkit",
3
3
  "description": "Toolkit to prepare problems for Jutge.org",
4
- "version": "4.2.6",
4
+ "version": "4.2.8",
5
5
  "homepage": "https://jutge.org",
6
6
  "author": {
7
7
  "name": "Jutge.org",
@@ -21,6 +21,11 @@
21
21
  "type": "git",
22
22
  "url": "git+https://github.com/jutge-org/new-jutge-toolkit.git"
23
23
  },
24
+ "keywords": [
25
+ "jutge.org",
26
+ "cli",
27
+ "command line interface"
28
+ ],
24
29
  "publishConfig": {
25
30
  "access": "public"
26
31
  },
@@ -29,17 +34,18 @@
29
34
  "bin": {
30
35
  "jutge-toolkit": "dist/index.js",
31
36
  "jtk": "dist/index.js",
32
- "dev": "toolkit/index.ts"
37
+ "jtk-dev": "toolkit/index.ts"
33
38
  },
34
39
  "scripts": {
35
40
  "lint": "eslint .",
36
41
  "format": "bun prettier --write .",
37
42
  "depcheck": "bunx depcheck",
38
43
  "dev": "bun build --target bun --outfile dist/index.js ./toolkit --watch",
39
- "build": "bun build --target bun --minify --outfile dist/index.js ./toolkit ",
44
+ "build": "bun build --target bun --minify --outfile dist/index.js ./toolkit",
40
45
  "update-jutge-client": "(cd lib ; rm -f jutge_api_client.ts ; https --download https://api.jutge.org/clients/download/typescript)"
41
46
  },
42
47
  "files": [
48
+ "README.md",
43
49
  "dist",
44
50
  "toolkit",
45
51
  "docs",
@@ -67,7 +73,6 @@
67
73
  "nanoid": "^5.1.6",
68
74
  "openai": "^6.15.0",
69
75
  "ora": "^9.0.0",
70
- "prettier": "^3.7.4",
71
76
  "pretty-bytes": "^7.1.0",
72
77
  "pretty-ms": "^9.3.0",
73
78
  "radash": "^12.1.1",
@@ -82,6 +87,7 @@
82
87
  "zod-validation-error": "^5.0.0"
83
88
  },
84
89
  "devDependencies": {
90
+ "prettier": "^3.7.4",
85
91
  "typescript-eslint": "^8.51.0",
86
92
  "@types/archiver": "^7.0.0",
87
93
  "@types/image-size": "^0.8.0",
package/toolkit/ask.ts CHANGED
@@ -32,7 +32,7 @@ export async function loadDocumentation(): Promise<string> {
32
32
  const documentsDir = join(projectDir(), 'docs')
33
33
  const toolkitDir = join(projectDir(), 'toolkit')
34
34
 
35
- const documentPaths = await Array.fromAsync(glob('*.md', { cwd: documentsDir }))
35
+ const documentPaths = await Array.fromAsync(glob('*.{md,tex}', { cwd: documentsDir }))
36
36
  const sourcePaths = await Array.fromAsync(glob('*.ts', { cwd: toolkitDir }))
37
37
 
38
38
  const documents = await all(documentPaths.map((file) => readTextInDir(documentsDir, file)))
@@ -0,0 +1,72 @@
1
+ import { Command } from '@commander-js/extra-typings'
2
+ import { findRealDirectories } from '../lib/helpers'
3
+ import { newProblem } from '../lib/problem'
4
+ import tui from '../lib/tui'
5
+ import { readTextInDir, writeTextInDir } from '../lib/utils'
6
+
7
+ export const convertCmd = new Command('convert')
8
+ .description('Convert deprecated elements in problem statements to the new format')
9
+
10
+ .action(() => {
11
+ convertCmd.help()
12
+ })
13
+
14
+ convertCmd
15
+ .command('transform-at-signs')
16
+ .description('Transform @ signs to lstinline')
17
+
18
+ .option('-d, --directories <directories...>', 'problem directories', ['.'])
19
+
20
+ .action(async ({ directories }) => {
21
+ const realDirectories = await findRealDirectories(directories)
22
+
23
+ for (const realDirectory of realDirectories) {
24
+ await tui.section(`Processing ${realDirectory}`, async () => {
25
+ const problem = await newProblem(realDirectory)
26
+ for (const language of problem.languages) {
27
+ await tui.section(`Converting problem.${language}.tex`, async () => {
28
+ const originalText = await readTextInDir(realDirectory, `problem.${language}.tex`)
29
+ const convertedText = replaceAtSigns(originalText)
30
+ if (originalText !== convertedText) {
31
+ await writeTextInDir(realDirectory, `problem.${language}.tex`, convertedText)
32
+ await writeTextInDir(realDirectory, `problem.${language}.tex.original.bak`, originalText)
33
+ tui.success(
34
+ `Converted problem.${language}.tex, original backed up to problem.${language}.tex.original.bak`,
35
+ )
36
+ } else {
37
+ tui.warning(`No changes needed for problem.${language}.tex`)
38
+ }
39
+ })
40
+ }
41
+ })
42
+ }
43
+ })
44
+
45
+ /**
46
+ * Replaces all occurrences of @text@ with \lstinline|text|
47
+ *
48
+ * @param input - The input string to process
49
+ * @returns A new string with all @text@ patterns replaced with \lstinline|text|
50
+ *
51
+ * @remarks
52
+ * This function is designed to convert inline code markers from the @ syntax
53
+ * to LaTeX \lstinline syntax. It processes the input string and replaces all
54
+ * valid patterns while preserving invalid ones.
55
+ *
56
+ * Pattern matching rules:
57
+ * - Matches text enclosed between two @ symbols: @text@
58
+ * - The enclosed text must not contain @ symbols
59
+ * - The enclosed text must not contain newline characters (\n or \r)
60
+ * - The enclosed text must contain at least one character
61
+ * - All valid matches in the input are replaced (global replacement)
62
+ *
63
+ * @example
64
+ * Basic usage:
65
+ * ```typescript
66
+ * replaceAtSigns("Use @console.log()@ for debugging")
67
+ * // Returns: "Use \lstinline|console.log()| for debugging"
68
+ * ```
69
+ */
70
+ function replaceAtSigns(input: string): string {
71
+ return input.replace(/@([^@\n\r]+)@/g, '\\lstinline|$1|')
72
+ }
package/toolkit/index.ts CHANGED
@@ -19,6 +19,7 @@ import { quizCmd } from './quiz'
19
19
  import { upgradeCmd } from './upgrade'
20
20
  import { uploadCmd } from './upload'
21
21
  import { askCmd } from './ask'
22
+ import { convertCmd } from './convert'
22
23
 
23
24
  program.name(Object.keys(packageJson.bin as Record<string, string>)[0] as string)
24
25
  program.alias(Object.keys(packageJson.bin as Record<string, string>)[1] as string)
@@ -34,6 +35,7 @@ program.addCommand(makeCmd)
34
35
  program.addCommand(uploadCmd)
35
36
  program.addCommand(cleanCmd)
36
37
  program.addCommand(verifyCmd)
38
+ program.addCommand(convertCmd)
37
39
  program.addCommand(doctorCmd)
38
40
  if (settings.developer) {
39
41
  program.addCommand(quizCmd)
File without changes
File without changes
File without changes
File without changes
File without changes