initial commit

This commit is contained in:
Martin Sukany
2025-06-05 09:39:46 +02:00
commit cced7f02f7
58 changed files with 7275 additions and 0 deletions

33
docs/book.toml Executable file
View File

@@ -0,0 +1,33 @@
[book]
title = "MDBook to PDF template"
authors = ["Martin Sukany"]
language = "en"
multilingual = false
src = "src"
[preprocessor.obsidian]
[output.html]
[output.pandoc.profile.pdf]
output-file = "output.pdf"
to = "latex"
pdf-engine = "pdflatex"
standalone = true
include-in-header = "header.tex"
filters = ["column-fit.lua"]
[output.html.print]
enable = true # include support for printable output
page-break = true # insert page-break after each chapter
[output.html.fold]
enable = false # whether or not to enable section folding
level = 0 # the depth to start folding
[output.pandoc.profile.pdf.variables]
# this makes Pandoc emit \date{\today} into the LaTeX it generates
date = "\\today"
documentclass = "report"
fontsize = "10pt"

61
docs/column-fit.lua Normal file
View File

@@ -0,0 +1,61 @@
-- column-fit.lua (robust, 2025-06-05)
-- Auto-sizes every table so columns get a width proportional to the
-- longest word/line they contain. Works on Pandoc 2.17 → 3.x.
local stringify = (require 'pandoc.utils').stringify
local hasRCW = type(pandoc.RelativeColumnWidth) == "function"
-- UTF-8 code-point length (pure Lua)
local function ulen(s)
local _, n = s:gsub('[\0-\127\194-\244][\128-\191]*', '')
return n
end
-- ensure arrays are long enough ----------------------------------------
local function ensure(tbl, i, v)
if not tbl[i] then tbl[i] = v end
end
-- walk every cell ------------------------------------------------------
local function each_cell(t, fn)
local function rows(block)
if block then
for _, row in ipairs(block) do
for c, cell in ipairs(row.cells) do fn(cell, c) end
end
end
end
rows(t.head.rows)
for _, body in ipairs(t.bodies) do rows(body.body) end
rows(t.foot.rows)
end
function Table(t)
local max = {} -- longest token per col
-- pass 1 measure --------------------------------------------------
each_cell(t, function (cell, col)
ensure(max, col, 0)
ensure(t.colspecs, col, {pandoc.AlignDefault, 0})
local txt = stringify(cell.contents or cell)
for line in txt:gmatch('[^\n]+') do
for word in line:gmatch('%S+') do
local len = ulen(word)
if len > max[col] then max[col] = len end
end
end
end)
local total = 0
for _, v in ipairs(max) do total = total + v end
if total == 0 then return nil end -- empty table
-- pass 2 write widths back ----------------------------------------
for c, spec in ipairs(t.colspecs) do
local rel = max[c] / total
spec[2] = hasRCW and pandoc.RelativeColumnWidth(rel) or rel
end
return t
end

125
docs/header.tex Normal file
View File

@@ -0,0 +1,125 @@
% header.tex
% Professional header for mdBook (via Pandoc) PDF output.
% Intended for use with pdflatex.
%
% This header provides:
% - Modern fonts and microtypography
% - Clean page geometry and headers/footers
% - Improved title formatting (with larger author text)
% - Professional table styling with alternating row colors and auto-scaling
%% 1. Encoding, Fonts, and Microtypography
\usepackage[utf8]{inputenc} % Source encoding
\usepackage[T1]{fontenc} % Font encoding
\usepackage{lmodern} % Modern fonts
\usepackage{microtype} % Improves typography
%% 1a. some additional stuff
\usepackage{titleps}
\usepackage{fancyhdr}
\usepackage{awesomebox}
\usepackage{minitoc}
%% 2. Page Geometry
\usepackage[a4paper,margin=1in]{geometry}
%% 3. Graphics and Colors
\usepackage{graphicx} % For images
\usepackage{xcolor}
\definecolor{linkcolor}{RGB}{0, 0, 180} % Deep blue for links
\definecolor{tableShade}{RGB}{245,245,245} % Light gray for table row shading
\definecolor{lightGreen}{RGB}{240,255,240} % Very light green
\definecolor{mediumGreen}{RGB}{220,255,220} % Darker green
\usepackage{colortbl}
%% 4. Hyperlinks
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
linkcolor = linkcolor,
urlcolor = linkcolor,
citecolor = linkcolor,
}
%% 5. Title Formatting (using titling package)
\usepackage{titling}
\renewcommand{\maketitle}{%
\begin{titlepage}
\centering
% push block to vertical centre
\vspace*{\fill}
% Title
{\LARGE\bfseries\thetitle\par}
\vspace{1em}
% Author
{\large\theauthor\par}
\vspace{2em}
% Date
{\normalsize\itshape\thedate\par}
\vspace{2em}
% Logo
\includegraphics[width=0.35\textwidth]{logo.png}\par
% balance to bottom
\vspace*{\fill}
\end{titlepage}%
}
%% 6. Headers and Footers (fancyhdr)
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % Clear header/footer
\lhead{\small \nouppercase{\leftmark}}
\rhead{\small \thepage}
\rhead{\includegraphics[width=1cm]{logo.png}}
\renewcommand{\headrulewidth}{0.4pt}
%% 8. Table Packages: booktabs, tabularx, longtable, and array
%\usepackage{booktabs} % Professional table rules
%\usepackage{tabularx} % Flexible-width tables
%\usepackage{longtable} % Tables spanning multiple pages
%\usepackage{array} % Enhanced array and tabular environments
%\usepackage{colortbl} % For colored table rows
%% 9. Automatic Table Scaling and Alternating Row Colors
\usepackage{adjustbox} % For scaling tables to \textwidth
\usepackage{etoolbox} % For patching environments
% For longtable, add alternating row colors (without adjustbox to avoid grouping conflicts).
\AtBeginEnvironment{longtable}{\rowcolors{1}{mediumGreen}{lightGreen}}
%% 10. Define Custom Column Types for tabularx (optional)
% Use these column types in your Markdown (via Pandoc filters or manual LaTeX)
% to enforce equal-width columns.
\newcolumntype{Y}{>{\centering\arraybackslash}X} % centered
\newcolumntype{L}{>{\raggedright\arraybackslash}X} % left-aligned
\newcolumntype{R}{>{\raggedleft\arraybackslash}X} % right-aligned
%% 11. Use Helvetica sans-serif font
\usepackage{helvet} % Use Helvetica
\renewcommand{\familydefault}{\sfdefault} % Set the default to sans serif
%% 12. highlighting code blocks
\usepackage{listings}
\lstset{
backgroundcolor=\color{yellow},
basicstyle=\ttfamily,
breaklines=true
}

BIN
docs/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

22
docs/src/README.md Normal file
View File

@@ -0,0 +1,22 @@
# MDBook PDF template
## Description
This templates allows you to create fency PDF documents directly from MarkDown sources.
## Workflow
1. Firstly, you need to run Podman on your workstation
2. Build mdbook-local container image which will be used. Image contains all needed components
```
podman build -f Dockerfile -t mdbook-local .
```
3. Edit following files in `docs` directory
- **book.toml** - change author and title and do any adjustments you need
- **src/SUMMARY.md** - Table of content (source document) from which MDBook generates the documentation
4. Run `mdbook_export.sh`
5. Find your new files in export directory

6
docs/src/SUMMARY.md Normal file
View File

@@ -0,0 +1,6 @@
# SUMMARY
# First part
- [How to use this template](<README.md>)