Merge pull request #89 from TurboGit/master

Better renaming of the images to keep files in temp dir.
This commit is contained in:
supertobi
2017-04-09 22:10:49 +02:00
committed by GitHub

View File

@@ -123,6 +123,13 @@ local function my_write(latexfile,arg)
end end
end end
local function img_filename(file,i)
local dir=string.gsub(file, "(.*)(%/.*%..*)", "%1")
local ext=string.gsub(file, "(.*)(%..*)", "%2")
local lfile = dir.."/slide"..i..ext
return lfile
end
local function slide(latexfile,i,image,file) local function slide(latexfile,i,image,file)
local title = "" local title = ""
if title_widget.text ~= "" then if title_widget.text ~= "" then
@@ -146,19 +153,15 @@ local function slide(latexfile,i,image,file)
title = string.gsub(title, "\r", "") title = string.gsub(title, "\r", "")
title = string.gsub(title, "\t", "") title = string.gsub(title, "\t", "")
local lfile = "slide"..i..".jpg" local lfile = img_filename(file,i)
os.rename(file, lfile) os.rename(file, lfile)
-- fact is that latex will get confused if the filename has multiple dots. my_write(latexfile,"\\begin{figure}\n")
-- so \includegraphics{file.01.jpg} wont work. We need to output the filename my_write(latexfile,"\\begin{measuredfigure}\n")
-- and extention separated, e.g: \includegraphics{{file.01}.jpg} my_write(latexfile,"\\includegraphics[height=0.92\\textheight]{"..lfile.."}\n")
local filenoext=string.gsub(lfile, "(.*)(%..*)", "%1") my_write(latexfile,"\\end{measuredfigure}\n")
local ext=string.gsub(lfile, "(.*)(%..*)", "%2") my_write(latexfile,"\\caption{{\\color{white}"..title.."}}\n")
my_write(latexfile,"\\begin{minipage}[b]{0,99\\textwidth}\n") my_write(latexfile,"\\end{figure}\n")
my_write(latexfile,"\\includegraphics[height=0.95\\textheight]{{"..filenoext.."}"..ext.."}\\newline\n")
my_write(latexfile,"\\centering{{\\color{white}\\verb|"..title.."|}}\n")
my_write(latexfile,"\\end{minipage}\\quad\n")
end end
dt.register_storage("pdf_slideshow",_("pdf slideshow"), dt.register_storage("pdf_slideshow",_("pdf slideshow"),
@@ -166,10 +169,11 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
function(storage,image_table) function(storage,image_table)
local preamble = [[ local preamble = [[
\documentclass[a4paper,10pt,landscape]{beamer} \documentclass[a4paper,12pt,landscape]{beamer}
\usetheme{default} \usetheme{default}
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage{graphicx} \usepackage{graphicx}
\usepackage{threeparttable}
\usepackage[space]{grffile} % needed to support filename with spaces \usepackage[space]{grffile} % needed to support filename with spaces
\pagestyle{empty} \pagestyle{empty}
\parindent0pt \parindent0pt
@@ -177,7 +181,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
\usepackage{color} \usepackage{color}
\pagecolor{black!100} \pagecolor{black!100}
\color{white} \color{white}
\geometry{a4paper,landscape,left=5mm,right=5mm, top=5mm, bottom=5mm} \geometry{a4paper,landscape,left=2mm,right=2mm, top=2mm, bottom=2mm}
\mode<presentation> \mode<presentation>
\transduration{]]..delay_widget.value..[[} \transduration{]]..delay_widget.value..[[}
\setbeamertemplate{footline}{} \setbeamertemplate{footline}{}
@@ -187,6 +191,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
\setbeamercolor{background canvas}{fg=white,bg=black!100} \setbeamercolor{background canvas}{fg=white,bg=black!100}
\setbeamercolor{normal text}{fg=white} \setbeamercolor{normal text}{fg=white}
\hypersetup{pdfstartpage=1,pdfpagemode=FullScreen} \hypersetup{pdfstartpage=1,pdfpagemode=FullScreen}
\setbeamertemplate{caption}{\insertcaption}
\begin{document} \begin{document}
]] ]]
@@ -229,7 +234,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
-- finally do some clean-up -- finally do some clean-up
local i = 1 local i = 1
for img,file in pairs(image_table) do for img,file in pairs(image_table) do
local lfile = "slide"..i..".jpg" local lfile = img_filename(file,i)
os.remove(lfile) os.remove(lfile)
i = i+1 i = i+1
end end