From 1204fe6e28e9e60e6b122282462029eef6f8e0c6 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Thu, 28 Mar 2024 17:27:30 +0100 Subject: [PATCH] add command to modify markdown --- .../df-wiki-cli/df_wiki_cli/content/main.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/df-wiki-cli/df_wiki_cli/content/main.py b/packages/df-wiki-cli/df_wiki_cli/content/main.py index ac707257..751e7d48 100644 --- a/packages/df-wiki-cli/df_wiki_cli/content/main.py +++ b/packages/df-wiki-cli/df_wiki_cli/content/main.py @@ -413,6 +413,45 @@ def refseq_type_count( grouped_per_type.reset_index().to_csv(output, index=False) +@app.command() +def markdown( + dir: Annotated[ + Path, + typer.Option( + exists=True, + file_okay=False, + writable=True, + readable=True, + resolve_path=True, + help="Dir where all systems article are", + ), + ], + # output: Annotated[ + # Path, + # typer.Option( + # file_okay=True, + # dir_okay=False, + # writable=True, + # resolve_path=True, + # ), + # ], +): + + for file in dir.iterdir(): + if file.suffix == ".md": + + console.rule(f"[bold blue]{file.name}", style="blue") + with open(file, "r+") as f: + new_f = re.sub( + r"##\s+Structure\n.+##\s+Experimental\s+validation", + "## Structure\n\n::article-structure\n::\n\n## Experimental validation", + f.read(), + flags=re.DOTALL, + ) + f.seek(0, 0) + f.write(new_f) + + def remove_version(assembly): return assembly.split(".")[0] -- GitLab