Use the suffix so that the file is actually highlighted correctly
This commit is contained in:
parent
0f07d72249
commit
27a8165761
1 changed files with 13 additions and 3 deletions
|
@ -6,9 +6,10 @@ import argparse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
import shutil
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from atomicwrites import atomic_write
|
from atomicwrites import atomic_write, AtomicWriter
|
||||||
import frontmatter
|
import frontmatter
|
||||||
from git import Repo
|
from git import Repo
|
||||||
import sarge
|
import sarge
|
||||||
|
@ -36,7 +37,8 @@ def commit_initial_post(post_title: str, post_filename: str):
|
||||||
def edit_post(post_path):
|
def edit_post(post_path):
|
||||||
|
|
||||||
with post_path.open() as handle:
|
with post_path.open() as handle:
|
||||||
with atomic_write(str(post_path), overwrite=True) as writer:
|
with atomic_write(str(post_path), overwrite=True,
|
||||||
|
suffix=".md") as writer:
|
||||||
writer.write(handle.read())
|
writer.write(handle.read())
|
||||||
writer.write("\n\n")
|
writer.write("\n\n")
|
||||||
writer.flush()
|
writer.flush()
|
||||||
|
@ -50,10 +52,18 @@ def create_post(post_title: str, tags: List[str] = None,
|
||||||
categories: List[str] = None,
|
categories: List[str] = None,
|
||||||
comments: bool = True,
|
comments: bool = True,
|
||||||
draft: bool = True) -> Path or None:
|
draft: bool = True) -> Path or None:
|
||||||
cmd = ["hugo", "new", "-k", "posts", "--quiet"]
|
|
||||||
|
hugo_cmd = shutil.which("hugo")
|
||||||
|
|
||||||
|
if hugo_cmd is None:
|
||||||
|
print("hugo executable not found in PATH.")
|
||||||
|
return
|
||||||
|
|
||||||
|
cmd = [hugo_cmd, "new", "-k", "posts", "--quiet"]
|
||||||
title = new_post_title(post_title)
|
title = new_post_title(post_title)
|
||||||
path = Path(POST_PATH) / title
|
path = Path(POST_PATH) / title
|
||||||
cmd.append(str(path))
|
cmd.append(str(path))
|
||||||
|
print(" ".join(cmd))
|
||||||
|
|
||||||
pid = sarge.run(cmd)
|
pid = sarge.run(cmd)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue