Przeglądaj źródła

Ability to display orphan fragments

master
David Larlet 4 lat temu
rodzic
commit
ed213aa943
Nie znaleziono w bazie danych klucza dla tego podpisu
1 zmienionych plików z 13 dodań i 5 usunięć
  1. 13
    5
      site.py

+ 13
- 5
site.py Wyświetl plik

@@ -124,11 +124,19 @@ class Page:


@cli
def fragment(title: str):
"""Create a new fragment and open it in iA Writer."""
fragment_path = DAVID / "2020" / "fragments" / f"{title}.md"
open(fragment_path, "w+").write(f"## {title}")
os.popen(f'open -a "iA Writer" "{fragment_path}"')
def orphans():
"""Print out fragments not linked to any page."""
linked_fragments = []
for file_path in each_markdown_from(DAVID / "2020"):
for line in open(file_path).readlines():
if line.startswith(".. include:: fragments/"):
linked_fragments.append(line[len(".. include:: fragments/") : -1])
all_fragments = []
for file_path in each_markdown_from(DAVID / "2020" / "fragments"):
all_fragments.append(file_path[len("david/2020/fragments/") :])
for fragment_filename in set(all_fragments) - set(linked_fragments):
# Prepending path for easy command+click from fish.
print(DAVID / "2020" / "fragments" / fragment_filename)


@cli

Ładowanie…
Anuluj
Zapisz