put lántas svgs in a directory named after the page

This commit is contained in:
Rhiannon Morris 2021-05-20 23:32:08 +02:00
parent bb903be015
commit c493595407
2 changed files with 10 additions and 5 deletions

View file

@ -37,8 +37,10 @@ build: $(OUTPUT)
$(BUILDDIR)/%.html: $(PAGESDIR)/%.md $(TEMPLATE) $(LANGFILTER) $(LAANTAS_SCRIPT)
@echo "[pandoc] $<"
mkdir -p $(dir $@)
mkdir -p $(basename $@)
LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" \
DIRNAME="$(subst $(PAGESDIR),$(BUILDDIR),$(dir $<))" \
DIRNAME="$(basename $@)" \
FILENAME="$@" \
pandoc -s --toc --template $(TEMPLATE) -o $@ $< \
--filter $(LANGFILTER)

View file

@ -92,12 +92,15 @@ toTitle = Text.filter \c -> c /= '\\' && c /= '#'
makeImage :: Image -> IO Inline
makeImage (Image {..}) = do
exe <- getEnv "LAANTAS_SCRIPT"
dir <- getEnv "DIRNAME"
exe <- getEnv "LAANTAS_SCRIPT"
parent <- dropFileName <$> getEnv "FILENAME"
dir <- getEnv "DIRNAME"
let fullFile = dir </> file
let relFile = Text.pack $ makeRelative parent fullFile
callProcess exe
["-S", show size, "-K", show stroke, "-W", show width,
"-C", Text.unpack color, "-t", Text.unpack text, "-o", dir </> file]
pure $ Pandoc.Image ("", ["scr","laantas"], []) [] (Text.pack file, title)
"-C", Text.unpack color, "-t", Text.unpack text, "-o", fullFile]
pure $ Pandoc.Image ("", ["scr","laantas"], []) [] (relFile, title)
weirdUrl :: Char -> Bool
weirdUrl c = c `elem` ("#\\?&_/.·,{} " :: String)