Removing dom ID requirement for margin/sidenotes (#10)

* Removing dom ID requirement for margin/sidenotes

Prior to this commit, when using the `marginnote` or `sidenote`
shortcodes, you would need to pass a domId parameter to the shortcode.

With this change you no longer need to pass a parameter, and any
parameter passed is ignored. The pre-amble creates a unique domID for
the shortcodes.

* Replacing convoluted Scratch with Ordinal

I was leveraging the Scratch function of Hugo, when I could instead
rely on `.Ordinal`
This commit is contained in:
Jeremy Friesen 2019-04-18 09:37:06 -07:00 committed by Shawn O'Hare
parent cfa6769e1c
commit 4299d3bfdb
3 changed files with 20 additions and 22 deletions

View file

@ -13,8 +13,8 @@ Mathjax renders LaTeX written inside of markdown files. LaTeX can be
written more or less as normal, but inline and display environments that written more or less as normal, but inline and display environments that
start with `\` must be escaped. Some examples: start with `\` must be escaped. Some examples:
- `This $\LaTeX$ will be rendered inline.` - `This $\LaTeX$ will be rendered inline.`
- `This \\(\LaTeX\\) will be rendered inline.` - `This \\(\LaTeX\\) will be rendered inline.`
- `A simple displayed equation: $$f(x, y) := e^{x^2 - y^2}.$$` - `A simple displayed equation: $$f(x, y) := e^{x^2 - y^2}.$$`
- `A simple displayed equation: \\[f(x, y) := e^{x^2 - y^2}.\\]` - `A simple displayed equation: \\[f(x, y) := e^{x^2 - y^2}.\\]`
@ -53,7 +53,7 @@ The site specific parameters that this theme recognizes 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. - `math` boolean: if true, try to render the page's LaTeX code using MatheJax.
- `meta` boolean: if true, display page metadata such as author, date, categories provided - `meta` boolean: if true, display page metadata such as 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.
@ -62,17 +62,17 @@ The site specific parameters that this theme recognizes are:
## Shortcodes ## Shortcodes
This theme provides the following shortcodes in an attempt to completely This theme provides the following shortcodes in an attempt to completely
support all the features present in the support all the features present in the
[Tufte-css](https://github.com/edwardtufte/tufte-css) project. [Tufte-css](https://github.com/edwardtufte/tufte-css) project.
- `blockquote` - `blockquote`
- **Description**: Wrap text in a blockquote and insert optional - **Description**: Wrap text in a blockquote and insert optional
`cite` or `footer` metadata. `cite` or `footer` metadata.
- **Usage**: Accepts the named parameters `cite` and `footer`. - **Usage**: Accepts the named parameters `cite` and `footer`.
- **Example**: - **Example**:
```html ```html
{{% blockquote cite="www.shawnohare.com" footer="Shawn" %}} {{% blockquote cite="www.shawnohare.com" footer="Shawn" %}}
There is nothing more beautiful than an elegant mathematical proof. There is nothing more beautiful than an elegant mathematical proof.
{{% /blockquote %}}` {{% /blockquote %}}`
``` ```
@ -84,20 +84,20 @@ support all the features present in the
Accepts the style parameters `class` and `id`. Accepts the style parameters `class` and `id`.
If only the positional argument `"end"` is passed, a closing tag If only the positional argument `"end"` is passed, a closing tag
will be inserted. will be inserted.
- **Example**: `{{< div class="my-class" >}}` inserts a - **Example**: `{{< div class="my-class" >}}` inserts a
`<div class="my-class">` tag, while `<div class="my-class">` tag, while
`{{<div "end" >}}` inserts the closing `</div>` tag. `{{<div "end" >}}` inserts the closing `</div>` tag.
- `epigraph` - `epigraph`
- **Description**: Create an epigraph with the wrapped text. - **Description**: Create an epigraph with the wrapped text.
- **Usage**: To include a footer with source attribution, pass in the - **Usage**: To include a footer with source attribution, pass in the
optional named parameters `pre`, `cite`, `post`. These parameters optional named parameters `pre`, `cite`, `post`. These parameters
make no styling assumptions, so spacing is important. A more compactly make no styling assumptions, so spacing is important. A more compactly
styled epigraph will be used if the `type` parameter is set to `compact`. styled epigraph will be used if the `type` parameter is set to `compact`.
- **Example**: - **Example**:
``` ```
{{% epigraph pre="Author Writer, " cite="Math is Fun" %}} {{% epigraph pre="Author Writer, " cite="Math is Fun" %}}
This is an example of an epigraph with some math This is an example of an epigraph with some math
\\( \mathbb N \subseteq \mathbb R \\) \\( \mathbb N \subseteq \mathbb R \\)
to start the beginning of a section. to start the beginning of a section.
{{% /epigraph %}} {{% /epigraph %}}
@ -105,9 +105,8 @@ support all the features present in the
- `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: `{{% marginnote %}}...{{% /marginnote %}}`
`{{% marginnote "<margin note id>"" %}}...{{% /marginnote %}}` - **Example**: `{{% marginnote %}}Some marginnote{{% /marginnote%}}`
- **Example**: `{{% marginnote "mn-example" %}}Some marginnote{{% /marginnote%}}`
- `section` - `section`
- **Description**: This shortcode is provided as a work-around for wrapping - **Description**: This shortcode is provided as a work-around for wrapping
@ -116,17 +115,16 @@ support all the features present in the
- **Usage**: Accepts the style parameters `class` and `id`. - **Usage**: Accepts the style parameters `class` and `id`.
If only the positional argument `"end"` is passed, a closing tag If only the positional argument `"end"` is passed, a closing tag
will be inserted. will be inserted.
- **Example**: `{{< section class="my-class" >}}` inserts a - **Example**: `{{< section class="my-class" >}}` inserts a
`<section class="my-class">` tag, while `<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`
Accepts a required positional argument that is the side note id. `{{% sidenote %}}...{{% /sidenote %}}`
`{{% sidenote "<side note id>"" %}}...{{% /sidenote %}}` - **Example**: `{{% sidenote %}}Some sidenote{{% /sidenote %}}`
- **Example**: `{{% sidenote "sn-example" %}}Some sidenote{{% /sidenote %}}`
## Templates ## Templates

View file

@ -1,3 +1,3 @@
<label for="{{ .Get 0 }}" class="margin-toggle">&#8853;</label> {{ $marginnoteDomIdSuffix := .Ordinal }}<label for="marginnote-{{.Page.UniqueID}}-{{ $marginnoteDomIdSuffix }}" class="margin-toggle">&#8853;</label>
<input type="checkbox" id="{{ .Get 0 }}" class="margin-toggle"/> <input type="checkbox" id="marginnote-{{.Page.UniqueID}}-{{ $marginnoteDomIdSuffix }}" class="margin-toggle"/>
<span class="marginnote">{{ .Inner }}</span> <span class="marginnote">{{ .Inner }}</span>

View file

@ -1,3 +1,3 @@
<label for="{{ .Get "id" }}" class="margin-toggle sidenote-number"></label> {{ $sidenoteDomIdSuffix := .Ordinal }}<label for="sidenote-{{.Page.UniqueID}}-{{ $sidenoteDomIdSuffix }}" class="margin-toggle sidenote-number"></label>
<input type="checkbox" id="{{ .Get "id" }}" class="margin-toggle"/> <input type="checkbox" id="sidenote-{{.Page.UniqueID}}-{{ $sidenoteDomIdSuffix }}" class="margin-toggle"/>
<span class="sidenote">{{ .Inner }}</span> <span class="sidenote">{{ .Inner }}</span>