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

Add remark-d2 to list of plugins #1197

Closed
wants to merge 1 commit into from
Closed

Conversation

mech-a
Copy link

@mech-a mech-a commented Aug 6, 2023

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

I've made a plugin, remark-d2, that makes it so you can turn d2 code blocks into their compiled images. d2 is a fast-to-develop and easy diagramming language, so I think it would be a good addition to the list. They also have a website where you can compare d2 code to other diagramming tools like Mermaid, PlantUML, and others.

I'm not affiliated with d2 in any way, in case that is of concern.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Aug 6, 2023
@codecov-commenter
Copy link

Codecov Report

Patch and project coverage have no change.

Comparison is base (1c6e5ba) 100.00% compared to head (6cc37a3) 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1197   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          874       874           
=========================================
  Hits           874       874           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -88,6 +88,8 @@ The list of plugins:
* ⚠️ [`remark-custom-blocks`](https://github.com/zestedesavoir/zmarkdown/tree/HEAD/packages/remark-custom-blocks#readme)
— new syntax for custom blocks (new node types, rehype compatible)
(👉 **note**: [`remark-directive`][d] is similar and up to date)
* 🟢 [`remark-d2`](https://github.com/mech-a/remark-d2)
— turn [d2](https://d2lang.com/) diagram code blocks into images
Copy link
Member

Choose a reason for hiding this comment

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

Hi! Some tips on how to improve your plugin:

  • You don’t need 'use strict' in ESM, they are always strict
  • Instead of using node:path, I recommend using URLs, they work across platforms (unix vs windows)
  • Throw errors instead of printing to console.error when things are misconfigured
  • You don’t need to path.parse(file.path), file already has direname and other fields
  • replace process.cwd() with file.cwd, files can theoretically exist with multiple, different, “cwds”
  • Use async versions of fs calls, the transformer can be async
  • an exists call before a mkdir or write call is an anti-pattern, instead, try to mkdir or write, and swallow the error if it already exists
  • do not change node.type, instead, replace one node with another, some more info here: https://unifiedjs.com/learn/recipe/remove-node/#removing-a-node
  • It is probably better to do async work instead of spawn, so that when many files are processed, or many code blocks exist, work can be done at the same time
  • What is the benefit of the HTML version? What can it do more than the markdown version? If there are no benefits, I recommend removing it, because raw strings of HTML don’t always work well with markdown, particularly when dealing with VDOM frameworks like React, such as MDX. There are also perhaps openings for XSS attacks, or at least bugs, when building a string of HTML like you do now, instead of using something like hastscript and hast-util-to-html!

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for this feedback. I'll integrate your feedback where applicable and reply back.

Copy link
Member

Choose a reason for hiding this comment

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

how’s it going with the feedback?

Copy link
Member

Choose a reason for hiding this comment

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

Ping! :)

@wooorm wooorm closed this Oct 27, 2023
@wooorm
Copy link
Member

wooorm commented Oct 27, 2023

Closing for now. Feel free to PR again, thanks!

@github-actions

This comment has been minimized.

@wooorm wooorm added the 🤷 no/invalid This cannot be acted upon label Oct 27, 2023
@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on
Development

Successfully merging this pull request may close these issues.

3 participants