Skip to content

Markwon extensition support elegant code background. 为 Markwon 提供优雅的代码块显示

Notifications You must be signed in to change notification settings

kingideayou/MarkwonCodeEx

Repository files navigation

MarkwonCodeEx

Markwon extensition support elegant code background.
Markwon 提供优雅的代码块显示效果

Preview

ProGuard

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
  implementation 'ru.noties:markwon:2.0.1' 
  implementation 'com.github.kingideayou:MarkwonCodeEx:1.0.0'

Simple usage snippet

val builder = SpannableBuilder()
val visitor = CodeVisitor(
    spannableBuilder,
    builder,
    spannableTheme,
    resources.getColor(R.color.codeTextColor) //Note: code text color
)

Markwon.createParser().parse("a simple `code`").accept(visitor)
tvContent.text = builder.text()

layout

<me.next.codex.roundedbg.RoundedBgTextView
        android:id="@+id/tv_content"
        style="@style/Widget.RoundedBackground.SampleTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

style

<style name="Widget.RoundedBackground.SampleTextView">
    <item name="android:lineSpacingExtra">2dp</item>
    <item name="android:lineSpacingMultiplier">1.2</item>
    <item name="android:padding">4dp</item>
    <item name="android:textSize">18sp</item>
    <item name="android:includeFontPadding">true</item>
    <item name="roundedTextHorizontalPadding">2.6dp</item> <!-- code background padding-->
    <item name="roundedTextVerticalPadding">2dp</item>
</style>

Thanks

This library is inspired by noties/Markwon & googlesamples/android-text and uses some of its source code.

License

Copyright 2018 NeXT.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Markwon extensition support elegant code background. 为 Markwon 提供优雅的代码块显示

Resources

Stars

Watchers

Forks

Packages

No packages published