removed pandoc fully and will now use a stale build to determine whether or not things are working
This commit is contained in:
parent
06671b3b3b
commit
b1f9a8d2f9
2 changed files with 1 additions and 71 deletions
|
|
@ -17,8 +17,6 @@ import Development.Shake.FilePath ((<.>), (</>))
|
||||||
import qualified Development.Shake.FilePath as FP
|
import qualified Development.Shake.FilePath as FP
|
||||||
import HTML
|
import HTML
|
||||||
import Markdown
|
import Markdown
|
||||||
import Text.Pandoc (Block (Plain), Meta (..), MetaValue (..), Pandoc (..))
|
|
||||||
import qualified Text.Pandoc as Pandoc
|
|
||||||
import Text.Parsec hiding (Error)
|
import Text.Parsec hiding (Error)
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
|
|
@ -46,46 +44,6 @@ markdownToHtml filePath = do
|
||||||
let Right metadata = decodeEither' $ encodeUtf8 metadataText
|
let Right metadata = decodeEither' $ encodeUtf8 metadataText
|
||||||
pure (metadata, compileToHTML document)
|
pure (metadata, compileToHTML document)
|
||||||
|
|
||||||
markdownToHtml_ :: (FromJSON a) => FilePath -> Action (a, Text)
|
|
||||||
markdownToHtml_ filePath = do
|
|
||||||
content <- Shake.readFile' filePath
|
|
||||||
Shake.quietly . Shake.traced "Markdown to HTML" $ do
|
|
||||||
pandoc@(Pandoc meta _) <-
|
|
||||||
runPandoc . Pandoc.readMarkdown readerOptions . T.pack $ content
|
|
||||||
-- WARNING markdown needs to have no whitespace before/after dashes
|
|
||||||
-- print meta
|
|
||||||
meta' <- fromMeta meta
|
|
||||||
html <- runPandoc . Pandoc.writeHtml5String writerOptions $ pandoc
|
|
||||||
return (meta', html)
|
|
||||||
where
|
|
||||||
readerOptions =
|
|
||||||
Pandoc.def
|
|
||||||
{ Pandoc.readerStandalone = True,
|
|
||||||
Pandoc.readerExtensions = Pandoc.enableExtension Pandoc.Ext_yaml_metadata_block Pandoc.pandocExtensions
|
|
||||||
}
|
|
||||||
writerOptions =
|
|
||||||
Pandoc.def {Pandoc.writerExtensions = Pandoc.pandocExtensions}
|
|
||||||
fromMeta (Meta meta) =
|
|
||||||
A.fromJSON . A.toJSON <$> traverse metaValueToJSON meta >>= \case
|
|
||||||
Success res -> pure res
|
|
||||||
Error err -> fail $ "json conversion error:" <> err
|
|
||||||
metaValueToJSON = \case
|
|
||||||
MetaMap m -> A.toJSON <$> traverse metaValueToJSON m
|
|
||||||
MetaList m -> A.toJSONList <$> traverse metaValueToJSON m
|
|
||||||
MetaBool m -> pure $ A.toJSON m
|
|
||||||
MetaString m -> pure $ A.toJSON $ T.strip m
|
|
||||||
MetaInlines m -> metaValueToJSON $ MetaBlocks [Plain m]
|
|
||||||
MetaBlocks m ->
|
|
||||||
fmap (A.toJSON . T.strip)
|
|
||||||
. runPandoc
|
|
||||||
. Pandoc.writePlain Pandoc.def
|
|
||||||
$ Pandoc mempty m
|
|
||||||
|
|
||||||
runPandoc :: Pandoc.PandocIO b -> IO b
|
|
||||||
runPandoc action =
|
|
||||||
Pandoc.runIO (Pandoc.setVerbosity Pandoc.ERROR >> action)
|
|
||||||
>>= either (fail . show) return
|
|
||||||
|
|
||||||
now :: Action T.Text
|
now :: Action T.Text
|
||||||
now = Shake.liftIO $ fmap (T.pack . iso8601Show) getCurrentTime
|
now = Shake.liftIO $ fmap (T.pack . iso8601Show) getCurrentTime
|
||||||
|
|
||||||
|
|
@ -97,34 +55,6 @@ markdownToPost path = do
|
||||||
let Right post = decodeEither' $ encodeUtf8 postData
|
let Right post = decodeEither' $ encodeUtf8 postData
|
||||||
pure post
|
pure post
|
||||||
|
|
||||||
markdownToPost_ :: FilePath -> Action Post
|
|
||||||
markdownToPost_ path = do
|
|
||||||
content <- Shake.readFile' path
|
|
||||||
(Pandoc meta _) <-
|
|
||||||
Shake.liftIO . runPandoc . Pandoc.readMarkdown readerOptions . T.pack $ content
|
|
||||||
Shake.liftIO $ fromMeta meta
|
|
||||||
where
|
|
||||||
readerOptions =
|
|
||||||
Pandoc.def
|
|
||||||
{ Pandoc.readerStandalone = True,
|
|
||||||
Pandoc.readerExtensions = Pandoc.enableExtension Pandoc.Ext_yaml_metadata_block Pandoc.pandocExtensions
|
|
||||||
}
|
|
||||||
fromMeta (Meta meta) =
|
|
||||||
A.fromJSON . A.toJSON <$> traverse metaValueToJSON meta >>= \case
|
|
||||||
Success res -> pure res
|
|
||||||
Error err -> fail $ "json conversion error:" <> err
|
|
||||||
metaValueToJSON = \case
|
|
||||||
MetaMap m -> A.toJSON <$> traverse metaValueToJSON m
|
|
||||||
MetaList m -> A.toJSONList <$> traverse metaValueToJSON m
|
|
||||||
MetaBool m -> pure $ A.toJSON m
|
|
||||||
MetaString m -> pure $ A.toJSON $ T.strip m
|
|
||||||
MetaInlines m -> metaValueToJSON $ MetaBlocks [Plain m]
|
|
||||||
MetaBlocks m ->
|
|
||||||
fmap (A.toJSON . T.strip)
|
|
||||||
. runPandoc
|
|
||||||
. Pandoc.writePlain Pandoc.def
|
|
||||||
$ Pandoc mempty m
|
|
||||||
|
|
||||||
yamlToPost :: FilePath -> Action Post
|
yamlToPost :: FilePath -> Action Post
|
||||||
yamlToPost path = do
|
yamlToPost path = do
|
||||||
post <- decodeFileThrow path
|
post <- decodeFileThrow path
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ executable psb
|
||||||
|
|
||||||
-- Other library packages from which modules are imported.
|
-- Other library packages from which modules are imported.
|
||||||
-- https://hackage.haskell.org/package/texmath
|
-- https://hackage.haskell.org/package/texmath
|
||||||
build-depends: base >=4.17.2.1, mustache >=2.4.2, pandoc >=3.2.1, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text, time, unordered-containers, yaml, parsec >= 3.1.18.0, typst >= 0.6.1, typst-symbols >= 0.1.7
|
build-depends: base >=4.17.2.1, mustache >=2.4.2, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text, time, unordered-containers, yaml, parsec >= 3.1.18.0
|
||||||
|
|
||||||
-- Directories containing source files.
|
-- Directories containing source files.
|
||||||
hs-source-dirs: app
|
hs-source-dirs: app
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue