-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from qmd-lab/trigger-shortcut-attr
Trigger shortcut attr
- Loading branch information
Showing
14 changed files
with
339 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
format: | ||
html: | ||
toc: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Authoring Tools | ||
--- | ||
|
||
Coming soon! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
title: Closeread Components | ||
--- | ||
|
||
Every closeread document consists of three components: | ||
|
||
1. A section of the document flagged as a closeread section. | ||
2. Within the section, an element flagged to appear in the main column of the closeread section (the "sticky"), and also | ||
3. An element (often a paragraph of text) that will serve to trigger the appearance of the sticky element. | ||
|
||
## Closeread Sections | ||
|
||
To create a closeread section within a document, open up a [fenced div](https://quarto.org/docs/authoring/markdown-basics.html#sec-divs-and-spans) and add the `cr-section` class. | ||
|
||
```markdown | ||
:::{.cr-section} | ||
< add paragraphs, images, code cells, etc. > | ||
::: | ||
``` | ||
|
||
Elements within a `.cr-section` div will appear as a closeread story while elements outside of a section will appear as a normal Quarto HTML document. This allows you to integrate one or more closeread sections into a conventional HTML document. | ||
|
||
By wrapping your entire document with a `cr-section` div, you can make a 100% closeread document. By default, all elements with a closeread section appear in the narrative column unless you've indicated that they should be a sticky. | ||
|
||
## Stickies | ||
|
||
An element of your document that you wish to do a close read of is called a "sticky": as the user scrolls, it will remained pinned in the middle of the main column like a sticky note. To flag an element as a sticky, wrap it in a fenced div and provide an identifier that is prefixed with `cr-`. | ||
|
||
```markdown | ||
:::{#cr-myimage} | ||
![](path-to-myimage.png) | ||
::: | ||
``` | ||
|
||
The syntax is the same regardless of whether the element you'd like to turn into a sticky is an image, a paragraph, a list, math, a code cell, etc. For example, the the syntax for a code cell is: | ||
|
||
````markdown | ||
:::{#cr-myplot} | ||
```{{r}} | ||
hist(rnorm(15)) | ||
``` | ||
::: | ||
```` | ||
All sticky elements are placed in the main column of the closeread section and will be transparent. To make them appear, you need to create a trigger. | ||
|
||
## Triggers | ||
|
||
Any elements within a closeread section that are not stickies - usually paragraphs - will be placed in the narrative column. You can set a paragraph to trigger focus on a particular sticky by using Quarto's cross-referencing syntax: `@cr-mysticky`. | ||
|
||
````markdown | ||
When this paragraph scrolls into view it will reveal a histogram. @cr-myplot | ||
|
||
:::{#cr-myplot} | ||
```{{r}} | ||
hist(rnorm(15)) | ||
``` | ||
::: | ||
```` | ||
|
||
The reference can be placed anywhere in the paragraph, but it should be separated from other content by spaces. This syntax mirrors the syntax of Quarto Cross-refs but uses a distinct prefix for the identifier (`cr-`) and does not require a caption. | ||
|
||
If you have multiple document blocks (say, two paragraphs) that you'd like to appear as a single trigger, wrap the blocks in a fenced div and supply a `focus-on` attribute and provide the sticky name as a string. For example: | ||
|
||
````markdown | ||
:::{focus-on="cr-myplot"} | ||
This paragraph and the one that follows will appear as one narrative block | ||
|
||
When these paragraphs scroll into view, they will reveal a histogram. | ||
::: | ||
|
||
:::{#cr-myplot} | ||
```{{r}} | ||
hist(rnorm(15)) | ||
``` | ||
::: | ||
```` | ||
|
||
The primary role of triggers is to make a sticky element appear. They can also be used to trigger focus effects by attaching additional attributes to your triggers. Learn more in [Focus Effects](focus-effects.qmd). | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: Focus Effects | ||
--- | ||
|
||
Focus effects are used to closely guide your readers attention to particular aspects of your stickies. They are all supplied as [attributes](https://quarto.org/docs/authoring/markdown-basics.html#ordering-of-attributes), which follow a `attribute="value"` syntax where the value must be quoted and where `=` separates the value from the attribute with no spaces. | ||
|
||
## Highlighting | ||
|
||
You can highlight parts of the code and text of your sticky using the following syntax. | ||
|
||
1. `highlight="1,3"`: highlight lines 1 and 3 | ||
2. `highlight="1-3"`: highlight lines 1, 2, and 3 | ||
3. `highlight="cr-span1"`: highlight the span with id `cr-span1` | ||
4. `highlight="cr-span1,cr-span2"`: highlight the spans with ids `cr-span1` and `cr-span2` | ||
|
||
Line highlighting (1 and 2) works on code cells and line blocks while span highlighting (3 and 4) only works on Line Blocks. | ||
|
||
### Code Cell Examples | ||
|
||
This will highlight lines 1 and 2: | ||
|
||
````qmd | ||
This is where we load the library. [@cr-dplyr]{highlight="1,2"} | ||
|
||
:::{#cr-dplyr} | ||
```{{r}} | ||
library(dplyr) | ||
library(palmerpenguins) | ||
|
||
penguins |> | ||
group_by(island) |> | ||
summarize(avg_bill_length = mean(bill_length_mm)) | ||
``` | ||
::: | ||
```` | ||
|
||
This will highlight lines 4 through 6. | ||
|
||
````qmd | ||
This calculates summary statistics. [@cr-dplyr]{highlight="4-6"} | ||
|
||
:::{#cr-dplyr} | ||
```{{r}} | ||
library(dplyr) | ||
library(palmerpenguins) | ||
|
||
penguins |> | ||
group_by(island) |> | ||
summarize(avg_bill_length = mean(bill_length_mm)) | ||
``` | ||
::: | ||
```` | ||
|
||
Highlighting spans of code within a line is currently not possible. | ||
|
||
|
||
### Line Block Examples | ||
|
||
To do. | ||
|
||
|
||
## Panning | ||
|
||
To do. | ||
|
||
|
||
## Scaling | ||
|
||
To do. | ||
|
||
|
||
## Zooming | ||
|
||
To do. |
Oops, something went wrong.