Skip to content

Requesting adding support for the Solidity language #2237

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

Open
Genesis3800 opened this issue Nov 15, 2023 · 3 comments
Open

Requesting adding support for the Solidity language #2237

Genesis3800 opened this issue Nov 15, 2023 · 3 comments
Labels
A-Highlighting Area: Code colored syntax highlighting C-enhancement Category: Enhancement or feature request

Comments

@Genesis3800
Copy link

Problem

Solidity is a popular language used to write smart contracts.
Projects in Web3 are starting to use Mdbook to document Solidity based frameworks.
For example: https://book.getfoundry.sh/

Highlight.js docs show that they support Solidity.

Proposed Solution

I propose that I be allowed to create a PR that adds native support for the Solidity language inside mdbook, so that folks don't have to use custom JS.

Notes

No response

@Genesis3800 Genesis3800 added the C-enhancement Category: Enhancement or feature request label Nov 15, 2023
@ehuss ehuss added the A-Highlighting Area: Code colored syntax highlighting label Feb 13, 2024
@MarcusWentz
Copy link

I found a work around for this.

Foundry Book supports Solidity syntax highlighting.

To copy this setup with a new mdbook project:

  1. In book.toml for your mdbook project, go to output.html to add additional-js with the following path:
[output.html]
additional-js = ["src/static/solidity.min.js"]
  1. Copy the solidity.min.js file in Foundry Book:
    https://github.com/foundry-rs/book/blob/master/src/static/solidity.min.js
    into the path just like Foundry Book for mdbook to load.

@Genesis3800
Copy link
Author

That's exactly what I ended up doing @MarcusWentz .
Back then I was big into solidity and set up a bit of a 'foundry book' of my own (https://www.solidity-in-foundry.com/index.html)

Took a lot of inspiration from the foundry book tbh.

@nickspurry
Copy link

nickspurry commented Apr 18, 2025

If highlight.js already supports a language you want that isn't included in mdbook by default, you can supply a custom version of highlight.js to override the default version.

The simplest way is to download a custom build directly from https://highlightjs.org/download where you can select the languages to include. In this case, highlight.js might need to be built from source since it requires an additional package for support.

Follow the instructions at https://rust-lang.github.io/mdBook/format/theme/index.html to override the default highlight.js file like you would any other default theme file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Highlighting Area: Code colored syntax highlighting C-enhancement Category: Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

4 participants