Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interval setting for lists and indent for blocks #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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 {
Expand Down