git.iko.soy/typeable/pandoc
on master help sign in
Push inlines via lua constructors and constants
0085251Albert Krewinkel
src/Text/Pandoc/Lua/StackInstances.hs+29−41
@@ -136,37 +136,31 @@ instance StackValue Block where
136
136
137instance StackValue Inline where
137instance StackValue Inline where
138 push lua = \case
138 push lua = \case
139− Cite citations lst -> pushTagged lua "Cite" (citations, lst)
139+ Cite citations lst -> pushViaConstructor lua "Cite" lst citations
140− Code attr lst -> pushTagged lua "Code" (attr, lst)
140+ Code attr lst -> pushViaConstructor lua "Code" lst attr
141− Emph inlns -> pushTagged lua "Emph" inlns
141+ Emph inlns -> pushViaConstructor lua "Emph" inlns
142− Image attr lst tgt -> pushTagged lua "Image" (attr, lst, tgt)
142+ Image attr alt (src,tit) -> pushViaConstructor lua "Image" alt src tit attr
143− LineBreak -> pushTagged' lua "LineBreak"
143+ LineBreak -> pushViaConstructor lua "LineBreak"
144− Link attr lst tgt -> pushTagged lua "Link" (attr, lst, tgt)
144+ Link attr lst (src,tit) -> pushViaConstructor lua "Link" lst src tit attr
145− Note blcks -> pushTagged lua "Note" blcks
145+ Note blcks -> pushViaConstructor lua "Note" blcks
146− Math mty str -> pushTagged lua "Math" (mty, str)
146+ Math mty str -> pushViaConstructor lua "Math" mty str
147− Quoted qt inlns -> pushTagged lua "Quoted" (qt, inlns)
147+ Quoted qt inlns -> pushViaConstructor lua "Quoted" qt inlns
148− RawInline f cs -> pushTagged lua "RawInline" (f, cs)
148+ RawInline f cs -> pushViaConstructor lua "RawInline" f cs
149− SmallCaps inlns -> pushTagged lua "SmallCaps" inlns
149+ SmallCaps inlns -> pushViaConstructor lua "SmallCaps" inlns
150− SoftBreak -> pushTagged' lua "SoftBreak"
150+ SoftBreak -> pushViaConstructor lua "SoftBreak"
151− Space -> pushTagged' lua "Space"
151+ Space -> pushViaConstructor lua "Space"
152− Span attr inlns -> pushTagged lua "Span" (attr, inlns)
152+ Span attr inlns -> pushViaConstructor lua "Span" inlns attr
153− Str str -> pushTagged lua "Str" str
153+ Str str -> pushViaConstructor lua "Str" str
154− Strikeout inlns -> pushTagged lua "Strikeout" inlns
154+ Strikeout inlns -> pushViaConstructor lua "Strikeout" inlns
155− Strong inlns -> pushTagged lua "Strong" inlns
155+ Strong inlns -> pushViaConstructor lua "Strong" inlns
156− Subscript inlns -> pushTagged lua "Subscript" inlns
156+ Subscript inlns -> pushViaConstructor lua "Subscript" inlns
157− Superscript inlns -> pushTagged lua "Superscript" inlns
157+ Superscript inlns -> pushViaConstructor lua "Superscript" inlns
158 peek = peekInline
158 peek = peekInline
159 valuetype _ = TTABLE
159 valuetype _ = TTABLE
160
160
161instance StackValue Citation where
161instance StackValue Citation where
162− push lua c = do
162+ push lua (Citation cid prefix suffix mode noteNum hash) =
163− newtable lua
163+ pushViaConstructor lua "Citation" cid mode prefix suffix noteNum hash
164− addKeyValue lua "citationId" (citationId c)
165− addKeyValue lua "citationPrefix" (citationPrefix c)
166− addKeyValue lua "citationSuffix" (citationSuffix c)
167− addKeyValue lua "citationMode" (citationMode c)
168− addKeyValue lua "citationNoteNum" (citationNoteNum c)
169− addKeyValue lua "citationHash" (citationHash c)
170 peek lua idx = do
164 peek lua idx = do
171 id' <- getField lua idx "citationId"
165 id' <- getField lua idx "citationId"
172 prefix <- getField lua idx "citationPrefix"
166 prefix <- getField lua idx "citationPrefix"
@@ -174,20 +168,14 @@ instance StackValue Citation where
174 mode <- getField lua idx "citationMode"
168 mode <- getField lua idx "citationMode"
175 num <- getField lua idx "citationNoteNum"
169 num <- getField lua idx "citationNoteNum"
176 hash <- getField lua idx "citationHash"
170 hash <- getField lua idx "citationHash"
177− return $ Citation
171+ return $ Citation <$> id' <*> prefix <*> suffix <*> mode <*> num <*> hash
178− <$> id'
179− <*> prefix
180− <*> suffix
181− <*> mode
182− <*> num
183− <*> hash
184 valuetype _ = TTABLE
172 valuetype _ = TTABLE
185
173
186instance StackValue CitationMode where
174instance StackValue CitationMode where
187 push lua = \case
175 push lua = \case
188− AuthorInText -> pushTagged' lua "AuthorInText"
176+ AuthorInText -> getglobal2 lua "pandoc.AuthorInText"
189− NormalCitation -> pushTagged' lua "NormalCitation"
177+ NormalCitation -> getglobal2 lua "pandoc.NormalCitation"
190− SuppressAuthor -> pushTagged' lua "SuppressAuthor"
178+ SuppressAuthor -> getglobal2 lua "pandoc.SuppressAuthor"
191 peek lua idx = do
179 peek lua idx = do
192 tag <- getField lua idx "t"
180 tag <- getField lua idx "t"
193 case tag of
181 case tag of
@@ -204,8 +192,8 @@ instance StackValue Format where
204
192
205instance StackValue MathType where
193instance StackValue MathType where
206 push lua = \case
194 push lua = \case
207− InlineMath -> pushTagged' lua "InlineMath"
195+ InlineMath -> getglobal2 lua "pandoc.InlineMath"
208− DisplayMath -> pushTagged' lua "DisplayMath"
196+ DisplayMath -> getglobal2 lua "pandoc.DisplayMath"
209 peek lua idx = do
197 peek lua idx = do
210 res <- getField lua idx "t"
198 res <- getField lua idx "t"
211 case res of
199 case res of
@@ -216,8 +204,8 @@ instance StackValue MathType where
216
204
217instance StackValue QuoteType where
205instance StackValue QuoteType where
218 push lua = \case
206 push lua = \case
219− SingleQuote -> pushTagged' lua "SingleQuote"
207+ SingleQuote -> getglobal2 lua "pandoc.SingleQuote"
220− DoubleQuote -> pushTagged' lua "DoubleQuote"
208+ DoubleQuote -> getglobal2 lua "pandoc.DoubleQuote"
221 peek lua idx = do
209 peek lua idx = do
222 res <- getField lua idx "t"
210 res <- getField lua idx "t"
223 case res of
211 case res of