Improved mkdocspdf.sh

This commit is contained in:
Revar Desmera 2023-05-08 16:45:38 -07:00
parent 99c3f460a9
commit 8cb006cd46
4 changed files with 244 additions and 13 deletions

3
.gitignore vendored
View file

@ -110,4 +110,7 @@ foo.scad
BOSL2.wiki BOSL2.wiki
/ref/ /ref/
docsgen_report.json docsgen_report.json
BOSL2_Docs.html
BOSL2_Docs.epub
BOSL2_Docs.pdf

167
resources/docs_custom.css Normal file
View file

@ -0,0 +1,167 @@
html {
font-family: Arial;
color: #1a1a1a;
background-color: #fdfdfd;
}
body {
margin: 0 auto;
max-width: 36em;
padding-left: 50px;
padding-right: 50px;
padding-top: 50px;
padding-bottom: 50px;
hyphens: auto;
overflow-wrap: break-word;
text-rendering: optimizeLegibility;
font-kerning: normal;
}
@media (max-width: 600px) {
body {
font-size: 0.9em;
padding: 12px;
}
h1 {
font-size: 1.8em;
}
}
@media print {
html {
background-color: white;
}
body {
background-color: transparent;
color: black;
font-size: 12pt;
}
p, h2, h3 {
orphans: 3;
widows: 3;
}
h2, h3, h4 {
page-break-after: avoid;
}
}
p {
margin: 1em 0;
}
a {
color: #1a1a1a;
}
a:visited {
color: #1a1a1a;
}
img {
max-width: 100%;
}
h1 {
margin-top: 2.5em;
}
h2, h3, h4, h5, h6 {
margin-top: 1.4em;
}
h5, h6 {
font-size: 1em;
font-style: italic;
}
h6 {
font-weight: normal;
}
h1, h2 {
border-bottom: 1px solid #1a1a1a;
}
ol, ul {
padding-left: 1.7em;
margin-top: 1em;
}
li > ol, li > ul {
margin-top: 0;
}
blockquote {
margin: 1em 0 1em 1.7em;
padding-left: 1em;
border-left: 2px solid #e6e6e6;
color: #606060;
}
code {
font-family: Menlo, Monaco, Consolas, 'Lucida Console', monospace;
font-size: 85%;
margin: 0;
hyphens: manual;
}
pre {
margin: 1em 0;
overflow: auto;
}
pre code {
padding: 0;
overflow: visible;
overflow-wrap: normal;
}
.sourceCode {
background-color: transparent;
overflow: visible;
}
hr {
background-color: #1a1a1a;
border: none;
height: 1px;
margin: 1em 0;
}
table {
margin: 1em 0;
border-collapse: collapse;
width: 100%;
overflow-x: auto;
display: block;
font-variant-numeric: lining-nums tabular-nums;
}
table caption {
margin-bottom: 0.75em;
}
thead {
background-color: #ccf
}
tbody {
margin-top: 0.5em;
}
tr {
}
th {
padding: 0.25em 0.5em 0.25em 0.5em;
vertical-align: top;
text-align: left;
border: 1px solid #1a1a1a;
}
td {
padding: 0.125em 0.5em 0.25em 0.5em;
vertical-align: top;
border: 1px solid #1a1a1a;
}
header {
margin-bottom: 4em;
text-align: center;
}
#TOC li {
list-style: none;
}
#TOC ul {
padding-left: 1.3em;
}
#TOC > ul {
padding-left: 0;
}
#TOC a:not(:hover) {
text-decoration: none;
}
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}

View file

@ -0,0 +1,53 @@
-- links-filter.lua
function Link(el)
found, _, a, b = string.find(el.target, "^(%w+)%.scad#(.*)$")
if found then
el.target = string.format("#%sscadmd__%s", string.lower(a), string.lower(b))
return el
end
found, _, a = string.find(el.target, "^(%w+)%.scad$")
if found then
el.target = string.format("#%sscadmd", string.lower(a))
return el
end
found, _, a, b = string.find(el.target, "^Tutorial-(%w+)%#(.*)$")
if found then
el.target = string.format("#tutorial-%smd__%s", string.lower(a), string.lower(b))
return el
end
found, _, a = string.find(el.target, "^Tutorial-(%w+)$")
if found then
el.target = string.format("#tutorial-%smd", string.lower(a))
return el
end
found, _, a, b = string.find(el.target, "^(%w+)%.md#(.*)$")
if found then
el.target = string.format("#%smd__%s", string.lower(a), string.lower(b))
return el
end
found, _, a = string.find(el.target, "^(%w+)%.md$")
if found then
el.target = string.format("#%smd", string.lower(a))
return el
end
found, _, a, b = string.find(el.target, "^(%w+)#(.*)$")
if found then
el.target = string.format("#%smd__%s", string.lower(a), string.lower(b))
return el
end
found, _, a = string.find(el.target, "^(%w+)$")
if found then
el.target = string.format("#%smd", string.lower(a))
return el
end
return el
end

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
FORMAT=pdf OUTFILE_BASE="BOSL2_Docs"
SUFFIX=pdf FORMATS="html5"
SOURCES="*.scad.md Tutorial-*.md Topics.md AlphaIndex.md" SOURCES="constants.scad.md transforms.scad.md attachments.scad.md shapes2d.scad.md shapes3d.scad.md drawing.scad.md masks2d.scad.md masks3d.scad.md distributors.scad.md color.scad.md partitions.scad.md mutators.scad.md paths.scad.md regions.scad.md skin.scad.md vnf.scad.md beziers.scad.md rounding.scad.md turtle3d.scad.md math.scad.md linalg.scad.md vectors.scad.md coords.scad.md geometry.scad.md trigonometry.scad.md version.scad.md comparisons.scad.md lists.scad.md utility.scad.md strings.scad.md structs.scad.md fnliterals.scad.md threading.scad.md screws.scad.md metric_screws.scad.md screw_drive.scad.md bottlecaps.scad.md ball_bearings.scad.md cubetruss.scad.md gears.scad.md hinges.scad.md joiners.scad.md linear_bearings.scad.md modular_hose.scad.md nema_steppers.scad.md polyhedra.scad.md sliders.scad.md tripod_mounts.scad.md walls.scad.md wiring.scad.md Tutorial-*.md Topics.md AlphaIndex.md"
PANDOC="/usr/local/Cellar/pandoc/3.1/bin/pandoc" PANDOC="/usr/local/Cellar/pandoc/3.1/bin/pandoc"
TITLE="Documentation for the Belfry OpenSCAD Library v2" TITLE="Documentation for the Belfry OpenSCAD Library v2"
AUTHOR="Garth Minette" AUTHOR="Garth Minette"
@ -14,16 +14,24 @@ fi
cd BOSL2.wiki cd BOSL2.wiki
${PANDOC} -f gfm -t ${FORMAT} -o ../documentation.${SUFFIX} \ for format in ${FORMATS} ; do
suffix=$(echo ${format} | sed 's/html5/html/')
outfile="${OUTFILE_BASE}.${suffix}"
echo "Generating ${outfile} ..."
${PANDOC} -f gfm -t ${format} -o ../${outfile} \
-s --embed-resources --mathjax --file-scope --pdf-engine=xelatex \ -s --embed-resources --mathjax --file-scope --pdf-engine=xelatex \
--toc --columns=100 --epub-cover-image=../images/BOSL2logo.png \ --columns=100 --epub-cover-image=../images/BOSL2logo.png \
--toc -N --toc-depth=2 --css=../resources/docs_custom.css \
--lua-filter=../resources/links-filter-html.lua \
--resource-path='.:images:images/*' \
--variable mainfont=Arial --variable sansfont=Arial \ --variable mainfont=Arial --variable sansfont=Arial \
--metadata title="${TITLE}" \ --metadata title="${TITLE}" \
--metadata author="${AUTHOR}" \ --metadata author="${AUTHOR}" \
--metadata date="$(date -j "+%B %e, %Y")" \ --metadata date="$(date -j "+%B %e, %Y")" \
--metadata geometry=left=3cm,right=3cm,top=2cm,bottom=2cm \ --metadata geometry=left=3cm,right=3cm,top=2cm,bottom=2cm \
${SOURCES} ${SOURCES}
done
cd .. cd ..