Makeup - A syntax highlighter for Elixir

Releases should be tagged but they aren’t. I’m sorry for that. The README is not up to date yet. I’ll rewrite it when I have the time.

2 Likes

Oh, I just realized that package is from Overmind and yet on Github:
I missed it as I read the readme and Github search missed it too :stuck_out_tongue:

I sent you a pull request for a couple of tiny typos. :slight_smile:

Thanks a lot ^-^

New version released. Makeup.Lexer is now a behaviour with some callbacks you must implement. Having those callbacks might make lexers easier to compose in the future.

If you want to start contributing new lexers, now is a good time. There is a cookiecutter template that can help you get started (cookiecutter a python package that works as a very extensible mix generator; the link contains documentation on how to use cookiecutter).

3 Likes

Makeup will be included as the default syntax highlighter in ExDocs 0.19.
I’d like to invite people to take a look at the elixir docs rendered with the latest MakeupElixir lexer to try to find some bugs or some thing that just don’t look right: https://tmbb.github.io/exdocs_makedown_demo/api-reference.html (despite the url, the link above does not use makedown anymore)

Please report problems here or as an issue in the MakeupElixir repo: https://github.com/tmbb/makeup_elixir

NOTE: These docs are NOT the official docs for Elixir 1.7-rc. Those are still rendered with an elixir lexer from some days ago.

3 Likes

New makeup version released, compatible with nimble_parsec 0.5.0. Thanks to @kip

3 Likes

I have released a new version.

Makeup now provides a registry where you can register your own lexers.
Then, you just have to depend on the lexer and Makeup will discover it automatically.
This is the first step to support any programming language in ExDoc

EDIT:
Once I commit to this API I should update makeup to v1.0.0.
My only question is now the following:

Should I add an extension registry? That way, lexers could be associated with an extension. For example, the ElixirLexer could be associated with .ex or .exs files. I can’t see a use case for this now, but it might be useful later.

1 Like

No because some languages have shared extensions annoyingly. Instead use a mimetype registry. Like how markdown uses a ‘name’ of a language (like elixir even though the extension in .ex/.exs or so) it is good to have something that is always properly unique for these purposes. :slight_smile:

Hey, I know this is an old post but I’m trying to add GraphQL syntax highlighting by implementing Makeup.Lexer. I believe I have the lexer implemented properly but it still doesn’t seem to be using syntax highlighting when I have GraphQL in my markdown like this:

@doc"""
```graphql
mutation {
  foo(input: "bar") {
    result
  }
}
```‎
"""
def my_func() do
end

Am I misunderstanding how this is supposed to work? I was hoping the ex_doc would pick up that graphql tag in the code block and look up my lexer to use for highlighting but that’s not what I’m seeing :frowning:
Here’s a link to what I have:

1 Like

Strings inside a @doc attribute are simply highlighted as strings. They are not highlighted as markdown (and fenced code blocks are not recognized either). I’m not sure how I feel about highlighting @doc strings as something else other than strings. Maybe @josevalim could chime in?

Happy new year everyone! I just wanted to remind possible contributer that although this forum thread has been a bit stale, we still welcome contributions to makeup in the form of new lexers. @josevalim has mostly taken over the project, as I have been dedicating myself to other things.

New contributions for 2024 in the form of new lexers are extremely welcome.

3 Likes