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}
|
||||
\include{packages}
|
||||
|
||||
\graphicspath{{$inputDir$/img/}}
|
||||
|
||||
\renewcommand{\thesection}{}
|
||||
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
|
||||
\makeatletter
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
\usepackage{url}
|
||||
\usepackage{ellipsis}
|
||||
\usepackage[margin=1in,includefoot]{geometry}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\hypersetup{
|
||||
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]
|
||||
|
||||
Foo is equal to \$foo\$.
|
||||
Input directory is at \$inputDir\$.
|
||||
|
||||
\includegraphics[width=\textwidth]{test-image}
|
||||
|
|
|
@ -2,16 +2,23 @@ local vars = {}
|
|||
|
||||
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
|
||||
if v.t == 'MetaInlines' then
|
||||
local var_key = "$" .. k .. "$"
|
||||
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
|
||||
setVariable(meta, k, table.unpack(v)["c"])
|
||||
end
|
||||
end
|
||||
return meta
|
||||
|
@ -20,9 +27,9 @@ end
|
|||
return {
|
||||
{
|
||||
Meta = function (meta)
|
||||
meta = getVars(meta)
|
||||
meta['outputFile'] = os.getenv("OUTPUT_FILE")
|
||||
meta['inputDir'] = os.getenv("INPUT_DIR")
|
||||
setVariable(meta, 'outputFile', os.getenv("OUTPUT_FILE"))
|
||||
setVariable(meta, 'inputDir', os.getenv("INPUT_DIR"))
|
||||
return getVarsFromMeta(meta)
|
||||
end
|
||||
},
|
||||
{
|
||||
|
|
Reference in a new issue