diff --git a/sample/A/problem.toml b/sample/A/problem.toml index 069b275..907f08f 100644 --- a/sample/A/problem.toml +++ b/sample/A/problem.toml @@ -8,12 +8,14 @@ params_path = "./tests/constraints.hpp" [[statements]] path = "./statement/statement_ja.md" lang = "ja" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] [[statements]] path = "./statement/statement_en.md" lang = "en" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] # write constraints [constraints] - MIN_AB = 1 - MAX_AB = 1_000_000_000 +MIN_AB = 1 +MAX_AB = 1_000_000_000 diff --git a/sample/B/problem.toml b/sample/B/problem.toml index 09c17da..3d55fe4 100644 --- a/sample/B/problem.toml +++ b/sample/B/problem.toml @@ -9,10 +9,11 @@ params_path = "./tests/constraints.hpp" [[statements]] path = "./statement/statement.md" lang = "ja" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] # 問題制約を書く [constraints] - MIN_N = 1 - MAX_N = 100_000 - N_IS_ODD = "$N$ は奇数であることが保証される" - GIVEN_STRING_IS_LOWERCASE = "与えられる文字列は英小文字のみからなる" +MIN_N = 1 +MAX_N = 100_000 +N_IS_ODD = "$N$ は奇数であることが保証される" +GIVEN_STRING_IS_LOWERCASE = "与えられる文字列は英小文字のみからなる" diff --git a/sample/C/problem.toml b/sample/C/problem.toml index a7546c0..e99fc1a 100644 --- a/sample/C/problem.toml +++ b/sample/C/problem.toml @@ -8,30 +8,34 @@ params_path = "./tests/constraints.hpp" [[statements]] path = "./statement/en/statement_1.md" lang = "en" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] [[statements]] path = "./statement/en/statement_2.md" lang = "en" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] [[statements]] path = "./statement/ja/statement_1.md" lang = "ja" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] [[statements]] path = "./statement/ja/statement_2.md" lang = "ja" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] # write constraints [constraints] - MIN_A = -1_000_000_000 - MAX_A = +1_000_000_000 - - MIN_N_SMALL = 1 - MAX_N_SMALL = 1000 - MIN_Q_SMALL = 1 - MAX_Q_SMALL = 1000 - - MIN_N_LARGE = 1 - MAX_N_LARGE = 100_000 - MIN_Q_LARGE = 1 - MAX_Q_LARGE = 100_000 \ No newline at end of file +MIN_A = -1_000_000_000 +MAX_A = +1_000_000_000 + +MIN_N_SMALL = 1 +MAX_N_SMALL = 1000 +MIN_Q_SMALL = 1 +MAX_Q_SMALL = 1000 + +MIN_N_LARGE = 1 +MAX_N_LARGE = 100_000 +MIN_Q_LARGE = 1 +MAX_Q_LARGE = 100_000 diff --git a/sample/D/problem.toml b/sample/D/problem.toml index b1d757e..9028bbf 100644 --- a/sample/D/problem.toml +++ b/sample/D/problem.toml @@ -7,11 +7,12 @@ params_path = "./tests/constraints.hpp" # path to statements [[statements]] path = "./statement/statement.md" -lang = "en" # 見出しを英語にするため +lang = "en" # 見出しを英語にするため +markdown_extensions = ["md_in_html", "tables", "fenced_code"] # write constraints [constraints] - MIN_AB = 1 - MAX_AB = 1_000_000_000 - MIN_T = 1 - MAX_T = 100_000 +MIN_AB = 1 +MAX_AB = 1_000_000_000 +MIN_T = 1 +MAX_T = 100_000 diff --git a/sample/H/problem.toml b/sample/H/problem.toml index 85e085a..52b90cb 100644 --- a/sample/H/problem.toml +++ b/sample/H/problem.toml @@ -12,13 +12,14 @@ params_path = "./tests/constraints.hpp" path = "1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns" # path = "https://docs.google.com/document/d/1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns/edit?usp=sharing" lang = "en" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] [constraints] - MIN_N = 1 - MAX_N = 1000 - MIN_C = 1 - MAX_C = 100_000 - MIN_Q = 1 - MAX_Q = 100_000 - MIN_D = 1 - MAX_D = 100_000 +MIN_N = 1 +MAX_N = 1000 +MIN_C = 1 +MAX_C = 100_000 +MIN_Q = 1 +MAX_Q = 100_000 +MIN_D = 1 +MAX_D = 100_000 diff --git a/sample/I/problem.toml b/sample/I/problem.toml index 149be06..890a5b5 100644 --- a/sample/I/problem.toml +++ b/sample/I/problem.toml @@ -12,8 +12,9 @@ assets_path = "./statement/assets/" [[statements]] path = "./statement/statement.md" lang = "ja" +markdown_extensions = ["md_in_html", "tables", "fenced_code"] # 問題制約を書く [constraints] - MIN_N = 1 - MAX_N = 10000 +MIN_N = 1 +MAX_N = 10000 diff --git a/statements_manager/src/project.py b/statements_manager/src/project.py index 826feaf..17d7f51 100644 --- a/statements_manager/src/project.py +++ b/statements_manager/src/project.py @@ -60,11 +60,15 @@ def _check_project(self) -> None: "statement_path", "mode", "lang", + "markdown_extensions", ] for problem in self.problem_attr.values(): for key in problem.keys(): if key not in acceptable_attr: logger.warning( + "" + if "id" not in problem.keys() + else f"problem {problem['id']}: " f"unknown attribute in problem setting file: '{key}'" ) @@ -88,6 +92,7 @@ def _check_statement_info(self, statement_info: dict[str, Any]): "path", # これは後で 'statement_path' に置換される "lang", "mode", + "markdown_extensions", ] for key in statement_info.keys(): if key not in acceptable_attr: diff --git a/statements_manager/src/renderer.py b/statements_manager/src/renderer.py index 4de794c..082c41f 100644 --- a/statements_manager/src/renderer.py +++ b/statements_manager/src/renderer.py @@ -159,14 +159,12 @@ def generate_html( rendered_contents = self.replace_vars( problem_attr[problem_id], contents ) + markdown_extensions = [ + self.replace_sample_format, + *problem_attr[problem_id].get("markdown_extensions", list()), + ] rendered_contents = markdown( - rendered_contents, - extensions=[ - self.replace_sample_format, - "md_in_html", - "tables", - "fenced_code", - ], + rendered_contents, extensions=markdown_extensions ) problem_attr[problem_id]["statement"] = rendered_contents