Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected padding between formulas #138

Closed
ringosham opened this issue Jun 19, 2019 · 2 comments
Closed

Unexpected padding between formulas #138

ringosham opened this issue Jun 19, 2019 · 2 comments
Labels
Milestone

Comments

@ringosham
Copy link

  • Markwon version: 3.0.2
  • Markwon Latex plugin version: 3.0.2
  • Compiled SDK version: 28
  • Android version: Pie (9)
  1. Please specify expected/actual behavior
    There's extra padding between the formulas where there should be none.
    Screenshot_20190619-160606

  2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)
    This is the code used in the activity.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView text = findViewById(R.id.test);
    Markwon markdown = Markwon.builder(this).usePlugin(ImagesPlugin.create(this)).usePlugin(JLatexMathPlugin.create(50)).build();
    markdown.setMarkdown(text, readMarkdownFile(R.raw.markdown));
}

public String readMarkdownFile(int resourceId) {
    InputStream in = getResources().openRawResource(resourceId);
    Scanner scan = new Scanner(in).useDelimiter("\\A");
    return scan.hasNext() ? scan.next() : "";
}

The markdown used.

$$
  P(X=r)=\frac{\lambda^r e^{-\lambda}}{r!}
$$

$$
  P(X<r)=P(X<r-1)
$$

$$
  P(X>r)=1-P(X<r=1)
$$

$$
  \text{Variance} = \lambda
$$
@noties
Copy link
Owner

noties commented Jun 20, 2019

Hello @ringosham !

I can reproduce this issue. This happens because JLatexMathPlugin relies on ImagesPlugin (all latex is displayed via AsyncDrawable). And internally we set image-size for a latex formula to be 100% of canvas width. Thus, image is scaled up whilst keeping the ratio (increase in both width and height), but this scaling is ignored by JLatexMathDrawable.

The solution would be of cause to stop relying on ImagesPlugin. And the good thing is: it is already done in upcoming 4.0.0 snapshot version. I'm going to fix this issue also. So, if you are only evaluating the project starting with the next 4.0.0 version might be a good idea (less migration).

I have also noticed that JLatexMathPlugin uses the same drawable for all latex formulas background and going to fix that also.

v4.0.0

@noties noties added the bug label Jun 20, 2019
@noties noties added this to the 4.0.0 milestone Jun 20, 2019
@noties
Copy link
Owner

noties commented Jul 2, 2019

This issue is fixed in 4.0.0 version

@noties noties closed this as completed Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants