-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💬 Add epigraph
, pull-quote
and blockquote
directive
#961
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
7095951
wip: epigraph directive
agoose77 adca09e
fix: transform all quotes
agoose77 8289049
fix: add pull-quote default directive
agoose77 f5e54e7
chore: run prettier
agoose77 6c7e3d5
test: fix test
agoose77 2c30fd3
fix: proper transform signature
agoose77 ae99140
fix: update package lock
agoose77 fed6ecd
fix: only match start of attribution line
agoose77 6d90547
fix: drop new Epigraph node
agoose77 4abab89
test: add more testing
agoose77 780378e
feat: don't run transform for empty attributions
agoose77 f9c2877
docs: add pull-quote & epigraph
agoose77 7bc7759
feat: add support for label and class
agoose77 5a8c73b
Update packages/myst-transforms/src/containers.ts
agoose77 6df8530
chore: lint
agoose77 1ba389d
refactor: simplify(?) logic
agoose77 e3b1134
fix: make quote transform re-entrant
agoose77 19f7146
docs: add note about pull-quote and block quotes
agoose77 6ae3d71
feat: change variant to be a class
agoose77 626287d
docs: change to block-quote
agoose77 9bbe875
fix: add missing dependency
agoose77 cf15100
fix: add label
agoose77 a514896
feat: drop unused nodes
agoose77 06d7f3a
fix: set identifier
agoose77 d6d56ce
chore: changeset
agoose77 bcf747d
chore: rename quote to blockquote
agoose77 c71f0b9
fix: add ts-expect-error
agoose77 b5f7ce8
Update packages/myst-directives/src/blockquote.ts
agoose77 d4e11b2
Update .changeset/seven-roses-cough.md
agoose77 25e30c1
Update packages/myst-transforms/src/blockquote.ts
agoose77 85a7bab
feat: change name o directive
agoose77 7a1f214
feat!: make container kind required
agoose77 93ecb71
chore: add changeset for myst-spec-ext
agoose77 63ad459
fix: rename use of blockquote
agoose77 cc4f0c4
changeset
rowanc1 65f2ae9
Fix up docs
rowanc1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"myst-cli": patch | ||
--- | ||
|
||
Add pullquotes, blockquotes and epigraph directives |
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 @@ | ||
--- | ||
'myst-spec-ext': patch | ||
--- | ||
|
||
Require `kind` for `Container` |
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,6 @@ | ||
--- | ||
"myst-directives": minor | ||
"myst-transforms": minor | ||
--- | ||
|
||
Add support for epigraphs and pull-quotes using a new blockquote directive. |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,50 @@ | ||
import type { DirectiveSpec, DirectiveData, GenericNode } from 'myst-common'; | ||
import { normalizeLabel } from 'myst-common'; | ||
import type { Container } from 'myst-spec-ext'; | ||
import classNames from 'classnames'; | ||
|
||
export const blockquoteDirective: DirectiveSpec = { | ||
name: 'blockquote', | ||
alias: ['epigraph', 'pull-quote'], | ||
doc: 'Block quotes are used to indicate that the enclosed content forms an extended quotation. They may be followed by an inscription or attribution formed of a paragraph beginning with `--`, `---`, or an em-dash.', | ||
options: { | ||
label: { | ||
type: String, | ||
alias: ['name'], | ||
}, | ||
class: { | ||
type: String, | ||
doc: `CSS classes to add to your blockquote. Special classes include: | ||
|
||
- \`pull-quote\`: used for a blockquote node which should attract attention | ||
- \`epigraph\`: used for a blockquote node that are usually found at the beginning of a document`, | ||
}, | ||
}, | ||
body: { | ||
type: 'myst', | ||
doc: 'The body of the quote, which may contain a special attribution paragraph that is turned into a caption', | ||
}, | ||
run(data: DirectiveData): GenericNode[] { | ||
const children: GenericNode[] = []; | ||
if (data.body) { | ||
children.push(...(data.body as GenericNode[])); | ||
} | ||
const { label, identifier } = normalizeLabel(data.options?.label as string | undefined) || {}; | ||
const className = data.options?.class as string; | ||
const container: Container = { | ||
type: 'container', | ||
kind: 'quote', | ||
label, | ||
identifier, | ||
class: classNames({ [className]: className, [data.name]: data.name !== 'blockquote' }), | ||
children: [ | ||
{ | ||
// @ts-expect-error: myst-spec needs updating to support blockquote | ||
type: 'blockquote', | ||
children: children as any[], | ||
}, | ||
], | ||
}; | ||
return [container]; | ||
}, | ||
}; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this handled in the myst-spec updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No! Actually now I understand where my confusion came from. Let me fix that up.