From 5fa5a1c1f887cbb26d2c86f5be457bd3aabf43fd Mon Sep 17 00:00:00 2001 From: Andrey Rylov Date: Fri, 9 Jun 2023 20:06:05 +0400 Subject: [PATCH] add interval setting for lists and indent for blocks --- README.md | 3 +++ Sources/SwiftyMarkdown/SwiftyMarkdown.swift | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4873ec7..d86a67d 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,9 @@ strikethrough.fontStyle : FontStyle underlineLinks : Bool bullet : String + +listInterval: CGFloat +blockIndent: CGFloat ``` `FontStyle` is an enum with these cases: `normal`, `bold`, `italic`, and `bolditalic` to give you more precise control over how lines and character styles should look. For example, perhaps you want blockquotes to default to having the italic style: diff --git a/Sources/SwiftyMarkdown/SwiftyMarkdown.swift b/Sources/SwiftyMarkdown/SwiftyMarkdown.swift index 1e9ef16..99cfd75 100644 --- a/Sources/SwiftyMarkdown/SwiftyMarkdown.swift +++ b/Sources/SwiftyMarkdown/SwiftyMarkdown.swift @@ -247,6 +247,10 @@ If that is not set, then the system default will be used. open var strikethrough = BasicStyles() public var bullet : String = "・" + + public var listInterval: CGFloat = 30 + + public var blockIndent: CGFloat = 20 public var underlineLinks : Bool = false @@ -496,17 +500,17 @@ extension SwiftyMarkdown { case .codeblock: lineProperties = body let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.firstLineHeadIndent = 20.0 + paragraphStyle.firstLineHeadIndent = self.blockIndent attributes[.paragraphStyle] = paragraphStyle case .blockquote: lineProperties = self.blockquotes let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.firstLineHeadIndent = 20.0 - paragraphStyle.headIndent = 20.0 + paragraphStyle.firstLineHeadIndent = self.blockIndent + paragraphStyle.headIndent = self.blockIndent attributes[.paragraphStyle] = paragraphStyle case .unorderedList, .unorderedListIndentFirstOrder, .unorderedListIndentSecondOrder, .orderedList, .orderedListIndentFirstOrder, .orderedListIndentSecondOrder: - let interval : CGFloat = 30 + let interval : CGFloat = self.listInterval var addition = interval var indent = "" switch line.lineStyle as! MarkdownLineStyle {