Explorar el Código

Ability to display orphan fragments

master
David Larlet hace 4 años
padre
commit
ed213aa943
No se encontró ninguna clave conocida en la base de datos para esta firma
Se han modificado 1 ficheros con 13 adiciones y 5 borrados
  1. 13
    5
      site.py

+ 13
- 5
site.py Ver fichero

@@ -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

Cargando…
Cancelar
Guardar