Skip to content

Commit

Permalink
List/Reader: Nitpicky code style fixes (#12)
Browse files Browse the repository at this point in the history
Slight tweaks to make the code style a bit more consistent.
  • Loading branch information
JohnSundell committed Nov 29, 2019
1 parent 63e75da commit 44ce07c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Sources/Ink/Internal/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/

internal struct List: Fragment {
private static let orderedListMarkers: Set<Character> = [".", ")"]

var modifierTarget: Modifier.Target { .lists }

private var listMarker: Character
Expand All @@ -23,6 +21,7 @@ internal struct List: Fragment {
let isOrdered = reader.currentCharacter.isNumber

var list: List

if isOrdered {
let firstNumberString = try reader.readCharacters(matching: \.isNumber, max: 9)
let firstNumber = Int(firstNumberString) ?? 1
Expand Down Expand Up @@ -78,7 +77,7 @@ internal struct List: Fragment {
try addTextToLastItem()
}
case \.isNumber:
guard case .ordered(_) = list.kind else {
guard case .ordered = list.kind else {
try addTextToLastItem()
continue
}
Expand Down Expand Up @@ -127,12 +126,14 @@ internal struct List: Fragment {
modifiers: ModifierCollection) -> String {
let tagName: String
let startAttribute: String

switch kind {
case .unordered:
tagName = "ul"
startAttribute = ""
case let .ordered(startingIndex):
tagName = "ol"

if startingIndex != 1 {
startAttribute = #" start="\#(startingIndex)""#
} else {
Expand Down Expand Up @@ -165,4 +166,6 @@ private extension List {
case unordered
case ordered(firstNumber: Int)
}

static let orderedListMarkers: Set<Character> = [".", ")"]
}
1 change: 0 additions & 1 deletion Sources/Ink/Internal/Reader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ extension Reader {
while !didReachEnd
&& count < maxCount
&& currentCharacter[keyPath: keyPath] {

advanceIndex()
count += 1
}
Expand Down

0 comments on commit 44ce07c

Please sign in to comment.