noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.76k stars 313 forks source link

How to use $ latex $ inline latex ? #365

Open zhouzhuo810 opened 3 years ago

zhouzhuo810 commented 3 years ago

How to use $ latex $ inline latex ?

I can use $$ latex $$ now, but can not use $ latex $, can you help me ?

mMarkwon = Markwon
            .builder(this)
            .usePlugin(StrikethroughPlugin.create())
            .usePlugin(TaskListPlugin.create(MarkdownDetailPlusImmersiveActivity.this))
            .usePlugin(SyntaxHighlightPlugin.create(new Prism4j(new MyGrammarLocator()), isNightMode() ? Prism4jThemeDarkula.create()
                : Prism4jThemeDefault.create()))
            .usePlugin(HtmlPlugin.create(new HtmlPlugin.HtmlConfigure() {
                @Override
                public void configureHtml(@NonNull HtmlPlugin plugin) {
                    plugin.addHandler(new AlignTagHandler());
                    plugin.addHandler(new FontColorTagHandler());
                }
            }))
            .usePlugin(TablePlugin.create(new TablePlugin.ThemeConfigure() {
                @Override
                public void configureTheme(@NonNull TableTheme.Builder builder) {
                    boolean nightMode = isNightMode();
                    builder
                        .tableBorderWidth(2)
                        .tableEvenRowBackgroundColor(Color.parseColor(nightMode ? "#4Dcccccc" : "#4D9EBCE2"))
                        .tableOddRowBackgroundColor(Color.parseColor(nightMode ? "#2Dcccccc" : "#2D9EBCE2"))
                        .tableCellPadding(SettingUtil.getScaleTextSize(4));
                }
            }))
            .usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
                @Override
                public void configureImages(@NonNull ImagesPlugin plugin) {
                    plugin.addMediaDecoder(SvgPictureMediaDecoder.create());
                    plugin.addMediaDecoder(GifMediaDecoder.create(true));
                    plugin.addSchemeHandler(FileSchemeHandler.create());
                    plugin.addSchemeHandler(OkHttpNetworkSchemeHandler.create());
                }
            }))
            .usePlugin(PicassoImagesPlugin.create(Picasso.get()))
            .usePlugin(new AbstractMarkwonPlugin() {
                @Override
                public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
                    super.configureConfiguration(builder);
                    builder.linkResolver(new MyLinkResolver());
                }

                @Override
                public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
                    super.beforeSetText(textView, markdown);
                    AsyncDrawableScheduler.unschedule(textView);
                }

                @Override
                public void afterSetText(@NonNull TextView textView) {
                    super.afterSetText(textView);
                    AsyncDrawableScheduler.schedule(textView);
                }
            })
            .usePlugin(MarkwonInlineParserPlugin.create())
            .usePlugin(JLatexMathPlugin.create(mEtMarkdown.getTextSize(), new JLatexMathPlugin.BuilderConfigure() {
                @Override
                public void configureBuilder(@NonNull JLatexMathPlugin.Builder builder) {
                    builder.inlinesEnabled(true);
                }
            }))
            .build();
noties commented 3 years ago

Hello @zhouzhuo810 ,

unfortunately there is no way use single $ signs to mark inline latex out of box

zhouzhuo810 commented 3 years ago

Hello @zhouzhuo810 ,

unfortunately there is no way use single $ signs to mark inline latex out of box

Okay, Thank you ! I find it works in Pure Writer App with $ , but I don't kown how it does.

zhouzhuo810 commented 10 months ago

@noties are you ok? I need your help

  1. situation 1
<video id="video" controls="" preload="none" poster="file:///storage/emulated/0/Android/data/me.zhouzhuo810.zznote/tiny/2023_12_07_14_58_34.jpg">
<source id="mp4" src="file:///storage/emulated/0/Android/data/me.zhouzhuo810.zznote/tiny/2023_12_07_14_58_33.mp4" type="video/mp4">
</video>

use SimpleTagHandler to parse

Result :

HtmlTag's start == end ,

  1. situation 2
<video id="video" controls="" preload="none" poster="file:///storage/emulated/0/Android/data/me.zhouzhuo810.zznote/tiny/2023_12_07_14_58_34.jpg"><source id="mp4" src="file:///storage/emulated/0/Android/data/me.zhouzhuo810.zznote/tiny/2023_12_07_14_58_33.mp4" type="video/mp4">
</video>

use SimpleTagHandler to parse

Result :

HtmlTag's start != end

That's why ? it seems that MarkwonHtmlParser has some problem