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

feat: Implemented transformer for the wavedrom library #1503

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexandruradovici
Copy link

@alexandruradovici alexandruradovici commented Apr 6, 2024

Description

This pull request implements a transformer for the wavedrom library. It allows writing waveform diagrams in the slides.

This allows writing wavefrom diagrams using the wavedrom transformer.

```wavedrom
{signal: [
  {name: 'clk', wave: 'p.....|...'},
  {name: 'dat', wave: 'x.345x|=.x', data: ['head', 'body', 'tail', 'data']},
  {name: 'req', wave: '0.1..0|1.0'},
  {},
  {name: 'ack', wave: '1.....|01.'}
]}
```

Why

This is useful when creating engineering slides. Without this feature, users have to manually transform the waveform JSON into SVG files and include those.

Disadvantages

  • wavedrom, onml and json5 dev dependencies
  • onml depends on two deprecated packages

Copy link

netlify bot commented Apr 6, 2024

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 73fe417
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/6611e23e9de9f0000892a6d2
😎 Deploy Preview https://deploy-preview-1503--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@alexandruradovici alexandruradovici changed the title Implemented transformer for the wavedrom library feat: Implemented transformer for the wavedrom library Apr 6, 2024
@KermanX
Copy link
Member

KermanX commented Apr 8, 2024

Thanks for your contribution! Can this feature be used as a standalone addon package? If not, what's the missing hook?

@alexandruradovici
Copy link
Author

I think it can be an addon, I just don't know where to find the documentation on how to use a hook. I would be very happy to convert it.

@KermanX
Copy link
Member

KermanX commented Apr 8, 2024

About addon writing: https://sli.dev/addons/write-an-addon

You can have setup and components folder in your addon, just like in your slides folder.

@alexandruradovici
Copy link
Author

I saw this, but is there any API documentation?

@KermanX
Copy link
Member

KermanX commented Apr 8, 2024

Here we can register a markdown-it plugin for waredrom: https://sli.dev/custom/config-vite#configure-internal-plugins

@alexandruradovici
Copy link
Author

I am sorry, I still do not understand how to connect my plugin to slidev.

  1. I created a new package
  2. I added slidev as a dependecy

How to I make it initialize my plugin?

This is really confusing here, an API documentation and example would be great.

@antfu
Copy link
Member

antfu commented Apr 8, 2024

This looks very cool! But yeah I agree with @KermanX, I also think it's better to implement it as an external addon.

@KermanX
Copy link
Member

KermanX commented Apr 9, 2024

I am sorry, I still do not understand how to connect my plugin to slidev.

  1. I created a new package
  2. I added slidev as a dependecy

How to I make it initialize my plugin?

This is really confusing here, an API documentation and example would be great.

There seem to be some difficulties in having a custom transformer... The priority of markdown-it plugins are too low. The preparser may help, but I don't think it is graceful enough. Maybe we need a setupTransformers like this:

type MarkdownTransfromer = (ctx: MarkdownTransformContext) => void
type TransformersSetup = (transformers: MarkdownTransfromer[]) => MarkdownTransfromer[]

@KermanX KermanX mentioned this pull request Apr 11, 2024
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.

None yet

3 participants