SwiftPackageIndex / SwiftPackageIndex-Server

The Swift Package Index is the place to find Swift packages!
https://swiftpackageindex.com
Apache License 2.0
540 stars 42 forks source link

Add Mermaid chart support to readme files #3348

Open daveverwer opened 2 weeks ago

daveverwer commented 2 weeks ago

Discussed in https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/discussions/3346

Originally posted by **leogdion** August 29, 2024
From https://github.com/brightdigit/SublimationBonjour
from GitHub brightdigit/SublimationBonjour Repo
Mermaid is supported by Github Markdown...
From
From Swift Package Index brightidigt/SublimationBonjour Page
... but not the Swift Package Index site. It seems that [the javascript needs to be added to automatically parse these `pre` tags.](https://mermaid.js.org/intro/getting-started.html#_4-calling-the-mermaid-javascript-api) I'd love to help add support to this if needed.
daveverwer commented 2 weeks ago

I took a look and I think this would be a good addition to the site if you wanted to work on it, Leo.

You’ll already find a ReadmeController in readme_controller.js and you’ll probably need to add a connect function to initialise the Mermaid rendering there. Looks like there’s a standard package for rendering, so let’s use that. If you need to pre-process the HTML (which I don’t think will be necessary), we mainly do that in Swift in PackageReadme+Model.swift.

You can also find any readme-specific styles that you might need in readme.scss.

It should be a nicely self-contained bit of functionality. 👍

I’ll convert this into an issue now so we can track it and for any further discussion. I’m also happy to help out if you need any help getting up and running with the front-end development environment or with anything to do with the changes.