add support for ####-paragraphs and dark mode
This commit is contained in:
14
Makefile
14
Makefile
@@ -8,22 +8,24 @@ help:
|
||||
%.html: %.markdown src/template-*.html src/rules-html-pre.sed src/rules-html-post.sed
|
||||
@echo
|
||||
@echo "Build HTML: $*.html"
|
||||
n="$*"; python3 src/temp_prepare.py src/template-$${n%%-*}.html $*.markdown $*.html.1.tmp
|
||||
sed -f src/rules-html-pre.sed $*.markdown.tmp | pandoc -t html -o $*.html.2.tmp
|
||||
sed -f src/rules-html-pre.sed $*.markdown > $*.sed.md
|
||||
n="$*"; python3 src/temp_prepare.py src/template-$${n%%-*}.html $*.sed.md > $*.html.1.tmp
|
||||
pandoc -t html -o $*.html.2.tmp -f markdown $*.sed.md.tmp
|
||||
sed -f src/rules-html-post.sed $*.html.2.tmp > $*.html
|
||||
python3 src/temp_combine.py $*.html.1.tmp $*.html
|
||||
rm -f $*.markdown.tmp $*.html.1.tmp $*.html.2.tmp
|
||||
rm -f $*.sed.md $*.sed.md.tmp $*.html.1.tmp $*.html.2.tmp
|
||||
cp $*.html bin/
|
||||
|
||||
%.tex: %.markdown src/template-*.tex src/rules-tex-pre.sed src/rules-tex-post.sed
|
||||
@echo
|
||||
@echo "Build TEX: $*.tex"
|
||||
n="$*"; python3 src/temp_prepare.py src/template-$${n%%-*}.tex $*.markdown $*.tex.1.tmp
|
||||
sed -f src/rules-tex-pre.sed $*.markdown > $*.sed.md
|
||||
n="$*"; python3 src/temp_prepare.py src/template-$${n%%-*}.tex $*.sed.md > $*.tex.1.tmp
|
||||
# heading shift needed because tufte doesnt have subsubsection
|
||||
sed -f src/rules-tex-pre.sed $*.markdown.tmp | pandoc --shift-heading-level-by=-1 -t latex -o $*.tex.2.tmp
|
||||
pandoc --shift-heading-level-by=-1 -t latex -o $*.tex.2.tmp -f markdown $*.sed.md.tmp
|
||||
sed -f src/rules-tex-post.sed $*.tex.2.tmp > $*.tex
|
||||
python3 src/temp_combine.py $*.tex.1.tmp $*.tex
|
||||
rm -f $*.markdown.tmp $*.tex.1.tmp $*.tex.2.tmp
|
||||
rm -f $*.sed.md $*.sed.md.tmp $*.tex.1.tmp $*.tex.2.tmp
|
||||
|
||||
%.pdf: %.tex
|
||||
@echo
|
||||
|
||||
55
README.md
55
README.md
@@ -21,19 +21,36 @@ Included in the package:
|
||||
- Font [Cochineal](https://www.ctan.org/pkg/cochineal), by Michael Sharpe
|
||||
- Font [Roboto](https://github.com/googlefonts/roboto), by Christian Robertson
|
||||
- Font [Iosevka](https://github.com/be5invis/Iosevka), by Belleve Invis
|
||||
- Font [Piazzolla](https://github.com/huertatipografica/piazzolla), by Juan Pablo del Peral
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
The format is mostly markdown, except for these modifications:
|
||||
|
||||
- Use `\,` to insert a non-breaking thin-space.
|
||||
- Whitespace
|
||||
- Use `\,` to insert a non-breaking thin-space.
|
||||
- Use `\~` or the actual character to insert a normal-width non-breaking space (unicode nbsp in macOS: `Alt + Space`, Linux: `???`, Windows: `???`).
|
||||
- Use `\newpage` to start a new page in latex (which is ignored in html)
|
||||
|
||||
- To insert a normal-width non-breaking space use `\~` or the actual character (macOS: `Alt + Space`, Linux: `???`, Windows: `???`).
|
||||
- Use `@== CONTENT ==@` to create a margin element; Text or image or whatever.
|
||||
- multi-line content allowed.
|
||||
- the prefix `@=latex=` will display its content in pdf only. There is no html-prefix equivalent.
|
||||
|
||||
- Use `\newpage` to start a new page in latex (which is ignored in html)
|
||||
- Use `####` to create paragraph like sections. These sections are displayed in the margin. Like an index for quick reference. In mobile html they are normal `h4` headings.
|
||||
- Of course `#`, `##`, and `###` are translated to `h1` to `h3` headings
|
||||
|
||||
- It supports the latex `\begin{description}` environment by using the html equivalent `<dl><dt><dd>`
|
||||
- You can add a reference-id to a title by adding `{#label}` after the title, e.g., `## Title {#title}`
|
||||
- other than that, all titles have implicit labels where spaces are replaced with dashes `My Title` becomes `my-title`
|
||||
- btw., you can also add classes this way `{.fullwidth}`
|
||||
- Use normal markdown syntax `[name](#ref)` to link to a section (works in both, html and latex)
|
||||
|
||||
- Use `<dl><dt><dd>` to create definition lists. This will be translated to a latex `\begin{description}` environment.
|
||||
|
||||
|
||||
## Templating
|
||||
|
||||
- The file prefix, e.g. `en`, is the template file identifier. This can be used for multi-language generation or different types of webpages.
|
||||
|
||||
- The header always begins and ends with a line of at least five colons `:::::`
|
||||
- Each line inside the header has the format `KEY: VALUE`
|
||||
@@ -44,37 +61,7 @@ The format is mostly markdown, except for these modifications:
|
||||
- Each ML-variable begins with ` KEY : @@@ ` and ends with a line of just three at-signs (regex: `^@@@$`). No whitespace allowed.
|
||||
- multi-line variables may contain a line of colons (the header terminator is ignored here)
|
||||
|
||||
- You can add a reference to a title by adding `{#label}` after the title, e.g., `## Title {#title}`
|
||||
- other than that, all titles have implicit labels where spaces are replaced with dashes `My Title` becomes `my-title`
|
||||
- btw., you can also add classes this way `{.fullwidth}`
|
||||
|
||||
- The file prefix, e.g. `en`, is the template file identifier. This can be used for multi-language generation or different types of webpages.
|
||||
|
||||
- Use `@== content ==@` to place something in the border margin.
|
||||
- multi-line content is allowed.
|
||||
- the prefix `@=latex=` will display something in the pdf but not in html. (there is no equivalent for html-only)
|
||||
|
||||
|
||||
## Limitations
|
||||
|
||||
This script has not been tested on Linux or Windows. However, Linux should work fine ... in theory.
|
||||
|
||||
### Known Issues
|
||||
|
||||
__#1__: If using URLs ins the margin, adding a newline before the href will add an unwanted space. e.g.:
|
||||
|
||||
```
|
||||
@==
|
||||
[multi line, super long name desc!](multi-line-url)
|
||||
==@
|
||||
```
|
||||
|
||||
will become:
|
||||
|
||||
```
|
||||
| multi line,
|
||||
| super long
|
||||
| name desc!
|
||||
```
|
||||
|
||||
Fix for __#1__: place the beginning of the url on the same line `@==[]()...` (does not have to be closed on the same line)
|
||||
|
||||
109
bin/custom.css
Normal file → Executable file
109
bin/custom.css
Normal file → Executable file
@@ -1,43 +1,89 @@
|
||||
.button {
|
||||
border: 2px solid #ff5050;
|
||||
color: #ff5050;
|
||||
background-color: #fff;
|
||||
padding: 16px 32px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
color: #fff;
|
||||
background-color: #ff5050;
|
||||
@font-face { font-family: 'Roboto'; src: url(fonts/Roboto-Regular.otf); } /* only h1-6, thus no italic */
|
||||
@font-face { font-family: 'Piazzolla'; src: url(fonts/Piazzolla.ttf); }
|
||||
@font-face { font-family: 'Piazzolla'; font-style: italic; src: url(fonts/Piazzolla-Italic.ttf); }
|
||||
|
||||
body {
|
||||
font-family: Piazzolla, Helvetica Neue, sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
b,strong { font-weight: 600; }
|
||||
h1,h2,h3,h4,h5,h6,.topnav {
|
||||
font-family: Roboto, Helvetica Neue, sans-serif;
|
||||
}
|
||||
#subtitle { margin-top: inherit; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #17110E; color: #DDD; font-weight: 500; }
|
||||
b, strong { font-weight: 600; color: #FFF; }
|
||||
}
|
||||
|
||||
/* Quick-jump to section navigation */
|
||||
div.topnav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
color:grey;
|
||||
z-index: 1;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
width: max-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.topnav a {
|
||||
float: left;
|
||||
color:grey;
|
||||
text-align: center;
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
font-size: 16px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.topnav a:hover {
|
||||
background-color: whitesmoke;
|
||||
color: black;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
div.topnav { background-color: #372F2C; color: #DDD; }
|
||||
}
|
||||
|
||||
/* Back-to-top button */
|
||||
.button {
|
||||
border: 2px solid #ff5050;
|
||||
color: #ff5050;
|
||||
background-color: #ffffff;
|
||||
align-self: baseline;
|
||||
padding: 16px 32px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 4px 2px;
|
||||
transition-duration: 0.4s;
|
||||
cursor: pointer;
|
||||
position: fixed;
|
||||
bottom: 1em;
|
||||
}
|
||||
.button:hover {
|
||||
color: #ffffff;
|
||||
transition-timing-function: ease-in;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
background-color: #ff5050;
|
||||
}
|
||||
|
||||
/* Margin-Sections */
|
||||
p + .h4-spacer {
|
||||
margin-top: 2.2rem;
|
||||
}
|
||||
h4 {
|
||||
display: none;
|
||||
font-size: 1.4em;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
h4 + p { margin-top: 0; }
|
||||
@media (max-width: 760px) {
|
||||
.h4-spacer { display: none; }
|
||||
h4 { display: inherit; }
|
||||
h4 + p>.marginnote, h4 + p>.sidenote {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Override original Tufte CSS */
|
||||
|
||||
@@ -47,15 +93,32 @@ p {
|
||||
-ms-hyphens: auto;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
h3 { line-height: inherit; }
|
||||
|
||||
h2, h3, h4 {
|
||||
font-style: unset;
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
a:link, .tufte-underline, .hover-tufte-underline:hover {
|
||||
/*background: unset;*/
|
||||
text-shadow: unset;
|
||||
}
|
||||
|
||||
/*
|
||||
You can choose between two modes.
|
||||
The former will display all margin notes in-text.
|
||||
The latter will add a toggle button.
|
||||
*/
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.sidenote, .marginnote {
|
||||
/* for now, until toggle works */
|
||||
display: block;
|
||||
width: 90%;
|
||||
margin: 2rem 5%;
|
||||
margin: 1rem 5%;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
label.mtoggle::before { content: unset; }
|
||||
@media (max-width: 760px) {
|
||||
label.mtoggle::before { content: ' ⊕'; }
|
||||
}*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>md2tufte</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="tufte.css"/>
|
||||
<link rel="stylesheet" href="custom.css"/>
|
||||
</head>
|
||||
@@ -22,12 +22,12 @@
|
||||
<article>
|
||||
<section>
|
||||
<h1 id="title">md2tufte</h1>
|
||||
<h2>Exemplary overview document</h2>
|
||||
<p><em>relikd</em> (v20210704)</p>
|
||||
<h2 id="subtitle">Exemplary overview document · v2021-09-10</h2>
|
||||
<p><em id="author">relikd</em></p>
|
||||
<p>This document is an exemplary usage of this tool. Of course it will look better with actual documents when the content is longer and the lines break more nicely.</p>
|
||||
</section><section><h2 id="features">Features</h2>
|
||||
<p>This document was created with <a href="https://github.com/relikd/md2tufte"><code>md2tufte</code></a> – a tool which takes a markdown file as input and returns html and pdf as output. It supports the usual markdown syntax and is augmented with a substitution header. To place something in the margin, use the <code>@ ==</code> syntax.</p>
|
||||
<p>For further examples, refer to the README file. You can use in-document references.<span class="marginnote">e.<span style="white-space:nowrap"> </span>g., see section <a href="#requirements">Requirements</a>. </span></p>
|
||||
<p>This document<span style="display: none"> A HTML version of this document using a responsive layout for small screens is available at <a href="https://relikd.github.io/md2tufte/bin/en-example.html">https://relikd.github.io/md2tufte/bin/en-example.html</a> </span> was created with <a href="https://github.com/relikd/md2tufte"><code>md2tufte</code></a> – a tool which takes a markdown file as input and returns html and pdf as output. It supports the usual markdown syntax and is augmented with a substitution header. To place something in the margin, use the <code>@ ==</code> syntax.<span class="marginnote"> <a href="multi-line-url">multi line, super long name desc with various other words than these mere few you saw in the beginning!</a> </span></p>
|
||||
<p>For further examples, refer to the README file. You can use in-document references.<span class="marginnote"> e.<span style="white-space:nowrap"> </span>g., see section <a href="#requirements">Requirements</a>. </span></p>
|
||||
<p>As you see, you can put about anything in the margin. If you want to control that something should be only visible in the pdf version of the document but not in the html version, use the <code>@ =latex=</code> syntax. Currently there is no inverse, i.<span style="white-space:nowrap"> </span>e., <code>@ =html=</code> will <strong>not</strong> work.</p>
|
||||
</section><section><h2 id="requirements">Requirements</h2>
|
||||
<p><span class="marginnote"><img src="img/example.png" /> You can use margin images!</span></p>
|
||||
@@ -69,3 +69,4 @@ build the intermediate file only.
|
||||
<button class="button" onclick="window.scrollTo({top: 0, behavior: 'smooth'})">back to top</button>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
93
bin/fonts/LICENSE-Piazzolla.txt
Executable file
93
bin/fonts/LICENSE-Piazzolla.txt
Executable file
@@ -0,0 +1,93 @@
|
||||
Copyright 2018 The Piazzolla Project Authors (https://github.com/huertatipografica/piazzolla)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
bin/fonts/Piazzolla-Italic.ttf
Normal file
BIN
bin/fonts/Piazzolla-Italic.ttf
Normal file
Binary file not shown.
BIN
bin/fonts/Piazzolla.ttf
Normal file
BIN
bin/fonts/Piazzolla.ttf
Normal file
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>md2tufte</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="tufte.css"/>
|
||||
<link rel="stylesheet" href="custom.css"/>
|
||||
</head>
|
||||
@@ -22,12 +22,12 @@
|
||||
<article>
|
||||
<section>
|
||||
<h1 id="title">md2tufte</h1>
|
||||
<h2>Exemplary overview document</h2>
|
||||
<p><em>relikd</em> (v20210704)</p>
|
||||
<h2 id="subtitle">Exemplary overview document · v2021-09-10</h2>
|
||||
<p><em id="author">relikd</em></p>
|
||||
<p>This document is an exemplary usage of this tool. Of course it will look better with actual documents when the content is longer and the lines break more nicely.</p>
|
||||
</section><section><h2 id="features">Features</h2>
|
||||
<p>This document was created with <a href="https://github.com/relikd/md2tufte"><code>md2tufte</code></a> – a tool which takes a markdown file as input and returns html and pdf as output. It supports the usual markdown syntax and is augmented with a substitution header. To place something in the margin, use the <code>@ ==</code> syntax.</p>
|
||||
<p>For further examples, refer to the README file. You can use in-document references.<span class="marginnote">e.<span style="white-space:nowrap"> </span>g., see section <a href="#requirements">Requirements</a>. </span></p>
|
||||
<p>This document<span style="display: none"> A HTML version of this document using a responsive layout for small screens is available at <a href="https://relikd.github.io/md2tufte/bin/en-example.html">https://relikd.github.io/md2tufte/bin/en-example.html</a> </span> was created with <a href="https://github.com/relikd/md2tufte"><code>md2tufte</code></a> – a tool which takes a markdown file as input and returns html and pdf as output. It supports the usual markdown syntax and is augmented with a substitution header. To place something in the margin, use the <code>@ ==</code> syntax.<span class="marginnote"> <a href="multi-line-url">multi line, super long name desc with various other words than these mere few you saw in the beginning!</a> </span></p>
|
||||
<p>For further examples, refer to the README file. You can use in-document references.<span class="marginnote"> e.<span style="white-space:nowrap"> </span>g., see section <a href="#requirements">Requirements</a>. </span></p>
|
||||
<p>As you see, you can put about anything in the margin. If you want to control that something should be only visible in the pdf version of the document but not in the html version, use the <code>@ =latex=</code> syntax. Currently there is no inverse, i.<span style="white-space:nowrap"> </span>e., <code>@ =html=</code> will <strong>not</strong> work.</p>
|
||||
</section><section><h2 id="requirements">Requirements</h2>
|
||||
<p><span class="marginnote"><img src="img/example.png" /> You can use margin images!</span></p>
|
||||
@@ -69,3 +69,4 @@ build the intermediate file only.
|
||||
<button class="button" onclick="window.scrollTo({top: 0, behavior: 'smooth'})">back to top</button>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
TITLE : md2tufte
|
||||
SUBTITLE : Exemplary overview document
|
||||
SUBTITLE : Exemplary overview document \~·\~ v2021-09-10
|
||||
AUTHOR : relikd
|
||||
VERSION : v20210704
|
||||
TOC : @@@
|
||||
<a href="#features">Features</a>
|
||||
<a href="#requirements">Requirements</a>
|
||||
@@ -22,7 +21,9 @@ A HTML version of this document using a responsive layout for small screens is a
|
||||
==@
|
||||
was created with [`md2tufte`](https://github.com/relikd/md2tufte) – a tool which takes a markdown file as input and returns html and pdf as output.
|
||||
It supports the usual markdown syntax and is augmented with a substitution header.
|
||||
To place something in the margin, use the `@ ==` syntax.
|
||||
To place something in the margin, use the `@ ==` syntax.@==
|
||||
[multi line, super long name desc with various other words than these mere few you saw in the beginning!](multi-line-url)
|
||||
==@
|
||||
|
||||
For further examples, refer to the README file.
|
||||
You can use in-document references.@==
|
||||
|
||||
BIN
en-example.pdf
BIN
en-example.pdf
Binary file not shown.
75
src/common-preamble.tex
Executable file
75
src/common-preamble.tex
Executable file
@@ -0,0 +1,75 @@
|
||||
\usepackage{fontspec}
|
||||
\usepackage{babel}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{xcolor}
|
||||
\hypersetup{
|
||||
colorlinks,
|
||||
linkcolor={red!50!black},
|
||||
citecolor={blue!50!black},
|
||||
urlcolor={blue!80!black}
|
||||
}
|
||||
\pagestyle{fancy}
|
||||
\setlength{\parskip}{\medskipamount}
|
||||
\setlength{\parindent}{0pt}
|
||||
\usepackage{url}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{microtype}
|
||||
|
||||
\setmainfont[
|
||||
Path = fonts/,
|
||||
%Scale = 0.95,
|
||||
BoldFont = {Cochineal-Bold},
|
||||
ItalicFont = {Cochineal-Italic},
|
||||
BoldItalicFont = {Cochineal-BoldItalic}
|
||||
]{Cochineal-Roman}
|
||||
\setsansfont[
|
||||
Path = fonts/,
|
||||
BoldFont = {Roboto-Bold},
|
||||
ItalicFont = {Roboto-Italic},
|
||||
BoldItalicFont = {Roboto-BoldItalic}
|
||||
]{Roboto-Regular}
|
||||
\setmonofont[
|
||||
Path = fonts/,
|
||||
BoldFont = {iosevka-ss04-bold},
|
||||
ItalicFont = {iosevka-ss04-italic},
|
||||
BoldItalicFont = {iosevka-ss04-bolditalic}
|
||||
]{iosevka-ss04-regular}
|
||||
|
||||
\makeatletter
|
||||
|
||||
\usepackage{etoolbox}
|
||||
\usepackage{caption}
|
||||
|
||||
\setcounter{secnumdepth}{2}
|
||||
|
||||
\usepackage{titlesec}
|
||||
\titleformat{\section}
|
||||
{\sffamily\Large}{\thesection.}{0.2em}{}
|
||||
\titleformat{\subsection}
|
||||
{\sffamily\normalsize}{\thesubsection.}{0.2em}{}
|
||||
|
||||
\titlespacing{\section}{0pt}{*6}{*1}
|
||||
\titlespacing{\subsection}{0pt}{*3}{*0.5}
|
||||
|
||||
\usepackage[absolute]{textpos}
|
||||
|
||||
\urlstyle{same}
|
||||
|
||||
\setcounter{secnumdepth}{0}
|
||||
\def\tightlist{}
|
||||
\renewcommand\allcapsspacing[1]{{\addfontfeature{LetterSpace=15}#1}}
|
||||
\renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace=10}#1}}
|
||||
|
||||
\newcommand{\marginsection}[1]{
|
||||
\if@noskipsec\leavevmode\fi \par
|
||||
\paragraph{}
|
||||
\def\@svsechd{\marginnote{#1}}\@xsect{0pt}}
|
||||
|
||||
\setlength{\parindent}{0pt}
|
||||
|
||||
\AtBeginDocument{
|
||||
\def\labelitemi{\normalsize\normalfont\bfseries{--}}
|
||||
}
|
||||
|
||||
\makeatother
|
||||
9
src/rules-html-post.sed
Normal file → Executable file
9
src/rules-html-post.sed
Normal file → Executable file
@@ -1,8 +1,3 @@
|
||||
# Margin note
|
||||
#s?==@?</span>?g
|
||||
#s?@==?<span class="marginnote">?g
|
||||
s?@==[[:space:]]*\(.*\)[[:space:]]*==@?<span class="marginnote">\1</span>?g
|
||||
s?@=latex=\(.*\)==@??g
|
||||
# sectioning
|
||||
# Sectioning
|
||||
s?<h2?</section><section><h2?g
|
||||
s?</section><section><h2 class="no-sect"?<h2?g
|
||||
s?</section><section><h2 class="no-sect"?<h2?g
|
||||
|
||||
15
src/rules-html-pre.sed
Normal file → Executable file
15
src/rules-html-pre.sed
Normal file → Executable file
@@ -1,3 +1,18 @@
|
||||
# thinspace isnt handled very well in html
|
||||
s?\\,?<span style="white-space:nowrap">\ </span>?g
|
||||
s?\\~?\ ?g
|
||||
|
||||
# Margin note
|
||||
s?####[[:space:]]*\(.*\)$?<p class="h4-spacer"></p>\
|
||||
#### \1\
|
||||
@== \1 ==@?g
|
||||
|
||||
# Use this to show margin notes inline
|
||||
s?@=latex=?<span style="display: none">?g
|
||||
s?@==[[:space:]]*?<span class="marginnote">?g
|
||||
s?[[:space:]]*==@?</span>?g
|
||||
|
||||
# OR: use this to enable margin-toggle
|
||||
# s?@=latex=?<label style="display: none"><span>?g
|
||||
# s?[[:space:]]*==@?</span></label>?g
|
||||
# s?@==[[:space:]]*?<label class="mtoggle"><input type="checkbox" class="margin-toggle"><span class="marginnote">?g
|
||||
|
||||
2
src/rules-tex-post.sed
Normal file → Executable file
2
src/rules-tex-post.sed
Normal file → Executable file
@@ -2,4 +2,4 @@
|
||||
s?@=\(latex\)\{0,1\}=[[:space:]]*?\\marginnote{?g
|
||||
s?[[:space:]]*==@?}?g
|
||||
# scale images
|
||||
s?\\marginnote{\\includegraphics?\\marginnote{\\includegraphics[width=1\\linewidth]?g
|
||||
s?\\marginnote{\\includegraphics?\\marginnote{\\includegraphics[width=1\\linewidth]?g
|
||||
|
||||
3
src/rules-tex-pre.sed
Normal file → Executable file
3
src/rules-tex-pre.sed
Normal file → Executable file
@@ -1,8 +1,9 @@
|
||||
s?\\~? ?g
|
||||
s?\\,?\\thinspace ?g
|
||||
s?\\~?\ ?g
|
||||
s?<dl>?\\begin{description}?g
|
||||
s?</dl>?\\end{description}?g
|
||||
s?<dt>?\\item[?g
|
||||
s?</dt>?] ?g
|
||||
s?<dd>??g
|
||||
s?</dd>??g
|
||||
s?####[[:space:]]*\(.*\)$?\\marginsection{\1}?g
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print(' usage: script {template-file} {md-file} {destination-file}')
|
||||
if len(sys.argv) != 3:
|
||||
print(' usage: script {template-file} {md-file}')
|
||||
exit(1)
|
||||
|
||||
temp = sys.argv[1]
|
||||
src = sys.argv[2]
|
||||
dest = sys.argv[3]
|
||||
if not os.path.isfile(temp) or not os.path.isfile(src):
|
||||
print('Error: file does not exist')
|
||||
exit(1)
|
||||
@@ -57,5 +56,4 @@ with open(src, 'r') as f:
|
||||
with open(src + '.tmp', 'w') as f:
|
||||
f.write(f_md)
|
||||
|
||||
with open(dest, 'w') as f:
|
||||
f.write(f_temp)
|
||||
print(f_temp)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title><#_TITLE_#></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="tufte.css"/>
|
||||
<link rel="stylesheet" href="custom.css"/>
|
||||
</head>
|
||||
@@ -19,8 +19,8 @@
|
||||
<article>
|
||||
<section>
|
||||
<h1 id="title"><#_TITLE_#></h1>
|
||||
<h2><#_SUBTITLE_#></h2>
|
||||
<p><em><#_AUTHOR_#></em> (<#_VERSION_#>)</p>
|
||||
<h2 id="subtitle"><#_SUBTITLE_#></h2>
|
||||
<p><em id="author"><#_AUTHOR_#></em></p>
|
||||
<#_BODY_#>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@@ -1,74 +1,12 @@
|
||||
\documentclass[12pt,american,nohyper,a4paper,sfsidenotes]{tufte-handout}
|
||||
\usepackage{fontspec}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{hyperref}
|
||||
\pagestyle{fancy}
|
||||
\setlength{\parskip}{\medskipamount}
|
||||
\setlength{\parindent}{0pt}
|
||||
\usepackage{url}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{microtype}
|
||||
|
||||
\setmainfont[
|
||||
Path = fonts/,
|
||||
%Scale = 0.95,
|
||||
BoldFont = {Cochineal-Bold},
|
||||
ItalicFont = {Cochineal-Italic},
|
||||
BoldItalicFont = {Cochineal-BoldItalic}
|
||||
]{Cochineal-Roman}
|
||||
\setsansfont[
|
||||
Path = fonts/,
|
||||
BoldFont = {Roboto-Bold},
|
||||
ItalicFont = {Roboto-Italic},
|
||||
BoldItalicFont = {Roboto-BoldItalic}
|
||||
]{Roboto-Regular}
|
||||
\setmonofont[
|
||||
Path = fonts/,
|
||||
BoldFont = {iosevka-ss04-bold},
|
||||
ItalicFont = {iosevka-ss04-italic},
|
||||
BoldItalicFont = {iosevka-ss04-bolditalic}
|
||||
]{iosevka-ss04-regular}
|
||||
|
||||
\makeatletter
|
||||
|
||||
\usepackage{etoolbox}
|
||||
\usepackage{caption}
|
||||
|
||||
\setcounter{secnumdepth}{2}
|
||||
|
||||
\usepackage{titlesec}
|
||||
\titleformat{\section}
|
||||
{\sffamily\Large}{\thesection.}{0.2em}{}
|
||||
\titleformat{\subsection}
|
||||
{\sffamily\normalsize}{\thesubsection.}{0.2em}{}
|
||||
|
||||
\titlespacing{\section}{0pt}{*6}{*1}
|
||||
\titlespacing{\subsection}{0pt}{*3}{*0.5}
|
||||
|
||||
\usepackage[absolute]{textpos}
|
||||
|
||||
\urlstyle{same}
|
||||
|
||||
|
||||
\setcounter{secnumdepth}{0}
|
||||
\def\tightlist{}
|
||||
\renewcommand\allcapsspacing[1]{{\addfontfeature{LetterSpace=15}#1}}
|
||||
\renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace=10}#1}}
|
||||
|
||||
|
||||
\setlength{\parindent}{0pt}
|
||||
|
||||
\AtBeginDocument{
|
||||
\def\labelitemi{\normalsize\normalfont\bfseries{--}}
|
||||
}
|
||||
|
||||
\makeatother
|
||||
|
||||
\input{../src/common-preamble}
|
||||
\usepackage{polyglossia}
|
||||
\setdefaultlanguage[variant=american]{english}
|
||||
|
||||
|
||||
\begin{document}
|
||||
\noindent{\linespread{1.2}\LARGE\textsf{\mbox{<#_TITLE_#>}}}\par
|
||||
\noindent{\linespread{1.2}\textsf{\mbox{<#_SUBTITLE_#>}\hspace{\fill}<#_VERSION_#>}}\par
|
||||
\noindent{\linespread{1.2}\textsf{\mbox{\LARGE <#_TITLE_#>}}}\par
|
||||
\noindent{\linespread{1.2}\textsf{\mbox{\hspace{.75pt}\textit{<#_SUBTITLE_#>}}}}\par
|
||||
\bigskip
|
||||
\setstretch{1}
|
||||
\normalsize
|
||||
|
||||
Reference in New Issue
Block a user