diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ee699..9467ef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,18 @@ ## Master -### Changes +### Enhancements +- None + +### Fixes - None +## 0.3.0 + +### Enhancements +- Add support for collapsible blocks on GitHub.com and rendered GitHub Pages. + + ## 0.2.1 ### Fixes @@ -31,3 +40,4 @@ ## 0.1.0 - Initial Release + diff --git a/Sources/MarkdownGenerator/MarkdownCollapsibleSection.swift b/Sources/MarkdownGenerator/MarkdownCollapsibleSection.swift index e6e0965..63be74a 100644 --- a/Sources/MarkdownGenerator/MarkdownCollapsibleSection.swift +++ b/Sources/MarkdownGenerator/MarkdownCollapsibleSection.swift @@ -7,10 +7,29 @@ import Foundation +/// Collapsible blocks are a great way to hide large portions of content +/// that, while valuable to the reader, would result on a lot of noise. +/// +/// Collapsible blocks work well in most Markdown readers, including +/// GitHub.com and rendered GitHub Pages. However, because they rely on +/// HTML tags, they will make the _raw_ markdown output harder to read. +/// +/// ```html +///
Block Title +/// +/// Block details. +/// +///
+/// ``` public struct MarkdownCollapsibleSection: MarkdownConvertible { let summary: String let details: MarkdownConvertible + /// MarkdownCollapsibleSection initializer + /// + /// - Parameters: + /// - summary: Plain text or HTML string containing the block title. + /// - details: Markdown convertible elements to include in the collapsible block. public init(summary: String, details: MarkdownConvertible) { self.summary = summary self.details = details @@ -19,9 +38,10 @@ public struct MarkdownCollapsibleSection: MarkdownConvertible { /// Generated Markdown output public var markdown: String { return """ -
\(summary) +
\(summary) \(details.markdown) +
""" } diff --git a/Tests/MarkdownGeneratorTests/MarkdownCollapsibleSectionTests.swift b/Tests/MarkdownGeneratorTests/MarkdownCollapsibleSectionTests.swift index 7ae6b88..499cc83 100644 --- a/Tests/MarkdownGeneratorTests/MarkdownCollapsibleSectionTests.swift +++ b/Tests/MarkdownGeneratorTests/MarkdownCollapsibleSectionTests.swift @@ -12,9 +12,10 @@ class MarkdownCollapsibleSectionTests: XCTestCase { func testSimple() { let output = """ -
Hello +
Hello World +
""" XCTAssertEqual(MarkdownCollapsibleSection(summary: "Hello", details: "World").markdown, output) @@ -22,7 +23,7 @@ class MarkdownCollapsibleSectionTests: XCTestCase { func testComplex() { let output = """ -
This is cool stuff +
This is cool stuff # Title @@ -38,6 +39,7 @@ class MarkdownCollapsibleSectionTests: XCTestCase { ```swift let foo = Bar() ``` +
"""