Skip to content

Commit

Permalink
Fix "implicit index"
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed May 17, 2021
1 parent e6fd5b1 commit f1bb432
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mkdocs_literate_nav/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def make_nav(
assert section.tag in _LIST_TAGS
result = []
if first_item is not None:
seen_items.add(first_item)
if type(first_item) is str:
seen_items.add(first_item)
result.append({None: first_item})
for item in section:
assert item.tag == "li"
Expand Down Expand Up @@ -176,7 +177,7 @@ def make_nav(
if error:
raise LiterateNavParseError(error, item)

if isinstance(out_item, str):
if type(out_item) is str:
seen_items.add(out_item)
result.append({out_title: out_item})

Expand Down
20 changes: 20 additions & 0 deletions tests/markdown_to_nav/nested/test_borgs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
files:
- index.md
- baz.md
- borgs/index.md
- borgs/bar.md
- borgs/foo.md
navs:
/: |
* [Frob](index.md)
* [Baz](baz.md)
* [Borgs](borgs/)
/borgs: |
* [Bar](bar.md)
* [Foo](foo.md)
output:
- Frob: index.md
- Baz: baz.md
- Borgs:
- Bar: borgs/bar.md
- Foo: borgs/foo.md
21 changes: 21 additions & 0 deletions tests/markdown_to_nav/nested/test_borgs_implicit_index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
files:
- index.md
- baz.md
- borgs/index.md
- borgs/bar.md
- borgs/foo.md
navs:
/: |
* [Baz](baz.md)
* [Borgs](borgs/)
/borgs: |
* [Bar](bar.md)
* [Foo](foo.md)
implicit_index: true
output:
- null: index.md
- Baz: baz.md
- Borgs:
- null: borgs/index.md
- Bar: borgs/bar.md
- Foo: borgs/foo.md

0 comments on commit f1bb432

Please sign in to comment.