Parma 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Parma 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Parma 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !

软件简介

Parma

Display Markdown using pure SwiftUI components. Taking advantages of ViewBuilder to make custom appearances for Text and View.

Example

import Parma

struct ContentView: View {
    var markdown = "I'm **Strong**."
    
    var body: some View {
        Parma(markdown)
    }
}

For more examples, please refer to demo app.

Markdown Support

Already Supported

  • Heading level 1-6
  • Paragraph
  • Multi-level bullet list
  • Multi-level ordered list
    • Period delimiter
    • Parenthesis delimiter
  • Image (Needs extra configurations)
  • Inline text
    • Strong
    • Emphasis
    • Code

Possibly Support in Future Versions

  • Divider
  • Block quote
  • Code block

Unsupported

  • Inline hyperlink

Installation

Requirement

  • Xcode 11.0 or later
  • Swift 5 or later
  • iOS 13.0 / macOS 10.15 or later deployment targets

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies on all platforms.

Adding Parma as a dependency by using Xcode’s GUI, the package url is https://github.com/dasautoooo/Parma .

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Parma into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Parma'

Appearance Customization

To customize Text styles and Views, create a new render which conform to protocol ParmaRenderable, and only reimplement those that fit your purposes. Finally, assign the customized render as a new render when create Parma view.

import Parma

struct ContentView: View {
    var markdown = "I'm **Strong**."
    
    var body: some View {
        Parma(markdown, render: MyRender())
    }
}

struct MyRender: ParmaRenderable {
    ...
}

There's a DemoApp that modified some of these delegate methods below for everyone to take as a reference.

/// Define the heading text style.
/// - Parameters:
///   - level: The level of heading.
///   - textView: The textView generated from captured heading string.
func heading(level: HeadingLevel?, textView: Text) -> Text

/// Define the paragraph text style.
/// - Parameter text: The text string captured from paragraph.
func paragraph(text: String) -> Text

/// Define the text style for plain text. Do NOT recommend to alter this if there's no special purpose.
/// - Parameter text: The text string captured from markdown.
func plainText(_ text: String) -> Text

/// Define the strong text style.
/// - Parameter textView: The textView generated from captured strong string.
func strong(textView: Text) -> Text

/// Define the emphasis text style.
/// - Parameter textView: The textView generated from captured emphasis string.
func emphasis(textView: Text) -> Text

/// Define the link text style.
/// - Parameters:
///   - textView: The textView generated from captured link string.
///   - destination: The destination of the link.
func link(textView: Text, destination: String?) -> Text

/// Define the code text style.
/// - Parameter text: The text string captured from code.
func code(_ text: String) -> Text

/// Define the style of heading view.
/// - Parameters:
///   - level: The level of heading.
///   - view: The view contains heading text.
func headingBlock(level: HeadingLevel?, view: AnyView) -> AnyView

/// Define the style of paragraph view.
/// - Parameter view: The view contains view(s) which belong(s) to this paragraph.
func paragraphBlock(view: AnyView) -> AnyView

/// Define the style of list item.
/// - Parameter attributes: Attributes of the list containing the item. Those must be considered for proper item rendering.
/// - Parameter index: Normalized index of the list item. For exemple, the index of the third item of a one level list would be `[2]` and the second item of a sublist appearing fourth in it's parent list would be `[3, 1]`.
/// - Parameter view: The view contains view(s) which belong(s) to this item.
func listItem(attributes: ListAttributes, index: [Int], view: AnyView) -> AnyView

/// Define the style of image view.
/// - Parameter urlString: The url string for this image view.
/// - Parameter altTextView: The view contains alt text.
func imageView(with urlString: String, altTextView: AnyView?) -> AnyView

Name Origin

Parma is a city in the northern Italy, which is famous for its architecture, music and art. The reason of choosing this city name as the project name is Giambattista Bodoni, a famous typographer, who spent most his lifetime living and working in this city.

Bodoni was an Italian typographer, type-designer in Parma. During his lifespan, he designed many typefaces that known as Bodoni nowadays. Each Mac has Bodoni font installed, and free to use.

Credit

The package is built upon Down, which is a markdown parser in Swift.

展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
发表于开发技能专区
2018/05/13 18:08

mybatis多个参数(不使用@param注解情况下),sql参数占位符正确写法

useActualParamName配置 useActualParamName 允许使用方法签名中的名称作为语句参数名称。 为了使用该特性,你的工程必须采用Java 8编译,并且加上-parameters选项。(从3.4.1开始) true | false true mybatis的全局配置useActualParamName决定了mapper中参数的写法,默认为true 代码展示: @Test public void findUserById() { SqlSession sqlSession = getSessionFactory().openSession(); UserDao userMapper = ...

7
15
发表了博客
2019/08/01 10:47

ThinkPHP5.1接收post、get参数

我们要先认识的是请求对象Request类 <?php //要用Request类 第一步就要引入他,才能在当前控制器上使用 //知识点:use 与 namespace前面不可有空格等其他操作。 namespace app\admin\controller; use think\Request; class Index{   // 在index方法引入Request   public function index(Request $request){     // parma 表示接收所有传过来的参数 不管是post请求还是get请求 parma都能接收到参数     $data = $re...

0
0
发表了博客
2018/12/09 22:27

SAP HANA HDBSQL命令

1.登录: window操作系统下面: 打开C:\Program Files\SAP\hdbclient\hdbsql.exe \c 连接数据库 connect的缩写 HANA hostname: hanasvr-10 HANA system number: 00 Your user-id: P1526659201 Your password: Phucga3V \c[onnect] -i <instance number> 实例号 00 -n <host>[:<port>] 主机名 端口可选 hanasvr -u <user_name> 用户名 P1526659201 -p <password> 密码 Phucga3V -U <user_store_key> 用户根据username password存...

0
0
发表了博客
2019/02/22 15:43

小程序富文本转换

富文本编辑器可以不引用wxss,可以省略 1.index.js var WxParse = require('../../utils/wxParse/wxParse.js'); //请求接口 获取到对应的字段var parma = { id: that.data.id } wx.request({ url: app.globalData.url + "******", data: parma, header: { 'content-type': 'application/x-www-form-urlencoded' // 默认值 }, method: 'POST', success: fun...

0
0
发表了博客
2019/03/06 20:09

模拟HTTP请求调用controller

原文参考本人的简书:https://www.jianshu.com/p/0221edbe1598 MockMvc实现了对Http请求的模拟,能够直接使用网络的形式,转换到Controller调用,这样使得测试速度更快,不依赖网络环境。而且提供了一套验证的工具。代码如下: 1 @RunWith(SpringRunner.class) 2 @WebMvcTest(MyController.class) 3 public class MyControllerTest { 4 @Autowired 5 private MockMvc mockMvc; 6 /** 7 * 测试方法 8 ...

0
0
发表于大前端专区
2014/11/09 00:04

Javascript 基础知识之数据类型

javascript是一种弱类型的脚本语言 1)var param ;(根据所赋值的类型确定变量类型,变量类型可以随意改变) 全局变量 1)方法外的变量,或者是方法中未使用var声明的变量 局部变量 1)方法中使用var声明的变量 Number类型 1) 小数不能直接使用“==”来判断相等;NaN、Infinity、-Infinity 等 undifined 1) 变量已经声明过但是没有被赋值。 null 1)声明变量为空值,如 var parma = null ; 基本数据类型(5 种) 1) Number...

0
0
发表了博客
2018/03/10 00:01

R语言常用包分类总结

常用包: ——数据处理:lubridata ,plyr ,reshape2,stringr,formatR,mcmc; ——机器学习:nnet,rpart,tree,party,lars,boost,e1071,BayesTree,gafit,arules; ——可视化包:ggplot2,lattice,googleVis; ——地图包:ggmap,RgoogleMaps,rworldmap; 金融包: ——时间序列:zoo,xts,chorn,its,timeDate; ——金融分析:quantmod,RQuantLib,portfolio,PerformanceAnalytics,TTR,sde,YieldCurve;...

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部