Skip to content

Add support for ```java snippets in Markdown inputs#4284

Open
Gedochao wants to merge 1 commit into
VirtusLab:mainfrom
Gedochao:feature/markdown-java-snippets
Open

Add support for ```java snippets in Markdown inputs#4284
Gedochao wants to merge 1 commit into
VirtusLab:mainfrom
Gedochao:feature/markdown-java-snippets

Conversation

@Gedochao
Copy link
Copy Markdown
Contributor

@Gedochao Gedochao commented May 20, 2026

Closes #1602
Closes #1601

Rather than the scala and scala raw snippets we have for Scala in Markdown (which mirror .sc and .scala inputs, respectively), I believe we'll just have java snippets for .java inputs. This is due to wrapping script-like Java snippets being difficult, due to how imports and other syntax is handled. We could simply wrap code in a main method, but that seems too limiting in comparison to what we have in Scala.

Perhaps we could have jshell snippets and/or .jsh input support at some point, as that would deliver some of what we could possibly want from Java scripts... Eespecially as we now have JShell support in the REPL. But that is definitely out of scope here (and I'm not sure how feasible, either).

And so, this change allows for markdown inputs like this:

## Some Markdown Stuff
blah blah Java snippet
```java
public class Snippet {
  public static void main(String[] args) {
    System.out.println("Hello");
  }
}
```

Checklist

  • tested the solution locally and it works
  • ran the code formatter (scala-cli fmt .)
  • ran scalafix (./mill -i __.fix)
  • ran reference docs auto-generation (./mill -i 'generate-reference-doc[]'.run)

How much have your relied on LLM-based tools in this contribution?

Extensively, Cursor + Claude

How was the solution tested?

new automated tests

@Gedochao Gedochao force-pushed the feature/markdown-java-snippets branch from 877b233 to 6390db0 Compare May 20, 2026 11:29
@Gedochao Gedochao marked this pull request as ready for review May 20, 2026 14:50
@Gedochao Gedochao requested review from tgodzik and zielinsky May 20, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support plain java snippets in .md inputs Support java raw snippets in .md inputs

2 participants