import re from gmirator.generate import ( process_file, process_list, process_inline, repl_url, repl_heading ) def test_process_file(): pass def test_process_list_legit_item(): test_str = "* this is a list item" assert process_list(test_str, True) == (f"
  • {test_str[2:]}
  • ", True) assert process_list(test_str, False) == (f"\n\n{test_str}", False) assert process_list(test_str, False) == (test_str, False) test_str = "*this is NOT a list item*" assert process_list(test_str, True) == (f"\n\n{test_str}", False) assert process_list(test_str, False) == (f"{test_str}", False) def test_process_list_empty_line(): assert process_list("", True) == ("\n\n", False) assert process_list("", False) == ("", False) def test_process_inline(): assert process_inline("*Hello* ~~world~~!") == "Hello world!" def test_repl_url_external_gmi_url(): external_url = "=> gemini://domain/gempage.gmi\n" new_url = re.sub(r'^=> (?P[^ ]*) ?(?P.*)\n', repl_url, external_url) assert new_url == '=> gemini://domain/gempage.gmi
    \n' def test_repl_url_internal_gmi_url(): external_url = "=> /gempage.gmi title\n" new_url = re.sub(r'^=> (?P[^ ]*) ?(?P.*)\n', repl_url, external_url) assert new_url == '=> title
    \n' def test_repl_heading(): line = "# this is h1 title" html_h1 = re.sub(r'^(#+) (.*)', repl_heading, line) line = "## this is h2 title" html_h2 = re.sub(r'^(#+) (.*)', repl_heading, line) line = "### this is h3 title" html_h3 = re.sub(r'^(#+) (.*)', repl_heading, line) assert html_h1 == "

    # this is h1 title

    " assert html_h2 == "

    ## this is h2 title

    " assert html_h3 == "

    ### this is h3 title

    " def test_repl_heading_h4(): line = "#### this is h4 title" html_h4 = re.sub(r'^(#+) (.*)', repl_heading, line) assert html_h4 == "

    #### this is h4 title

    "