Skip to content

Commit

Permalink
add property: markdown_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutaj committed Sep 9, 2023
1 parent 3de135b commit fc95608
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 40 deletions.
6 changes: 4 additions & 2 deletions sample/A/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions sample/B/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "与えられる文字列は英小文字のみからなる"
28 changes: 16 additions & 12 deletions sample/C/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
11 changes: 6 additions & 5 deletions sample/D/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 9 additions & 8 deletions sample/H/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions sample/I/problem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions statements_manager/src/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
)

Expand All @@ -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:
Expand Down
12 changes: 5 additions & 7 deletions statements_manager/src/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fc95608

Please sign in to comment.