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

Line breaks and Latex rendering #149

Closed
ringosham opened this issue Jul 3, 2019 · 3 comments
Closed

Line breaks and Latex rendering #149

ringosham opened this issue Jul 3, 2019 · 3 comments
Labels
Milestone

Comments

@ringosham
Copy link

ringosham commented Jul 3, 2019

  • Markwon version: 4.0.1
  • Markwon Latex plugin: 4.0.1

Thanks for the fast bug fixes. Here's another bug I found.

  1. Please specify expected/actual behavior
    This formula gets rendered twice. It's kind of random and it doesn't happen on every expression.
    I speculate it's something when superscript, subscript and fractions are present in an expression? I might be wrong. I'm not sure.
    Edit: The same issue appears in v3.x.x
    Screenshot_20190703-135158

  2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)

Activity class

@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(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.

$$ 
    \sigma_T^2 = \frac{1-p}{p^2}
$$
@noties
Copy link
Owner

noties commented Jul 4, 2019

Hello @ringosham !

Thank you for your feedback, it's really valuable! 👍

About the issue: it was an interesting debugging session. Turns out that Android will draw a drawable for each line of text (for which span is applied). Yeah. And this is not related to actual formula, you can change \sigma_T^2 = \frac{1-p}{p^2} for any other and the result will still be duplicated. But if you remove the space character after opening $$ when formula won't be duplicated. I'm going to change what text is actually added to a TextView, so formula won't have multiple lines (to be shown as a placeholder text). I'm going to publish 4.0.2-SNAPSHOT soon.

Thanks again for your scrupulous bug finding! 🙌

@noties noties added this to the 4.0.2 milestone Jul 4, 2019
@noties noties added the bug label Jul 4, 2019
@ringosham ringosham changed the title Formulas rendered multiple times Line breaks and Latex rendering Jul 5, 2019
@ringosham
Copy link
Author

The snapshot seems to be working fine.

@noties
Copy link
Owner

noties commented Jul 15, 2019

Released in 4.0.2 👍

@noties noties closed this as completed Jul 15, 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