鸿蒙开发实战:基于【Markwon】移植和开发

电子说

1.2w人已加入

描述

本项目是基于开源项目Markwon进行适用harmonyos的移植和开发的。

移植版本:v4.6.2

1. 项目介绍

项目名称:Markwon

所属系列:harmonyos的第三方组件适配移植

功能:

  • Emphasis (*, _)
  • Strong emphasis (**, __)
  • Strike-through (~~)
  • Headers (#{1,6})
  • Links () && [][])
  • Images
  • Thematic break (---, ***, ___)
  • Quotes & nested quotes (>{1,})
  • Ordered & non-ordered lists & nested ones
  • Strike-through (, , )~~
  • Link (a).

项目移植状态:

项目已完成移植,完成度50%,差异如下

  • 主界面点击右上角图标,进入README.md界面不能正常显示内容
  • 主界面stable 版本信息栏使用固定信息及样式
  • 主界面CHECK FOR UPDATE 点击检测更新版本无对应链接
  • 主界面列表条目点击后进入页面不能正常显示内容
  • 主界面列表条目标签4个以上不能自动换行
    添加了demo模块用于效果展示;

编程语言:java

2. 集成指引

方式一

  1. 下载或自行编译生成Markwon的.har文件,文件路径为:./demo/libs/Markwon-debug.har。
  2. 自行编译时,需要注意要自行添加签名。
  3. 导入你的harmonyos项目模块的**./libs**中。
  4. 在模块下的build.gradle中确认依赖**./libs**下的.har包,implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
  5. 在代码中使用。

方式二:

  1. 在根目录的build.gradle文件中添加mavenCentral()
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    ...
    buildscript {
        repositories {
            ...
            mavenCentral()
        }
        ...
    }
    
    allprojects {
        repositories {
            ...
            mavenCentral()
        }
    }
    
  2. 在module目录下的build.gradle文件中添加``
    ...
    dependencies {
        ...
        implementation 'com.gitee.ts_ohos:markwon:1.0.1'
    }
    

3. 使用说明

更多用法参考本项目的 demo ,原项目Java DocOHOS的文档。
主要用法如下:

Inline HTML

< u >< i >H< sup >T< sub >M< /sub >< /sup >< b >< s >L< /s >< /b >< /i >< /u >

*HTML*


< ScrollView
  android:id="@+id/scroll_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginTop="?android:attr/actionBarSize" >

  < TextView
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="16dip"
    android:lineSpacingExtra="2dip"
    android:textSize="16sp"
    tools:text="yonman" / >

< /ScrollView >
// username, repo, branch, lastPathSegment

    String RE_FILE = "^"+TextUtils.getHttps()+"github.com/([w-.]+?)/([w-.]+?)/(?:blob|raw)/([w-.]+?)/(.+)$";
    private static final String RE_REPOSITORY = "^"+TextUtils.getHttps()+"github.com/([w-.]+?)/([w-.]+?)/*$";

    public static Pair< String, String > parseRepository(String url) {

        Pattern pattern = Pattern.compile(RE_REPOSITORY);
        Matcher matcher = pattern.matcher(url);
        if (matcher.matches()) {
            String user = matcher.group(1);
            String repository = matcher.group(2);
            if (TextUtils.isEmpty(user) || TextUtils.isEmpty(user)) {
                return new Pair<  >(null, null);
            } else {
                return new Pair<  >(user, repository);
            }
        } else {
            return new Pair< String, String >(null, null);
        }
    }
private static final String SAMPLE_PREFIX = "io.noties.markwon.app.";

    @NonNull
    public static List< Sample > readSamples(@NonNull Context context) {

        RawFileEntry rawFileEntry = context.getResourceManager().getRawFileEntry("resources/rawfile/samples.json");
        try (InputStream inputStream = rawFileEntry.openRawFile()) {
            return readSamples(inputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

更多鸿蒙开发应用知识已更新gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md参考前往。

或+mau123789学习,是v喔

鸿蒙

4. 效果演示

1. 主界面展示
2. 点击item中plugin标签,显示选择结果

*注 : demo中的图片是点击不同标签,进行筛选显示结果

鸿蒙鸿蒙

5. 版本迭代

  • v1.0.0 基于原项目最新版本,移植功能及提交。
  • v1.0.1 更新harmonyos API至5。

6. 版本和许可信息

  • Apache License 2.0
  • [LICENSE]
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

  

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.

审核编辑 黄宇

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分