Skip to content

Commit

Permalink
feat: Add custom rulers and PDF include and optional table midrules (#29
Browse files Browse the repository at this point in the history
)

Features:

- md: Add rulers, e.g. `[Name:]{.hrule-fill thickness=0.5pt width=10cm}`.
- md: Add PDF include syntax, e.g. `![Pandoc User's Guide](files/PandocUsersGuide.pdf){.includepdf pages=5- style="width:100%;height:20cm;max-width:100%"}`.
- md: Custom table conversion includes some option to add horizontal rules.

Bugfixes:

- build various old setups.
- html: duplicated ids in navigation and TOC.
- latex: Do not load `lmodern` in `xelatex`.
- docker: Add `poppler` utils to the Docker containers.
  • Loading branch information
gabyx authored Apr 23, 2022
1 parent e880f0e commit 410a49d
Show file tree
Hide file tree
Showing 32 changed files with 584 additions and 325 deletions.
24 changes: 0 additions & 24 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,6 @@
"**/CVS": true
},
"files.trimTrailingWhitespace": false,
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.latex.recipes": [
{
"name": "latexmk 🔃",
"tools": [
"latexmk"
]
}
],
"latex-workshop.latex.tools": [
{
"args": [
"-r",
"../tools/.latexmkrc",
"-xelatex",
"-cd-",
"%DOC%"
],
"command": "latexmk",
"cwd": "",
"env": {},
"name": "latexmk"
}
],
"prettier.configPath": "tools/.prettierrc",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv",
"python.formatting.provider": "yapf",
Expand Down
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
// "group": "converter"
// }
// },
{
"label": "🛠️ Build with latexmk",
"type": "shell",
"command": "latexmk",
"args": [
"-xelatex",
"-r",
"tools/.latexmkrc",
"-gg",
"-outdir=build/output-tex",
"build/output-tex/input.tex"],
"problemMatcher": [],
"presentation": {
"group": "converter"
},
},
{
"label": "📄 View HTML",
"type": "shell",
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ abstract class PandocTask @Inject constructor() : Exec() {
failIfWarning.convention(true)
verbose.convention(false)
additionalArgs.convention(arrayOf())
markdownFiles.convention(project.fileTree("${project.rootDir}/chapters/"){include("**/*.md", "**/*.html")})
markdownFiles.convention(project.fileTree("${project.rootDir}/chapters/"){include("**/*.md", "**/*.html", "**/*.tex")})
assetFiles.convention(project.fileTree("${project.rootDir}/files/"){ include("**/*") })
literatureFiles.convention(project.fileTree("${project.rootDir}/literature/"){ include("**/*") })
convertFiles.convention(project.fileTree("${settings.dataDir}"){ include("**/*") })
Expand Down
174 changes: 90 additions & 84 deletions build/Content.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,28 @@

sidnav.style.width = `${expandWidth}px`;
if (m.offsetLeft - expandWidth < 0) {
m.style.marginLeft = `${expandWidth + 40}px`
m.style.marginLeft = `${expandWidth + 40}px`;
}

document.getElementById("nav-content-inline").style.display = "none";

document.getElementById("nav-content").style.display = "none";

toc = document.getElementById("TOC");
// Append to sidebar.
toc.parentNode.removeChild(toc);
document.getElementById("side-nav-content").append(toc);
}

function closeSideNav() {
document.getElementById("side-nav").style.width = "0";
document.getElementById("main-markdown").style.marginLeft = null;
document.getElementById("nav-content-inline").style.display = "initial";

navContent = document.getElementById("nav-content");
navContent.style.display = "initial";

toc = document.getElementById("TOC");
// Append to inline.
toc.parentNode.removeChild(toc);
document.getElementById("nav-content").append(toc);
}

var EXPAND_ALL = "⊞";
Expand Down Expand Up @@ -258,73 +270,14 @@
<a class="expand-btn" id="expand" href="javascript:void(0)" onClick="toggleExpandCollapse()" style="baseline-shift:-10%"></a>
<a class="close-btn" href="javascript:void(0)" onclick="closeSideNav()">&times;</a>
</div>
<div id="nav-content">
<nav id="TOC" role="doc-toc">
<ul>
<li><a href="#intro" id="toc-intro"><span
class="toc-section-number">1</span>
Intro</a></li>
<li><a href="#samples" id="toc-samples"><span
class="toc-section-number">2</span> Samples</a>
<ul>
<li><a href="#konvexe-probleme"
id="toc-konvexe-probleme"><span
class="toc-section-number">2.1</span> Konvexe
Probleme</a>
<ul>
<li><a href="#konvexe-menge"
id="toc-konvexe-menge"><span
class="toc-section-number">2.1.1</span> Konvexe
Menge</a></li>
<li><a href="#proximaler-punkt"
id="toc-proximaler-punkt"><span
class="toc-section-number">2.1.2</span>
Proximaler Punkt</a></li>
<li><a href="#normalkegel"
id="toc-normalkegel"><span
class="toc-section-number">2.1.3</span>
Normalkegel</a></li>
<li><a
href="#zusammenhang-von-normalkegel-und-proximaler-punkt"
id="toc-zusammenhang-von-normalkegel-und-proximaler-punkt"><span
class="toc-section-number">2.1.4</span>
Zusammenhang von Normalkegel und Proximaler
Punkt</a></li>
<li><a
href="#zusammenhang-von-normalkegel-und-konvexer-optimierung"
id="toc-zusammenhang-von-normalkegel-und-konvexer-optimierung"><span
class="toc-section-number">2.1.5</span>
Zusammenhang von Normalkegel und Konvexer
Optimierung</a></li>
</ul></li>
<li><a href="#code-sample"
id="toc-code-sample"><span
class="toc-section-number">2.2</span> Code
Sample</a></li>
<li><a href="#tables" id="toc-tables"><span
class="toc-section-number">2.3</span> Tables</a>
<ul>
<li><a href="#html-table"
id="toc-html-table"><span
class="toc-section-number">2.3.1</span> HTML
Table</a></li>
<li><a href="#sec:multi-line-table"
id="toc-sec:multi-line-table"><span
class="toc-section-number">2.3.2</span> Markdown
Table</a></li>
</ul></li>
</ul></li>
<li><a href="#references"
id="toc-references">References</a></li>
</ul>
</nav>
<div id="side-nav-content">
</div>
</div><div id="main-markdown">
<header>
<div class="title-block">
<h1 class="title">Technical Documents</h1>
<h3 class="subtitle">Demonstrating the Power of Markdown
with Pandoc</h4>
with Pandoc</h3>
<p class="author">
<strong>Authors: </strong>Gabriel Nützi, The Community
</p>
Expand All @@ -345,7 +298,7 @@ <h3 class="subtitle">Demonstrating the Power of Markdown
<a href="https://gradle.org"><code>gradle</code></a> and of course <a
href="https://pandoc.org"><code>pandoc</code></a>.
</div>
<div id="nav-content-inline">
<div id="nav-content">
<nav id="TOC">
<ul>
<li><a href="#intro" id="toc-intro"><span
Expand Down Expand Up @@ -383,15 +336,23 @@ <h3 class="subtitle">Demonstrating the Power of Markdown
<li><a href="#code-sample" id="toc-code-sample"><span
class="toc-section-number">2.2</span> Code
Sample</a></li>
<li><a href="#pdf-include-sample"
id="toc-pdf-include-sample"><span
class="toc-section-number">2.3</span> PDF Include
Sample</a></li>
<li><a href="#questionaire-sample"
id="toc-questionaire-sample"><span
class="toc-section-number">2.4</span> Questionaire
Sample</a></li>
<li><a href="#tables" id="toc-tables"><span
class="toc-section-number">2.3</span> Tables</a>
class="toc-section-number">2.5</span> Tables</a>
<ul>
<li><a href="#html-table" id="toc-html-table"><span
class="toc-section-number">2.3.1</span> HTML
class="toc-section-number">2.5.1</span> HTML
Table</a></li>
<li><a href="#sec:multi-line-table"
id="toc-sec:multi-line-table"><span
class="toc-section-number">2.3.2</span> Markdown
class="toc-section-number">2.5.2</span> Markdown
Table</a></li>
</ul></li>
</ul></li>
Expand Down Expand Up @@ -835,10 +796,49 @@ <h2 data-number="2.2" id="code-sample"><span
<span id="cb1-89"><a href="#cb1-89"></a> InputSockets <span class="va">m_inputs</span><span class="op">;</span> <span class="co">//!&lt; The input sockets.</span></span>
<span id="cb1-90"><a href="#cb1-90"></a> OutputSockets <span class="va">m_outputs</span><span class="op">;</span> <span class="co">//!&lt; The output sockets.</span></span>
<span id="cb1-91"><a href="#cb1-91"></a><span class="op">};</span></span></code></pre></div>
<h2 data-number="2.3" id="tables"><span
class="header-section-number">2.3</span> Tables</h2>
<h3 data-number="2.3.1" id="html-table"><span
class="header-section-number">2.3.1</span> HTML Table</h3>
<h2 data-number="2.3" id="pdf-include-sample"><span
class="header-section-number">2.3</span> PDF Include Sample</h2>
<p>You can also include PDFs directly by: Selecting pages works only in
<code>latex</code> output.</p>
<figure>
<embed src="files/PandocUsersGuide.pdf" class="includepdf"
data-pages="5-" style="width:100%;height:20cm;max-width:100%" />
<figcaption aria-hidden="true">Pandoc User’s Guide</figcaption>
</figure>
<h2 data-number="2.4" id="questionaire-sample"><span
class="header-section-number">2.4</span> Questionaire Sample</h2>
<h3 class="unnumbered unlisted" id="personal">Personal</h3>
<ul>
<li><span class="hrule-fill"
style="width:10cm;border-bottom-width:0.5pt">Name:</span></li>
<li><span class="hrule-fill"
style="width:10cm;border-bottom-width:0.5pt">Email:</span></li>
</ul>
<h3 class="unnumbered unlisted" id="how-hard-is-markdown">How hard is
Markdown?</h3>
<ul class="task-list">
<li><input type="checkbox" disabled="" />
easy</li>
<li><input type="checkbox" disabled="" />
medium hard</li>
<li><input type="checkbox" disabled="" />
ridiculuous hard</li>
</ul>
<h3 class="unnumbered unlisted"
id="which-features-would-you-like-to-have-which-markdown-does-currently-not-support">Which
features would you like to have which Markdown does currently not
support?</h3>
<p><span class="hrule-fill"
style="width:100%;border-bottom-width:0.5pt"></span><br />
<span class="hrule-fill"
style="width:100%;border-bottom-width:0.5pt"></span><br />
<span class="hrule-fill"
style="width:50%;border-bottom-width:0.5pt"></span><br />
</p>
<h2 data-number="2.5" id="tables"><span
class="header-section-number">2.5</span> Tables</h2>
<h3 data-number="2.5.1" id="html-table"><span
class="header-section-number">2.5.1</span> HTML Table</h3>
<div>
<ul>
<li>Included html file as <code>html</code>.</li>
Expand All @@ -857,15 +857,21 @@ <h3 data-number="2.3.1" id="html-table"><span
</colgroup>
<thead>
<tr class="header">
<th>Fruits</th>
<th>Vegetables</th>
<th>Constraints</th>
<th>Properties</th>
<th><strong>Fruits asd</strong></th>
<th><strong>Vegetables</strong></th>
<th><strong>Constraints</strong></th>
<th><strong>Properties</strong></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><strong>First</strong></td>
<td>Pre</td>
<td>Zuccini</td>
<td>ripe</td>
<td>long</td>
</tr>
<tr class="even">
<td>First</td>
<td><ol>
<li>Lorem ipsum.</li>
<li>Aliquam tinc.</li>
Expand All @@ -882,8 +888,8 @@ <h3 data-number="2.3.1" id="html-table"><span
</dl></td>
<td></td>
</tr>
<tr class="even">
<td><strong>Second</strong></td>
<tr class="odd">
<td>Second</td>
<td><ul>
<li>Lorem ipsum.</li>
<li>Mauris eu.</li>
Expand All @@ -900,8 +906,8 @@ <h3 data-number="2.3.1" id="html-table"><span
</tbody>
</table>
</div>
<h3 data-number="2.3.2" id="sec:multi-line-table"><span
class="header-section-number">2.3.2</span> Markdown Table</h3>
<h3 data-number="2.5.2" id="sec:multi-line-table"><span
class="header-section-number">2.5.2</span> Markdown Table</h3>
<ul>
<li>Included markdown files.</li>
<li>Cross references do work here.</li>
Expand Down Expand Up @@ -959,7 +965,7 @@ <h3 data-number="2.3.2" id="sec:multi-line-table"><span
<td><ul>
<li>cures scurvy</li>
<li>tasty</li>
<li>Link chap. <a href="#sec:multi-line-table">2.3.2</a></li>
<li>Link chap. <a href="#sec:multi-line-table">2.5.2</a></li>
</ul></td>
</tr>
</tbody>
Expand All @@ -985,4 +991,4 @@ <h1 class="unnumbered" id="references">References</h1>
</div>
</body>

</html>
</html>
Binary file modified build/Content.pdf
Binary file not shown.
Loading

0 comments on commit 410a49d

Please sign in to comment.