@@ -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,17 @@ 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+implicit_figures" ;
65+ // const fromString = "markdown+implicit_figures";
66+
6067 try {
6168 await pdcTs . Execute ( {
62- from : "markdown-implicit_figures" , // pandoc source format (disabling the implicit_figures extension to remove all image captions)
69+ from : fromString ,
6370 to : "latex" , // pandoc output format
6471 pandocArgs,
6572 spawnOpts : { argv0 : "+RTS -M512M -RTS" } ,
@@ -76,7 +83,7 @@ export const handler = async function (
7683 }
7784
7885 const TeXoutput = await pdcTs . Execute ( {
79- from : "markdown-implicit_figures" , // pandoc source format (disabling the implicit_figures extension to remove all image captions)
86+ from : fromString ,
8087 to : "latex" , // pandoc output format
8188 pandocArgs,
8289 outputToFile : false , // Controls whether the output will be returned as a string or written to a file
@@ -130,6 +137,7 @@ export const handler = async function (
130137 let url = "" ;
131138 for ( let eachRequestData of requestData ) {
132139 const markdown = eachRequestData . markdown ;
140+ const isMilkdown = eachRequestData . isMilkdown ;
133141
134142 switch ( eachRequestData . typeOfFile ) {
135143 case "PDF" :
@@ -138,7 +146,8 @@ export const handler = async function (
138146 const generatePDFResult = await generateFile (
139147 [ "--pdf-engine=xelatex" , `--template=./template.latex` ] ,
140148 localPathPDF ,
141- markdown
149+ markdown ,
150+ isMilkdown
142151 ) ;
143152
144153 if ( generatePDFResult ?. statusCode ) {
@@ -154,7 +163,8 @@ export const handler = async function (
154163 await generateFile (
155164 [ `--template=./template.latex` ] ,
156165 localPathTEX ,
157- markdown
166+ markdown ,
167+ isMilkdown
158168 ) ;
159169
160170 const s3PathTEX = `${ eachRequestData . userId } /${ filenameTEX } ` ;
0 commit comments