Comments (12)
Hey @Adonai !
Yeah, I think that the library should respect TextView canvas size to not exceed it (keeping original ratio of cause). Meanwhile, if it's an option, you could use HTML img
tags. Markwon takes into account width
and height
attributes and allows then reference %
and em
(font size), so as pixels (actually everything else except %
and em
is considered to be in pixels). For example:
<!-- takes 33% of canvas width keeping the original ratio -->
<img src="my-super-image.png" width="33%">
from markwon.
Ugh, compiling aar without uploading it is such a pain.
You should have told me about jitpack earlier, bro :)
https://jitpack.io/com/github/noties/Markwon/v1.0.5-SNAPSHOT/
from markwon.
@noties, yep, thanks, I recognized the difference in htmlParser/native markdown.
The problem is that I can't control what users write in the app so for now will come up with small postprocessing hack.
Thanks for quick reply!
from markwon.
Hey @Adonai !
I have created a new branch for the next release and pushed there discussed changes, here. I have tested it and it works for me. How it's for you? π
from markwon.
@noties , I'll test it this week and report, thanks!
from markwon.
Dafuq is this? πΆ It's not created by me.
While we are on this I can recommend using local maven repo: https://noties.github.io/blog/2018/03/24/local-maven-repo no need to upload anything
from markwon.
This thing is auto-generating build artifacts for any github repo you request it to do.
See this, very handy
from markwon.
Yeah, I don't like it. Maybe I should create a snapshot myself as development for the next release is mainly in one branch.
from markwon.
Ok, tested this, works as expected. You may close this once it's released.
Thanks!
from markwon.
The other problem, though, is that bounds in AsyncDrawable
are resolved in setResult()
but canvas width detection occurs in draw()
. When TextView is just inflated its width and height are zero, thus AsyncDrawable may fail to properly resolve dimensions.
In particular, this happens when you have RecyclerView
with TextView items and scroll too fast or reload adapter.
from markwon.
I think if you do something like this it should solve the RecyclerView issue:
public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyHolder> {
@Override
public void onBindViewHolder(@NonNull final MyHolder holder, final int position) {
whenReady(holder.text, new Runnable() {
@Override
public void run() {
Markwon.setMarkdown(holder.text, getMarkdown(position));
}
});
}
private static void whenReady(@NonNull final View view, @NonNull final Runnable action) {
if (view.getWidth() == 0) {
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (view.getWidth() > 0) {
view.getViewTreeObserver().removeOnPreDrawListener(this);
action.run();
}
return true;
}
});
} else {
action.run();
}
}
}
from markwon.
Thanks, I solved it the other but fairly similar way.
Anyway, this issue is resolved.
from markwon.
Related Issues (20)
- editor plugin doesn't highlight the '~' syntax
- If the width of the TextView is set to wrap_content, the table cannot be displayed.
- about MarkwonAdapter
- Custom plugin: Asynchronously change text
- Image covering content HOT 2
- How to escape German gender diversity "*" within words? (Without a special escape character!)
- How to disable ListItem (BulletList, OrderedList) HOT 1
- <strong> 解ζδΈδΊ
- Getting Started simple markdown doesn't work
- Color / underline for a text
- How to add vertical margin to an image? HOT 2
- Last paragraph has weird bottom margin
- None
- Single new line is ignored. HOT 2
- [Question] Change editor theme
- "%" shown are garbage in the app
- Hello @agnostic-apollo , I find that this method is no longer effective HOT 1
- TableEntry cannot use textLayout interface
- Use html in table
- Question: Will the library parse and render Latex only if, in the text, it starts and ends with $$
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markwon.