Skip to content

Commit

Permalink
Merge pull request #4 from edudnyk/edudnyk/inline_content_type_strong
Browse files Browse the repository at this point in the history
Fix of issues #2 and #3
  • Loading branch information
helje5 committed Oct 2, 2021
2 parents ce7162b + 904cb55 commit adaef3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/DocCArchive/Schema_0_1/Content/CodeListing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
extension DocCArchive.DocCSchema_0_1.Content {

public struct CodeListing: Equatable, CustomStringConvertible, Codable {
public var syntax : String
public var syntax : String?
public var code : [ String ]

public var description: String {
return syntax.isEmpty ? "<Code #\(code.count)>"
: "<Code[\(syntax)]: #\(code.count)>"
guard let syntax = syntax, !syntax.isEmpty else {
return "<Code #\(code.count)>"
}
return "<Code[\(syntax)]: #\(code.count)>"
}
}
}
8 changes: 8 additions & 0 deletions Sources/DocCArchive/Schema_0_1/InlineContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension DocCArchive.DocCSchema_0_1 {
overridingTitleInlineContent : [ InlineContent ]?)
case image (identifier: String)
case emphasis ([ InlineContent ])
case strong ([ InlineContent ])
case codeVoice(code: String)

public var description: String {
Expand All @@ -27,6 +28,7 @@ extension DocCArchive.DocCSchema_0_1 {
return "\(id)\(isActive ? "" : "-inactive")"
case .image (let id) : return "<img \(id)>"
case .emphasis (let content) : return "*\(content)*"
case .strong (let content) : return "**\(content)**"
case .codeVoice(let code) : return "`\(code)`"
}
}
Expand Down Expand Up @@ -54,6 +56,9 @@ extension DocCArchive.DocCSchema_0_1 {
case "emphasis":
self = .emphasis(try container.decode([ InlineContent ].self,
forKey: .inlineContent))
case "strong":
self = .strong(try container.decode([ InlineContent ].self,
forKey: .inlineContent))
case "reference":
self = .reference(
identifier:
Expand Down Expand Up @@ -90,6 +95,9 @@ extension DocCArchive.DocCSchema_0_1 {
case .emphasis(let content):
try container.encode("emphasis" , forKey: .type)
try container.encode(content , forKey: .inlineContent)
case .strong(let content):
try container.encode("strong" , forKey: .type)
try container.encode(content , forKey: .inlineContent)
case .reference(let identifier, let isActive, let ot, let otc):
try container.encode("reference" , forKey: .type)
try container.encode(identifier , forKey: .identifier)
Expand Down

0 comments on commit adaef3e

Please sign in to comment.