Codota Logo
Prism4j
Code IndexAdd Codota to your IDE (free)

How to use
Prism4j
in
ru.noties.prism4j

Best Java code snippets using ru.noties.prism4j.Prism4j (Showing top 6 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: ru.noties/prism4j

@NonNull
public static Prism4j.Grammar require(@NonNull Prism4j prism4j, @NonNull String name) {
  final Prism4j.Grammar grammar = prism4j.grammar(name);
  if (grammar == null) {
    throw new IllegalStateException("Unexpected state, requested language is not found: " + name);
  }
  return grammar;
}
origin: noties/Markwon

@NonNull
protected CharSequence highlight(@NonNull String language, @NonNull Prism4j.Grammar grammar, @NonNull String code) {
  final SpannableStringBuilder builder = new SpannableStringBuilder();
  final Prism4jSyntaxVisitor visitor = new Prism4jSyntaxVisitor(language, theme, builder);
  visitor.visit(prism4j.tokenize(code, grammar));
  return builder;
}
origin: ru.noties/prism4j

@NonNull
public List<Node> tokenize(@NonNull String text, @NonNull Grammar grammar) {
  final List<Node> entries = new ArrayList<>(3);
  entries.add(new TextImpl(text));
  matchGrammar(text, entries, grammar, 0, 0, false, null);
  return entries;
}
origin: ru.noties/prism4j

if (isSyntaxNode(node)) {
  continue;
  int p = position;
  for (int len = entries.size(); k < len && (p < to || (!isSyntaxNode(entries.get(k)) && !isGreedyNode(entries.get(k - 1)))); ++k) {
    p += entries.get(k).textLength();
  if (isSyntaxNode(entries.get(i))) {
    continue;
final boolean hasInside = inside != null;
if (hasInside) {
  tokenEntries = tokenize(match, inside);
} else {
  tokenEntries = Collections.singletonList(new TextImpl(match));
  matchGrammar(text, entries, grammar, i, position, true, token);
origin: noties/Markwon

@Provides
@Singleton
Prism4j prism4j() {
  return new Prism4j(new GrammarLocatorDef());
}
origin: noties/Markwon

@NonNull
protected CharSequence highlightWithLanguageInfo(@NonNull String info, @NonNull String code) {
  final CharSequence out;
  final String language;
  final Prism4j.Grammar grammar;
  {
    String _language = info;
    Prism4j.Grammar _grammar = prism4j.grammar(info);
    if (_grammar == null && !TextUtils.isEmpty(fallback)) {
      _language = fallback;
      _grammar = prism4j.grammar(fallback);
    }
    language = _language;
    grammar = _grammar;
  }
  if (grammar != null) {
    out = highlight(language, grammar, code);
  } else {
    out = code;
  }
  return out;
}
ru.noties.prism4jPrism4j

Most used methods

  • grammar
  • tokenize
  • <init>
  • isGreedyNode
  • isSyntaxNode
  • matchGrammar

Popular in Java

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • findViewById (Activity)
  • getExternalFilesDir (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • String (java.lang)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • BoxLayout (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now