Skip to content

Commit

Permalink
Merge pull request #105 from noties/v3.0.0
Browse files Browse the repository at this point in the history
# 3.0.0

* Plugins, plugins, plugins
* Split basic functionality blocks into standalone modules
* Maven artifacts group changed to `ru.noties.markwon` (previously had been `ru.noties`)
* removed `markwon`, `markwon-image-loader`, `markwon-html-pareser-api`, `markwon-html-parser-impl`, `markwon-view` modules
* new module system: `core`, `ext-latex`, `ext-strikethrough`, `ext-tables`, `ext-tasklist`, `html`, `image-gif`, `image-okhttp`, `image-svg`, `recycler`, `recycler-table`, `syntax-highlight`
* Add BufferType option for Markwon configuration
* Fix typo in AsyncDrawable waitingForDimensions
* New tests format
* `Markwon.render` returns `Spanned` instance of generic `CharSequence`
* LinkMovementMethod is applied implicitly if not set on a TextView explicitly
* Split code and codeBlock spans and factories
* Add CustomTypefaceSpan 
* Add NoCopySpansFactory
* Add placeholder to image loading

Generally speaking there are a lot of changes. Most of them are not backwards-compatible.
The main point of this release is the `Plugin` system that allows more fluent configuration
and opens the possibility of extending `Markwon` with 3rd party functionality in a simple
and intuitive fashion. Please refer to the [documentation web-site](https://noties.github.io/Markwon)
that has information on how to start migration.

The shortest excerpt of this release can be expressed like this:

```java
// previous v2.x.x way
Markwon.setMarkdown(textView, "**Hello there!**");
```

```java
// 3.x.x
Markwon.create(context)
        .setMarkdown(textView, "**Hello there!**");
```

But there is much more to it, please visit documentation web-site
to get the full picture of latest changes.
  • Loading branch information
noties authored Mar 18, 2019
2 parents c634973 + 0b03dd2 commit d7558c8
Show file tree
Hide file tree
Showing 519 changed files with 16,495 additions and 6,288 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android:
- tools

- build-tools-28.0.3
- android-27
- android-28

branches:
except:
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

# Markwon

[![markwon](https://img.shields.io/maven-central/v/ru.noties/markwon.svg?label=markwon)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon%22)
[![markwon-image-loader](https://img.shields.io/maven-central/v/ru.noties/markwon-image-loader.svg?label=markwon-image-loader)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-image-loader%22)
[![markwon-syntax-highlight](https://img.shields.io/maven-central/v/ru.noties/markwon-syntax-highlight.svg?label=markwon-syntax-highlight)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-syntax-highlight%22)
[![markwon-view](https://img.shields.io/maven-central/v/ru.noties/markwon-view.svg?label=markwon-view)](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-view%22)

[![Build Status](https://travis-ci.org/noties/Markwon.svg?branch=master)](https://travis-ci.org/noties/Markwon)

**Markwon** is a markdown library for Android. It parses markdown
Expand All @@ -32,15 +27,20 @@ features listed in [commonmark-spec] are supported
[sample-apk]: https://github.com/noties/Markwon/releases

## Installation

![stable](https://img.shields.io/maven-central/v/ru.noties.markwon/core.svg?label=stable)
![snapshot](https://img.shields.io/nexus/s/https/oss.sonatype.org/ru.noties.markwon/core.svg?label=snapshot)

```groovy
implementation "ru.noties:markwon:${markwonVersion}"
implementation "ru.noties:markwon-image-loader:${markwonVersion}" // optional
implementation "ru.noties:markwon-syntax-highlight:${markwonVersion}" // optional
implementation "ru.noties:markwon-view:${markwonVersion}" // optional
implementation "ru.noties.markwon:core:${markwonVersion}"
```

Please visit [documentation] web-site for further reference


> You can find previous version of Markwon in [2.x.x](https://github.com/noties/Markwon/tree/2.x.x) branch

## Supported markdown features:
* Emphasis (`*`, `_`)
* Strong emphasis (`**`, `__`)
Expand All @@ -55,6 +55,7 @@ Please visit [documentation] web-site for further reference
* Code blocks
* Tables (*with limitations*)
* Syntax highlight
* LaTeX formulas
* HTML
* Emphasis (`<i>`, `<em>`, `<cite>`, `<dfn>`)
* Strong emphasis (`<b>`, `<strong>`)
Expand Down
13 changes: 9 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
targetSdkVersion config['target-sdk']
versionCode 1
versionName version
setProperty("archivesBaseName", "markwon-sample-$versionName")
setProperty("archivesBaseName", "markwon-$versionName")
}

lintOptions {
Expand All @@ -28,8 +28,13 @@ android {

dependencies {

implementation project(':markwon')
implementation project(':markwon-image-loader')
implementation project(':markwon-core')
implementation project(':markwon-ext-strikethrough')
implementation project(':markwon-ext-tables')
implementation project(':markwon-ext-tasklist')
implementation project(':markwon-html')
implementation project(':markwon-image-gif')
implementation project(':markwon-image-svg')
implementation project(':markwon-syntax-highlight')

deps.with {
Expand All @@ -43,4 +48,4 @@ dependencies {
annotationProcessor it['prism4j-bundler']
annotationProcessor it['dagger-compiler']
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.view.View;

import ru.noties.markwon.R;
import ru.noties.markwon.spans.TaskListDrawable;
import ru.noties.markwon.ext.tasklist.TaskListDrawable;

public class DebugCheckboxDrawableView extends View {

Expand Down
20 changes: 4 additions & 16 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.noties.markwon">

<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -10,8 +11,10 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppThemeLight">
android:theme="@style/AppThemeLight"
tools:ignore="AllowBackup">

<activity android:name=".MainActivity">

Expand All @@ -38,21 +41,6 @@
android:host="*"
android:scheme="https" />

<!--<data-->
<!--android:host="*"-->
<!--android:scheme="http"-->
<!--android:mimeType="text/markdown"/>-->

<!--<data-->
<!--android:host="*"-->
<!--android:scheme="file"-->
<!--android:mimeType="text/markdown"/>-->

<!--<data-->
<!--android:host="*"-->
<!--android:scheme="https"-->
<!--android:mimeType="text/markdown"/>-->

<data android:pathPattern=".*\\.markdown" />
<data android:pathPattern=".*\\.mdown" />
<data android:pathPattern=".*\\.mkdn" />
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ru/noties/markwon/AppBarItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ static class Renderer {
final TextView subtitle;

Renderer(@NonNull View view, @NonNull View.OnClickListener themeChangeClicked) {
this.title = Views.findView(view, R.id.app_bar_title);
this.subtitle = Views.findView(view, R.id.app_bar_subtitle);
this.title = view.findViewById(R.id.app_bar_title);
this.subtitle = view.findViewById(R.id.app_bar_subtitle);
view.findViewById(R.id.app_bar_theme_changer)
.setOnClickListener(themeChangeClicked);
}
Expand Down
36 changes: 7 additions & 29 deletions app/src/main/java/ru/noties/markwon/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import ru.noties.markwon.il.AsyncDrawableLoader;
import ru.noties.markwon.il.GifMediaDecoder;
import ru.noties.markwon.il.ImageMediaDecoder;
import ru.noties.markwon.il.SvgMediaDecoder;
import ru.noties.markwon.spans.AsyncDrawable;
import ru.noties.markwon.syntax.Prism4jThemeDarkula;
import ru.noties.markwon.syntax.Prism4jThemeDefault;
import ru.noties.prism4j.Prism4j;
Expand Down Expand Up @@ -72,23 +67,6 @@ UriProcessor uriProcessor() {
return new UriProcessorImpl();
}

@Provides
AsyncDrawable.Loader asyncDrawableLoader(
OkHttpClient client,
ExecutorService executorService,
Resources resources) {
return AsyncDrawableLoader.builder()
.client(client)
.executorService(executorService)
.resources(resources)
.mediaDecoders(
SvgMediaDecoder.create(resources),
GifMediaDecoder.create(false),
ImageMediaDecoder.create(resources)
)
.build();
}

@Provides
@Singleton
Prism4j prism4j() {
Expand All @@ -104,12 +82,12 @@ Prism4jThemeDefault prism4jThemeDefault() {
@Singleton
@Provides
Prism4jThemeDarkula prism4jThemeDarkula() {
return Prism4jThemeDarkula.create();
}

@Singleton
@Provides
GifProcessor gifProcessor() {
return GifProcessor.create();
return Prism4jThemeDarkula.create(0x0Fffffff);
}
//
// @Singleton
// @Provides
// GifProcessor gifProcessor() {
// return GifProcessor.create();
// }
}
36 changes: 0 additions & 36 deletions app/src/main/java/ru/noties/markwon/GifAwareSpannableFactory.java

This file was deleted.

15 changes: 4 additions & 11 deletions app/src/main/java/ru/noties/markwon/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Spanned;
import android.view.View;
import android.widget.TextView;

Expand All @@ -27,9 +28,6 @@ public class MainActivity extends Activity {
@Inject
UriProcessor uriProcessor;

@Inject
GifProcessor gifProcessor;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -40,9 +38,6 @@ protected void onCreate(final Bundle savedInstanceState) {

themes.apply(this);

// how can we obtain SpannableConfiguration after theme was applied?
// as we inject `themes` we won't be able to inject configuration, as it requires theme set

setContentView(R.layout.activity_main);

// we process additionally github urls, as if url has in path `blob`, we won't receive
Expand All @@ -58,7 +53,7 @@ public void onClick(View v) {
}
});

final TextView textView = Views.findView(this, R.id.text);
final TextView textView = findViewById(R.id.text);
final View progress = findViewById(R.id.progress);

appBarRenderer.render(appBarState());
Expand All @@ -68,11 +63,9 @@ public void onClick(View v) {
public void apply(final String text) {
markdownRenderer.render(MainActivity.this, themes.isLight(), uri(), text, new MarkdownRenderer.MarkdownReadyListener() {
@Override
public void onMarkdownReady(CharSequence markdown) {

Markwon.setText(textView, markdown);
public void onMarkdownReady(@NonNull Markwon markwon, Spanned markdown) {

gifProcessor.process(textView);
markwon.setParsedMarkdown(textView, markdown);

Views.setVisible(progress, false);
}
Expand Down
Loading

0 comments on commit d7558c8

Please sign in to comment.