GithubHelp home page GithubHelp logo

Comments (14)

josevalim avatar josevalim commented on June 14, 2024

Don't we have one of those javascript highlighting tools that accept either textmate or pygments source files?

from ex_doc.

pminten avatar pminten commented on June 14, 2024

It's a decent bit of work. Serendipitously Josh Adams is working on highlight.js support for Elixir.

Basic highlight.js integration should be simple enough.

from ex_doc.

josevalim avatar josevalim commented on June 14, 2024

Awesome! For me something like highlight.js would be the easiest to bundle into ExDoc.

from ex_doc.

vanstee avatar vanstee commented on June 14, 2024

Oh yeah highlight.js is a great option.

I'll try to put this together once this pull request gets merged: highlightjs/highlight.js#317 Thanks for working on this @knewter.

from ex_doc.

josevalim avatar josevalim commented on June 14, 2024

Fantastic job @knewter! ❀️ πŸ’š πŸ’™ πŸ’› πŸ’œ

from ex_doc.

alco avatar alco commented on June 14, 2024

Any chance we could use pygments (if it is installed on the user's system)?

from ex_doc.

josevalim avatar josevalim commented on June 14, 2024

That's one option, there is another issue though: how can we guarantee it is elixir syntax since we don't tag languages?

from ex_doc.

alco avatar alco commented on June 14, 2024

We can set default language for all code blocks. Pygments could also guess the language by contents.

from ex_doc.

alco avatar alco commented on June 14, 2024

Also, there has to be an option of cancelling highlighting if an error token is found. I saw this behaviour in sphinx. So we set elixir for all code blocks, but if there is a shell code example (containing $), the dollar will not be recognized by the elixir lexer, and the whole code block will be left unhighlighted.

from ex_doc.

alco avatar alco commented on June 14, 2024

Just for the record: adding support for pygments at the current stage would be rather complicated. To make it work for sundown and pandoc, we'd need to scan the resulting html and replace code blocks in it.

Using markdown converter written in Elixir with support for user-supplied filters would be best.

So currently, the most pragmatic approach is to bring highlight.js up to date with modern Elixir and use that. /cc @knewter

from ex_doc.

dignifiedquire avatar dignifiedquire commented on June 14, 2024

As far as I understand one could use pandoc (if installed) to take care of any syntax highlighting by setting the flag

--indented-code-classes=CLASSES
Specify classes to use for indented code blocks–for example, perl,numberLines or haskell. Multiple classes may be separated by spaces or commas.

to elixir and adding elixir support to pandoc / highlighting-kate. For that reason I've started working on doing exactly that:
dignifiedquire/highlighting-kate@1955130

It's not ready for prime time yet, but I hope to have something reasonable in the next few days.

from ex_doc.

whatyouhide avatar whatyouhide commented on June 14, 2024

If I understand correctly, this should be now solved since ex_doc is using highlight.js (with Elixir support) to highlight code examples in the documentation. Should we close this?

from ex_doc.

vanstee avatar vanstee commented on June 14, 2024

Yep good call. Here's the relevant PR: #168

Thanks for following up @whatyouhide.

from ex_doc.

whatyouhide avatar whatyouhide commented on June 14, 2024

@vanstee no problem, my pleasure!

from ex_doc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.