diff options
| author | Albert Krewinkel <albert@zeitkraut.de> | 2023-03-20 13:58:09 +0100 |
|---|---|---|
| committer | Albert Krewinkel <albert@zeitkraut.de> | 2023-03-20 16:06:18 +0100 |
| commit | ed5197f5258fa52de7676980799ddc47fa4f2278 (patch) | |
| tree | 1974f49d075f343527c934089d9fabe940da63d5 /pandoc-lua-engine/src/Text/Pandoc/Lua/Module | |
| parent | 5af2d70b0da46e74672a9089c51b9ad5d883d6ef (diff) | |
Lua: load text module as `pandoc.text`.
This only affects the name in the Lua-internal documentation. It is
still possible to load the modules via `require 'text'`, although this
is deprecated.
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Text.hs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Text.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Text.hs new file mode 100644 index 000000000..6705a5f62 --- /dev/null +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Text.hs @@ -0,0 +1,51 @@ +{-# LANGUAGE OverloadedStrings #-} +{-| +Module : Text.Pandoc.Lua.Module.Text +Copyright : © 2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <albert@hslua.org> + +Lua module to work with UTF-8 strings. +-} +module Text.Pandoc.Lua.Module.Text + ( documentedModule + ) where + +import Data.Version (makeVersion) +import HsLua +import Text.Pandoc.Error (PandocError) +import Text.Pandoc.Lua.PandocLua () + +import qualified Data.Text as T +import qualified HsLua.Module.Text as TM + +-- | The @aeson@ module specification. +documentedModule :: Module PandocError +documentedModule = TM.documentedModule + { moduleName = "pandoc.text" + , moduleFunctions = + [ TM.fromencoding `since` v[3,0] + , TM.len `since` v[2,0,3] + , TM.lower `since` v[2,0,3] + , TM.reverse `since` v[2,0,3] + , TM.sub `since` v[2,0,3] + , TM.toencoding `since` v[3,0] + , TM.upper `since` v[2,0,3] + ] + , moduleDescription = T.unlines + [ "UTF-8 aware text manipulation functions, implemented in Haskell." + , "" + , "The text module can also be loaded under the name `text`, although" + , "this is discouraged and deprecated." + , "" + , "``` lua" + , "-- uppercase all regular text in a document:" + , "function Str (s)" + , " s.text = pandoc.text.upper(s.text)" + , " return s" + , "end" + , "```" + ] + } + where + v = makeVersion |
