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:
Shawn O'Hare 2016-01-01 11:51:23 -08:00
parent 381982f4a7
commit b9ec18d78e
6 changed files with 76 additions and 13 deletions

View file

@ -7,6 +7,10 @@ attempts to be a faithful implementation of the
It supports mathematical typesetting via [MathJax](https://www.mathjax.org). It supports mathematical typesetting via [MathJax](https://www.mathjax.org).
By utilizing copious partial templates the theme is largely customizable. By utilizing copious partial templates the theme is largely customizable.
## Math
TODO explain the different ways to write LaTeX.
## Site Parameters ## Site Parameters
The site specific parameters that this theme :wrecognizes are: 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. true, `hideDate` takes greater precedence.
- `hideReadTime` boolean: if true, do not display the page's reading time - `hideReadTime` boolean: if true, do not display the page's reading time
estimate. When `meta` is set to true, `hideReadTime` takes greater precedence. 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 - `math` boolean: if true, try to render the page's LaTeX code using MatheJax.
theme follows the conventions in [Hugo's MathJax tutorial].
- `meta` boolean: if true, display page meta-data author, date, categories provided - `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, these page parameters exist and are not overridden. Content in the `/post` directory,
(i.e., pages of type "post") ignore this parameter. (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. There is nothing more beautiful than an elegant mathematical proof.
{{% /blockquote %}}` {{% /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` - `marginnote`
- Description: Wrap text to produce a numberless margin note. - Description: Wrap text to produce a numberless margin note.
- Usage: Accepts a required positional argument that is the margin note id. - Usage: Accepts a required positional argument that is the margin note id.
@ -51,12 +83,16 @@ This theme provides the following shortcodes.
- `section` - `section`
- Description: This shortcode is provided as a work-around for wrapping - Description: This shortcode is provided as a work-around for wrapping
complex blocks of markdown in section tags. complex blocks of markdown in section tags. The wrapped text can
- Usage: `{{< section "<begin || end>" >}}` map respectively to include other shortcodes
`<section>` and `</section>` tags. - Usage: Accepts the style parameters `class` and `id`.
- Example: `{{< section "begin" >}}` inserts a `<section>` tag, while 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. `{{<section "end" >}}` inserts the closing `</section>` tag.
- `sidenote` - `sidenote`
- Description: Wrap text to produce an automatically numbered sidenote. - Description: Wrap text to produce an automatically numbered sidenote.
- Usage: identical to `marginnote`. - Usage: identical to `marginnote`.

View file

@ -0,0 +1 @@
<cite>{{ .Inner }}</cite>

View 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 }}

View 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>

View file

@ -1,9 +1,9 @@
{{ with .Get 0 }} {{ $loc := .Get 0 }}
{{ if eq . "begin" }} {{ if .IsNamedParams }}
<section {{with .Get "class"}} class="{{.}}"{{end}}{{with .Get "id"}} id="{{.}}"{{end}}>
{{ else if or (eq $loc "") (eq $loc "begin") }}
<section> <section>
{{ else if eq . "end" }} {{ else if eq $loc "end" }}
</section> </section>
{{ end }} {{ end }}
{{ end }}

View file

@ -0,0 +1,5 @@
{{ if .IsNamedParams }}
<{{ .Get "name" }}{{with .Get "class"}} class="{{.}}"{{end}}{{with .Get "id"}} id="{{.}}"{{end}}>
{{ else }}
<{{ .Get 0 }}>
{{ end }}