Skip to content

Commit d399943

Browse files
committed
Lua: Remove prefixes from Lua type names
Lua type names were inconsistent with regard to the use of prefixes; all prefixes are removed now, and Lua types now have the same name as the Haskell types. The use of app-specific prefixes is suggested by the Lua manual to avoid collisions. However, this shouldn't be a problem with pandoc, as it cannot be used as a Lua package. Closes: #8574
1 parent 734227a commit d399943

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

cabal.project

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ flags: +embed_data_files
77
constraints: skylighting-format-blaze-html >= 0.1.1.2,
88
skylighting-format-context >= 0.1.0.2
99

10+
source-repository-package
11+
type: git
12+
location: https://github.com/pandoc/pandoc-lua-marshal.git
13+
tag: 2dc58d431bb3e4d55999db03c470fbf32970b3d5

pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/Chunks.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pushChunk :: LuaError e => Pusher e Chunk
3030
pushChunk = pushUD typeChunk
3131

3232
typeChunk :: LuaError e => DocumentedType e Chunk
33-
typeChunk = deftype "pandoc.Chunk"
33+
typeChunk = deftype "Chunk"
3434
[ operation Tostring $ lambda
3535
### liftPure show
3636
<#> udparam typeChunk "chunk" "chunk to print in native format"
@@ -103,7 +103,7 @@ pushChunkedDoc = pushUD typeChunkedDoc
103103

104104
-- | Lua type for 'ChunkedDoc' values.
105105
typeChunkedDoc :: LuaError e => DocumentedType e ChunkedDoc
106-
typeChunkedDoc = deftype "pandoc.ChunkedDoc"
106+
typeChunkedDoc = deftype "ChunkedDoc"
107107
[]
108108
[ readonly "chunks"
109109
"list of chunks that make up the document"

pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Text.Pandoc.Lua.Marshal.LogMessage (pushLogMessage)
2222

2323
-- | Lua type used for the @CommonState@ object.
2424
typeCommonState :: LuaError e => DocumentedType e CommonState
25-
typeCommonState = deftype "pandoc CommonState" []
25+
typeCommonState = deftype "CommonState" []
2626
[ readonly "input_files" "input files passed to pandoc"
2727
(pushPandocList pushString, stInputFiles)
2828

pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/LogMessage.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import qualified Data.Aeson as Aeson
1919

2020
-- | Type definition for pandoc log messages.
2121
typeLogMessage :: LuaError e => DocumentedType e LogMessage
22-
typeLogMessage = deftype "pandoc LogMessage"
22+
typeLogMessage = deftype "LogMessage"
2323
[ operation Index $ defun "__tostring"
2424
### liftPure showLogMessage
2525
<#> udparam typeLogMessage "msg" "object"

pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/Sources.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Text.Parsec (SourcePos, sourceName)
2525
pushSources :: LuaError e => Pusher e Sources
2626
pushSources (Sources srcs) = do
2727
pushList (pushUD typeSource) srcs
28-
newListMetatable "pandoc Sources" $ do
28+
newListMetatable "Sources" $ do
2929
pushName "__tostring"
3030
pushHaskellFunction $ do
3131
sources <- forcePeek $ peekList (peekUD typeSource) (nthBottom 1)
@@ -43,7 +43,7 @@ peekSources idx = liftLua (ltype idx) >>= \case
4343

4444
-- | Source object type.
4545
typeSource :: LuaError e => DocumentedType e (SourcePos, Text)
46-
typeSource = deftype "pandoc input source"
46+
typeSource = deftype "Source"
4747
[ operation Tostring $ lambda
4848
### liftPure snd
4949
<#> udparam typeSource "srcs" "Source to print in native format"

pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/Template.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ peekTemplate idx = liftLua (ltype idx) >>= \case
4040

4141
-- | Template object type.
4242
typeTemplate :: LuaError e => DocumentedType e (Template Text)
43-
typeTemplate = deftype "pandoc Template" [] []
43+
typeTemplate = deftype "Template" [] []

pandoc-lua-engine/test/lua/module/pandoc-structure.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ return {
5959
test('returns a chunked doc', function ()
6060
assert.are_equal(
6161
pandoc.utils.type(structure.split_into_chunks(pandoc.Pandoc{})),
62-
'pandoc.ChunkedDoc'
62+
'ChunkedDoc'
6363
)
6464
end),
6565
},

pandoc-lua-engine/test/lua/module/pandoc-template.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ return {
5555
test('returns a Template', function ()
5656
assert.are_equal(
5757
pandoc.utils.type(template.compile('$title$')),
58-
'pandoc Template'
58+
'Template'
5959
)
6060
end),
6161
test('returns a Template', function ()
6262
local templ_path = pandoc.path.join{'lua', 'module', 'default.test'}
6363
assert.are_equal(
6464
pandoc.utils.type(template.compile('${ partial() }', templ_path)),
65-
'pandoc Template'
65+
'Template'
6666
)
6767
end),
6868
test('fails if template has non-existing partial', function ()
@@ -76,7 +76,7 @@ return {
7676
assert.are_equal(type(jats_template), 'string')
7777
assert.are_equal(
7878
pandoc.utils.type(template.compile(jats_template)),
79-
'pandoc Template'
79+
'Template'
8080
)
8181
end),
8282
},

stack.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ extra-deps:
2020
- doctemplates-0.11.0.1
2121
- typst-0.6
2222
- hslua-module-doclayout-1.2.0
23-
- pandoc-lua-marshal-0.2.9
2423
- djot-0.1.2.2
2524
- texmath-0.12.8.11
2625
- commonmark-0.2.6.1
2726
- commonmark-pandoc-0.2.2.2
28-
27+
- git: https://github.com/pandoc/pandoc-lua-marshal
28+
commit: 2dc58d431bb3e4d55999db03c470fbf32970b3d5
2929
ghc-options:
3030
"$locals": -fhide-source-paths -Wno-missing-home-modules
3131
resolver: lts-22.33

0 commit comments

Comments
 (0)