-
Notifications
You must be signed in to change notification settings - Fork 71
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
Conversation
Here's what I wrote in Discord about my initial thoughts:
|
I then noticed some prior art for epigraphs, in |
It looks like this falls foul of another transform, https://github.com/executablebooks/mystmd/blob/76c4d7b961579e2d1a3464360424b977f062cebe/packages/myst-transforms/src/containers.ts#L182, which seems to assume a closed set of container node types. It looks like the |
The next step from here probably depends upon whether we want If not, then we need to adjust the container transform. |
I think the simplest solution is to make all quotes support captions, which is what 87e4189 does. Now, pull-quotes and epigraphs can be styled separately should we wish for them to be. |
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.
Looking good. Have some comments about the change in functionality (I think we should keep it!), adding more tests, changesets, and some files that have been changed and probably don't need to be anymore (package.json, spec-ext).
On the changed functionality: This might have been hashed out in discord/convos, but I am a fan of the list item transform which this PR is planning to remove. One reason I like it is that the attribution doesn't require a new line, and in both cases we are interpreting the final markup using this transform, in one case to turn a paragraph into an attribution caption and in the other to turn a single list item into an attribution. I don't really see the difference, and it is nice that we can do this:
> We know what we are, but know not what we may be.
> - Hamlet act 4, Scene 5
Rather than:
> We know what we are, but know not what we may be.
>
> -- Hamlet act 4, Scene 5
I foresee challenges when people forget that there needs to be an extra new line, which means there is only one paragraph. Some of that can be addressed potentially if we take over the body content in the parsing of the epigraph/pull-quote directives (where we are explicitly expecting an attribution, and can change the parsing).
Regardless of the choice, this PR should update the docs here:
https://github.com/executablebooks/mystjs/blob/main/docs/typography.md#L112
Testing
I would also love to see a few more tests around the regexp, expanding it to endash, I think there is a bug when it isn't the start of the line (e.g. blah --- attribtuion
), and ensuring we return false if there is no actual attribution. It would also be good to add some tests for the directive parsing specifically.
There should also be some e2e test (or at least exploratory conformation) that this doesn't clash with the smart typography, which turns --
into –
(endash), in which case, expanding the regexp into ---
\u2014-
meaning three dashes will always fail currently.
The directive docs/references should also be added to include the two new directives:
https://github.com/executablebooks/mystjs/blob/main/docs/directives.md#L2
Before merge, should add changesets!
Somewhere along the way we have lost adding the class I think this actually might be on the theme and putting the |
I see the convenience of using
I had this thought too. We could also introduce an explicit role, e.g. > We know what we are, but know not what we may be.
> {attrib}`Hamlet act 4, Scene 5` I'm not saying that I love that, just that it's a member of the phase space ;)
Yep, TODO. Footnotes
|
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.
I think only major comment left is picking up the options in the directives (and adding a test!).
Before merge:
- We should also finalize/update the docs in
typography.md
. - changeset!
On the functionality change, thanks for explaining your thinking - happy on my side to be taken in this direction. :) We should make an explicit note in the docs updates to remember to add a newline. Note that updating the docs will take a release, theme release, and then website release to consume the theme (in the live example). |
epigraph
directiveepigraph
and pull-quote
directive
c8d2101
to
642671b
Compare
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.
Nice to see the consolidation into one directive. What do you think of naming this blockquote (no dash?). Can alias as well? Maybe I am too used to reading html source.
import classNames from 'classnames'; | ||
|
||
export const blockQuoteDirective: DirectiveSpec = { | ||
name: 'block-quote', |
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.
I think this should be blockquote
(maybe aliased to block-quote
?).
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.
Hmm. I'm on the fence. I like that it reflects symmetry with pull-quote
, but of course the internal AST node is blockquote
. You make the call!
class: classNames({ [className]: className, [data.name]: data.name !== 'block-quote' }), | ||
children: [ | ||
{ | ||
// @ts-expect-error: myst-spec needs updating to support blockquote |
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.
@rowanc1 this is ready for handover! |
Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
Co-authored-by: Rowan Cockett <rowanc1@gmail.com>
46e291c
to
65f2ae9
Compare
epigraph
and pull-quote
directiveepigraph
, pull-quote
and blockquote
directive
🎆 |
The intentions of this PR are twofold:
I'll try and document my thought processes as we go.
The merge order should be
blockquote
to supported container contents myst-spec#64epigraph
,pull-quote
andblockquote
directive #961