Allow including images from img
directory
This commit is contained in:
parent
daadbd5773
commit
5c28dd5cba
5 changed files with 24 additions and 11 deletions
2
main.tex
2
main.tex
|
@ -1,6 +1,8 @@
|
||||||
\documentclass[12pt,titlepage,a4paper,twoside]{article}
|
\documentclass[12pt,titlepage,a4paper,twoside]{article}
|
||||||
\include{packages}
|
\include{packages}
|
||||||
|
|
||||||
|
\graphicspath{{$inputDir$/img/}}
|
||||||
|
|
||||||
\renewcommand{\thesection}{}
|
\renewcommand{\thesection}{}
|
||||||
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
|
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
|
||||||
\makeatletter
|
\makeatletter
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
\usepackage{url}
|
\usepackage{url}
|
||||||
\usepackage{ellipsis}
|
\usepackage{ellipsis}
|
||||||
\usepackage[margin=1in,includefoot]{geometry}
|
\usepackage[margin=1in,includefoot]{geometry}
|
||||||
|
\usepackage{graphicx}
|
||||||
|
|
||||||
\hypersetup{
|
\hypersetup{
|
||||||
hidelinks=true
|
hidelinks=true
|
||||||
|
|
BIN
test/img/test-image.png
Normal file
BIN
test/img/test-image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 801 B |
|
@ -8,3 +8,6 @@ subtitle: Test Document
|
||||||
\lipsum[3-15]
|
\lipsum[3-15]
|
||||||
|
|
||||||
Foo is equal to \$foo\$.
|
Foo is equal to \$foo\$.
|
||||||
|
Input directory is at \$inputDir\$.
|
||||||
|
|
||||||
|
\includegraphics[width=\textwidth]{test-image}
|
||||||
|
|
|
@ -2,16 +2,23 @@ local vars = {}
|
||||||
|
|
||||||
local additionalChars = {".", ",", "!", ":", ";"}
|
local additionalChars = {".", ",", "!", ":", ";"}
|
||||||
|
|
||||||
local function getVars(meta)
|
|
||||||
|
local function setVariable(meta, key, val)
|
||||||
|
local var_key = "$" .. key .. "$"
|
||||||
|
vars[var_key] = val
|
||||||
|
meta[key] = val
|
||||||
|
for _, char in pairs(additionalChars) do
|
||||||
|
vars[var_key .. char] = val .. char
|
||||||
|
vars[char .. var_key] = char .. val
|
||||||
|
meta[var_key .. char] = val .. char
|
||||||
|
meta[char .. var_key] = char .. val
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getVarsFromMeta(meta)
|
||||||
for k, v in pairs(meta) do
|
for k, v in pairs(meta) do
|
||||||
if v.t == 'MetaInlines' then
|
if v.t == 'MetaInlines' then
|
||||||
local var_key = "$" .. k .. "$"
|
setVariable(meta, k, table.unpack(v)["c"])
|
||||||
local var_value = table.unpack(v)["c"]
|
|
||||||
vars[var_key] = var_value
|
|
||||||
for _, char in pairs(additionalChars) do
|
|
||||||
vars[var_key .. char] = var_value .. char
|
|
||||||
vars[char .. var_key] = char .. var_value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return meta
|
return meta
|
||||||
|
@ -20,9 +27,9 @@ end
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
Meta = function (meta)
|
Meta = function (meta)
|
||||||
meta = getVars(meta)
|
setVariable(meta, 'outputFile', os.getenv("OUTPUT_FILE"))
|
||||||
meta['outputFile'] = os.getenv("OUTPUT_FILE")
|
setVariable(meta, 'inputDir', os.getenv("INPUT_DIR"))
|
||||||
meta['inputDir'] = os.getenv("INPUT_DIR")
|
return getVarsFromMeta(meta)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue