Class FormatDetector

java.lang.Object
io.jenkins.plugins.interactiveinput.view.FormatDetector

public final class FormatDetector extends Object
Maps a file name to a ReviewDocument render format and a Prism language hint.

The format decides how the review page presents the snapshot: markdown is rendered to safe HTML, everything else (including HTML and any programming language) is shown as escaped, syntax-highlighted source — the file is never executed. The language string is a Prism grammar id used by prism-api for highlighting (see Prism languages); "none" disables highlighting for plain text.

  • Method Details

    • detect

      @NonNull public static FormatDetector.Detected detect(@NonNull String fileName)
      Parameters:
      fileName - a file name or path (only the extension / base name is inspected)
      Returns:
      the detected format and Prism language (never null)
    • resolve

      @NonNull public static FormatDetector.Detected resolve(@CheckForNull String format, @NonNull String fileName)
      Resolve an explicit user-supplied format override to a FormatDetector.Detected, falling back to extension detection for the language hint.
      Parameters:
      format - one of markdown|html|text|code (case-insensitive); blank means auto
      fileName - used to derive the language hint (and the format when format is blank)