congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Prism4j
Code IndexAdd Tabnine 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)

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

  • Finding current android device location
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • startActivity (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Path (java.nio.file)
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now