use beautifulsoup to derive title from HTML h1
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
1
tests/instance/pages/no-title-or-h1.md
Normal file
1
tests/instance/pages/no-title-or-h1.md
Normal file
@@ -0,0 +1 @@
|
||||
there's just some words here but no title tag or h1
|
||||
1
tests/instance/pages/no-title-subdir/index.md
Normal file
1
tests/instance/pages/no-title-subdir/index.md
Normal file
@@ -0,0 +1 @@
|
||||
there's just some words here but no title tag or h1
|
||||
1
tests/instance/pages/no-title-subdir/no-title-or-h1.md
Normal file
1
tests/instance/pages/no-title-subdir/no-title-or-h1.md
Normal file
@@ -0,0 +1 @@
|
||||
there's just some words here but no title tag or h1
|
||||
@@ -146,11 +146,33 @@ def test_parse_md_metadata_forced_no_title():
|
||||
assert page_title == 'example.org'
|
||||
|
||||
|
||||
def test_parse_md_metadata_no_title_so_path():
|
||||
def test_parse_md_metadata_no_title_so_h1():
|
||||
"""Test the direct results of parsing a markdown file."""
|
||||
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'subdir/index.md'), PAGES_DIR)
|
||||
assert page_name == '/subdir/'
|
||||
assert page_title == '/subdir/ - example.org'
|
||||
assert page_name == 'another page'
|
||||
assert page_title == 'another page - example.org'
|
||||
|
||||
|
||||
def test_parse_md_metadata_no_title_or_h1_so_path():
|
||||
"""Test the direct results of parsing a markdown file."""
|
||||
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'no-title-or-h1.md'), PAGES_DIR)
|
||||
assert page_name == '/no-title-or-h1'
|
||||
assert page_title == '/no-title-or-h1 - example.org'
|
||||
|
||||
|
||||
def test_parse_md_metadata_no_title_or_h1_so_path_dir():
|
||||
"""Test the direct results of parsing a markdown file."""
|
||||
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'no-title-subdir/index.md'), PAGES_DIR)
|
||||
assert page_name == '/no-title-subdir/'
|
||||
assert page_title == '/no-title-subdir/ - example.org'
|
||||
|
||||
|
||||
def test_parse_md_metadata_no_title_or_h1_so_path_dir_file():
|
||||
"""Test the direct results of parsing a markdown file."""
|
||||
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'no-title-subdir/no-title-or-h1.md'),
|
||||
PAGES_DIR)
|
||||
assert page_name == '/no-title-subdir/no-title-or-h1'
|
||||
assert page_title == '/no-title-subdir/no-title-or-h1 - example.org'
|
||||
|
||||
|
||||
def test_parse_md_no_file():
|
||||
|
||||
Reference in New Issue
Block a user