PrismJS / PrismJS/prism

There are some flaws in Prism's rendering of Kotlin.

Open
#3,693 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Information:

  • Prism version: 1.29.0
  • Plugins: none
  • Environment: Node

Description
When I write a piece of code in Kotlin, Prism does not recognise the class name:

fun main() {
    GMap.Builder.apply {
        width = 80
        height = 40
    }.build().use {
        // do something
    }
    GMap.Builder.dispose()
}

In the code above, GMap, Builder are marked as text, but I want Prism to mark them as class-name, which Prism renders as

<br> GMap<span class="token punctuation">.</span>Builder

However, for the Java form of this code, Prism correctly identifies the class name:

public class Main {

    public static void main(String[] args) {
        GMap.BuilderJava.INSTANCE
                .setWidth(80)
                .setHeight(40);
        try (GMap map = GMap.Builder.build()) {
            // do something
        }
        GMap.Builder.dispose();
    }

}

The rendering results in:

<span class="token class-name">GMap<span class="token punctuation">.</span>BuilderJava</span>

Also, Prism does not recognise the type in the argument list of Kotlin functions, the name of the parent class of an anonymous internal class, etc.

And Prism doesn't seem to recognise the names of variables (or constants) in Kotlin and Java, when I define variables they are marked as text, I'm not sure if this is deliberate or a loophole.

Example

If my instructions are not clear enough, current renderings can be viewed on my website at: http://kmar.top/posts/521b560d/#481801a0

There is a lot of Kotlin and Java code to view and compare in the above pages, starting with the anchor #481801a0.

My site doesn't support English, but this shouldn't affect the ability to see how Prism works.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Kotlin and Java snippets in Prism 1.29.0 under Node and compare their rendered token classes. The issue mentions no source files or tests; done means the reported Kotlin class names and types receive the intended highlighting, with variable and constant handling clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, kotlin
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.