Skip to content

Commit

Permalink
Add interval setting for lists and indent for blocks (SimonFairbairn#143
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPartzsch committed Mar 7, 2024
1 parent ba93508 commit 6ada646
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions Sources/SwiftyMarkdown/SwiftyMarkdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -498,17 +502,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 {
Expand Down

0 comments on commit 6ada646

Please sign in to comment.