Skip to content

Commit

Permalink
Fixed #14
Browse files Browse the repository at this point in the history
1. with correction to image lua filter
2. adding --resource-path param to pandoc
  • Loading branch information
Abhi-1U committed Jun 28, 2022
1 parent 770e752 commit cbf26bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion R/rj-article.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,20 @@ convert_to_markdown<-function(article_dir){
}
}
print(input_file)
library(tools)
abs_file_path<-file_path_as_absolute(article_dir)
md_file=paste(toString(tools::file_path_sans_ext(input_file)),".md",sep="")
print(md_file)
bib_filter<-system.file("extdata/bib_filter.lua", package = "texor")
code_block_filter<-system.file("extdata/code_block_filter.lua", package = "texor")
image_filter<-system.file("extdata/image_filter.lua", package = "texor")
pandoc_opt<-c("-s",
"--resource-path",abs_file_path,
"--lua-filter",bib_filter,
"--lua-filter",image_filter,
"--lua-filter",code_block_filter)
# This will generate a markdown file with YAML headers.
rmarkdown::pandoc_convert(input_file,to= "markdown",options=pandoc_opt,output = md_file,citeproc = TRUE,verbose = TRUE)
rmarkdown::pandoc_convert(input_file,from = "latex",to= "markdown",options=pandoc_opt,output = md_file,citeproc = TRUE,verbose = TRUE)
}

#' generate rmarkdown file in output folder
Expand Down
19 changes: 12 additions & 7 deletions inst/extdata/image_filter.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@

function removePDFExtensions(s)
return s:gsub("%.pdf", "")
function removePDFExtensions(src)
return src:gsub("%.pdf", "")
end


function checkPDFextension(src)
return src:match("%.pdf")
end
function Image(img)
local img_old_src = removePDFExtensions(img.src)
local new_src = img_old_src .. ".png"
local image = pandoc.Image(img.caption, new_src, img.title, img.attr)
return image
if(checkPDFextension(img.src)) then
local img_old_src = removePDFExtensions(img.src)
local new_src = img_old_src .. ".png"
local image = pandoc.Image(img.caption, new_src, img.title, img.attr)
return image
end
return img
end

0 comments on commit cbf26bf

Please sign in to comment.