Compare commits

...

6 Commits

Author SHA1 Message Date
Sven e754ab1c80 Provide access to the list delimiter (#275)
* Provide access to the list delimiter

* Fix test
2021-10-18 13:22:18 +02:00
Sergey Pimenov 3b07bb52cf [Fix] DownTextView: Trigger re-render on styler change (#271)
Co-authored-by: John Nguyen <polyxo@protonmail.com>
2021-08-21 09:27:29 +02:00
John Nguyen 055f818ed7 Add codecov threshold (#272) 2021-08-21 09:07:28 +02:00
Oliver Fox 9997dc00cb RTL support in lists (#261)
- Added text alignment option to lists

Co-authored-by: John Nguyen <polyxo@protonmail.com>
2021-08-21 08:13:29 +02:00
Erik Kerber e2b597d469 [Chore] Add arm64 to simulator supported archs (#265) 2021-07-28 18:06:09 +02:00
John Nguyen bf24fcbb2d [Changes] v0.11.0 2021-05-04 21:56:02 +02:00
9 changed files with 76 additions and 7 deletions
+21 -1
View File
@@ -1,5 +1,25 @@
# Changelog
## [v0.11.0](https://github.com/johnxnguyen/Down/tree/v0.11.0) (2021-05-04)
[Full Changelog](https://github.com/johnxnguyen/Down/compare/v0.10.0...v0.11.0)
**Implemented enhancements:**
- \[CodeCoverage\] Improve accuracy for combined code coverage reporting [\#205](https://github.com/johnxnguyen/Down/issues/205)
**Closed issues:**
- DownStyler not included when installed via CocoaPods [\#254](https://github.com/johnxnguyen/Down/issues/254)
- \[Commonmark\] Strikethrough not working / not supported [\#253](https://github.com/johnxnguyen/Down/issues/253)
- \[Attributed Strings\] Unordered list items with a single line appear further indented than those with multiple lines when using a custom font [\#246](https://github.com/johnxnguyen/Down/issues/246)
**Merged pull requests:**
- \[Feature\] Custom list prefixes for AttributedStringVisitor [\#255](https://github.com/johnxnguyen/Down/pull/255) ([dloic](https://github.com/dloic))
- \[Chore\] Add SwiftLint [\#252](https://github.com/johnxnguyen/Down/pull/252) ([johnxnguyen](https://github.com/johnxnguyen))
- \[Chore\] Fix codecov report [\#251](https://github.com/johnxnguyen/Down/pull/251) ([johnxnguyen](https://github.com/johnxnguyen))
## [v0.10.0](https://github.com/johnxnguyen/Down/tree/v0.10.0) (2021-02-28)
[Full Changelog](https://github.com/johnxnguyen/Down/compare/v0.9.5...v0.10.0)
@@ -87,6 +107,7 @@
**Merged pull requests:**
- Swift 5.1 Support [\#204](https://github.com/johnxnguyen/Down/pull/204) ([ghost](https://github.com/ghost))
- Resolves Swift Package Manager issue related to swift-snapshot-testing [\#203](https://github.com/johnxnguyen/Down/pull/203) ([ghost](https://github.com/ghost))
## [v0.9.1](https://github.com/johnxnguyen/Down/tree/v0.9.1) (2020-02-28)
@@ -115,7 +136,6 @@
**Merged pull requests:**
- Resolves Swift Package Manager issue related to swift-snapshot-testing [\#203](https://github.com/johnxnguyen/Down/pull/203) ([ghost](https://github.com/ghost))
- Improve configurability of DownStyler [\#188](https://github.com/johnxnguyen/Down/pull/188) ([mgacy](https://github.com/mgacy))
- Make color & font collection initializers public [\#184](https://github.com/johnxnguyen/Down/pull/184) ([johnxnguyen](https://github.com/johnxnguyen))
+31 -1
View File
@@ -34,12 +34,29 @@ public class List: BaseNode {
public lazy var isTight: Bool = cmark_node_get_list_tight(cmarkNode) == 1
/// The list delimiter.
public lazy var delimiter: Delimiter? = Delimiter(cmarkNode.listDelimiter)
}
// MARK: - List Type
public extension List {
enum Delimiter {
case period
case paren
init?(_ cmark: cmark_delim_type) {
switch cmark {
case CMARK_NO_DELIM: return nil
case CMARK_PERIOD_DELIM: self = .period
case CMARK_PAREN_DELIM: self = .paren
default: preconditionFailure("Invalid delim type")
}
}
}
enum ListType: CustomDebugStringConvertible {
case bullet
case ordered(start: Int)
@@ -71,7 +88,20 @@ public extension List {
extension List: CustomDebugStringConvertible {
public var debugDescription: String {
return "List - type: \(listType), isTight: \(isTight)"
var result = "List - type: \(listType), isTight: \(isTight)"
if let delim = delimiter {
result += ", delimiter: \(delim)"
}
return result
}
}
extension List.Delimiter: CustomDebugStringConvertible {
public var debugDescription: String {
switch self {
case .paren: return "paren"
case .period: return "period"
}
}
}
+4
View File
@@ -101,6 +101,10 @@ public extension CMarkNode {
return Int(cmark_node_get_list_start(self))
}
var listDelimiter: cmark_delim_type {
return cmark_node_get_list_delim(self)
}
var url: String? {
return String(cString: cmark_node_get_url(self))
}
@@ -46,6 +46,7 @@ public class ListItemParagraphStyler {
let style = NSMutableParagraphStyle()
style.paragraphSpacingBefore = options.spacingAbove
style.paragraphSpacing = options.spacingBelow
style.alignment = options.alignment
return style
}
@@ -76,7 +77,7 @@ public class ListItemParagraphStyler {
}
private func tabStop(at location: CGFloat) -> NSTextTab {
return NSTextTab(textAlignment: .left, location: location, options: [:])
return NSTextTab(textAlignment: options.alignment, location: location, options: [:])
}
}
@@ -26,18 +26,21 @@ public struct ListItemOptions {
public var spacingAfterPrefix: CGFloat
public var spacingAbove: CGFloat
public var spacingBelow: CGFloat
public var alignment: NSTextAlignment
// MARK: - Life cycle
public init(maxPrefixDigits: UInt = 2,
spacingAfterPrefix: CGFloat = 8,
spacingAbove: CGFloat = 4,
spacingBelow: CGFloat = 8) {
spacingBelow: CGFloat = 8,
alignment: NSTextAlignment = .natural) {
self.maxPrefixDigits = maxPrefixDigits
self.spacingAfterPrefix = spacingAfterPrefix
self.spacingAbove = spacingAbove
self.spacingBelow = spacingBelow
self.alignment = alignment
}
}
@@ -26,7 +26,11 @@ open class DownTextView: TextView {
// MARK: - Properties
open var styler: Styler
open var styler: Styler {
didSet {
try? render()
}
}
#if canImport(UIKit)
@@ -1,7 +1,7 @@
SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos appletvos appletvsimulator
VALID_ARCHS[sdk=macosx*] = i386 x86_64 arm64
VALID_ARCHS[sdk=iphoneos*] = arm64 armv7 armv7s
VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64
VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 arm64
VALID_ARCHS[sdk=appletv*] = arm64
VALID_ARCHS[sdk=appletvsimulator*] = x86_64
@@ -1,7 +1,7 @@
Document
↳ Paragraph
↳ Text - Text text.
↳ List - type: Ordered (start: 3), isTight: true
↳ List - type: Ordered (start: 3), isTight: true, delimiter: period
↳ Item
↳ Paragraph
↳ Text - One
+7
View File
@@ -2,3 +2,10 @@ ignore:
- "Sources/cmark/"
- "Down-Example/"
- "Tests/"
coverage:
status:
project:
default:
target: auto
threshold: 3%