mirror of
https://github.com/loikein/hugo-tufte.git
synced 2024-11-15 04:46:58 +01:00
Add and Refactor shortcodes.
Add the epigraph shortcode. This should complete the Tufte-CSS specific shortcodes. Additionally, the section and div shortcodes were refactored for ease of use.
This commit is contained in:
parent
381982f4a7
commit
b9ec18d78e
6 changed files with 76 additions and 13 deletions
48
README.md
48
README.md
|
@ -7,6 +7,10 @@ attempts to be a faithful implementation of the
|
|||
It supports mathematical typesetting via [MathJax](https://www.mathjax.org).
|
||||
By utilizing copious partial templates the theme is largely customizable.
|
||||
|
||||
## Math
|
||||
|
||||
TODO explain the different ways to write LaTeX.
|
||||
|
||||
## Site Parameters
|
||||
|
||||
The site specific parameters that this theme :wrecognizes are:
|
||||
|
@ -22,8 +26,7 @@ The site specific parameters that this theme :wrecognizes are:
|
|||
true, `hideDate` takes greater precedence.
|
||||
- `hideReadTime` boolean: if true, do not display the page's reading time
|
||||
estimate. When `meta` is set to true, `hideReadTime` takes greater precedence.
|
||||
- `math` boolean: if true, try to render the page's LaTeX code using MatheJax. The
|
||||
theme follows the conventions in [Hugo's MathJax tutorial].
|
||||
- `math` boolean: if true, try to render the page's LaTeX code using MatheJax.
|
||||
- `meta` boolean: if true, display page meta-data author, date, categories provided
|
||||
these page parameters exist and are not overridden. Content in the `/post` directory,
|
||||
(i.e., pages of type "post") ignore this parameter.
|
||||
|
@ -43,6 +46,35 @@ This theme provides the following shortcodes.
|
|||
There is nothing more beautiful than an elegant mathematical proof.
|
||||
{{% /blockquote %}}`
|
||||
```
|
||||
|
||||
- `div`
|
||||
- Description: This shortcode is provided as a work-around for wrapping
|
||||
complex blocks of markdown in div tags. The wrapped text can
|
||||
include other shortcodes
|
||||
- Usage: Identical to the `section` shortcode.
|
||||
Accepts the style parameters `class` and `id`.
|
||||
If no only the positional argument `"end"` is passed, a closing tag
|
||||
will be inserted.
|
||||
- Example: `{{< div class="my-class" >}}` inserts a
|
||||
`<div class="my-class">` tag, while
|
||||
`{{<div "end" >}}` inserts the closing `</div>` tag.
|
||||
|
||||
- `epigraph`
|
||||
- Description: Create an epigraph with the wrapped text.
|
||||
- Usage: To include a footer with source attribution, pass in the
|
||||
optional named parameters `pre`, `cite`, `post`. These parameters are
|
||||
make no styling assumptions, so spacing is important. A more compactly
|
||||
styled epigraph will be used if the `type` parameter is set to `compact`.
|
||||
(This just wraps the content in a paragraph tag.)
|
||||
- Example:
|
||||
```html
|
||||
{{% epigraph pre="Author Writer, " cite="Math is Fun" %}}
|
||||
This is an example of an epigraph with some math
|
||||
\\(\mathbb N \subseteq \mathbb R \\)
|
||||
to start the beginning of a section.
|
||||
{{% /epigraph %}}
|
||||
```
|
||||
|
||||
- `marginnote`
|
||||
- Description: Wrap text to produce a numberless margin note.
|
||||
- Usage: Accepts a required positional argument that is the margin note id.
|
||||
|
@ -51,12 +83,16 @@ This theme provides the following shortcodes.
|
|||
|
||||
- `section`
|
||||
- Description: This shortcode is provided as a work-around for wrapping
|
||||
complex blocks of markdown in section tags.
|
||||
- Usage: `{{< section "<begin || end>" >}}` map respectively to
|
||||
`<section>` and `</section>` tags.
|
||||
- Example: `{{< section "begin" >}}` inserts a `<section>` tag, while
|
||||
complex blocks of markdown in section tags. The wrapped text can
|
||||
include other shortcodes
|
||||
- Usage: Accepts the style parameters `class` and `id`.
|
||||
If no only the positional argument `"end"` is passed, a closing tag
|
||||
will be inserted.
|
||||
- Example: `{{< section class="my-class" >}}` inserts a
|
||||
`<section class="my-class">` tag, while
|
||||
`{{<section "end" >}}` inserts the closing `</section>` tag.
|
||||
|
||||
|
||||
- `sidenote`
|
||||
- Description: Wrap text to produce an automatically numbered sidenote.
|
||||
- Usage: identical to `marginnote`.
|
||||
|
|
1
layouts/shortcodes/cite.html
Normal file
1
layouts/shortcodes/cite.html
Normal file
|
@ -0,0 +1 @@
|
|||
<cite>{{ .Inner }}</cite>
|
8
layouts/shortcodes/div.html
Normal file
8
layouts/shortcodes/div.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{ $loc := .Get 0 }}
|
||||
{{ if .IsNamedParams }}
|
||||
<div {{with .Get "class"}} class="{{.}}"{{end}}{{with .Get "id"}} id="{{.}}"{{end}}>
|
||||
{{ else if or (eq $loc "") (eq $loc "begin") }}
|
||||
<div>
|
||||
{{ else if eq $loc "end" }}
|
||||
</div>
|
||||
{{ end }}
|
13
layouts/shortcodes/epigraph.html
Normal file
13
layouts/shortcodes/epigraph.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<div class="epigraph">
|
||||
<blockquote>
|
||||
{{ $t := .Get "type" }}
|
||||
{{ if eq $t "compact" }}{{ .Inner }}{{ else }}<p>{{ .Inner }}</p>{{ end }}
|
||||
{{ if .IsNamedParams }}
|
||||
<footer>
|
||||
{{ with .Get "pre" }}{{ . }}{{ end }}
|
||||
{{ with .Get "cite" }}<cite>{{ . }}</cite>{{ end }}
|
||||
{{ with .Get "post" }}{{ . }}{{ end }}
|
||||
</footer>
|
||||
{{ end }}
|
||||
<blockquote>
|
||||
</div>
|
|
@ -1,9 +1,9 @@
|
|||
{{ with .Get 0 }}
|
||||
{{ if eq . "begin" }}
|
||||
<section>
|
||||
{{ else if eq . "end" }}
|
||||
</section>
|
||||
{{ end }}
|
||||
{{ $loc := .Get 0 }}
|
||||
{{ if .IsNamedParams }}
|
||||
<section {{with .Get "class"}} class="{{.}}"{{end}}{{with .Get "id"}} id="{{.}}"{{end}}>
|
||||
{{ else if or (eq $loc "") (eq $loc "begin") }}
|
||||
<section>
|
||||
{{ else if eq $loc "end" }}
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
|
5
layouts/shortcodes/tag.html
Normal file
5
layouts/shortcodes/tag.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{ if .IsNamedParams }}
|
||||
<{{ .Get "name" }}{{with .Get "class"}} class="{{.}}"{{end}}{{with .Get "id"}} id="{{.}}"{{end}}>
|
||||
{{ else }}
|
||||
<{{ .Get 0 }}>
|
||||
{{ end }}
|
Loading…
Reference in a new issue