Skip to content
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

Use viewer api to to enable customization of markdown nodes #122

Merged
merged 44 commits into from
Apr 6, 2022

Conversation

zampino
Copy link
Collaborator

@zampino zampino commented Mar 24, 2022

This processes the parsed markdown nodes through the viewer api, enabling the same customization as for results. In addition, folks can extend the markdown tokenization and use the JVM-parts of the viewer api (:fetch-fn and :transform-fn) to introduce new behavior.

CleanShot.2022-03-30.at.09.42.30.mp4

@zampino zampino mentioned this pull request Mar 24, 2022
1 task
@zampino
Copy link
Collaborator Author

zampino commented Mar 24, 2022

CleanShot.2022-03-24.at.18.45.08.mp4

@zampino zampino force-pushed the described-markdown-II branch from bdbbaf0 to b8b56d4 Compare March 29, 2022 12:06
Evaluating the inspect function on edamame read instead of having to 
deal with ifns seems to make Reagent happier.
@zampino
Copy link
Collaborator Author

zampino commented Mar 29, 2022

I do not completely grasp why fe1e9a6 fixes the in-text slider re-rendering issue, but the reagent structure in devtools shows that with [inspect args] (left) instead of [ViewerFn{:f inspect} args] (right) we get no "anonymous" components interspersed among inspect ones. These are of the form reagent + number in the inspector and are those unnecessarily re-rendering when we try to drag the slider.

CleanShot 2022-03-29 at 17 12 07@2xCleanShot 2022-03-29 at 17 11 23@2x

@zampino zampino force-pushed the described-markdown-II branch from e3d99a4 to 1ee6b2c Compare March 30, 2022 15:54
deps.edn Outdated
io.github.nextjournal/viewers {:git/sha "d88a9abd1f2bfd28ff2d3983407a9319c6f04501"}
io.github.nextjournal/viewers {:git/sha "d88a9abd1f2bfd28ff2d3983407a9319c6f04501"
:exclusions [io.github.nextjournal/markdown
io.github.nextjournal/clerk]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👆 these redundant deps confuse my intellij, can we exclude them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove those from the viewers so it doesn't bring both of those in.

@zampino zampino marked this pull request as ready for review March 30, 2022 16:34
@zampino zampino force-pushed the described-markdown-II branch from 81ef1ed to 359761c Compare April 4, 2022 08:48
@mk mk changed the title Customisable Markdown Customizable Markdown Apr 4, 2022
deps.edn Outdated
io.github.nextjournal/viewers {:git/sha "d88a9abd1f2bfd28ff2d3983407a9319c6f04501"}
io.github.nextjournal/viewers {:git/sha "d88a9abd1f2bfd28ff2d3983407a9319c6f04501"
:exclusions [io.github.nextjournal/markdown
io.github.nextjournal/clerk]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove those from the viewers so it doesn't bring both of those in.

(with-md-viewer (parse text))))

(reset! nextjournal.clerk.webserver/!doc nextjournal.clerk.webserver/help-doc)
(reset! v/!viewers (v/get-all-viewers)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop this.

{:name :nextjournal.markdown/sidenote
:transform-fn (into-markup (fn [{:keys [attrs]}] [:span.sidenote [:sup {:style {:margin-right "3px"}} (-> attrs :ref inc)]]))}
{:name :nextjournal.markdown/sidenote-ref
:transform-fn (into-markup [:sup.sidenote-ref])}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move those to a separate def.

@mk mk changed the title Customizable Markdown Use viewer api to to enable customization of markdown nodes Apr 6, 2022
@mk mk merged commit 9d1702b into main Apr 6, 2022
@mk mk deleted the described-markdown-II branch April 6, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants