-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
{-# LANGUAGE OverloadedStrings #-} | ||
{- | | ||
Module : Text.Pandoc.Lua.Marshal.Chunks | ||
Copyright : © 2022 Albert Krewinkel | ||
Copyright : © 2022-2024 Albert Krewinkel | ||
License : GPL-2.0-or-later | ||
Maintainer : Albert Krewinkel <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
@@ -11,7 +12,7 @@ | |
License : GPL-2.0-or-later | ||
Maintainer : Albert Krewinkel <[email protected]> | ||
PandocMonad instance which allows execution of Lua operations and which | ||
PandocMonad instance that allows execution of Lua operations; it | ||
uses Lua to handle state. | ||
-} | ||
module Text.Pandoc.Lua.PandocLua | ||
|
@@ -22,6 +23,7 @@ module Text.Pandoc.Lua.PandocLua | |
import Control.Monad.Catch (MonadCatch, MonadMask, MonadThrow) | ||
import Control.Monad.Except (MonadError (catchError, throwError)) | ||
import Control.Monad.IO.Class (MonadIO) | ||
import Data.Default (def) | ||
import HsLua as Lua | ||
import Text.Pandoc.Class (PandocMonad (..)) | ||
import Text.Pandoc.Error (PandocError (..)) | ||
|
@@ -77,8 +79,13 @@ instance PandocMonad PandocLua where | |
getModificationTime = IO.getModificationTime | ||
|
||
getCommonState = PandocLua $ do | ||
Lua.getfield registryindex "PANDOC_STATE" | ||
forcePeek $ peekCommonState Lua.top `lastly` pop 1 | ||
-- initialize with the default value if is hadn't been initialized yet. | ||
Lua.getfield registryindex "PANDOC_STATE" >>= \case | ||
TypeNil -> do | ||
pop 1 -- pop nil | ||
unPandocLua $ putCommonState def | ||
return def | ||
_ -> forcePeek $ peekCommonState Lua.top `lastly` pop 1 | ||
putCommonState cst = PandocLua $ do | ||
pushCommonState cst | ||
Lua.pushvalue Lua.top | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters