@@ -13,6 +13,7 @@ export const schema = z.array(
1313 fileName : z . string ( ) ,
1414 typeOfFile : TypeOfFileSchema ,
1515 markdown : z . string ( ) ,
16+ isMilkdown : z . boolean ( ) . optional ( ) ,
1617 } )
1718) ;
1819
@@ -55,11 +56,16 @@ export const handler = async function (
5556 const generateFile = async (
5657 pandocArgs : string [ ] ,
5758 destFilePath : string ,
58- markdown : string
59+ markdown : string ,
60+ isMilkdown : boolean = true
5961 ) => {
62+ // pandoc source format
63+ // If Milkdown, disable the implicit_figures extension to remove all image captions
64+ const fromString = isMilkdown ? "markdown-implicit_figures" : "markdown" ;
65+
6066 try {
6167 await pdcTs . Execute ( {
62- from : "markdown-implicit_figures" , // pandoc source format (disabling the implicit_figures extension to remove all image captions)
68+ from : fromString ,
6369 to : "latex" , // pandoc output format
6470 pandocArgs,
6571 spawnOpts : { argv0 : "+RTS -M512M -RTS" } ,
@@ -76,7 +82,7 @@ export const handler = async function (
7682 }
7783
7884 const TeXoutput = await pdcTs . Execute ( {
79- from : "markdown-implicit_figures" , // pandoc source format (disabling the implicit_figures extension to remove all image captions)
85+ from : fromString ,
8086 to : "latex" , // pandoc output format
8187 pandocArgs,
8288 outputToFile : false , // Controls whether the output will be returned as a string or written to a file
@@ -130,6 +136,7 @@ export const handler = async function (
130136 let url = "" ;
131137 for ( let eachRequestData of requestData ) {
132138 const markdown = eachRequestData . markdown ;
139+ const isMilkdown = eachRequestData . isMilkdown ;
133140
134141 switch ( eachRequestData . typeOfFile ) {
135142 case "PDF" :
@@ -138,7 +145,8 @@ export const handler = async function (
138145 const generatePDFResult = await generateFile (
139146 [ "--pdf-engine=xelatex" , `--template=./template.latex` ] ,
140147 localPathPDF ,
141- markdown
148+ markdown ,
149+ isMilkdown
142150 ) ;
143151
144152 if ( generatePDFResult ?. statusCode ) {
@@ -154,7 +162,8 @@ export const handler = async function (
154162 await generateFile (
155163 [ `--template=./template.latex` ] ,
156164 localPathTEX ,
157- markdown
165+ markdown ,
166+ isMilkdown
158167 ) ;
159168
160169 const s3PathTEX = `${ eachRequestData . userId } /${ filenameTEX } ` ;
0 commit comments