diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2021-11-23 18:32:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 09:32:53 -0800 |
commit | bffd74323cfd91f5c44ca34e09633247d1d28954 (patch) | |
tree | 2036e51b9043c15b4e88e513c9c9bdc20a4b469c /src | |
parent | 0c0945b93c2ae502c0629d93e9ad520dbe17c625 (diff) | |
download | pandoc-bffd74323cfd91f5c44ca34e09633247d1d28954.tar.gz |
Lua: add function `pandoc.utils.text` (#7710)
The function converts a string to `Inlines`, treating interword spaces
as `Space`s or `SoftBreak`s. If you want a `Str` with literal spaces,
use `pandoc.Str`.
Closes: #7709
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/AST.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua/Module/Utils.hs | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/AST.hs b/src/Text/Pandoc/Lua/Marshaling/AST.hs index 31d040c83..9cf683055 100644 --- a/src/Text/Pandoc/Lua/Marshaling/AST.hs +++ b/src/Text/Pandoc/Lua/Marshaling/AST.hs @@ -44,6 +44,7 @@ module Text.Pandoc.Lua.Marshaling.AST , pushBlock , pushCitation , pushInline + , pushInlines , pushListAttributes , pushMeta , pushMetaValue diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs index 01ba4eb46..6fd707bf8 100644 --- a/src/Text/Pandoc/Lua/Module/Utils.hs +++ b/src/Text/Pandoc/Lua/Module/Utils.hs @@ -29,8 +29,8 @@ import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError) import Text.Pandoc.Lua.Marshaling () import Text.Pandoc.Lua.Marshaling.AST - ( peekBlock, peekInline, peekPandoc, pushBlock, pushInline, pushPandoc - , peekAttr, peekMeta, peekMetaValue) + ( peekBlock, peekInline, peekPandoc, pushBlock, pushInline, pushInlines + , pushPandoc, peekAttr, peekMeta, peekMetaValue) import Text.Pandoc.Lua.Marshaling.ListAttributes (peekListAttributes) import Text.Pandoc.Lua.Marshaling.List (pushPandocList) import Text.Pandoc.Lua.Marshaling.SimpleTable @@ -122,6 +122,14 @@ documentedModule = Module <#> parameter peekAstElement "AST element" "elem" "some pandoc AST element" =#> functionResult pushText "string" "stringified element" + , defun "text" + ### liftPure (B.toList . B.text) + <#> parameter peekText "string" "words" "markup-less inlines text" + =#> functionResult pushInlines "Inlines" "list of inline elements" + #? ("Converts a string to `Inlines`, treating interword spaces as " <> + "`Space`s or `SoftBreak`s. If you want a `Str` with literal " <> + "spaces, use `pandoc.Str`.") + , defun "from_simple_table" ### from_simple_table <#> parameter peekSimpleTable "SimpleTable" "simple_tbl" "" |