mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
211fdab250
TODO - Issues of https://codeberg.org/gitnex-garage/useLangDefs https://codeberg.org/gitnex/GitNex/issues/1180 Also see https://codeberg.org/gitnex-garage/useLangDefs Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1196 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
48 lines
1.5 KiB
Java
48 lines
1.5 KiB
Java
package org.mian.gitnex.helpers.codeeditor.markwon;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
import io.noties.markwon.MarkwonConfiguration;
|
|
import io.noties.markwon.core.MarkwonTheme;
|
|
import org.mian.gitnex.helpers.codeeditor.theme.Theme;
|
|
|
|
/**
|
|
* @author qwerty287
|
|
*/
|
|
public class MarkwonHighlighter extends AbstractMarkwonPlugin {
|
|
|
|
private final Theme theme;
|
|
private final Context context;
|
|
private final String fallbackLanguage;
|
|
|
|
public MarkwonHighlighter(
|
|
Context context, @NonNull Theme theme, @Nullable String fallbackLanguage) {
|
|
this.theme = theme;
|
|
this.context = context;
|
|
this.fallbackLanguage = fallbackLanguage;
|
|
}
|
|
|
|
@NonNull public static MarkwonHighlighter create(Context context, @NonNull Theme theme) {
|
|
return create(context, theme, null);
|
|
}
|
|
|
|
@NonNull public static MarkwonHighlighter create(
|
|
Context context, @NonNull Theme theme, @Nullable String fallbackLanguage) {
|
|
return new MarkwonHighlighter(context, theme, fallbackLanguage);
|
|
}
|
|
|
|
@Override
|
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
|
builder.codeTextColor(context.getResources().getColor(theme.getDefaultColor(), null))
|
|
.codeBackgroundColor(
|
|
context.getResources().getColor(theme.getBackgroundColor(), null));
|
|
}
|
|
|
|
@Override
|
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
|
builder.syntaxHighlight(SyntaxHighlighter.create(context, theme, fallbackLanguage));
|
|
}
|
|
}
|