About markdown syntax highlighter

Hi @discourse,

If I were to develop another markdown syntax highlighter (such as json, http, etc) would it be a markdown-it plugin such as markdown-it-sub?

If not, can you please direct me where I could learn more about writing new markdown syntax highlighter?

Best

Syntax highlighter would be neither :slight_smile:

Have a look at: https://highlightjs.org/ we are on version 9.13.1

1 Like

Thanks @Sam_Saffron!

I've sent a PR to highlight.js so they add support to Kibana Dev Tools syntax https://github.com/highlightjs/highlight.js/pull/1924

I am not sure when/if they will merge that. Do you think we could look into adding that change into the version used by you?

bump @discourse

I don't think this will be merged :frowning: but I think we can achieve this with a theme component here cause its simply a client side change. It is a bit tricky cause we defer load highlight so we would have to teach the client that ... when it defer loads highlight it injects this.

So you mind doing a post asking about how to add custom highlighter on https://meta.discoruse.org I will assign this out to a member of our team?

Thanks for replying! I will ask how to add a custom highlighter, but I thought that, since you use highlight.js, then it's basically adding another language syntax support to highlight.js, which is what I did in that PR.

I follow, if it is merged it will be no problem at all we will update highlight.js and be done. Its just that looking at it I am not sure it will be merged, so I think you will need a discourse specific customisation.

What if a patch is generated from the changes? Is it something that can be applied to the version used here?

It is not that easy, loading the patch is tricky, we can get this applied, I will track this official request and get back to you

1 Like

Hi @thiago, Sam asked me to look into adding this to your site as a theme component, and it should now be done. Here is a test:

GET _search?q=some text
POST /logstash-*/_search
{
    "size": 100,
    "query": { "match_all": {} },
    "aggs": {
        "price_avg": { 
            "avg": { "field": "price" }
        }
    }
}

If your PR for HighlightJS gets merged, let us know, we'll need to remove the theme component code I just added to support this here.

2 Likes

This is SO GREAT! Thank you very much!

Yes! I will let you know when/if gets merged. I've been trying to ping the authors with no luck. Will keep trying.

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.