diff --git a/main.tex b/main.tex index 3345e3e..55f5b12 100644 --- a/main.tex +++ b/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 diff --git a/packages.tex b/packages.tex index ee8475b..8b1436c 100644 --- a/packages.tex +++ b/packages.tex @@ -9,6 +9,7 @@ \usepackage{url} \usepackage{ellipsis} \usepackage[margin=1in,includefoot]{geometry} +\usepackage{graphicx} \hypersetup{ hidelinks=true diff --git a/test/img/test-image.png b/test/img/test-image.png new file mode 100644 index 0000000..05e2bc8 Binary files /dev/null and b/test/img/test-image.png differ diff --git a/test/main.md b/test/main.md index 460f471..31dfacb 100644 --- a/test/main.md +++ b/test/main.md @@ -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} diff --git a/variables.lua b/variables.lua index 77db379..871eac5 100644 --- a/variables.lua +++ b/variables.lua @@ -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 }, {