Repository: SwiftDocOrg/CommonMark Branch: main Commit: 6fc9d04ff536 Files: 79 Total size: 414.3 KB Directory structure: gitextract_min7gahu/ ├── .github/ │ └── workflows/ │ ├── ci.yml │ └── documentation.yml ├── .gitignore ├── Changelog.md ├── LICENSE.md ├── Makefile ├── Package.resolved ├── Package.swift ├── README.md ├── Resources/ │ ├── CommonMarkSpecTests.swift.gyb │ └── camelcase.awk ├── Sources/ │ └── CommonMark/ │ ├── Nodes/ │ │ ├── Block/ │ │ │ ├── BlockQuote.swift │ │ │ ├── CodeBlock.swift │ │ │ ├── HTMLBlock.swift │ │ │ ├── Heading.swift │ │ │ ├── List.swift │ │ │ ├── Paragraph.swift │ │ │ └── ThematicBreak.swift │ │ ├── Document.swift │ │ ├── Inline/ │ │ │ ├── Code.swift │ │ │ ├── Emphasis.swift │ │ │ ├── HardLineBreak.swift │ │ │ ├── Image.swift │ │ │ ├── Link.swift │ │ │ ├── RawHTML.swift │ │ │ ├── SoftLineBreak.swift │ │ │ ├── Strong.swift │ │ │ └── Text.swift │ │ └── Node.swift │ ├── Result Builders/ │ │ ├── ContainerOfBlocksBuilder.swift │ │ ├── ContainerOfInlineElementsBuilder.swift │ │ └── ListBuilder.swift │ ├── Supporting Types/ │ │ ├── Block.swift │ │ ├── Children.swift │ │ ├── Fragment.swift │ │ ├── Inline.swift │ │ ├── LineBreak.swift │ │ ├── Linked.swift │ │ ├── Literal.swift │ │ ├── Section.swift │ │ ├── Visitable.swift │ │ └── Visitor.swift │ └── Version.swift └── Tests/ ├── CommonMarkSpecTests/ │ ├── AtxHeadingsTests.swift │ ├── AutolinksTests.swift │ ├── BackslashEscapesTests.swift │ ├── BlankLinesTests.swift │ ├── BlockQuotesTests.swift │ ├── CodeSpansTests.swift │ ├── EmphasisAndStrongEmphasisTests.swift │ ├── EntityAndNumericCharacterReferencesTests.swift │ ├── FencedCodeBlocksTests.swift │ ├── HardLineBreaksTests.swift │ ├── HtmlBlocksTests.swift │ ├── ImagesTests.swift │ ├── IndentedCodeBlocksTests.swift │ ├── InlinesTests.swift │ ├── LinkReferenceDefinitionsTests.swift │ ├── LinksTests.swift │ ├── ListItemsTests.swift │ ├── ListsTests.swift │ ├── ParagraphsTests.swift │ ├── PrecedenceTests.swift │ ├── RawHtmlTests.swift │ ├── SetextHeadingsTests.swift │ ├── SoftLineBreaksTests.swift │ ├── TabsTests.swift │ ├── TextualContentTests.swift │ └── ThematicBreaksTests.swift ├── CommonMarkTests/ │ ├── CommonMarkBuilderTests.swift │ ├── CommonMarkTests.swift │ ├── ContainerManipulationTests.swift │ ├── DocumentTests.swift │ ├── Fixtures.swift │ ├── NodeTests.swift │ ├── ProtocolTests.swift │ ├── StatisticsVisitor.swift │ └── VisitorTests.swift └── LinuxMain.swift ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: push: branches: [main] pull_request: branches: [main] jobs: macos: runs-on: macos-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Build and Test run: swift test linux: runs-on: ubuntu-latest strategy: matrix: swift: - "5.3" - "5.4" container: image: swift:${{ matrix.swift }} steps: - name: Checkout uses: actions/checkout@v1 - name: Build and Test run: swift test --enable-test-discovery windows: runs-on: windows-latest steps: - uses: actions/checkout@v2 - uses: seanmiddleditch/gha-setup-vsdevenv@master - name: Install swift-5.4 run: | Install-Binary -Url "https://swift.org/builds/swift-5.4-release/windows10/swift-5.4-RELEASE/swift-5.4-RELEASE-windows10.exe" -Name "installer.exe" -ArgumentList ("-q") - name: Set Environment Variables run: | echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Adjust Paths run: | echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install Supporting Files run: | Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap" Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap" Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes" Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap" - name: Build and Test run: swift test --enable-test-discovery ================================================ FILE: .github/workflows/documentation.yml ================================================ name: Documentation on: push: branches: - main paths: - .github/workflows/documentation.yml - Sources/**.swift jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Generate Documentation uses: SwiftDocOrg/swift-doc@master with: inputs: "Sources" output: "Documentation" - name: Upload Documentation to Wiki uses: SwiftDocOrg/github-wiki-publish-action@master with: path: "Documentation" env: GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} ================================================ FILE: .gitignore ================================================ .DS_Store /.build /Packages /*.xcodeproj xcuserdata/ .swiftpm Resources/spec* ================================================ FILE: Changelog.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ## [0.5.1] - 2021-05-04 ### Added - Added `replace(child:with:)` methods for container nodes. #26 by @mattt. ### Fixed - Fixed documentation for `List`. #29 by @mattt. ### Changed - Changed implementation of `Hashable` conformance for `Node`. Previously the hash value of a node was computed from its content. Now it's computed from the opaque cmark pointer. #30 by @Lukas-Stuehrk. ## [0.5.0] - 2021-01-14 ### Added - Added support for the visitor pattern, by adding `protocol Visitor`/`protocol Visitable` & `enum VisitorContinueKind`. #13 by @regexident. ### Fixed - Fixed document parsing options. #21 by @regexident. - Fixed memory leaks. #22 by @regexident. ## [0.4.0] - 2020-05-01 ### Added - Added a changelog. #17 by @mattt. ### Changed - Changed `render` method, as well as nested `RenderingFormat` and `RenderingOptions` types, from `Document` to `Node`. #18 by @mattt. ### Fixed - Fixed abbreviation for "Universal Declaration of Human Rights" (UDHR) throughout project. #12 by @regexident. ## [0.3.2] - 2020-04-24 ### Fixed - Fixed implementations of `insert` methods. #10 by @Lukas-Stuehrk ## [0.3.1] - 2020-04-23 ### Fixed - Fixed error caused by missing a case for `CMARK_NODE_DOCUMENT` in `Node.create`. #8 by @mattt. ### Removed - Removed `assertionFailure` in `Node` `cmark_node_type` class property. 1903d99 by @mattt. ## [0.3.0] - 2020-04-10 ### Added - Added implementations of `buildIf` and `buildEither` to `StringBuilder`. #5 by @mattt. ### Changed - **Breaking Change**. Changed `HTML`, renaming it to `RawHTML`. #4 by @mattt. - Changed `Node` to conform to `Codable`. #6 by @mattt. - Changed access level of `Node` from `open` to `public`. #6 by @mattt. - Change access level for APIs referencing `cmark_node` to `internal` #6 by @mattt. - Changed swift-cmark dependency to more recent version. 2239c9c by @mattt. ### Fixed - Fixed error 'Top-level Document encoded as string JSON fragment.' 727e38f by @mattt. ## [0.2.2] - 2020-02-06 ### Fixed - Fixed bug in how closed ranges are constructed from reported source positions. #2 by @mattt. ## [0.2.1] - 2020-01-25 ### Added - Added `ForEach` type to `CommonMarkBuilder` module. 3cee5da by @mattt. - Added implementations of `buildIf` and `buildEither` to `CommonMarkBuilder`. a125d23 by @mattt. - Added convenience initializers to `List` for mapping sequence of values. ec61c45 by @mattt. ### Changed - Changed `List.Item` to allow initialization with `Inline` or `Block` children. c21468c0 by @mattt. - Changed inline types conform to `ListItemConvertible`. ffe900bf by @mattt. - Changed access of children to `public` and conformed them to `Block & Node`. 5e88c519 by @mattt ### Removed - Removed conformance of `Document` to `CustomReflectable`. 6b92588e by @mattt. - Removed `Child` typealias in favor of explicit compound types. c9a5b199 by @mattt. ## [0.2.0] - 2020-01-24 ### Added - Added CommonMarkBuilder interface. 79a98dd by @mattt. ### Changed - Changed access level for `Node` to open. 79a98dd by @mattt. - Changed initialization pattern of `Node`. 79a98dd by @mattt. - Changed `ListItem`, renaming it to `List.Item`. 79a98dd by @mattt. - Changed initializers for `Node` subclasses 79a98dd by @mattt. ### Removed - Removed `BulletList` and `OrderedList`, consolidating them into into a new `List` type. 79a98dd by @mattt. ## [0.1.2] - 2020-01-22 ### Changed - Changed cmark dependency to pin to a tag in a fork. 2f5a2a4 by @mattt. ## [0.1.1] - 2020-01-22 ### Changed - Changed cmark dependency to pin to a specific revision. 90704ff by @mattt. ## [0.1.0] - 2020-01-22 ### Added - Added node creation and mutation functionality. a41ba246 by @mattt. ## [0.0.1] - 2020-01-27 Initial release. [unreleased]: https://github.com/SwiftDocOrg/CommonMark/compare/0.5.1...main [0.5.1]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.5.1 [0.5.0]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.5.0 [0.4.0]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.4.0 [0.3.2]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.3.2 [0.3.1]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.3.1 [0.3.0]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.3.0 [0.2.2]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.2.2 [0.2.1]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.2.1 [0.2.0]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.2.0 [0.1.2]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.1.2 [0.1.1]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.1.1 [0.1.0]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.1.0 [0.0.1]: https://github.com/SwiftDocOrg/CommonMark/releases/tag/0.0.1 ================================================ FILE: LICENSE.md ================================================ Copyright 2019 Read Evaluate Press, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ COMMONMARK_SPEC_VERSION=0.29 Tests/CommonMarkSpecTests: Resources/spec.json | Resources/spec @mkdir -p $@ @for section in $(shell jq -c '.[].section' $< | uniq); do \ filename=`echo "$${section}" | awk -f Resources/camelcase.awk`; \ jq "map(select(.section == \"$${section}\"))" $< > "$|/$${filename}.json" ; \ gyb --line-directive '' -o $@/$${filename}Tests.swift -D filename="$${filename}" Resources/CommonMarkSpecTests.swift.gyb; \ done Resources/spec: @mkdir -p Resources/spec Resources/spec.json: @curl "https://spec.commonmark.org/${COMMONMARK_SPEC_VERSION}/spec.json" > $@ %.swift: %.swift.gyb @gyb --line-directive '' -o $@ $< .PHONY: clean: @rm -f Resources/spec.json @rm -rf Resources/spec @rm -rf Tests/CommonMarkSpecTests ================================================ FILE: Package.resolved ================================================ { "object": { "pins": [ { "package": "cmark", "repositoryURL": "https://github.com/SwiftDocOrg/swift-cmark.git", "state": { "branch": null, "revision": "9c8096a23f44794bde297452d87c455fc4f76d42", "version": "0.29.0+20210102.9c8096a" } } ] }, "version": 1 } ================================================ FILE: Package.swift ================================================ // swift-tools-version:5.1 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "CommonMark", products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( name: "CommonMark", targets: ["CommonMark"] ) ], dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/SwiftDocOrg/swift-cmark.git", from: Version(0, 29, 0, buildMetadataIdentifiers: ["20210102", "9c8096a"])), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( name: "CommonMark", dependencies: ["cmark"] ), .testTarget( name: "CommonMarkTests", dependencies: ["CommonMark"] ), .testTarget( name: "CommonMarkSpecTests", dependencies: ["CommonMark"] ) ] ) ================================================ FILE: README.md ================================================ # CommonMark ![CI][ci badge] [![Documentation][documentation badge]][documentation] A Swift package for working with [CommonMark][commonmark] text. It's built on top of [libcmark][cmark] and fully compliant with the [CommonMark Spec][commonmark]. ## Usage ```swift import CommonMark let markdown = #""" # [Universal Declaration of Human Rights][udhr] ## Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. [udhr]: https://www.un.org/en/universal-declaration-human-rights/ "View full version" """# let document = try Document(markdown) ``` ### Inspecting Document Nodes ```swift document.children.count // 3 let heading = document.children[0] as! Heading heading.headerLevel // 1 heading.children.count // 1 let link = heading.children[0] as! Link link.urlString // "https://www.un.org/en/universal-declaration-human-rights/") link.title // "View full version" let subheading = document.children[1] as! Heading subheading.headerLevel // 2 subheading.children.count // 1 let subheadingText = subheading.children[0] as! Text subheadingText.literal // "Article 1." let paragraph = document.children[2] as! Paragraph paragraph.description // "All human beings [ ... ]" paragraph.range.lowerBound // (line: 5, column: 1) paragraph.range.upperBound // (line: 7, column: 62) ``` ### Rendering to HTML, XML, LaTeX, and Manpage ```swift let html = document.render(format: .html) //

[ ... ] let xml = document.render(format: .xml) // ## [5.1 Block quotes](https://spec.commonmark.org/0.29/#block-quotes) > > A block quote marker consists of 0-3 spaces of initial indent, > plus (a) the character > together with a following space, > or (b) a single character > not followed by a space. */ public final class BlockQuote: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_BLOCK_QUOTE } public convenience init(children: [Block & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(@ContainerOfBlocksBuilder _ builder: () -> [Block & Node]) { self.init(children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Block/CodeBlock.swift ================================================ import cmark /** A code block. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [4.4 Indented code blocks](https://spec.commonmark.org/0.29/#indented-code-blocks) > > An indented code block is composed of > one or more indented chunks separated by blank lines. > An indented chunk is a sequence of non-blank lines, > each indented four or more spaces. > The contents of the code block are the literal contents of the lines, > including trailing line endings, > minus four spaces of indentation. > An indented code block has no info string. > ## [4.5 Fenced code blocks](https://spec.commonmark.org/0.29/#fenced-code-blocks) > > A code fence is a sequence of > at least three consecutive backtick characters (`) or tildes (~). > (Tildes and backticks cannot be mixed.) > A fenced code block begins with a code fence, > indented no more than three spaces. */ public final class CodeBlock: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_CODE_BLOCK } public var fenceInfo: String? { get { return String(cString: cmark_node_get_fence_info(cmark_node)) } set { cmark_node_set_fence_info(cmark_node, newValue) } } public convenience init(literal: String? = nil) { self.init() self.literal = literal } public convenience init(literal: String, fenceInfo: String? = nil) { self.init() self.literal = literal if let fenceInfo = fenceInfo { self.fenceInfo = fenceInfo } } public convenience init(fenceInfo: String? = nil, _ block: () -> String?) { self.init(literal: block()) if let fenceInfo = fenceInfo { self.fenceInfo = fenceInfo } } } ================================================ FILE: Sources/CommonMark/Nodes/Block/HTMLBlock.swift ================================================ import cmark /** An HTML block. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [4.6 HTML blocks](https://spec.commonmark.org/0.29/#html-blocks) > > An HTML block is a group of lines that is treated as raw HTML > (and will not be escaped in HTML output). */ public final class HTMLBlock: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_HTML_BLOCK } public convenience init(literal: String? = nil) { self.init() self.literal = literal } #if swift(>=5.4) public static func wrap( @ContainerOfBlocksBuilder _ body: () -> [Block & Node], before: () -> String?, after: () -> String? ) -> [Block & Node] { var blocks: [Block & Node] = [] blocks.append(HTMLBlock(literal: before())) blocks.append(contentsOf: body()) blocks.append(HTMLBlock(literal: after())) return blocks } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Block/Heading.swift ================================================ import cmark /** A heading. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [4.2 ATX headings](https://spec.commonmark.org/0.29/#atx-headings) > > An ATX heading consists of a string of characters, > parsed as inline content, > between an opening sequence of 1–6 unescaped # characters > and an optional closing sequence of any number of unescaped # characters. > The opening sequence of # characters must be followed by a space > or by the end of line. > The optional closing sequence of #s must be preceded by a space > and may be followed by spaces only. > The opening # character may be indented 0-3 spaces. > The raw contents of the heading are stripped of leading and trailing spaces > before being parsed as inline content. > The heading level is equal to the number of # characters > in the opening sequence. > ## [4.3 Setext headings](https://spec.commonmark.org/0.29/#setext-headings) > A setext heading consists of one or more lines of text, > each containing at least one non-whitespace character, > with no more than 3 spaces indentation, > followed by a setext heading underline. > The lines of text must be such that, > were they not followed by the setext heading underline, > they would be interpreted as a paragraph: > they cannot be interpretable as a > code fence, ATX heading, block quote, > thematic break, list item, or HTML block. */ public final class Heading: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_HEADING } static let levelRange: ClosedRange = 1...6 public var level: Int { get { return numericCast(cmark_node_get_heading_level(cmark_node)) } set { precondition(Heading.levelRange.contains(newValue)) cmark_node_set_heading_level(cmark_node, numericCast(newValue)) } } public convenience init(level: Int, text string: String) { self.init(level: level, children: [Text(literal: string)]) } public convenience init(level: Int, children: [Inline & Node] = []) { self.init() self.level = level guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(level: Int = 1, @ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(level: level, children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Block/List.swift ================================================ import cmark /** A list. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [5.3 Lists](https://spec.commonmark.org/0.29/#lists) > > A list is a sequence of one or more list items of the same type. > The list items may be separated by any number of blank lines. > ## [5.2 List items](https://spec.commonmark.org/0.29/#list-items) > > A list marker is a bullet list marker or an ordered list marker. > > An ordered list marker is a sequence of 1–9 arabic digits (0-9), > followed by either a . character or a ) character. > (The reason for the length limit is that > with 10 digits we start seeing integer overflows in some browsers.) */ public final class List: Node { public enum Kind: Hashable { case bullet case ordered } public enum Delimiter: Hashable { case none case period(Int = 1) case parenthesis(Int = 1) init(_ cmark_node: OpaquePointer) { switch cmark_node_get_list_delim(cmark_node) { case CMARK_PERIOD_DELIM: self = .period(numericCast(cmark_node_get_list_start(cmark_node))) case CMARK_PAREN_DELIM: self = .parenthesis(numericCast(cmark_node_get_list_start(cmark_node))) default: self = .none } } } override class var cmark_node_type: cmark_node_type { return CMARK_NODE_LIST } public var kind: Kind { return delimiter == .none ? .bullet : .ordered } public var delimiter: Delimiter { get { return Delimiter(cmark_node) } set { switch newValue { case .period(let listStart): cmark_node_set_list_type(cmark_node, CMARK_ORDERED_LIST) cmark_node_set_list_delim(cmark_node, CMARK_PERIOD_DELIM) cmark_node_set_list_start(cmark_node, numericCast(listStart)) case .parenthesis(let listStart): cmark_node_set_list_type(cmark_node, CMARK_ORDERED_LIST) cmark_node_set_list_delim(cmark_node, CMARK_PAREN_DELIM) cmark_node_set_list_start(cmark_node, numericCast(listStart)) default: cmark_node_set_list_type(cmark_node, CMARK_BULLET_LIST) } } } /** Whether the list is loose. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > A list is loose if any of its constituent list items > are separated by blank lines, > or if any of its constituent list items > directly contain two block-level elements with a blank line between them. > Otherwise a list is tight. */ public var loose: Bool { get { return !tight } set { tight = !newValue } } /** Whether the list is tight. - SeeAlso: `loose` */ public var tight: Bool { get { return cmark_node_get_list_tight(cmark_node) == 1 ? true : false } set { cmark_node_set_list_tight(cmark_node, newValue ? 1 : 0) } } public convenience init(delimiter: Delimiter = .none, children: [List.Item] = []) { self.init() self.delimiter = delimiter guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(delimiter: Delimiter = .none, tight: Bool = true, @ListBuilder _ builder: () -> [List.Item]) { self.init(delimiter: delimiter, children: builder()) self.tight = tight } public convenience init(of values: Values, delimiter: Delimiter = .none, tight: Bool = true, @ListBuilder _ builder: (Values.Element) -> [List.Item]) where Values: Sequence { self.init(delimiter: delimiter, children: values.flatMap { builder($0) }) self.tight = tight } #endif } extension List { public final class Item: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_ITEM } public convenience init(children: [Inline & Node] = []) { self.init(children: [Paragraph(children: children)]) } public convenience init(children: [Block & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(@ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(children: builder()) } public convenience init(@ContainerOfBlocksBuilder _ builder: () -> [Block & Node]) { self.init(children: builder()) } #endif } } ================================================ FILE: Sources/CommonMark/Nodes/Block/Paragraph.swift ================================================ import cmark /** A paragraph. From the [CommonMark Spec](https://spec.commonmark.org/0.29/#thematic-breaks): > ## [4.8 Paragraphs](https://spec.commonmark.org/0.29/#paragraphs) > > A sequence of non-blank lines > that cannot be interpreted as other kinds of blocks > forms a paragraph. > The contents of the paragraph are the result of > parsing the paragraph’s raw content as inlines. > The paragraph’s raw content is formed by > concatenating the lines and removing initial and final whitespace. */ public final class Paragraph: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_PARAGRAPH } public convenience init(text string: String, replacingNewLinesWithBreaks: Bool = true) { let children: [Inline & Node] if replacingNewLinesWithBreaks { children = string.split(separator: "\n", omittingEmptySubsequences: false) .flatMap { ($0.isEmpty ? [HardLineBreak()] : [Text(literal: "\($0)"), SoftLineBreak()]) } } else { children = [Text(literal: string)] } self.init(children: children) } public convenience init(children: [Inline & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(@ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Block/ThematicBreak.swift ================================================ import cmark /** A thematic break. From the [CommonMark Spec](https://spec.commonmark.org/0.29/): > ## [4.1 Thematic breaks](https://spec.commonmark.org/0.29/#thematic-breaks) > > A line consisting of 0-3 spaces of indentation, > followed by a sequence of three or more matching -, _, or * characters, > each followed optionally by any number of spaces or tabs, > forms a thematic break. */ public final class ThematicBreak: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_THEMATIC_BREAK } public convenience init() { self.init(nonrecursively: ()) } } ================================================ FILE: Sources/CommonMark/Nodes/Document.swift ================================================ import cmark /// A CommonMark document. public final class Document: Node { /// Options for parsing CommonMark text. public struct ParsingOptions: OptionSet { public var rawValue: Int32 public init(rawValue: Int32 = CMARK_OPT_DEFAULT) { self.rawValue = rawValue } /** Convert ASCII punctuation characters to "smart" typographic punctuation characters. - Straight quotes (" and ') become curly quotes (“ ” and ‘ ’) - Dashes (-- and ---) become en-dashes (–) and em-dashes (—) - Three consecutive full stops (...) become an ellipsis (…) */ public static let smart = Self(rawValue: CMARK_OPT_SMART) } /// A position within a document. public struct Position: Hashable { /** The line number. Line numbers start at 1 and increase monotonically. */ public var line: Int /** The line number. Column numbers start at 1 and increase monotonically. */ public var column: Int } /// An error when creating a document. public enum Error: Swift.Error { /// A document couldn't be constructed with the provided source. case invalid } override class var cmark_node_type: cmark_node_type { return CMARK_NODE_DOCUMENT } /** Creates a document from a CommonMark string. - Parameter commonmark: A CommonMark string. - Throws: - `Document.Error.invalid` if a document couldn't be constructed with the provided source. */ public convenience init(_ commonmark: String, options: ParsingOptions = []) throws { guard let cmark_node = cmark_parse_document(commonmark, commonmark.utf8.count, options.rawValue) else { throw Error.invalid } self.init(cmark_node) self.managed = true } public convenience init(children: [Block & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(options: ParsingOptions = [], @ContainerOfBlocksBuilder _ builder: () -> [Block & Node]) { self.init(children: builder()) } #endif } // MARK: - Comparable extension Document.Position: Comparable { public static func < (lhs: Document.Position, rhs: Document.Position) -> Bool { return lhs.line < rhs.line || (lhs.line == rhs.line && lhs.column < rhs.column) } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Code.swift ================================================ import cmark /** A code span. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.3 Code spans](https://spec.commonmark.org/0.29/#code-spans) > > A code span begins with a backtick string > and ends with a backtick string of equal length. */ public final class Code: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_CODE } public convenience init(literal: String? = nil) { self.init() self.literal = literal } public convenience init(_ block: () -> String?) { self.init(literal: block()) } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Emphasis.swift ================================================ import cmark /** An emphasis span. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.4 Emphasis and strong emphasis](https://spec.commonmark.org/0.29/#emphasis-and-strong-emphasis) */ public final class Emphasis: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_EMPH } public convenience init(text string: String) { self.init(children: [Text(literal: string)]) } public convenience init(children: [Inline & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(@ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Inline/HardLineBreak.swift ================================================ import cmark /** A hard line break. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.9 Hard line breaks](https://spec.commonmark.org/0.29/#hard-line-breaks) > > A line break (not in a code span or HTML tag) > that is preceded by two or more spaces > and does not occur at the end of a block > is parsed as a hard line break > (rendered in HTML as a `
` tag): */ public final class HardLineBreak: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_LINEBREAK } public convenience init() { self.init(nonrecursively: ()) } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Image.swift ================================================ import cmark /** An image. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.6 Images](https://spec.commonmark.org/0.29/#images) */ public final class Image: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_IMAGE } public convenience init(urlString: String, title: String? = nil) { self.init() self.urlString = urlString self.title = title } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Link.swift ================================================ import cmark /** A link. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.5 Links](https://spec.commonmark.org/0.29/#links) > > A link contains link text (the visible text), > a link destination (the URI that is the link destination), > and optionally a link title. > ## [4.7 Link reference definitions](https://spec.commonmark.org/0.29/#link-reference-definitions) > ## [6.7 Autolinks](https://spec.commonmark.org/0.29/#autolinks) */ public final class Link: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_LINK } public convenience init(urlString: String, title: String? = nil, text string: String) { self.init(urlString: urlString, title: title, children: [Text(literal: string)]) } public convenience init(urlString: String?, title: String?, children: [Inline & Node] = []) { self.init() self.urlString = urlString self.title = title guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(urlString: String?, title: String?, @ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(urlString: urlString, title: title, children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Inline/RawHTML.swift ================================================ import cmark /** Raw HTML. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.8 Raw HTML](https://spec.commonmark.org/0.29/#raw-html) > > Text between `<` and `>` that looks like an HTML tag > is parsed as a raw HTML tag > and will be rendered in HTML without escaping. > Tag and attribute names are not limited to current HTML tags, > so custom tags (and even, say, DocBook tags) may be used. */ public final class RawHTML: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_HTML_INLINE } public convenience init(literal: String?) { self.init() self.literal = literal } public convenience init(_ block: () -> String?) { self.init(literal: block()) } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/SoftLineBreak.swift ================================================ import cmark /** A soft line break. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.10 Soft line breaks](https://spec.commonmark.org/0.29/#soft-line-breaks) > > A regular line break (not in a code span or HTML tag) > that is not preceded by two or more spaces or a backslash > is parsed as a softbreak. > (A softbreak may be rendered in HTML > either as a line ending or as a space. > The result will be the same in browsers.) */ public final class SoftLineBreak: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_SOFTBREAK } public convenience init() { self.init(nonrecursively: ()) } } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Strong.swift ================================================ import cmark /** A strong emphasis span. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.4 Emphasis and strong emphasis](https://spec.commonmark.org/0.29/#emphasis-and-strong-emphasis) */ public final class Strong: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_STRONG } public convenience init(text string: String) { self.init(children: [Text(literal: string)]) } public convenience init(children: [Inline & Node] = []) { self.init() guard !children.isEmpty else { return } for child in children { append(child: child) } } #if swift(>=5.4) public convenience init(@ContainerOfInlineElementsBuilder _ builder: () -> [Inline & Node]) { self.init(children: builder()) } #endif } ================================================ FILE: Sources/CommonMark/Nodes/Inline/Text.swift ================================================ import cmark /** Textual content. From the [CommonMark Spec](https://spec.commonmark.org/0.29): > ## [6.11 Textual content](https://spec.commonmark.org/0.29/#textual-content) > > Any characters not given an interpretation by the above rules > will be parsed as plain textual content. */ public final class Text: Node { override class var cmark_node_type: cmark_node_type { return CMARK_NODE_TEXT } public convenience init(literal: String? = nil) { self.init() self.literal = literal } public convenience init(_ block: () -> String?) { self.init(literal: block()) } } ================================================ FILE: Sources/CommonMark/Nodes/Node.swift ================================================ import cmark /// A CommonMark node. public class Node: Codable { class var cmark_node_type: cmark_node_type { return CMARK_NODE_NONE } /// A pointer to the underlying `cmark_node` for the node. final let cmark_node: OpaquePointer /// Whether the underlying `cmark_node` should be freed upon deallocation. var managed: Bool = false /** Creates a node from a `cmark_node` pointer. - Parameter cmark_node: A `cmark_node` pointer. */ required init(_ cmark_node: OpaquePointer) { self.cmark_node = cmark_node assert(type(of: self) != Node.self) assert(cmark_node_get_type(cmark_node) == type(of: self).cmark_node_type) } convenience init(nonrecursively: Void) { self.init() } convenience init() { self.init(cmark_node_new(type(of: self).cmark_node_type)) self.managed = true } deinit { guard managed else { return } cmark_node_free(cmark_node) } /** Creates and returns the `Node` subclass corresponding to the type of a `cmark_node` pointer. - Parameter cmark_node: A `cmark_node` pointer. - Returns: An instance of a `Node` subclass. */ static func create(for cmark_node: OpaquePointer!) -> Node? { guard let cmark_node = cmark_node else { return nil } switch cmark_node_get_type(cmark_node) { case CMARK_NODE_DOCUMENT: return Document(cmark_node) case CMARK_NODE_BLOCK_QUOTE: return BlockQuote(cmark_node) case CMARK_NODE_LIST: switch cmark_node_get_list_type(cmark_node) { case CMARK_BULLET_LIST: return List(cmark_node) case CMARK_ORDERED_LIST: return List(cmark_node) default: return nil } case CMARK_NODE_ITEM: return List.Item(cmark_node) case CMARK_NODE_CODE_BLOCK: return CodeBlock(cmark_node) case CMARK_NODE_HTML_BLOCK: return HTMLBlock(cmark_node) case CMARK_NODE_PARAGRAPH: return Paragraph(cmark_node) case CMARK_NODE_HEADING: return Heading(cmark_node) case CMARK_NODE_THEMATIC_BREAK: return ThematicBreak(cmark_node) case CMARK_NODE_TEXT: return Text(cmark_node) case CMARK_NODE_SOFTBREAK: return SoftLineBreak(cmark_node) case CMARK_NODE_LINEBREAK: return HardLineBreak(cmark_node) case CMARK_NODE_CODE: return Code(cmark_node) case CMARK_NODE_HTML_INLINE: return RawHTML(cmark_node) case CMARK_NODE_EMPH: return Emphasis(cmark_node) case CMARK_NODE_STRONG: return Strong(cmark_node) case CMARK_NODE_LINK: return Link(cmark_node) case CMARK_NODE_IMAGE: return Image(cmark_node) default: return nil } } func unlink() { cmark_node_unlink(self.cmark_node) self.managed = true } /// The line and column range of the element in the document. public var range: ClosedRange { let start = Document.Position(line: numericCast(cmark_node_get_start_line(cmark_node)), column: numericCast(cmark_node_get_start_column(cmark_node))) let end = Document.Position(line: max(start.line, numericCast(cmark_node_get_end_line(cmark_node))), column: max(start.column, numericCast(cmark_node_get_end_column(cmark_node)))) return start...end } /// The parent of the element, if any. public var parent: Node? { return Node.create(for: cmark_node_parent(cmark_node)) } // MARK: - Rendering /// Formats for rendering a document. public enum RenderingFormat { /// CommonMark case commonmark /// HTML case html /// XML case xml /// LaTeX case latex /// Manpage case manpage } /// Options for rendering a CommonMark document. public struct RenderingOptions: OptionSet { public var rawValue: Int32 public init(rawValue: Int32 = CMARK_OPT_DEFAULT) { self.rawValue = rawValue } /** Render raw HTML and "unsafe" links. A link is considered to be "unsafe" if its scheme is `javascript:`, `vbscript:`, or `file:`, or if its scheme is `data:` and the MIME type of the encoded data isn't one of the following: - `image/png` - `image/gif` - `image/jpeg` - `image/webp` By default, raw HTML is replaced by a placeholder HTML comment. Unsafe links are replaced by empty strings. - Important: This option has an effect only when rendering HTML. */ public static let unsafe = Self(rawValue: CMARK_OPT_UNSAFE) /** Render softbreak elements as spaces. - Important: This option has no effect when rendering XML. */ public static let noBreaks = Self(rawValue: CMARK_OPT_NOBREAKS) /** Render softbreak elements as hard line breaks. - Important: This option has no effect when rendering XML. */ public static let hardBreaks = Self(rawValue: CMARK_OPT_HARDBREAKS) /** Include a `data-sourcepos` attribute on all block elements to map the rendered output to the source input. - Important: This option has an effect only when rendering HTML or XML. */ public static let includeSourcePosition = Self(rawValue: CMARK_OPT_SOURCEPOS) } /** Render a document into a given format with the specified options. - Parameters: - format: The rendering format - options: The rendering options - width: The column width used to wrap lines for rendered output (`.commonmark`, `.man`, and `.latex` formats only). Must be a positive number. Pass `0` to prevent line wrapping. - Returns: The rendered text. */ public func render(format: RenderingFormat, options: RenderingOptions = [], width: Int = 0) -> String { precondition(width >= 0) let cString: UnsafeMutablePointer switch format { case .commonmark: cString = cmark_render_commonmark(cmark_node, options.rawValue, Int32(clamping: width)) case .html: cString = cmark_render_html(cmark_node, options.rawValue) case .xml: cString = cmark_render_xml(cmark_node, options.rawValue) case .latex: cString = cmark_render_latex(cmark_node, options.rawValue, Int32(clamping: width)) case .manpage: cString = cmark_render_man(cmark_node, options.rawValue, Int32(clamping: width)) } defer { free(cString) } return String(cString: cString) } // MARK: - Codable public required convenience init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() let commonmark = try container.decode(String.self) let document = try Document(commonmark, options: []) let node: Node switch Self.cmark_node_type { case CMARK_NODE_DOCUMENT: node = document case CMARK_NODE_BLOCK_QUOTE, CMARK_NODE_LIST, CMARK_NODE_ITEM, CMARK_NODE_CODE_BLOCK, CMARK_NODE_HTML_BLOCK, CMARK_NODE_CUSTOM_BLOCK, CMARK_NODE_PARAGRAPH, CMARK_NODE_HEADING, CMARK_NODE_THEMATIC_BREAK: node = try Self.extractRootBlock(from: document, in: container) case CMARK_NODE_TEXT, CMARK_NODE_SOFTBREAK, CMARK_NODE_LINEBREAK, CMARK_NODE_CODE, CMARK_NODE_HTML_INLINE, CMARK_NODE_CUSTOM_INLINE, CMARK_NODE_EMPH, CMARK_NODE_STRONG, CMARK_NODE_LINK, CMARK_NODE_IMAGE: node = try Self.extractRootInline(from: document, in: container) default: throw DecodingError.dataCorruptedError(in: container, debugDescription: "unsupported node type") } // If the extracted node is not managed, then we most likely // introduced a memory bug in our extraction logic: assert( node.managed, "Expected extracted node to be managed" ) // Un-assign memory management duties from old owning node: node.managed = false self.init(node.cmark_node) // Re-assign memory management duties to new owning node: self.managed = true } public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() try container.encode(description) } private static func extractRootBlock(from document: Document, in container: SingleValueDecodingContainer) throws -> Self { // Unlink the children from the document node to prevent dangling pointers to the parent. let documentChildren = document.removeChildren() guard let block = documentChildren.first as? Self, documentChildren.count == 1 else { throw DecodingError.dataCorruptedError(in: container, debugDescription: "expected single block node") } assert(block.managed) return block } private static func extractRootInline(from document: Document, in container: SingleValueDecodingContainer) throws -> Self { // Unlink the children from the document node to prevent dangling pointers to the parent. let documentChildren = document.removeChildren() guard let paragraph = documentChildren.first as? Paragraph, documentChildren.count == 1 else { throw DecodingError.dataCorruptedError(in: container, debugDescription: "expected single paragraph node") } // Unlink the children from the root node to prevent dangling pointers to the parent. let paragraphChildren = paragraph.removeChildren() guard let inline = paragraphChildren.first as? Self, paragraphChildren.count == 1 else { throw DecodingError.dataCorruptedError(in: container, debugDescription: "expected single inline node") } assert(inline.managed) return inline } } // MARK: - Equatable extension Node: Equatable { public static func == (lhs: Node, rhs: Node) -> Bool { return lhs.cmark_node == rhs.cmark_node } } // MARK: - Hashable extension Node: Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(cmark_node) } } // MARK: - CustomStringConvertible extension Node: CustomStringConvertible { public var description: String { self.render(format: .commonmark) } } ================================================ FILE: Sources/CommonMark/Result Builders/ContainerOfBlocksBuilder.swift ================================================ #if swift(>=5.4) @resultBuilder public struct ContainerOfBlocksBuilder { /// Required by every result builder to build combined results from /// statement blocks. public static func buildBlock(_ components: [Block & Node]...) -> [Block & Node] { return components.flatMap { $0 } } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: Block & Node) -> [Block & Node] { return [expression] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: [Block & Node]) -> [Block & Node] { return expression } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: Section) -> [Block & Node] { return expression.children } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: String?) -> [Block & Node] { guard let expression = expression, !expression.isEmpty else { return [] } let document = try? Document(expression) // Unlink the children from the document node to prevent dangling pointers to the parent. let children = document?.removeChildren() ?? [] return children } /// Enables support for `if` statements that do not have an `else`. public static func buildOptional(_ component: [Block & Node]?) -> [Block & Node] { return component ?? [] } /// With buildEither(second:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(first component: [Block & Node]) -> [Block & Node] { return component } /// With buildEither(first:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(second component: [Block & Node]) -> [Block & Node] { return component } /// Enables support for 'for..in' loops by combining the /// results of all iterations into a single result. public static func buildArray(_ components: [[Block & Node]]) -> [Block & Node] { return components.flatMap { $0 } } /// If declared, this will be called on the partial result of an 'if /// #available' block to allow the result builder to erase type /// information. public static func buildLimitedAvailability(_ component: [Block & Node]) -> [Block & Node] { return component } } #endif ================================================ FILE: Sources/CommonMark/Result Builders/ContainerOfInlineElementsBuilder.swift ================================================ #if swift(>=5.4) @resultBuilder public struct ContainerOfInlineElementsBuilder { /// Required by every result builder to build combined results from /// statement blocks. public static func buildBlock(_ components: [Inline & Node]...) -> [Inline & Node] { return components.flatMap { $0 } } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: String?) -> [Inline & Node] { guard let expression = expression, !expression.isEmpty else { return [] } return [Text(literal: expression)] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: Inline & Node) -> [Inline & Node] { return [expression] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: [Inline & Node]) -> [Inline & Node] { return expression } /// Enables support for `if` statements that do not have an `else`. public static func buildOptional(_ component: [Inline & Node]?) -> [Inline & Node] { return component ?? [] } /// With buildEither(second:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(first component: [Inline & Node]) -> [Inline & Node] { return component } /// With buildEither(first:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(second component: [Inline & Node]) -> [Inline & Node] { return component } /// Enables support for 'for..in' loops by combining the /// results of all iterations into a single result. public static func buildArray(_ components: [[Inline & Node]]) -> [Inline & Node] { return components.flatMap { $0 } } /// If declared, this will be called on the partial result of an 'if /// #available' block to allow the result builder to erase type /// information. public static func buildLimitedAvailability(_ component: [Inline & Node]) -> [Inline & Node] { return component } } #endif ================================================ FILE: Sources/CommonMark/Result Builders/ListBuilder.swift ================================================ #if swift(>=5.4) @resultBuilder public struct ListBuilder { /// Required by every result builder to build combined results from /// statement blocks. public static func buildBlock(_ components: [List.Item]...) -> [List.Item] { return components.flatMap { $0 } } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: String?) -> [List.Item] { guard let expression = expression, !expression.isEmpty else { return [] } return [List.Item(children: [Paragraph(text: expression)])] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: Inline & Node) -> [List.Item] { return [List.Item(children: [expression])] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: Block & Node) -> [List.Item] { return [List.Item(children: [expression])] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: [Inline & Node]) -> [List.Item] { return [List.Item(children: expression)] } /// If declared, provides contextual type information for statement /// expressions to translate them into partial results. public static func buildExpression(_ expression: [Block & Node]) -> [List.Item] { return [List.Item(children: expression)] } /// Enables support for `if` statements that do not have an `else`. public static func buildOptional(_ component: [List.Item]?) -> [List.Item] { return component ?? [] } /// With buildEither(second:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(first component: [List.Item]) -> [List.Item] { return component } /// With buildEither(first:), enables support for 'if-else' and 'switch' /// statements by folding conditional results into a single result. public static func buildEither(second component: [List.Item]) -> [List.Item] { return component } /// Enables support for 'for..in' loops by combining the /// results of all iterations into a single result. public static func buildArray(_ components: [[List.Item]]) -> [List.Item] { return components.flatMap { $0 } } /// If declared, this will be called on the partial result of an 'if /// #available' block to allow the result builder to erase type /// information. public static func buildLimitedAvailability(_ component: [List.Item]) -> [List.Item] { return component } } #endif ================================================ FILE: Sources/CommonMark/Supporting Types/Block.swift ================================================ import cmark /// A block structure element. public protocol Block {} // MARK: - /// A block that can contain other blocks. public protocol ContainerBlock: Block {} extension BlockQuote: ContainerBlock {} extension List: ContainerBlock {} extension List.Item: ContainerBlock {} // MARK: - /// A block that can only contain inline elements. public protocol LeafBlock: Block {} extension Heading: LeafBlock {} extension Paragraph: LeafBlock {} extension HTMLBlock: LeafBlock {} extension CodeBlock: LeafBlock {} extension ThematicBreak: LeafBlock {} ================================================ FILE: Sources/CommonMark/Supporting Types/Children.swift ================================================ import cmark struct Children: Sequence { var cmark_node: OpaquePointer init(of node: Node) { cmark_node = node.cmark_node } init(of document: Document) { cmark_node = document.cmark_node } func makeIterator() -> AnyIterator { var iterator = CMarkNodeChildIterator(cmark_node) return AnyIterator { guard let child = iterator.next() else { return nil } return Node.create(for: child) } } } struct CMarkNodeChildIterator: IteratorProtocol { var current: OpaquePointer! init(_ node: OpaquePointer!) { current = cmark_node_first_child(node) } mutating func next() -> OpaquePointer? { guard let next = current else { return nil } defer { current = cmark_node_next(current) } return next } } // MARK: - public protocol ContainerOfBlocks: Node { var children: [Block & Node] { get } } extension Document: ContainerOfBlocks {} extension BlockQuote: ContainerOfBlocks {} extension ContainerOfBlocks { /** The block elements contained by the node. - Important: The returned child nodes are valid only during the lifetime of their parent. Use the `removeChildren()` method to detach and access children beyond the lifetime of their parent. */ public var children: [Block & Node] { get { return Children(of: self).compactMap { $0 as? Block & Node } } set { for child in children { remove(child: child) } for child in newValue { append(child: child) } } } /** Adds a block to the beginning of the node's children. - Parameters: - child: The block to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func prepend(child: Block & Node) -> Bool { guard cmark_node_prepend_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Adds a block to the end of the node's children. - Parameters: - child: The block to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func append(child: Block & Node) -> Bool { guard cmark_node_append_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts a block to the node's children before a specified sibling. - Parameters: - child: The block to add. - sibling: The child before which the block is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Block & Node, before sibling: Block & Node) -> Bool { guard cmark_node_insert_before(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts a block to the node's children after a specified sibling. - Parameters: - child: The block to add. - sibling: The child after which the block is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Block & Node, after sibling: Block & Node) -> Bool { guard cmark_node_insert_after(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Replaces a block with the specified node. - Parameters: - child: The block to replace. - replacement: The block to replace the existing block. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func replace(child: Block & Node, with replacement: Block & Node) -> Bool { guard cmark_node_replace(child.cmark_node, replacement.cmark_node) == 1 else { return false } replacement.managed = false child.managed = true return true } /** Removes a block from the node's children. - Parameters: - child: The block to remove. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func remove(child: Block & Node) -> Bool { guard child.parent == self else { return false } child.unlink() return true } /** Removes and returns the node's children. - Returns: An array of block structure elements. */ @discardableResult public func removeChildren() -> [Block & Node] { var children: [Block & Node] = [] for child in self.children { guard remove(child: child) else { continue } children.append(child) } return children } } // MARK: - public protocol ContainerOfInlineElements: Node { var children: [Inline & Node] { get } } extension Heading: ContainerOfInlineElements {} extension Paragraph: ContainerOfInlineElements {} extension CodeBlock: ContainerOfInlineElements {} extension ThematicBreak: ContainerOfInlineElements {} extension Strong: ContainerOfInlineElements {} extension Emphasis: ContainerOfInlineElements {} extension Link: ContainerOfInlineElements {} extension ContainerOfInlineElements { /** The inline elements contained by the node. - Important: The returned child nodes are valid only during the lifetime of their parent. Use the `removeChildren()` method to detach and access children beyond the lifetime of their parent. */ public var children: [Inline & Node] { get { return Children(of: self).compactMap { $0 as? Inline & Node } } set { for child in children { remove(child: child) } for child in newValue { append(child: child) } } } /** Adds an inline element to the beginning of the node's children. - Parameters: - child: The inline element to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func prepend(child: Inline & Node) -> Bool { guard cmark_node_prepend_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Adds an inline element to the end of the node's children. - Parameters: - child: The inline element to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func append(child: Inline & Node) -> Bool { guard cmark_node_append_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts an inline element to the node's children before a specified sibling. - Parameters: - child: The inline element to add. - sibling: The child before which the inline element is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Inline & Node, before sibling: Inline & Node) -> Bool { guard cmark_node_insert_before(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts an inline element to the node's children after a specified sibling. - Parameters: - child: The inline element to add. - sibling: The child after which the inline element is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Inline & Node, after sibling: Inline & Node) -> Bool { guard cmark_node_insert_after(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Replaces an inline element with the specified node. - Parameters: - child: The inline element to replace. - replacement: The inline element to replace the existing inline element. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func replace(child: Inline & Node, with replacement: Inline & Node) -> Bool { guard cmark_node_replace(child.cmark_node, replacement.cmark_node) == 1 else { return false } replacement.managed = false child.managed = true return true } /** Removes an inline element from the node's children. - Parameters: - child: The inline element to remove. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func remove(child: Inline & Node) -> Bool { guard child.parent == self else { return false } child.unlink() return true } /** Removes and returns the node's children. - Returns: An array of inline content elements. */ @discardableResult public func removeChildren() -> [Inline & Node] { var children: [Inline & Node] = [] for child in self.children { guard remove(child: child) else { continue } children.append(child) } return children } } // MARK: - extension List { /** The list's items. - Important: The returned child nodes are valid only during the lifetime of their parent. Use the `removeChildren()` method to detach and access children beyond the lifetime of their parent. */ public var children: [Item] { get { return Children(of: self).compactMap { $0 as? Item } } set { for child in children { remove(child: child) } for child in newValue { append(child: child) } } } /** Adds an item to the beginning of the list. - Parameters: - child: The item to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func prepend(child: Item) -> Bool { guard cmark_node_prepend_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Adds an to the end of the list. - Parameters: - child: The item to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func append(child: Item) -> Bool { guard cmark_node_append_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts an item to the list before a specified sibling. - Parameters: - child: The item to add. - sibling: The item before which the new item is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Item, before sibling: Item) -> Bool { guard cmark_node_insert_before(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts an item to the list after a specified sibling. - Parameters: - child: The item to add. - sibling: The item after which the new item is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Item, after sibling: Item) -> Bool { guard cmark_node_insert_after(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Replaces an item with the specified node. - Parameters: - child: The item to replace. - replacement: The item to replace the existing item. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func replace(child: Item, with replacement: Item) -> Bool { guard cmark_node_replace(child.cmark_node, replacement.cmark_node) == 1 else { return false } replacement.managed = false child.managed = true return true } /** Removes an item from the list. - Parameters: - child: The item to remove. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func remove(child: Item) -> Bool { guard child.parent == self else { return false } child.unlink() return true } /** Removes and returns the list's items. - Returns: An array of list items. */ @discardableResult public func removeChildren() -> [Item] { var children: [Item] = [] for child in self.children { guard remove(child: child) else { continue } children.append(child) } return children } } // MARK: - extension List.Item { /** The elements contained by the list item. - Important: The returned child nodes are valid only during the lifetime of their parent. Use the `removeChildren()` method to detach and access children beyond the lifetime of their parent. */ public var children: [Node] { get { return Children(of: self).map { $0 } } set { for child in children { remove(child: child) } for child in newValue { append(child: child) } } } /** Adds a node to the beginning of the list item's children. - Parameters: - child: The node to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func prepend(child: Node) -> Bool { guard cmark_node_prepend_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Adds a node to the end of the list item's children. - Parameters: - child: The node to add. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func append(child: Node) -> Bool { guard cmark_node_append_child(cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts a node to the list item's children before a specified sibling. - Parameters: - child: The node to add. - sibling: The child before which the node is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Node, before sibling: Node) -> Bool { guard cmark_node_insert_before(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Inserts a node to the list item's children after a specified sibling. - Parameters: - child: The node to add. - sibling: The child after which the node is added - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func insert(child: Node, after sibling: Node) -> Bool { guard cmark_node_insert_after(sibling.cmark_node, child.cmark_node) == 1 else { return false } child.managed = false return true } /** Replaces a node with a specified node. - Parameters: - child: The node to replace. - replacement: The node to replace the existing node. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func replace(child: Node, with replacement: Node) -> Bool { guard cmark_node_replace(child.cmark_node, replacement.cmark_node) == 1 else { return false } replacement.managed = false return true } /** Removes a node from the list item's children. - Parameters: - child: The node to remove. - Returns: `true` if successful, otherwise `false`. */ @discardableResult public func remove(child: Node) -> Bool { guard child.parent == self else { return false } child.unlink() return true } /** Removes and returns the list item's children. - Returns: An array of nodes. */ public func removeChildren() -> [Node] { var children: [Node] = [] for child in self.children { guard remove(child: child) else { continue } children.append(child) } return children } } ================================================ FILE: Sources/CommonMark/Supporting Types/Fragment.swift ================================================ public struct Fragment { public var children: [Block & Node] = [] init(children: [Block & Node]) { self.children = children } public init(_ string: String) { let document = try? Document(string) // Unlink the children from the document node to prevent dangling pointers to the parent. let children = document?.removeChildren() ?? [] self.init(children: children) } // // public init(@CommonMarkBuilder _ builder: () -> BlockConvertible) { // self.init(children: builder().blockValue) // } // public init(@CommonMarkBuilder _ builder: () -> BlockConvertible) { // self.init(children: builder().blockValue) // } } // MARK: - BlockConvertible // //extension Fragment: BlockConvertible { // public var blockValue: [Block & Node] { // return children // } //} // //// MARK: - ListItemConvertible // //extension Fragment: ListItemConvertible { // public var listItemValue: [List.Item] { // return children as? [List.Item] ?? [List.Item(children: children)] // } //} ================================================ FILE: Sources/CommonMark/Supporting Types/Inline.swift ================================================ /// An inline content element. public protocol Inline {} // MARK: - extension Text: Inline {} extension Strong: Inline {} extension Emphasis: Inline {} extension Link: Inline {} extension Image: Inline {} extension Code: Inline {} extension RawHTML: Inline {} extension SoftLineBreak: Inline {} extension HardLineBreak: Inline {} ================================================ FILE: Sources/CommonMark/Supporting Types/LineBreak.swift ================================================ /// A line break element. public protocol LineBreak {} // MARK: - extension HardLineBreak: LineBreak {} extension SoftLineBreak: LineBreak {} ================================================ FILE: Sources/CommonMark/Supporting Types/Linked.swift ================================================ import cmark public protocol Linked: Node {} extension Link: Linked {} extension Image: Linked {} extension Linked { public var urlString: String? { get { return String(cString: cmark_node_get_url(cmark_node)) } set { cmark_node_set_url(cmark_node, newValue) } } public var title: String? { get { return String(cString: cmark_node_get_title(cmark_node)) } set { cmark_node_set_title(cmark_node, newValue) } } } ================================================ FILE: Sources/CommonMark/Supporting Types/Literal.swift ================================================ import cmark /// An element with literal contents. public protocol Literal: Node { init(literal: String?) } // MARK: - extension Literal { /// The literal contents of the element. public var literal: String? { get { return String(cString: cmark_node_get_literal(cmark_node)) } set { cmark_node_set_literal(cmark_node, newValue) } } } // MARK: - extension Code: Literal {} extension CodeBlock: Literal {} extension RawHTML: Literal {} extension HTMLBlock: Literal {} extension Text: Literal {} ================================================ FILE: Sources/CommonMark/Supporting Types/Section.swift ================================================ public struct Section { private var levelAdjustment: Int public var children: [Block & Node] = [] init(levelAdjustment: Int = +1, children: [Block & Node]) { self.levelAdjustment = levelAdjustment self.children = children } #if swift(>=5.4) public init(levelAdjustment: Int = +1, @ContainerOfBlocksBuilder _ builder: () -> [Block & Node]) { self.init(levelAdjustment: levelAdjustment, children: builder().map { child in guard let heading = child as? Heading else { return child } heading.level += levelAdjustment return heading }) } #endif } ================================================ FILE: Sources/CommonMark/Supporting Types/Visitable.swift ================================================ public protocol Visitable { func accept(visitor: T) } // MARK: - Document extension Document: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(document: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(document: self) } } // MARK: - Container Blocks extension BlockQuote: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(blockQuote: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(blockQuote: self) } } extension List: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(list: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(list: self) } } extension List.Item: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(listItem: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(listItem: self) } } // MARK: - Leaf Blocks extension Heading: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(heading: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(heading: self) } } extension Paragraph: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(paragraph: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(paragraph: self) } } extension HTMLBlock: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(htmlBlock: self)) visitor.visitPost(htmlBlock: self) } } extension CodeBlock: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(codeBlock: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(codeBlock: self) } } extension ThematicBreak: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(thematicBreak: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(thematicBreak: self) } } // MARK: - Inline extension Text: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(text: self)) visitor.visitPost(text: self) } } extension Strong: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(strong: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(strong: self) } } extension Emphasis: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(emphasis: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(emphasis: self) } } extension Link: Visitable { public func accept(visitor: T) { let continueKind = visitor.visit(self, by: visitor.visit(link: self)) if continueKind == .visitChildren { self.walkVisitableChildren(with: visitor) } visitor.visitPost(link: self) } } extension Image: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(image: self)) visitor.visitPost(image: self) } } extension Code: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(code: self)) visitor.visitPost(code: self) } } extension RawHTML: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(rawHTML: self)) visitor.visitPost(rawHTML: self) } } extension SoftLineBreak: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(softLineBreak: self)) visitor.visitPost(softLineBreak: self) } } extension HardLineBreak: Visitable { public func accept(visitor: T) { _ = visitor.visit(self, by: visitor.visit(hardLineBreak: self)) visitor.visitPost(hardLineBreak: self) } } // MARK: - Convenience Helpers extension ContainerOfBlocks { internal var visitableChildren: AnyCollection { return AnyCollection(self.children.lazy.compactMap { $0 as? Visitable & Block & Node }) } internal func walkVisitableChildren(with visitor: T) { for child in self.visitableChildren { child.accept(visitor: visitor) } } } extension ContainerOfInlineElements { internal var visitableChildren: AnyCollection { return AnyCollection(self.children.lazy.compactMap { $0 as? Visitable & Inline & Node }) } internal func walkVisitableChildren(with visitor: T) { for child in self.visitableChildren { child.accept(visitor: visitor) } } } extension List { internal var visitableChildren: AnyCollection { return AnyCollection(self.children) } internal func walkVisitableChildren(with visitor: T) { for child in self.visitableChildren { child.accept(visitor: visitor) } } } extension List.Item { internal var visitableChildren: AnyCollection { return AnyCollection(self.children.lazy.compactMap { $0 as? Visitable & Node }) } internal func walkVisitableChildren(with visitor: T) { for child in self.visitableChildren { child.accept(visitor: visitor) } } } ================================================ FILE: Sources/CommonMark/Supporting Types/Visitor.swift ================================================ public enum VisitorContinueKind { /// The visitor should visit the descendents of the current node. case visitChildren /// The visitor should avoid visiting the descendents of the current node. case skipChildren /// The visitor should inherit the behavior from the current context. case inherit /// The default is `.visitChildren` static let `default`: Self = .visitChildren mutating func override(with other: Self) { switch other { case .visitChildren, .skipChildren: self = other case .inherit: break } } } /// Visitor for walking a visitable structure. /// /// Override the appropriate `func visit(…:)`'s return value /// to customize the behavior (e.g. skip a given element's children), /// with sub-types overriding their super-type's behavior. /// /// The default implementation of `func visit(…:)`returns `.inherit`, /// resulting in a deep walk over the entire document. /// /// ## Sub-type inheritance /// /// ```plain /// Node /// ├── Block /// │   ├── ContainerBlock /// │   │   ├── BlockQuote /// │   │   ├── List /// │   │   └── List.Item /// │   │ /// │   └── LeafBlock /// │   ├── CodeBlock /// │   ├── HTMLBlock /// │   ├── Heading /// │   ├── Paragraph /// │   └── ThematicBreak /// │ /// └── Inline /// ├── Code /// ├── Emphasis /// ├── HardLineBreak /// ├── Image /// ├── Link /// ├── RawHTML /// ├── SoftLineBreak /// ├── Strong /// └── Text /// ``` /// /// ## Order of Visitation /// /// The order of object-wise visitations is: super-type before sub-type. /// /// ## Order of Post-Visitation /// /// The order of object-wise visitations is: sub-type before super-type. public protocol Visitor { /// Walks a visitable structure. /// - Parameter visitable: The structure to walk. func walk(_ visitable: T) // MARK: - Document func visit(document: Document) -> VisitorContinueKind func visitPost(document: Document) // MARK: - Node func visit(node: Node) -> VisitorContinueKind func visitPost(node: Node) // MARK: - Blocks func visit(block: Block) -> VisitorContinueKind func visitPost(block: Block) // MARK: - Container Blocks func visit(containerBlock: ContainerBlock) -> VisitorContinueKind func visitPost(containerBlock: ContainerBlock) func visit(blockQuote: BlockQuote) -> VisitorContinueKind func visitPost(blockQuote: BlockQuote) func visit(list: List) -> VisitorContinueKind func visitPost(list: List) func visit(listItem: List.Item) -> VisitorContinueKind func visitPost(listItem: List.Item) // MARK: - Leaf Blocks /// A block that can only contain inline elements. func visit(leafBlock: LeafBlock) -> VisitorContinueKind func visitPost(leafBlock: LeafBlock) func visit(heading: Heading) -> VisitorContinueKind func visitPost(heading: Heading) func visit(paragraph: Paragraph) -> VisitorContinueKind func visitPost(paragraph: Paragraph) func visit(htmlBlock: HTMLBlock) -> VisitorContinueKind func visitPost(htmlBlock: HTMLBlock) func visit(codeBlock: CodeBlock) -> VisitorContinueKind func visitPost(codeBlock: CodeBlock) func visit(thematicBreak: ThematicBreak) -> VisitorContinueKind func visitPost(thematicBreak: ThematicBreak) // MARK: - Inline func visit(inline: Inline) -> VisitorContinueKind func visitPost(inline: Inline) func visit(text: Text) -> VisitorContinueKind func visitPost(text: Text) func visit(strong: Strong) -> VisitorContinueKind func visitPost(strong: Strong) func visit(emphasis: Emphasis) -> VisitorContinueKind func visitPost(emphasis: Emphasis) func visit(link: Link) -> VisitorContinueKind func visitPost(link: Link) func visit(image: Image) -> VisitorContinueKind func visitPost(image: Image) func visit(code: Code) -> VisitorContinueKind func visitPost(code: Code) func visit(rawHTML: RawHTML) -> VisitorContinueKind func visitPost(rawHTML: RawHTML) func visit(softLineBreak: SoftLineBreak) -> VisitorContinueKind func visitPost(softLineBreak: SoftLineBreak) func visit(hardLineBreak: HardLineBreak) -> VisitorContinueKind func visitPost(hardLineBreak: HardLineBreak) } extension Visitor { public func walk(_ visitable: T) { visitable.accept(visitor: self) } // MARK: - Document public func visit(document: Document) -> VisitorContinueKind { return .inherit } public func visitPost(document: Document) { // nothing by default } // MARK: - Node public func visit(node: Node) -> VisitorContinueKind { return .inherit } public func visitPost(node: Node) { // nothing by default } // MARK: - Blocks public func visit(block: Block) -> VisitorContinueKind { return .inherit } public func visitPost(block: Block) { // nothing by default } // MARK: - Container Blocks public func visit(containerBlock: ContainerBlock) -> VisitorContinueKind { return .inherit } public func visitPost(containerBlock: ContainerBlock) { // nothing by default } public func visit(blockQuote: BlockQuote) -> VisitorContinueKind { return .inherit } public func visitPost(blockQuote: BlockQuote) { // nothing by default } public func visit(list: List) -> VisitorContinueKind { return .inherit } public func visitPost(list: List) { // nothing by default } public func visit(listItem: List.Item) -> VisitorContinueKind { return .inherit } public func visitPost(listItem: List.Item) { // nothing by default } // MARK: - Leaf Blocks /// A block that can only contain inline elements. public func visit(leafBlock: LeafBlock) -> VisitorContinueKind { return .inherit } public func visitPost(leafBlock: LeafBlock) { // nothing by default } public func visit(heading: Heading) -> VisitorContinueKind { return .inherit } public func visitPost(heading: Heading) { // nothing by default } public func visit(paragraph: Paragraph) -> VisitorContinueKind { return .inherit } public func visitPost(paragraph: Paragraph) { // nothing by default } public func visit(htmlBlock: HTMLBlock) -> VisitorContinueKind { return .inherit } public func visitPost(htmlBlock: HTMLBlock) { // nothing by default } public func visit(codeBlock: CodeBlock) -> VisitorContinueKind { return .inherit } public func visitPost(codeBlock: CodeBlock) { // nothing by default } public func visit(thematicBreak: ThematicBreak) -> VisitorContinueKind { return .inherit } public func visitPost(thematicBreak: ThematicBreak) { // nothing by default } // MARK: - Inline public func visit(inline: Inline) -> VisitorContinueKind { return .inherit } public func visitPost(inline: Inline) { // nothing by default } public func visit(text: Text) -> VisitorContinueKind { return .inherit } public func visitPost(text: Text) { // nothing by default } public func visit(strong: Strong) -> VisitorContinueKind { return .inherit } public func visitPost(strong: Strong) { // nothing by default } public func visit(emphasis: Emphasis) -> VisitorContinueKind { return .inherit } public func visitPost(emphasis: Emphasis) { // nothing by default } public func visit(link: Link) -> VisitorContinueKind { return .inherit } public func visitPost(link: Link) { // nothing by default } public func visit(image: Image) -> VisitorContinueKind { return .inherit } public func visitPost(image: Image) { // nothing by default } public func visit(code: Code) -> VisitorContinueKind { return .inherit } public func visitPost(code: Code) { // nothing by default } public func visit(rawHTML: RawHTML) -> VisitorContinueKind { return .inherit } public func visitPost(rawHTML: RawHTML) { // nothing by default } public func visit(softLineBreak: SoftLineBreak) -> VisitorContinueKind { return .inherit } public func visitPost(softLineBreak: SoftLineBreak) { // nothing by default } public func visit(hardLineBreak: HardLineBreak) -> VisitorContinueKind { return .inherit } public func visitPost(hardLineBreak: HardLineBreak) { // nothing by default } } extension Visitor { internal func visit( _ visitable: T, by visitLeafTypeOf: @autoclosure () -> VisitorContinueKind ) -> VisitorContinueKind { var continueKind = VisitorContinueKind.visitChildren let inheritedContinueKind = self.visitSuperTypesOf(visitable: visitable) let leafTypeContinueKind = visitLeafTypeOf() continueKind.override(with: inheritedContinueKind) continueKind.override(with: leafTypeContinueKind) return continueKind } internal func visitSuperTypesOf(visitable: T) -> VisitorContinueKind { var continueKind: VisitorContinueKind = .inherit if let node = visitable as? Node { continueKind.override(with: self.visit(node: node)) } if let block = visitable as? Block { continueKind.override(with: self.visit(block: block)) } if let containerBlock = visitable as? ContainerBlock { continueKind.override(with: self.visit(containerBlock: containerBlock)) } if let leafBlock = visitable as? LeafBlock { continueKind.override(with: self.visit(leafBlock: leafBlock)) } if let inline = visitable as? Inline { continueKind.override(with: self.visit(inline: inline)) } return continueKind } } ================================================ FILE: Sources/CommonMark/Version.swift ================================================ import cmark /// A version number. public typealias Version = (major: Int, minor: Int, patch: Int) /// The version of CommonMark used by this package. public let version: Version = ( major: Int((cmark_version() & 0xFF0000) >> 16), minor: Int((cmark_version() & 0xFF00) >> 8), patch: Int((cmark_version() & 0xFF)) ) ================================================ FILE: Tests/CommonMarkSpecTests/AtxHeadingsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecAtxHeadingsTests: XCTestCase { func testExample32() throws { let markdown = #######""" # foo ## foo ### foo #### foo ##### foo ###### foo """####### let html = #######"""

foo

foo

foo

foo

foo
foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample33() throws { let markdown = #######""" ####### foo """####### let html = #######"""

####### foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample34() throws { let markdown = #######""" #5 bolt #hashtag """####### let html = #######"""

#5 bolt

#hashtag

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample35() throws { let markdown = #######""" \## foo """####### let html = #######"""

## foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample36() throws { let markdown = #######""" # foo *bar* \*baz\* """####### let html = #######"""

foo bar *baz*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample37() throws { let markdown = #######""" # foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample38() throws { let markdown = #######""" ### foo ## foo # foo """####### let html = #######"""

foo

foo

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample39() throws { let markdown = #######""" # foo """####### let html = #######"""
# foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample40() throws { let markdown = #######""" foo # bar """####### let html = #######"""

foo # bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample41() throws { let markdown = #######""" ## foo ## ### bar ### """####### let html = #######"""

foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample42() throws { let markdown = #######""" # foo ################################## ##### foo ## """####### let html = #######"""

foo

foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample43() throws { let markdown = #######""" ### foo ### """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample44() throws { let markdown = #######""" ### foo ### b """####### let html = #######"""

foo ### b

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample45() throws { let markdown = #######""" # foo# """####### let html = #######"""

foo#

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample46() throws { let markdown = #######""" ### foo \### ## foo #\## # foo \# """####### let html = #######"""

foo ###

foo ###

foo #

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample47() throws { let markdown = #######""" **** ## foo **** """####### let html = #######"""

foo


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample48() throws { let markdown = #######""" Foo bar # baz Bar foo """####### let html = #######"""

Foo bar

baz

Bar foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample49() throws { let markdown = #######""" ## # ### ### """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/AutolinksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecAutolinksTests: XCTestCase { func testExample590() throws { let markdown = #######""" """####### let html = #######"""

http://foo.bar.baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample591() throws { let markdown = #######""" """####### let html = #######"""

http://foo.bar.baz/test?q=hello&id=22&boolean

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample592() throws { let markdown = #######""" """####### let html = #######"""

irc://foo.bar:2233/baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample593() throws { let markdown = #######""" """####### let html = #######"""

MAILTO:FOO@BAR.BAZ

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample594() throws { let markdown = #######""" """####### let html = #######"""

a+b+c:d

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample595() throws { let markdown = #######""" """####### let html = #######"""

made-up-scheme://foo,bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample596() throws { let markdown = #######""" """####### let html = #######"""

http://../

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample597() throws { let markdown = #######""" """####### let html = #######"""

localhost:5001/foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample598() throws { let markdown = #######""" """####### let html = #######"""

<http://foo.bar/baz bim>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample599() throws { let markdown = #######""" """####### let html = #######"""

http://example.com/\[\

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample600() throws { let markdown = #######""" """####### let html = #######"""

foo@bar.example.com

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample601() throws { let markdown = #######""" """####### let html = #######"""

foo+special@Bar.baz-bar0.com

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample602() throws { let markdown = #######""" """####### let html = #######"""

<foo+@bar.example.com>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample603() throws { let markdown = #######""" <> """####### let html = #######"""

<>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample604() throws { let markdown = #######""" < http://foo.bar > """####### let html = #######"""

< http://foo.bar >

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample605() throws { let markdown = #######""" """####### let html = #######"""

<m:abc>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample606() throws { let markdown = #######""" """####### let html = #######"""

<foo.bar.baz>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample607() throws { let markdown = #######""" http://example.com """####### let html = #######"""

http://example.com

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample608() throws { let markdown = #######""" foo@bar.example.com """####### let html = #######"""

foo@bar.example.com

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/BackslashEscapesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecBackslashEscapesTests: XCTestCase { func testExample298() throws { let markdown = #######""" \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~ """####### let html = #######"""

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample299() throws { let markdown = #######""" \ \A\a\ \3\φ\« """####### let html = #######"""

\ \A\a\ \3\φ\«

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample300() throws { let markdown = #######""" \*not emphasized* \
not a tag \[not a link](/foo) \`not code` 1\. not a list \* not a list \# not a heading \[foo]: /url "not a reference" \ö not a character entity """####### let html = #######"""

*not emphasized* <br/> not a tag [not a link](/foo) `not code` 1. not a list * not a list # not a heading [foo]: /url "not a reference" &ouml; not a character entity

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample301() throws { let markdown = #######""" \\*emphasis* """####### let html = #######"""

\emphasis

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample302() throws { let markdown = #######""" foo\ bar """####### let html = #######"""

foo
bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample303() throws { let markdown = #######""" `` \[\` `` """####### let html = #######"""

\[\`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample304() throws { let markdown = #######""" \[\] """####### let html = #######"""
\[\]
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample305() throws { let markdown = #######""" ~~~ \[\] ~~~ """####### let html = #######"""
\[\]
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample306() throws { let markdown = #######""" """####### let html = #######"""

http://example.com?find=\*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample307() throws { let markdown = #######""" """####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample308() throws { let markdown = #######""" [foo](/bar\* "ti\*tle") """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample309() throws { let markdown = #######""" [foo] [foo]: /bar\* "ti\*tle" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample310() throws { let markdown = #######""" ``` foo\+bar foo ``` """####### let html = #######"""
foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/BlankLinesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecBlankLinesTests: XCTestCase { func testExample197() throws { let markdown = #######""" aaa # aaa """####### let html = #######"""

aaa

aaa

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/BlockQuotesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecBlockQuotesTests: XCTestCase { func testExample198() throws { let markdown = #######""" > # Foo > bar > baz """####### let html = #######"""

Foo

bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample199() throws { let markdown = #######""" ># Foo >bar > baz """####### let html = #######"""

Foo

bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample200() throws { let markdown = #######""" > # Foo > bar > baz """####### let html = #######"""

Foo

bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample201() throws { let markdown = #######""" > # Foo > bar > baz """####### let html = #######"""
> # Foo
        > bar
        > baz
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample202() throws { let markdown = #######""" > # Foo > bar baz """####### let html = #######"""

Foo

bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample203() throws { let markdown = #######""" > bar baz > foo """####### let html = #######"""

bar baz foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample204() throws { let markdown = #######""" > foo --- """####### let html = #######"""

foo


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample205() throws { let markdown = #######""" > - foo - bar """####### let html = #######"""
  • foo
  • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample206() throws { let markdown = #######""" > foo bar """####### let html = #######"""
foo
        
bar
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample207() throws { let markdown = #######""" > ``` foo ``` """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample208() throws { let markdown = #######""" > foo - bar """####### let html = #######"""

foo - bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample209() throws { let markdown = #######""" > """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample210() throws { let markdown = #######""" > > > """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample211() throws { let markdown = #######""" > > foo > """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample212() throws { let markdown = #######""" > foo > bar """####### let html = #######"""

foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample213() throws { let markdown = #######""" > foo > bar """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample214() throws { let markdown = #######""" > foo > > bar """####### let html = #######"""

foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample215() throws { let markdown = #######""" foo > bar """####### let html = #######"""

foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample216() throws { let markdown = #######""" > aaa *** > bbb """####### let html = #######"""

aaa


bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample217() throws { let markdown = #######""" > bar baz """####### let html = #######"""

bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample218() throws { let markdown = #######""" > bar baz """####### let html = #######"""

bar

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample219() throws { let markdown = #######""" > bar > baz """####### let html = #######"""

bar

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample220() throws { let markdown = #######""" > > > foo bar """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample221() throws { let markdown = #######""" >>> foo > bar >>baz """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample222() throws { let markdown = #######""" > code > not code """####### let html = #######"""
code
        

not code

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/CodeSpansTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecCodeSpansTests: XCTestCase { func testExample328() throws { let markdown = #######""" `foo` """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample329() throws { let markdown = #######""" `` foo ` bar `` """####### let html = #######"""

foo ` bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample330() throws { let markdown = #######""" ` `` ` """####### let html = #######"""

``

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample331() throws { let markdown = #######""" ` `` ` """####### let html = #######"""

``

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample332() throws { let markdown = #######""" ` a` """####### let html = #######"""

a

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample333() throws { let markdown = #######""" ` b ` """####### let html = #######"""

 b 

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample334() throws { let markdown = #######""" ` ` ` ` """####### let html = #######"""

 

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample335() throws { let markdown = #######""" `` foo bar baz `` """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample336() throws { let markdown = #######""" `` foo `` """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample337() throws { let markdown = #######""" `foo bar baz` """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample338() throws { let markdown = #######""" `foo\`bar` """####### let html = #######"""

foo\bar`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample339() throws { let markdown = #######""" ``foo`bar`` """####### let html = #######"""

foo`bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample340() throws { let markdown = #######""" ` foo `` bar ` """####### let html = #######"""

foo `` bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample341() throws { let markdown = #######""" *foo`*` """####### let html = #######"""

*foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample342() throws { let markdown = #######""" [not a `link](/foo`) """####### let html = #######"""

[not a link](/foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample343() throws { let markdown = #######""" `` """####### let html = #######"""

<a href="">`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample344() throws { let markdown = #######"""
` """####### let html = #######"""

`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample345() throws { let markdown = #######""" `` """####### let html = #######"""

<http://foo.bar.baz>`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample346() throws { let markdown = #######""" ` """####### let html = #######"""

http://foo.bar.`baz`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample347() throws { let markdown = #######""" ```foo`` """####### let html = #######"""

```foo``

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample348() throws { let markdown = #######""" `foo """####### let html = #######"""

`foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample349() throws { let markdown = #######""" `foo``bar`` """####### let html = #######"""

`foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/EmphasisAndStrongEmphasisTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecEmphasisAndStrongEmphasisTests: XCTestCase { func testExample350() throws { let markdown = #######""" *foo bar* """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample351() throws { let markdown = #######""" a * foo bar* """####### let html = #######"""

a * foo bar*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample352() throws { let markdown = #######""" a*"foo"* """####### let html = #######"""

a*"foo"*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample353() throws { let markdown = #######""" * a * """####### let html = #######"""

* a *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample354() throws { let markdown = #######""" foo*bar* """####### let html = #######"""

foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample355() throws { let markdown = #######""" 5*6*78 """####### let html = #######"""

5678

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample356() throws { let markdown = #######""" _foo bar_ """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample357() throws { let markdown = #######""" _ foo bar_ """####### let html = #######"""

_ foo bar_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample358() throws { let markdown = #######""" a_"foo"_ """####### let html = #######"""

a_"foo"_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample359() throws { let markdown = #######""" foo_bar_ """####### let html = #######"""

foo_bar_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample360() throws { let markdown = #######""" 5_6_78 """####### let html = #######"""

5_6_78

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample361() throws { let markdown = #######""" пристаням_стремятся_ """####### let html = #######"""

пристаням_стремятся_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample362() throws { let markdown = #######""" aa_"bb"_cc """####### let html = #######"""

aa_"bb"_cc

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample363() throws { let markdown = #######""" foo-_(bar)_ """####### let html = #######"""

foo-(bar)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample364() throws { let markdown = #######""" _foo* """####### let html = #######"""

_foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample365() throws { let markdown = #######""" *foo bar * """####### let html = #######"""

*foo bar *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample366() throws { let markdown = #######""" *foo bar * """####### let html = #######"""

*foo bar *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample367() throws { let markdown = #######""" *(*foo) """####### let html = #######"""

*(*foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample368() throws { let markdown = #######""" *(*foo*)* """####### let html = #######"""

(foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample369() throws { let markdown = #######""" *foo*bar """####### let html = #######"""

foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample370() throws { let markdown = #######""" _foo bar _ """####### let html = #######"""

_foo bar _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample371() throws { let markdown = #######""" _(_foo) """####### let html = #######"""

_(_foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample372() throws { let markdown = #######""" _(_foo_)_ """####### let html = #######"""

(foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample373() throws { let markdown = #######""" _foo_bar """####### let html = #######"""

_foo_bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample374() throws { let markdown = #######""" _пристаням_стремятся """####### let html = #######"""

_пристаням_стремятся

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample375() throws { let markdown = #######""" _foo_bar_baz_ """####### let html = #######"""

foo_bar_baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample376() throws { let markdown = #######""" _(bar)_. """####### let html = #######"""

(bar).

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample377() throws { let markdown = #######""" **foo bar** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample378() throws { let markdown = #######""" ** foo bar** """####### let html = #######"""

** foo bar**

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample379() throws { let markdown = #######""" a**"foo"** """####### let html = #######"""

a**"foo"**

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample380() throws { let markdown = #######""" foo**bar** """####### let html = #######"""

foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample381() throws { let markdown = #######""" __foo bar__ """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample382() throws { let markdown = #######""" __ foo bar__ """####### let html = #######"""

__ foo bar__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample383() throws { let markdown = #######""" __ foo bar__ """####### let html = #######"""

__ foo bar__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample384() throws { let markdown = #######""" a__"foo"__ """####### let html = #######"""

a__"foo"__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample385() throws { let markdown = #######""" foo__bar__ """####### let html = #######"""

foo__bar__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample386() throws { let markdown = #######""" 5__6__78 """####### let html = #######"""

5__6__78

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample387() throws { let markdown = #######""" пристаням__стремятся__ """####### let html = #######"""

пристаням__стремятся__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample388() throws { let markdown = #######""" __foo, __bar__, baz__ """####### let html = #######"""

foo, bar, baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample389() throws { let markdown = #######""" foo-__(bar)__ """####### let html = #######"""

foo-(bar)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample390() throws { let markdown = #######""" **foo bar ** """####### let html = #######"""

**foo bar **

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample391() throws { let markdown = #######""" **(**foo) """####### let html = #######"""

**(**foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample392() throws { let markdown = #######""" *(**foo**)* """####### let html = #######"""

(foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample393() throws { let markdown = #######""" **Gomphocarpus (*Gomphocarpus physocarpus*, syn. *Asclepias physocarpa*)** """####### let html = #######"""

Gomphocarpus (Gomphocarpus physocarpus, syn. Asclepias physocarpa)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample394() throws { let markdown = #######""" **foo "*bar*" foo** """####### let html = #######"""

foo "bar" foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample395() throws { let markdown = #######""" **foo**bar """####### let html = #######"""

foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample396() throws { let markdown = #######""" __foo bar __ """####### let html = #######"""

__foo bar __

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample397() throws { let markdown = #######""" __(__foo) """####### let html = #######"""

__(__foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample398() throws { let markdown = #######""" _(__foo__)_ """####### let html = #######"""

(foo)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample399() throws { let markdown = #######""" __foo__bar """####### let html = #######"""

__foo__bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample400() throws { let markdown = #######""" __пристаням__стремятся """####### let html = #######"""

__пристаням__стремятся

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample401() throws { let markdown = #######""" __foo__bar__baz__ """####### let html = #######"""

foo__bar__baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample402() throws { let markdown = #######""" __(bar)__. """####### let html = #######"""

(bar).

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample403() throws { let markdown = #######""" *foo [bar](/url)* """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample404() throws { let markdown = #######""" *foo bar* """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample405() throws { let markdown = #######""" _foo __bar__ baz_ """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample406() throws { let markdown = #######""" _foo _bar_ baz_ """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample407() throws { let markdown = #######""" __foo_ bar_ """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample408() throws { let markdown = #######""" *foo *bar** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample409() throws { let markdown = #######""" *foo **bar** baz* """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample410() throws { let markdown = #######""" *foo**bar**baz* """####### let html = #######"""

foobarbaz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample411() throws { let markdown = #######""" *foo**bar* """####### let html = #######"""

foo**bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample412() throws { let markdown = #######""" ***foo** bar* """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample413() throws { let markdown = #######""" *foo **bar*** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample414() throws { let markdown = #######""" *foo**bar*** """####### let html = #######"""

foobar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample415() throws { let markdown = #######""" foo***bar***baz """####### let html = #######"""

foobarbaz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample416() throws { let markdown = #######""" foo******bar*********baz """####### let html = #######"""

foobar***baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample417() throws { let markdown = #######""" *foo **bar *baz* bim** bop* """####### let html = #######"""

foo bar baz bim bop

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample418() throws { let markdown = #######""" *foo [*bar*](/url)* """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample419() throws { let markdown = #######""" ** is not an empty emphasis """####### let html = #######"""

** is not an empty emphasis

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample420() throws { let markdown = #######""" **** is not an empty strong emphasis """####### let html = #######"""

**** is not an empty strong emphasis

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample421() throws { let markdown = #######""" **foo [bar](/url)** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample422() throws { let markdown = #######""" **foo bar** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample423() throws { let markdown = #######""" __foo _bar_ baz__ """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample424() throws { let markdown = #######""" __foo __bar__ baz__ """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample425() throws { let markdown = #######""" ____foo__ bar__ """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample426() throws { let markdown = #######""" **foo **bar**** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample427() throws { let markdown = #######""" **foo *bar* baz** """####### let html = #######"""

foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample428() throws { let markdown = #######""" **foo*bar*baz** """####### let html = #######"""

foobarbaz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample429() throws { let markdown = #######""" ***foo* bar** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample430() throws { let markdown = #######""" **foo *bar*** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample431() throws { let markdown = #######""" **foo *bar **baz** bim* bop** """####### let html = #######"""

foo bar baz bim bop

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample432() throws { let markdown = #######""" **foo [*bar*](/url)** """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample433() throws { let markdown = #######""" __ is not an empty emphasis """####### let html = #######"""

__ is not an empty emphasis

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample434() throws { let markdown = #######""" ____ is not an empty strong emphasis """####### let html = #######"""

____ is not an empty strong emphasis

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample435() throws { let markdown = #######""" foo *** """####### let html = #######"""

foo ***

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample436() throws { let markdown = #######""" foo *\** """####### let html = #######"""

foo *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample437() throws { let markdown = #######""" foo *_* """####### let html = #######"""

foo _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample438() throws { let markdown = #######""" foo ***** """####### let html = #######"""

foo *****

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample439() throws { let markdown = #######""" foo **\*** """####### let html = #######"""

foo *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample440() throws { let markdown = #######""" foo **_** """####### let html = #######"""

foo _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample441() throws { let markdown = #######""" **foo* """####### let html = #######"""

*foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample442() throws { let markdown = #######""" *foo** """####### let html = #######"""

foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample443() throws { let markdown = #######""" ***foo** """####### let html = #######"""

*foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample444() throws { let markdown = #######""" ****foo* """####### let html = #######"""

***foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample445() throws { let markdown = #######""" **foo*** """####### let html = #######"""

foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample446() throws { let markdown = #######""" *foo**** """####### let html = #######"""

foo***

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample447() throws { let markdown = #######""" foo ___ """####### let html = #######"""

foo ___

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample448() throws { let markdown = #######""" foo _\__ """####### let html = #######"""

foo _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample449() throws { let markdown = #######""" foo _*_ """####### let html = #######"""

foo *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample450() throws { let markdown = #######""" foo _____ """####### let html = #######"""

foo _____

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample451() throws { let markdown = #######""" foo __\___ """####### let html = #######"""

foo _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample452() throws { let markdown = #######""" foo __*__ """####### let html = #######"""

foo *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample453() throws { let markdown = #######""" __foo_ """####### let html = #######"""

_foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample454() throws { let markdown = #######""" _foo__ """####### let html = #######"""

foo_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample455() throws { let markdown = #######""" ___foo__ """####### let html = #######"""

_foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample456() throws { let markdown = #######""" ____foo_ """####### let html = #######"""

___foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample457() throws { let markdown = #######""" __foo___ """####### let html = #######"""

foo_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample458() throws { let markdown = #######""" _foo____ """####### let html = #######"""

foo___

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample459() throws { let markdown = #######""" **foo** """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample460() throws { let markdown = #######""" *_foo_* """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample461() throws { let markdown = #######""" __foo__ """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample462() throws { let markdown = #######""" _*foo*_ """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample463() throws { let markdown = #######""" ****foo**** """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample464() throws { let markdown = #######""" ____foo____ """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample465() throws { let markdown = #######""" ******foo****** """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample466() throws { let markdown = #######""" ***foo*** """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample467() throws { let markdown = #######""" _____foo_____ """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample468() throws { let markdown = #######""" *foo _bar* baz_ """####### let html = #######"""

foo _bar baz_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample469() throws { let markdown = #######""" *foo __bar *baz bim__ bam* """####### let html = #######"""

foo bar *baz bim bam

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample470() throws { let markdown = #######""" **foo **bar baz** """####### let html = #######"""

**foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample471() throws { let markdown = #######""" *foo *bar baz* """####### let html = #######"""

*foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample472() throws { let markdown = #######""" *[bar*](/url) """####### let html = #######"""

*bar*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample473() throws { let markdown = #######""" _foo [bar_](/url) """####### let html = #######"""

_foo bar_

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample474() throws { let markdown = #######""" * """####### let html = #######"""

*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample475() throws { let markdown = #######""" ** """####### let html = #######"""

**

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample476() throws { let markdown = #######""" __ """####### let html = #######"""

__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample477() throws { let markdown = #######""" *a `*`* """####### let html = #######"""

a *

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample478() throws { let markdown = #######""" _a `_`_ """####### let html = #######"""

a _

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample479() throws { let markdown = #######""" **a """####### let html = #######"""

**ahttp://foo.bar/?q=**

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample480() throws { let markdown = #######""" __a """####### let html = #######"""

__ahttp://foo.bar/?q=__

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/EntityAndNumericCharacterReferencesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecEntityAndNumericCharacterReferencesTests: XCTestCase { func testExample311() throws { let markdown = #######"""   & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸ """####### let html = #######"""

  & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample312() throws { let markdown = #######""" # Ӓ Ϡ � """####### let html = #######"""

# Ӓ Ϡ �

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample313() throws { let markdown = #######""" " ആ ಫ """####### let html = #######"""

" ആ ಫ

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample314() throws { let markdown = #######"""   &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?; """####### let html = #######"""

&nbsp &x; &#; &#x; &#987654321; &#abcdef0; &ThisIsNotDefined; &hi?;

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample315() throws { let markdown = #######""" © """####### let html = #######"""

&copy

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample316() throws { let markdown = #######""" &MadeUpEntity; """####### let html = #######"""

&MadeUpEntity;

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample317() throws { let markdown = #######""" """####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample318() throws { let markdown = #######""" [foo](/föö "föö") """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample319() throws { let markdown = #######""" [foo] [foo]: /föö "föö" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample320() throws { let markdown = #######""" ``` föö foo ``` """####### let html = #######"""
foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample321() throws { let markdown = #######""" `föö` """####### let html = #######"""

f&ouml;&ouml;

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample322() throws { let markdown = #######""" föfö """####### let html = #######"""
f&ouml;f&ouml;
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample323() throws { let markdown = #######""" *foo* *foo* """####### let html = #######"""

*foo* foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample324() throws { let markdown = #######""" * foo * foo """####### let html = #######"""

* foo

  • foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample325() throws { let markdown = #######""" foo bar """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample326() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample327() throws { let markdown = #######""" [a](url "tit") """####### let html = #######"""

[a](url "tit")

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/FencedCodeBlocksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecFencedCodeBlocksTests: XCTestCase { func testExample89() throws { let markdown = #######""" ``` < > ``` """####### let html = #######"""
<
         >
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample90() throws { let markdown = #######""" ~~~ < > ~~~ """####### let html = #######"""
<
         >
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample91() throws { let markdown = #######""" `` foo `` """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample92() throws { let markdown = #######""" ``` aaa ~~~ ``` """####### let html = #######"""
aaa
        ~~~
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample93() throws { let markdown = #######""" ~~~ aaa ``` ~~~ """####### let html = #######"""
aaa
        ```
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample94() throws { let markdown = #######""" ```` aaa ``` `````` """####### let html = #######"""
aaa
        ```
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample95() throws { let markdown = #######""" ~~~~ aaa ~~~ ~~~~ """####### let html = #######"""
aaa
        ~~~
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample96() throws { let markdown = #######""" ``` """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample97() throws { let markdown = #######""" ````` ``` aaa """####### let html = #######"""

        ```
        aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample98() throws { let markdown = #######""" > ``` > aaa bbb """####### let html = #######"""
aaa
        

bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample99() throws { let markdown = #######""" ``` ``` """####### let html = #######"""

          
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample100() throws { let markdown = #######""" ``` ``` """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample101() throws { let markdown = #######""" ``` aaa aaa ``` """####### let html = #######"""
aaa
        aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample102() throws { let markdown = #######""" ``` aaa aaa aaa ``` """####### let html = #######"""
aaa
        aaa
        aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample103() throws { let markdown = #######""" ``` aaa aaa aaa ``` """####### let html = #######"""
aaa
         aaa
        aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample104() throws { let markdown = #######""" ``` aaa ``` """####### let html = #######"""
```
        aaa
        ```
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample105() throws { let markdown = #######""" ``` aaa ``` """####### let html = #######"""
aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample106() throws { let markdown = #######""" ``` aaa ``` """####### let html = #######"""
aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample107() throws { let markdown = #######""" ``` aaa ``` """####### let html = #######"""
aaa
            ```
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample108() throws { let markdown = #######""" ``` ``` aaa """####### let html = #######"""

aaa

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample109() throws { let markdown = #######""" ~~~~~~ aaa ~~~ ~~ """####### let html = #######"""
aaa
        ~~~ ~~
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample110() throws { let markdown = #######""" foo ``` bar ``` baz """####### let html = #######"""

foo

bar
        

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample111() throws { let markdown = #######""" foo --- ~~~ bar ~~~ # baz """####### let html = #######"""

foo

bar
        

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample112() throws { let markdown = #######""" ```ruby def foo(x) return 3 end ``` """####### let html = #######"""
def foo(x)
          return 3
        end
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample113() throws { let markdown = #######""" ~~~~ ruby startline=3 $%@#$ def foo(x) return 3 end ~~~~~~~ """####### let html = #######"""
def foo(x)
          return 3
        end
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample114() throws { let markdown = #######""" ````; ```` """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample115() throws { let markdown = #######""" ``` aa ``` foo """####### let html = #######"""

aa foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample116() throws { let markdown = #######""" ~~~ aa ``` ~~~ foo ~~~ """####### let html = #######"""
foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample117() throws { let markdown = #######""" ``` ``` aaa ``` """####### let html = #######"""
``` aaa
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/HardLineBreaksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecHardLineBreaksTests: XCTestCase { func testExample630() throws { let markdown = #######""" foo baz """####### let html = #######"""

foo
baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample631() throws { let markdown = #######""" foo\ baz """####### let html = #######"""

foo
baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample632() throws { let markdown = #######""" foo baz """####### let html = #######"""

foo
baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample633() throws { let markdown = #######""" foo bar """####### let html = #######"""

foo
bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample634() throws { let markdown = #######""" foo\ bar """####### let html = #######"""

foo
bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample635() throws { let markdown = #######""" *foo bar* """####### let html = #######"""

foo
bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample636() throws { let markdown = #######""" *foo\ bar* """####### let html = #######"""

foo
bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample637() throws { let markdown = #######""" `code span` """####### let html = #######"""

code span

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample638() throws { let markdown = #######""" `code\ span` """####### let html = #######"""

code\ span

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample639() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample640() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample641() throws { let markdown = #######""" foo\ """####### let html = #######"""

foo\

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample642() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample643() throws { let markdown = #######""" ### foo\ """####### let html = #######"""

foo\

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample644() throws { let markdown = #######""" ### foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/HtmlBlocksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecHtmlBlocksTests: XCTestCase { func testExample118() throws { let markdown = #######"""
        **Hello**,
        
        _world_.
        
"""####### let html = #######"""
        **Hello**,
        

world.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample119() throws { let markdown = #######"""
hi
okay. """####### let html = #######"""
hi

okay.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample120() throws { let markdown = #######"""
*foo* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample122() throws { let markdown = #######"""
*Markdown*
"""####### let html = #######"""

Markdown

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample123() throws { let markdown = #######"""
"""####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample124() throws { let markdown = #######"""
"""####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample125() throws { let markdown = #######"""
*foo* *bar* """####### let html = #######"""
*foo*

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample126() throws { let markdown = #######"""
"""####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample130() throws { let markdown = #######"""
foo
"""####### let html = #######"""
foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample131() throws { let markdown = #######"""
``` c int x = 33; ``` """####### let html = #######"""
``` c int x = 33; ``` """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample132() throws { let markdown = #######""" *bar* """####### let html = #######""" *bar* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample133() throws { let markdown = #######""" *bar* """####### let html = #######""" *bar* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample134() throws { let markdown = #######""" *bar* """####### let html = #######""" *bar* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample135() throws { let markdown = #######""" *bar* """####### let html = #######""" *bar* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample136() throws { let markdown = #######""" *foo* """####### let html = #######""" *foo* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample137() throws { let markdown = #######""" *foo* """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample138() throws { let markdown = #######""" *foo* """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample139() throws { let markdown = #######"""

        import Text.HTML.TagSoup
        
        main :: IO ()
        main = print $ parseTags tags
        
okay """####### let html = #######"""

        import Text.HTML.TagSoup
        
        main :: IO ()
        main = print $ parseTags tags
        

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample140() throws { let markdown = #######""" okay """####### let html = #######"""

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample141() throws { let markdown = #######""" okay """####### let html = #######"""

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample142() throws { let markdown = #######""" *foo* """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample146() throws { let markdown = #######""" *bar* *baz* """####### let html = #######""" *bar*

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample147() throws { let markdown = #######""" 1. *bar* """####### let html = #######""" 1. *bar* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample148() throws { let markdown = #######""" okay """####### let html = #######"""

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample149() throws { let markdown = #######""" '; ?> okay """####### let html = #######""" '; ?>

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample150() throws { let markdown = #######""" """####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample151() throws { let markdown = #######""" okay """####### let html = #######"""

okay

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample152() throws { let markdown = #######""" """####### let html = #######"""
<!-- foo -->
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample153() throws { let markdown = #######"""
"""####### let html = #######"""
<div>
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample154() throws { let markdown = #######""" Foo
bar
"""####### let html = #######"""

Foo

bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample155() throws { let markdown = #######"""
bar
*foo* """####### let html = #######"""
bar
*foo* """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample156() throws { let markdown = #######""" Foo baz """####### let html = #######"""

Foo baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample157() throws { let markdown = #######"""
*Emphasized* text.
"""####### let html = #######"""

Emphasized text.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample158() throws { let markdown = #######"""
*Emphasized* text.
"""####### let html = #######"""
*Emphasized* text.
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample159() throws { let markdown = #######"""
Hi
"""####### let html = #######"""
Hi
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample160() throws { let markdown = #######"""
Hi
"""####### let html = #######"""
<td>
          Hi
        </td>
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/ImagesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecImagesTests: XCTestCase { func testExample568() throws { let markdown = #######""" ![foo](/url "title") """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample569() throws { let markdown = #######""" ![foo *bar*] [foo *bar*]: train.jpg "train & tracks" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample570() throws { let markdown = #######""" ![foo ![bar](/url)](/url2) """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample571() throws { let markdown = #######""" ![foo [bar](/url)](/url2) """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample572() throws { let markdown = #######""" ![foo *bar*][] [foo *bar*]: train.jpg "train & tracks" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample573() throws { let markdown = #######""" ![foo *bar*][foobar] [FOOBAR]: train.jpg "train & tracks" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample574() throws { let markdown = #######""" ![foo](train.jpg) """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample575() throws { let markdown = #######""" My ![foo bar](/path/to/train.jpg "title" ) """####### let html = #######"""

My foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample576() throws { let markdown = #######""" ![foo]() """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample577() throws { let markdown = #######""" ![](/url) """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample578() throws { let markdown = #######""" ![foo][bar] [bar]: /url """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample579() throws { let markdown = #######""" ![foo][bar] [BAR]: /url """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample580() throws { let markdown = #######""" ![foo][] [foo]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample581() throws { let markdown = #######""" ![*foo* bar][] [*foo* bar]: /url "title" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample582() throws { let markdown = #######""" ![Foo][] [foo]: /url "title" """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample583() throws { let markdown = #######""" ![foo] [] [foo]: /url "title" """####### let html = #######"""

foo []

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample584() throws { let markdown = #######""" ![foo] [foo]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample585() throws { let markdown = #######""" ![*foo* bar] [*foo* bar]: /url "title" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample586() throws { let markdown = #######""" ![[foo]] [[foo]]: /url "title" """####### let html = #######"""

![[foo]]

[[foo]]: /url "title"

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample587() throws { let markdown = #######""" ![Foo] [foo]: /url "title" """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample588() throws { let markdown = #######""" !\[foo] [foo]: /url "title" """####### let html = #######"""

![foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample589() throws { let markdown = #######""" \![foo] [foo]: /url "title" """####### let html = #######"""

!foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/IndentedCodeBlocksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecIndentedCodeBlocksTests: XCTestCase { func testExample77() throws { let markdown = #######""" a simple indented code block """####### let html = #######"""
a simple
          indented code block
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample78() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

    bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample79() throws { let markdown = #######""" 1. foo - bar """####### let html = #######"""
  1. foo

    • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample80() throws { let markdown = #######""" *hi* - one """####### let html = #######"""
<a/>
        *hi*
        
        - one
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample81() throws { let markdown = #######""" chunk1 chunk2 chunk3 """####### let html = #######"""
chunk1
        
        chunk2
        
        
        
        chunk3
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample82() throws { let markdown = #######""" chunk1 chunk2 """####### let html = #######"""
chunk1
          
          chunk2
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample83() throws { let markdown = #######""" Foo bar """####### let html = #######"""

Foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample84() throws { let markdown = #######""" foo bar """####### let html = #######"""
foo
        

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample85() throws { let markdown = #######""" # Heading foo Heading ------ foo ---- """####### let html = #######"""

Heading

foo
        

Heading

foo
        

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample86() throws { let markdown = #######""" foo bar """####### let html = #######"""
    foo
        bar
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample87() throws { let markdown = #######""" foo """####### let html = #######"""
foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample88() throws { let markdown = #######""" foo """####### let html = #######"""
foo  
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/InlinesTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecInlinesTests: XCTestCase { func testExample297() throws { let markdown = #######""" `hi`lo` """####### let html = #######"""

hilo`

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/LinkReferenceDefinitionsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecLinkReferenceDefinitionsTests: XCTestCase { func testExample161() throws { let markdown = #######""" [foo]: /url "title" [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample162() throws { let markdown = #######""" [foo]: /url 'the title' [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample163() throws { let markdown = #######""" [Foo*bar\]]:my_(url) 'title (with parens)' [Foo*bar\]] """####### let html = #######"""

Foo*bar]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample164() throws { let markdown = #######""" [Foo bar]: 'title' [Foo bar] """####### let html = #######"""

Foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample165() throws { let markdown = #######""" [foo]: /url ' title line1 line2 ' [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample166() throws { let markdown = #######""" [foo]: /url 'title with blank line' [foo] """####### let html = #######"""

[foo]: /url 'title

with blank line'

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample167() throws { let markdown = #######""" [foo]: /url [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample168() throws { let markdown = #######""" [foo]: [foo] """####### let html = #######"""

[foo]:

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample169() throws { let markdown = #######""" [foo]: <> [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample170() throws { let markdown = #######""" [foo]: (baz) [foo] """####### let html = #######"""

[foo]: (baz)

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample171() throws { let markdown = #######""" [foo]: /url\bar\*baz "foo\"bar\baz" [foo] """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample172() throws { let markdown = #######""" [foo] [foo]: url """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample173() throws { let markdown = #######""" [foo] [foo]: first [foo]: second """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample174() throws { let markdown = #######""" [FOO]: /url [Foo] """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample175() throws { let markdown = #######""" [ΑΓΩ]: /φου [αγω] """####### let html = #######"""

αγω

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample176() throws { let markdown = #######""" [foo]: /url """####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample177() throws { let markdown = #######""" [ foo ]: /url bar """####### let html = #######"""

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample178() throws { let markdown = #######""" [foo]: /url "title" ok """####### let html = #######"""

[foo]: /url "title" ok

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample179() throws { let markdown = #######""" [foo]: /url "title" ok """####### let html = #######"""

"title" ok

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample180() throws { let markdown = #######""" [foo]: /url "title" [foo] """####### let html = #######"""
[foo]: /url "title"
        

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample181() throws { let markdown = #######""" ``` [foo]: /url ``` [foo] """####### let html = #######"""
[foo]: /url
        

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample182() throws { let markdown = #######""" Foo [bar]: /baz [bar] """####### let html = #######"""

Foo [bar]: /baz

[bar]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample183() throws { let markdown = #######""" # [Foo] [foo]: /url > bar """####### let html = #######"""

Foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample184() throws { let markdown = #######""" [foo]: /url bar === [foo] """####### let html = #######"""

bar

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample185() throws { let markdown = #######""" [foo]: /url === [foo] """####### let html = #######"""

=== foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample186() throws { let markdown = #######""" [foo]: /foo-url "foo" [bar]: /bar-url "bar" [baz]: /baz-url [foo], [bar], [baz] """####### let html = #######"""

foo, bar, baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample187() throws { let markdown = #######""" [foo] > [foo]: /url """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample188() throws { let markdown = #######""" [foo]: /url """####### let html = #######""" """####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/LinksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecLinksTests: XCTestCase { func testExample481() throws { let markdown = #######""" [link](/uri "title") """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample482() throws { let markdown = #######""" [link](/uri) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample483() throws { let markdown = #######""" [link]() """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample484() throws { let markdown = #######""" [link](<>) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample485() throws { let markdown = #######""" [link](/my uri) """####### let html = #######"""

[link](/my uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample486() throws { let markdown = #######""" [link](
) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample487() throws { let markdown = #######""" [link](foo bar) """####### let html = #######"""

[link](foo bar)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample488() throws { let markdown = #######""" [link]() """####### let html = #######"""

[link]()

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample489() throws { let markdown = #######""" [a]() """####### let html = #######"""

a

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample490() throws { let markdown = #######""" [link]() """####### let html = #######"""

[link](<foo>)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample491() throws { let markdown = #######""" [a]( [a](c) """####### let html = #######"""

[a](<b)c [a](<b)c> [a](c)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample492() throws { let markdown = #######""" [link](\(foo\)) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample493() throws { let markdown = #######""" [link](foo(and(bar))) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample494() throws { let markdown = #######""" [link](foo\(and\(bar\)) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample495() throws { let markdown = #######""" [link]() """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample496() throws { let markdown = #######""" [link](foo\)\:) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample497() throws { let markdown = #######""" [link](#fragment) [link](http://example.com#fragment) [link](http://example.com?foo=3#frag) """####### let html = #######"""

link

link

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample498() throws { let markdown = #######""" [link](foo\bar) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample499() throws { let markdown = #######""" [link](foo%20bä) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample500() throws { let markdown = #######""" [link]("title") """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample501() throws { let markdown = #######""" [link](/url "title") [link](/url 'title') [link](/url (title)) """####### let html = #######"""

link link link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample502() throws { let markdown = #######""" [link](/url "title \""") """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample503() throws { let markdown = #######""" [link](/url "title") """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample504() throws { let markdown = #######""" [link](/url "title "and" title") """####### let html = #######"""

[link](/url "title "and" title")

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample505() throws { let markdown = #######""" [link](/url 'title "and" title') """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample506() throws { let markdown = #######""" [link]( /uri "title" ) """####### let html = #######"""

link

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample507() throws { let markdown = #######""" [link] (/uri) """####### let html = #######"""

[link] (/uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample508() throws { let markdown = #######""" [link [foo [bar]]](/uri) """####### let html = #######"""

link [foo [bar]]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample509() throws { let markdown = #######""" [link] bar](/uri) """####### let html = #######"""

[link] bar](/uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample510() throws { let markdown = #######""" [link [bar](/uri) """####### let html = #######"""

[link bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample511() throws { let markdown = #######""" [link \[bar](/uri) """####### let html = #######"""

link [bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample512() throws { let markdown = #######""" [link *foo **bar** `#`*](/uri) """####### let html = #######"""

link foo bar #

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample513() throws { let markdown = #######""" [![moon](moon.jpg)](/uri) """####### let html = #######"""

moon

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample514() throws { let markdown = #######""" [foo [bar](/uri)](/uri) """####### let html = #######"""

[foo bar](/uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample515() throws { let markdown = #######""" [foo *[bar [baz](/uri)](/uri)*](/uri) """####### let html = #######"""

[foo [bar baz](/uri)](/uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample516() throws { let markdown = #######""" ![[[foo](uri1)](uri2)](uri3) """####### let html = #######"""

[foo](uri2)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample517() throws { let markdown = #######""" *[foo*](/uri) """####### let html = #######"""

*foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample518() throws { let markdown = #######""" [foo *bar](baz*) """####### let html = #######"""

foo *bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample519() throws { let markdown = #######""" *foo [bar* baz] """####### let html = #######"""

foo [bar baz]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample520() throws { let markdown = #######""" [foo """####### let html = #######"""

[foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample521() throws { let markdown = #######""" [foo`](/uri)` """####### let html = #######"""

[foo](/uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample522() throws { let markdown = #######""" [foo """####### let html = #######"""

[foohttp://example.com/?search=](uri)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample523() throws { let markdown = #######""" [foo][bar] [bar]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample524() throws { let markdown = #######""" [link [foo [bar]]][ref] [ref]: /uri """####### let html = #######"""

link [foo [bar]]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample525() throws { let markdown = #######""" [link \[bar][ref] [ref]: /uri """####### let html = #######"""

link [bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample526() throws { let markdown = #######""" [link *foo **bar** `#`*][ref] [ref]: /uri """####### let html = #######"""

link foo bar #

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample527() throws { let markdown = #######""" [![moon](moon.jpg)][ref] [ref]: /uri """####### let html = #######"""

moon

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample528() throws { let markdown = #######""" [foo [bar](/uri)][ref] [ref]: /uri """####### let html = #######"""

[foo bar]ref

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample529() throws { let markdown = #######""" [foo *bar [baz][ref]*][ref] [ref]: /uri """####### let html = #######"""

[foo bar baz]ref

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample530() throws { let markdown = #######""" *[foo*][ref] [ref]: /uri """####### let html = #######"""

*foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample531() throws { let markdown = #######""" [foo *bar][ref] [ref]: /uri """####### let html = #######"""

foo *bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample532() throws { let markdown = #######""" [foo [ref]: /uri """####### let html = #######"""

[foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample533() throws { let markdown = #######""" [foo`][ref]` [ref]: /uri """####### let html = #######"""

[foo][ref]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample534() throws { let markdown = #######""" [foo [ref]: /uri """####### let html = #######"""

[foohttp://example.com/?search=][ref]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample535() throws { let markdown = #######""" [foo][BaR] [bar]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample536() throws { let markdown = #######""" [Толпой][Толпой] is a Russian word. [ТОЛПОЙ]: /url """####### let html = #######"""

Толпой is a Russian word.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample537() throws { let markdown = #######""" [Foo bar]: /url [Baz][Foo bar] """####### let html = #######"""

Baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample538() throws { let markdown = #######""" [foo] [bar] [bar]: /url "title" """####### let html = #######"""

[foo] bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample539() throws { let markdown = #######""" [foo] [bar] [bar]: /url "title" """####### let html = #######"""

[foo] bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample540() throws { let markdown = #######""" [foo]: /url1 [foo]: /url2 [bar][foo] """####### let html = #######"""

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample541() throws { let markdown = #######""" [bar][foo\!] [foo!]: /url """####### let html = #######"""

[bar][foo!]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample542() throws { let markdown = #######""" [foo][ref[] [ref[]: /uri """####### let html = #######"""

[foo][ref[]

[ref[]: /uri

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample543() throws { let markdown = #######""" [foo][ref[bar]] [ref[bar]]: /uri """####### let html = #######"""

[foo][ref[bar]]

[ref[bar]]: /uri

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample544() throws { let markdown = #######""" [[[foo]]] [[[foo]]]: /url """####### let html = #######"""

[[[foo]]]

[[[foo]]]: /url

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample545() throws { let markdown = #######""" [foo][ref\[] [ref\[]: /uri """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample546() throws { let markdown = #######""" [bar\\]: /uri [bar\\] """####### let html = #######"""

bar\

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample547() throws { let markdown = #######""" [] []: /uri """####### let html = #######"""

[]

[]: /uri

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample548() throws { let markdown = #######""" [ ] [ ]: /uri """####### let html = #######"""

[ ]

[ ]: /uri

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample549() throws { let markdown = #######""" [foo][] [foo]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample550() throws { let markdown = #######""" [*foo* bar][] [*foo* bar]: /url "title" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample551() throws { let markdown = #######""" [Foo][] [foo]: /url "title" """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample552() throws { let markdown = #######""" [foo] [] [foo]: /url "title" """####### let html = #######"""

foo []

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample553() throws { let markdown = #######""" [foo] [foo]: /url "title" """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample554() throws { let markdown = #######""" [*foo* bar] [*foo* bar]: /url "title" """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample555() throws { let markdown = #######""" [[*foo* bar]] [*foo* bar]: /url "title" """####### let html = #######"""

[foo bar]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample556() throws { let markdown = #######""" [[bar [foo] [foo]: /url """####### let html = #######"""

[[bar foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample557() throws { let markdown = #######""" [Foo] [foo]: /url "title" """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample558() throws { let markdown = #######""" [foo] bar [foo]: /url """####### let html = #######"""

foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample559() throws { let markdown = #######""" \[foo] [foo]: /url "title" """####### let html = #######"""

[foo]

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample560() throws { let markdown = #######""" [foo*]: /url *[foo*] """####### let html = #######"""

*foo*

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample561() throws { let markdown = #######""" [foo][bar] [foo]: /url1 [bar]: /url2 """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample562() throws { let markdown = #######""" [foo][] [foo]: /url1 """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample563() throws { let markdown = #######""" [foo]() [foo]: /url1 """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample564() throws { let markdown = #######""" [foo](not a link) [foo]: /url1 """####### let html = #######"""

foo(not a link)

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample565() throws { let markdown = #######""" [foo][bar][baz] [baz]: /url """####### let html = #######"""

[foo]bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample566() throws { let markdown = #######""" [foo][bar][baz] [baz]: /url1 [bar]: /url2 """####### let html = #######"""

foobaz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample567() throws { let markdown = #######""" [foo][bar][baz] [baz]: /url1 [foo]: /url2 """####### let html = #######"""

[foo]bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/ListItemsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecListItemsTests: XCTestCase { func testExample223() throws { let markdown = #######""" A paragraph with two lines. indented code > A block quote. """####### let html = #######"""

A paragraph with two lines.

indented code
        

A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample224() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
  1. A paragraph with two lines.

    indented code
            

    A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample225() throws { let markdown = #######""" - one two """####### let html = #######"""
  • one

two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample226() throws { let markdown = #######""" - one two """####### let html = #######"""
  • one

    two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample227() throws { let markdown = #######""" - one two """####### let html = #######"""
  • one
 two
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample228() throws { let markdown = #######""" - one two """####### let html = #######"""
  • one

    two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample229() throws { let markdown = #######""" > > 1. one >> >> two """####### let html = #######"""
  1. one

    two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample230() throws { let markdown = #######""" >>- one >> > > two """####### let html = #######"""
  • one

two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample231() throws { let markdown = #######""" -one 2.two """####### let html = #######"""

-one

2.two

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample232() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

    bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample233() throws { let markdown = #######""" 1. foo ``` bar ``` baz > bam """####### let html = #######"""
  1. foo

    bar
            

    baz

    bam

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample234() throws { let markdown = #######""" - Foo bar baz """####### let html = #######"""
  • Foo

    bar
            
            
            baz
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample235() throws { let markdown = #######""" 123456789. ok """####### let html = #######"""
  1. ok
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample236() throws { let markdown = #######""" 1234567890. not ok """####### let html = #######"""

1234567890. not ok

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample237() throws { let markdown = #######""" 0. ok """####### let html = #######"""
  1. ok
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample238() throws { let markdown = #######""" 003. ok """####### let html = #######"""
  1. ok
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample239() throws { let markdown = #######""" -1. not ok """####### let html = #######"""

-1. not ok

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample240() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

    bar
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample241() throws { let markdown = #######""" 10. foo bar """####### let html = #######"""
  1. foo

    bar
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample242() throws { let markdown = #######""" indented code paragraph more code """####### let html = #######"""
indented code
        

paragraph

more code
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample243() throws { let markdown = #######""" 1. indented code paragraph more code """####### let html = #######"""
  1. indented code
            

    paragraph

    more code
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample244() throws { let markdown = #######""" 1. indented code paragraph more code """####### let html = #######"""
  1.  indented code
            

    paragraph

    more code
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample245() throws { let markdown = #######""" foo bar """####### let html = #######"""

foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample246() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample247() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

    bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample248() throws { let markdown = #######""" - foo - ``` bar ``` - baz """####### let html = #######"""
  • foo
  • bar
            
  • baz
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample249() throws { let markdown = #######""" - foo """####### let html = #######"""
  • foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample250() throws { let markdown = #######""" - foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample251() throws { let markdown = #######""" - foo - - bar """####### let html = #######"""
  • foo
  • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample252() throws { let markdown = #######""" - foo - - bar """####### let html = #######"""
  • foo
  • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample253() throws { let markdown = #######""" 1. foo 2. 3. bar """####### let html = #######"""
  1. foo
  2. bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample254() throws { let markdown = #######""" * """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample255() throws { let markdown = #######""" foo * foo 1. """####### let html = #######"""

foo *

foo 1.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample256() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
  1. A paragraph with two lines.

    indented code
            

    A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample257() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
  1. A paragraph with two lines.

    indented code
            

    A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample258() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
  1. A paragraph with two lines.

    indented code
            

    A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample259() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
1.  A paragraph
            with two lines.
        
                indented code
        
            > A block quote.
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample260() throws { let markdown = #######""" 1. A paragraph with two lines. indented code > A block quote. """####### let html = #######"""
  1. A paragraph with two lines.

    indented code
            

    A block quote.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample261() throws { let markdown = #######""" 1. A paragraph with two lines. """####### let html = #######"""
  1. A paragraph with two lines.
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample262() throws { let markdown = #######""" > 1. > Blockquote continued here. """####### let html = #######"""
  1. Blockquote continued here.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample263() throws { let markdown = #######""" > 1. > Blockquote > continued here. """####### let html = #######"""
  1. Blockquote continued here.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample264() throws { let markdown = #######""" - foo - bar - baz - boo """####### let html = #######"""
  • foo
    • bar
      • baz
        • boo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample265() throws { let markdown = #######""" - foo - bar - baz - boo """####### let html = #######"""
  • foo
  • bar
  • baz
  • boo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample266() throws { let markdown = #######""" 10) foo - bar """####### let html = #######"""
  1. foo
    • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample267() throws { let markdown = #######""" 10) foo - bar """####### let html = #######"""
  1. foo
  • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample268() throws { let markdown = #######""" - - foo """####### let html = #######"""
    • foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample269() throws { let markdown = #######""" 1. - 2. foo """####### let html = #######"""
      1. foo
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample270() throws { let markdown = #######""" - # Foo - Bar --- baz """####### let html = #######"""
  • Foo

  • Bar

    baz
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/ListsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecListsTests: XCTestCase { func testExample271() throws { let markdown = #######""" - foo - bar + baz """####### let html = #######"""
  • foo
  • bar
  • baz
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample272() throws { let markdown = #######""" 1. foo 2. bar 3) baz """####### let html = #######"""
  1. foo
  2. bar
  1. baz
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample273() throws { let markdown = #######""" Foo - bar - baz """####### let html = #######"""

Foo

  • bar
  • baz
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample274() throws { let markdown = #######""" The number of windows in my house is 14. The number of doors is 6. """####### let html = #######"""

The number of windows in my house is 14. The number of doors is 6.

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample275() throws { let markdown = #######""" The number of windows in my house is 1. The number of doors is 6. """####### let html = #######"""

The number of windows in my house is

  1. The number of doors is 6.
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample276() throws { let markdown = #######""" - foo - bar - baz """####### let html = #######"""
  • foo

  • bar

  • baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample277() throws { let markdown = #######""" - foo - bar - baz bim """####### let html = #######"""
  • foo
    • bar
      • baz

        bim

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample278() throws { let markdown = #######""" - foo - bar - baz - bim """####### let html = #######"""
  • foo
  • bar
  • baz
  • bim
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample279() throws { let markdown = #######""" - foo notcode - foo code """####### let html = #######"""
  • foo

    notcode

  • foo

code
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample280() throws { let markdown = #######""" - a - b - c - d - e - f - g """####### let html = #######"""
  • a
  • b
  • c
  • d
  • e
  • f
  • g
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample281() throws { let markdown = #######""" 1. a 2. b 3. c """####### let html = #######"""
  1. a

  2. b

  3. c

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample282() throws { let markdown = #######""" - a - b - c - d - e """####### let html = #######"""
  • a
  • b
  • c
  • d - e
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample283() throws { let markdown = #######""" 1. a 2. b 3. c """####### let html = #######"""
  1. a

  2. b

3. c
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample284() throws { let markdown = #######""" - a - b - c """####### let html = #######"""
  • a

  • b

  • c

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample285() throws { let markdown = #######""" * a * * c """####### let html = #######"""
  • a

  • c

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample286() throws { let markdown = #######""" - a - b c - d """####### let html = #######"""
  • a

  • b

    c

  • d

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample287() throws { let markdown = #######""" - a - b [ref]: /url - d """####### let html = #######"""
  • a

  • b

  • d

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample288() throws { let markdown = #######""" - a - ``` b ``` - c """####### let html = #######"""
  • a
  • b
            
            
            
  • c
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample289() throws { let markdown = #######""" - a - b c - d """####### let html = #######"""
  • a
    • b

      c

  • d
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample290() throws { let markdown = #######""" * a > b > * c """####### let html = #######"""
  • a

    b

  • c
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample291() throws { let markdown = #######""" - a > b ``` c ``` - d """####### let html = #######"""
  • a

    b

    c
            
  • d
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample292() throws { let markdown = #######""" - a """####### let html = #######"""
  • a
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample293() throws { let markdown = #######""" - a - b """####### let html = #######"""
  • a
    • b
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample294() throws { let markdown = #######""" 1. ``` foo ``` bar """####### let html = #######"""
  1. foo
            

    bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample295() throws { let markdown = #######""" * foo * bar baz """####### let html = #######"""
  • foo

    • bar

    baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample296() throws { let markdown = #######""" - a - b - c - d - e - f """####### let html = #######"""
  • a

    • b
    • c
  • d

    • e
    • f
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/ParagraphsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecParagraphsTests: XCTestCase { func testExample189() throws { let markdown = #######""" aaa bbb """####### let html = #######"""

aaa

bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample190() throws { let markdown = #######""" aaa bbb ccc ddd """####### let html = #######"""

aaa bbb

ccc ddd

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample191() throws { let markdown = #######""" aaa bbb """####### let html = #######"""

aaa

bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample192() throws { let markdown = #######""" aaa bbb """####### let html = #######"""

aaa bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample193() throws { let markdown = #######""" aaa bbb ccc """####### let html = #######"""

aaa bbb ccc

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample194() throws { let markdown = #######""" aaa bbb """####### let html = #######"""

aaa bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample195() throws { let markdown = #######""" aaa bbb """####### let html = #######"""
aaa
        

bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample196() throws { let markdown = #######""" aaa bbb """####### let html = #######"""

aaa
bbb

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/PrecedenceTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecPrecedenceTests: XCTestCase { func testExample12() throws { let markdown = #######""" - `one - two` """####### let html = #######"""
  • `one
  • two`
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/RawHtmlTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecRawHtmlTests: XCTestCase { func testExample609() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample610() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample611() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample612() throws { let markdown = #######""" """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample613() throws { let markdown = #######""" Foo """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample614() throws { let markdown = #######""" <33> <__> """####### let html = #######"""

<33> <__>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample615() throws { let markdown = #######"""
"""####### let html = #######"""

<a h*#ref="hi">

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample616() throws { let markdown = #######"""
<a href="hi'> <a href=hi'>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample617() throws { let markdown = #######""" < a>< foo> """####### let html = #######"""

< a>< foo><bar/ > <foo bar=baz bim!bop />

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample618() throws { let markdown = #######"""
"""####### let html = #######"""

<a href='bar'title=title>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample619() throws { let markdown = #######"""
"""####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample620() throws { let markdown = #######""" """####### let html = #######"""

</a href="foo">

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample621() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample622() throws { let markdown = #######""" foo """####### let html = #######"""

foo <!-- not a comment -- two hyphens -->

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample623() throws { let markdown = #######""" foo foo --> foo """####### let html = #######"""

foo <!--> foo -->

foo <!-- foo--->

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample624() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample625() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample626() throws { let markdown = #######""" foo &<]]> """####### let html = #######"""

foo &<]]>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample627() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample628() throws { let markdown = #######""" foo """####### let html = #######"""

foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample629() throws { let markdown = #######""" """####### let html = #######"""

<a href=""">

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/SetextHeadingsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecSetextHeadingsTests: XCTestCase { func testExample50() throws { let markdown = #######""" Foo *bar* ========= Foo *bar* --------- """####### let html = #######"""

Foo bar

Foo bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample51() throws { let markdown = #######""" Foo *bar baz* ==== """####### let html = #######"""

Foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample52() throws { let markdown = #######""" Foo *bar baz* ==== """####### let html = #######"""

Foo bar baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample53() throws { let markdown = #######""" Foo ------------------------- Foo = """####### let html = #######"""

Foo

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample54() throws { let markdown = #######""" Foo --- Foo ----- Foo === """####### let html = #######"""

Foo

Foo

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample55() throws { let markdown = #######""" Foo --- Foo --- """####### let html = #######"""
Foo
        ---
        
        Foo
        

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample56() throws { let markdown = #######""" Foo ---- """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample57() throws { let markdown = #######""" Foo --- """####### let html = #######"""

Foo ---

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample58() throws { let markdown = #######""" Foo = = Foo --- - """####### let html = #######"""

Foo = =

Foo


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample59() throws { let markdown = #######""" Foo ----- """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample60() throws { let markdown = #######""" Foo\ ---- """####### let html = #######"""

Foo\

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample61() throws { let markdown = #######""" `Foo ---- `
"""####### let html = #######"""

`Foo

`

<a title="a lot

of dashes"/>

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample62() throws { let markdown = #######""" > Foo --- """####### let html = #######"""

Foo


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample63() throws { let markdown = #######""" > foo bar === """####### let html = #######"""

foo bar ===

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample64() throws { let markdown = #######""" - Foo --- """####### let html = #######"""
  • Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample65() throws { let markdown = #######""" Foo Bar --- """####### let html = #######"""

Foo Bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample66() throws { let markdown = #######""" --- Foo --- Bar --- Baz """####### let html = #######"""

Foo

Bar

Baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample67() throws { let markdown = #######""" ==== """####### let html = #######"""

====

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample68() throws { let markdown = #######""" --- --- """####### let html = #######"""

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample69() throws { let markdown = #######""" - foo ----- """####### let html = #######"""
  • foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample70() throws { let markdown = #######""" foo --- """####### let html = #######"""
foo
        

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample71() throws { let markdown = #######""" > foo ----- """####### let html = #######"""

foo


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample72() throws { let markdown = #######""" \> foo ------ """####### let html = #######"""

> foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample73() throws { let markdown = #######""" Foo bar --- baz """####### let html = #######"""

Foo

bar

baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample74() throws { let markdown = #######""" Foo bar --- baz """####### let html = #######"""

Foo bar


baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample75() throws { let markdown = #######""" Foo bar * * * baz """####### let html = #######"""

Foo bar


baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample76() throws { let markdown = #######""" Foo bar \--- baz """####### let html = #######"""

Foo bar --- baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/SoftLineBreaksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecSoftLineBreaksTests: XCTestCase { func testExample645() throws { let markdown = #######""" foo baz """####### let html = #######"""

foo baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample646() throws { let markdown = #######""" foo baz """####### let html = #######"""

foo baz

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/TabsTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecTabsTests: XCTestCase { func testExample1() throws { let markdown = #######""" foo baz bim """####### let html = #######"""
foo	baz		bim
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample2() throws { let markdown = #######""" foo baz bim """####### let html = #######"""
foo	baz		bim
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample3() throws { let markdown = #######""" a a ὐ a """####### let html = #######"""
a	a
        ὐ	a
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample4() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

    bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample5() throws { let markdown = #######""" - foo bar """####### let html = #######"""
  • foo

      bar
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample6() throws { let markdown = #######""" > foo """####### let html = #######"""
  foo
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample7() throws { let markdown = #######""" - foo """####### let html = #######"""
  •   foo
            
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample8() throws { let markdown = #######""" foo bar """####### let html = #######"""
foo
        bar
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample9() throws { let markdown = #######""" - foo - bar - baz """####### let html = #######"""
  • foo
    • bar
      • baz
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample10() throws { let markdown = #######""" # Foo """####### let html = #######"""

Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample11() throws { let markdown = #######""" * * * """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/TextualContentTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecTextualContentTests: XCTestCase { func testExample647() throws { let markdown = #######""" hello $.;'there """####### let html = #######"""

hello $.;'there

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample648() throws { let markdown = #######""" Foo χρῆν """####### let html = #######"""

Foo χρῆν

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample649() throws { let markdown = #######""" Multiple spaces """####### let html = #######"""

Multiple spaces

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkSpecTests/ThematicBreaksTests.swift ================================================ // This file was automatically generated and should not be edited. import XCTest import CommonMark final class CommonMarkSpecThematicBreaksTests: XCTestCase { func testExample13() throws { let markdown = #######""" *** --- ___ """####### let html = #######"""


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample14() throws { let markdown = #######""" +++ """####### let html = #######"""

+++

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample15() throws { let markdown = #######""" === """####### let html = #######"""

===

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample16() throws { let markdown = #######""" -- ** __ """####### let html = #######"""

-- ** __

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample17() throws { let markdown = #######""" *** *** *** """####### let html = #######"""


"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample18() throws { let markdown = #######""" *** """####### let html = #######"""
***
        
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample19() throws { let markdown = #######""" Foo *** """####### let html = #######"""

Foo ***

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample20() throws { let markdown = #######""" _____________________________________ """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample21() throws { let markdown = #######""" - - - """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample22() throws { let markdown = #######""" ** * ** * ** * ** """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample23() throws { let markdown = #######""" - - - - """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample24() throws { let markdown = #######""" - - - - """####### let html = #######"""
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample25() throws { let markdown = #######""" _ _ _ _ a a------ ---a--- """####### let html = #######"""

_ _ _ _ a

a------

---a---

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample26() throws { let markdown = #######""" *-* """####### let html = #######"""

-

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample27() throws { let markdown = #######""" - foo *** - bar """####### let html = #######"""
  • foo

  • bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample28() throws { let markdown = #######""" Foo *** bar """####### let html = #######"""

Foo


bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample29() throws { let markdown = #######""" Foo --- bar """####### let html = #######"""

Foo

bar

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample30() throws { let markdown = #######""" * Foo * * * * Bar """####### let html = #######"""
  • Foo

  • Bar
"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } func testExample31() throws { let markdown = #######""" - Foo - * * * """####### let html = #######"""
  • Foo

"""####### let document = try Document(markdown) let actual = document.render(format: .html, options: [.unsafe]) let expected = html XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkTests/CommonMarkBuilderTests.swift ================================================ import XCTest import CommonMark #if swift(>=5.4) final class CommonMarkBuilderTests: XCTestCase { func testCommonMarkBuilder() throws { let urlString: String? = "https://www.un.org/en/universal-declaration-human-rights/" let articles: [String] = [ """ All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """ ] let document = Document { Heading { if let urlString = urlString { Link(urlString: urlString, title: "View full version") { "Universal Declaration of Human Rights" } } } for (number, body) in zip(1..., articles) { Section { Heading { "Article \(number)." } body } } } let expected = try Document(Fixtures.udhr) XCTAssertEqual(document.description, expected.description) } func testListBuilder() throws { let numbers = 1...3 let formatter = NumberFormatter() formatter.numberStyle = .spellOut formatter.locale = Locale(identifier: "en-US") do { let list = List(of: numbers) { n in formatter.string(for: n) } let expected = #""" - one - two - three """# let actual = list.description XCTAssertEqual(expected, actual) } do { let list = List(of: numbers, delimiter: .period(1)) { n in formatter.string(for: n) } let expected = #""" 1. one 2. two 3. three """# let actual = list.description XCTAssertEqual(expected, actual) } } func testHTMLBlock() throws { let document = Document { HTMLBlock.wrap { Paragraph { "Hello, world!" } } before: { "
" } after: { "
" } } let expected = #"""
Hello, world\!
"""# let actual = document.description XCTAssertEqual(expected, actual) } } #endif ================================================ FILE: Tests/CommonMarkTests/CommonMarkTests.swift ================================================ import XCTest import CommonMark final class CommonMarkTests: XCTestCase { func testCommonMarkVersion() { XCTAssertEqual(CommonMark.version.major, 0) XCTAssertEqual(CommonMark.version.minor, 29) XCTAssertEqual(CommonMark.version.patch, 0) } } ================================================ FILE: Tests/CommonMarkTests/ContainerManipulationTests.swift ================================================ import XCTest import CommonMark final class ContainerManipulationTests: XCTestCase { func testContainerOfBlocksManipulation() throws { let document = try Document(Fixtures.udhr) XCTAssertEqual(document.children.count, 3) let heading = document.children[0] as! Heading XCTAssertEqual(heading.level, 1) let subheading = document.children[1] as! Heading XCTAssertEqual(subheading.level, 2) let paragraph = document.children[2] as! Paragraph XCTAssert(paragraph.description.starts(with: "All human beings")) let newParagraph = Paragraph(text: #""" Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. """#) let wasNewParagraphInserted = document.insert(child: newParagraph, after: paragraph) XCTAssertTrue(wasNewParagraphInserted) XCTAssertEqual(document.children.count, 4) XCTAssertEqual(newParagraph, document.children[3]) let replacementParagraph = Paragraph(text: #""" Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. """# ) let wasNewParagraphReplaced = document.replace(child: newParagraph, with: replacementParagraph) XCTAssertTrue(wasNewParagraphReplaced) XCTAssertEqual(document.children.count, 4) XCTAssertEqual(replacementParagraph, document.children[3]) let newSubheading = Heading(level: 2, text: "Article 2.") let wasSubheadingInserted = document.insert(child: newSubheading, before: replacementParagraph) XCTAssertTrue(wasSubheadingInserted) XCTAssertEqual(document.children.count, 5) XCTAssertEqual(newSubheading, document.children[3]) } func testContainerOfInlineElementsManipulation() throws { let document = try Document(Fixtures.udhr) let paragraph = document.children[2] as! Paragraph XCTAssertEqual(paragraph.children.count, 5) let text = Text(literal: "Article 1:") let wasTextInserted = paragraph.insert(child: text, before: paragraph.children[0]) XCTAssertTrue(wasTextInserted) XCTAssertEqual(paragraph.children[0], text) let lineBreak = SoftLineBreak() let wasLineBreakInserted = paragraph.insert(child: lineBreak, after: text) XCTAssertTrue(wasLineBreakInserted) XCTAssertEqual(paragraph.children[1], lineBreak) } func testListManipulation() throws { let document = try Document( #""" * First * Second * Fourth """#) let list = document.children[0] as! List XCTAssertEqual(list.children.count, 3) let third = List.Item(children: [Text(literal: "Third")]) let wasThirdInserted = list.insert(child: third, before: list.children[2]) XCTAssertTrue(wasThirdInserted) XCTAssertEqual(list.children[2], third) let fifth = List.Item(children: [Text(literal: "Fifth")]) let wasFifthInserted = list.insert(child: fifth, after: list.children[3]) XCTAssertTrue(wasFifthInserted) XCTAssertEqual(list.children[4], fifth) } func testListItemManipulation() throws { let listItem = List.Item(children: [Paragraph(text: "First")]) let secondChild = Paragraph(text: "Second") let wasSecondChildInserted = listItem.insert(child: secondChild, after: listItem.children[0]) XCTAssertTrue(wasSecondChildInserted) XCTAssertEqual(listItem.children[1], secondChild) let thirdChild = Paragraph(text: "Third") let wasThirdChildInserted = listItem.insert(child: thirdChild, before: listItem.children[0]) XCTAssertTrue(wasThirdChildInserted) XCTAssertEqual(listItem.children[0], thirdChild) } } ================================================ FILE: Tests/CommonMarkTests/DocumentTests.swift ================================================ import XCTest import CommonMark final class DocumentTests: XCTestCase { // MARK: - Creation func testDocumentCreation() throws { let link = Link(urlString: "https://www.un.org/en/universal-declaration-human-rights/", title: "View full version", text: "Universal Declaration of Human Rights") let heading = Heading(level: 1, children: [link]) let subheading = Heading(level: 2, text: "Article 1.") let paragraph = Paragraph(text: #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """#, replacingNewLinesWithBreaks: true) let document = Document(children: [heading, subheading, paragraph]) let actual = document.description let expected = try Document(Fixtures.udhr).description XCTAssertEqual(actual, expected) } // MARK: - Parsing func testDocumentParsing() throws { let document = try Document(Fixtures.udhr) XCTAssertEqual(document.children.count, 3) let heading = document.children[0] as! Heading XCTAssertEqual(heading.level, 1) XCTAssertEqual(heading.children.count, 1) XCTAssertEqual(heading.parent, document) let link = heading.children[0] as! Link XCTAssertEqual(link.urlString, "https://www.un.org/en/universal-declaration-human-rights/") XCTAssertEqual(link.title, "View full version") XCTAssertEqual(link.parent, heading) let subheading = document.children[1] as! Heading XCTAssertEqual(subheading.level, 2) XCTAssertEqual(subheading.children.count, 1) XCTAssertEqual(subheading.parent, document) let subheadingText = subheading.children[0] as! Text XCTAssertEqual(subheadingText.literal, "Article 1.") XCTAssertEqual(subheadingText.parent, subheading) let paragraph = document.children[2] as! Paragraph XCTAssert(paragraph.description.starts(with: "All human beings")) XCTAssertEqual(paragraph.range.lowerBound.line, 5) XCTAssertEqual(paragraph.range.lowerBound.column, 1) XCTAssertEqual(paragraph.range.upperBound.line, 7) XCTAssertEqual(paragraph.range.upperBound.column, 62) XCTAssertEqual(paragraph.parent, document) } // https://github.com/SwiftDocOrg/CommonMark/issues/19 func testLinkParsing() throws { let document = try Document(#""" [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/ "View full version") """#) let paragraph = document.children[0] as! Paragraph XCTAssertEqual(paragraph.children.count, 1) XCTAssertEqual(paragraph.parent, document) let link = paragraph.children[0] as! Link XCTAssertEqual(link.urlString, "https://www.un.org/en/universal-declaration-human-rights/") XCTAssertEqual(link.title, "View full version") XCTAssertEqual(link.parent, paragraph) let text = link.children[0] as! Text XCTAssertEqual(text.literal, "Universal Declaration of Human Rights") XCTAssertEqual(text.parent, link) } // https://github.com/SwiftDocOrg/CommonMark/issues/1 func testInvalidRange() throws { let commonmark = "* #" let document = try Document(commonmark) let list = document.children.first as! List let item = list.children.first! as List.Item let heading = item.children.first as! Heading XCTAssertEqual(heading.range.lowerBound.line, 1) XCTAssertEqual(heading.range.lowerBound.column, 3) XCTAssertEqual(heading.range.upperBound.line, 1) XCTAssertEqual(heading.range.upperBound.column, 3) } // https://github.com/SwiftDocOrg/CommonMark/issues/20 func testParseWithoutOptions() throws { let commonmark = """ single-dash: - double-dash: -- triple-dash: --- single-quote: '' double-quote: "" single-period: . double-period: .. triple-period: ... """ let document = try Document(commonmark) let paragraph = document.children.first as! Paragraph let paragraphText = paragraph.description.trimmingCharacters( in: .whitespacesAndNewlines ) // Without smart options we expect no smart replacements to happen: let actual = paragraphText let expected = commonmark XCTAssertEqual(actual, expected) } // https://github.com/SwiftDocOrg/CommonMark/issues/20 func testParseWithSmartOptions() throws { let commonmark = """ single-dash: - double-dash: -- triple-dash: --- single-quote: '' double-quote: "" single-period: . double-period: .. triple-period: ... """ let document = try Document(commonmark, options: [.smart]) let paragraph = document.children.first as! Paragraph let paragraphText = paragraph.description.trimmingCharacters( in: .whitespacesAndNewlines ) // With smart options we expect the following smart replacements: // // single-dash -> no change // double-dash -> n-dash // triple-dash -> m-dash // single-quote -> curly single quotes // double-quote -> curly double quotes // single-period -> no change // double-period -> no change // triple-period -> ellipsis let actual = paragraphText let expected = """ single-dash: - double-dash: – triple-dash: — single-quote: ‘’ double-quote: “” single-period: . double-period: .. triple-period: … """ XCTAssertEqual(actual, expected) } // MARK: - Rendering func testDocumentCommonMarkRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .commonmark, width: 60) let expected = #""" # [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/ "View full version") ## Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# XCTAssertEqual(actual, expected) } // https://github.com/SwiftDocOrg/CommonMark/issues/19 func testLinkCommonMarkRendering() throws { let document = try Document(#""" [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/ "View full version") """#) let paragraph = document.children[0] as! Paragraph let link = paragraph.children[0] as! Link let actual = link.render(format: .commonmark) let expected = #""" [Universal Declaration of Human Rights](https://www.un.org/en/universal-declaration-human-rights/ "View full version") """# XCTAssertEqual(actual, expected) } func testNodeCommonMarkRendering() throws { let document = try Document(Fixtures.udhr) for child in document.children { XCTAssertEqual(child.render(format: .commonmark), child.description) } } func testDocumentHTMLRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .html) let expected = #"""

Universal Declaration of Human Rights

Article 1.

All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.

"""# XCTAssertEqual(actual, expected) } func testNodeHTMLRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .html) let expected = document.children.map { $0.render(format: .html) }.joined() XCTAssertEqual(actual, expected) } func testDocumentXMLRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .xml) let expected = #""" Universal Declaration of Human Rights Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# XCTAssertEqual(actual, expected) } func testDocumentLaTeXRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .latex) let expected = #""" \section{\href{https://www.un.org/en/universal-declaration-human-rights/}{Universal Declaration of Human Rights}} \subsection{Article 1.} All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# XCTAssertEqual(actual, expected) } func testDocumentManpageRendering() throws { let document = try Document(Fixtures.udhr) let actual = document.render(format: .manpage, width: 60) let expected = #""" .SH Universal Declaration of Human Rights (https://www.un.org/en/universal\-declaration\-human\-rights/) .SS Article 1. .PP All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# XCTAssertEqual(actual, expected) } // MARK: - Equality func testDocumentEquality() throws { let text = #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# let firstDocument = try Document("\(text)") let secondDocument = try Document("\(text)") XCTAssertNotEqual(firstDocument, secondDocument) XCTAssertEqual(firstDocument, firstDocument) XCTAssertEqual(secondDocument, secondDocument) } // MARK: - Hashable func testNodesHashable() throws { let text = #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# let firstDocument = try Document("\(text)") let secondDocument = try Document("\(text)") var map = [Document: String]() map[firstDocument] = "first" map[secondDocument] = "second" XCTAssertEqual(map[firstDocument], "first") XCTAssertEqual(map[secondDocument], "second") } func testHashValueConsistentAfterNodeIsModified() throws { let document = try Document(#""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience """#) var documents = Set() documents.insert(document) let paragraph = document.children.first as! Paragraph paragraph.append(child: SoftLineBreak()) paragraph.append(child: Text(literal: "and should act towards one another in a spirit of brotherhood.")) XCTAssertTrue(documents.contains(document)) XCTAssertEqual(document.description, #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """#) } // MARK: - Coding func testDocumentCodingRoundTrip() throws { let document = try Document(Fixtures.udhr) // Workaround for "Top-level Document encoded as string JSON fragment." let encoded = try JSONEncoder().encode([document]) let decoded = try JSONDecoder().decode([Document].self, from: encoded)[0] let actual = decoded.render(format: .commonmark) let expected = document.render(format: .commonmark) XCTAssertEqual(actual, expected) } func testBlockElementCodingRoundTrip() throws { let document = try Document(Fixtures.udhr) let heading = document.children.first! as! Heading // Workaround for "Top-level Heading encoded as string JSON fragment." let encoded = try JSONEncoder().encode([heading]) let decoded = try JSONDecoder().decode([Heading].self, from: encoded)[0] let actual = try Document(decoded.description).render(format: .commonmark) let expected = try Document(heading.description).render(format: .commonmark) XCTAssertEqual(actual, expected) } func testInlineElementCodingRoundTrip() throws { let document = try Document(Fixtures.udhr) let heading = document.children.first! as! Heading let link = heading.children.first! as! Link // Workaround for "Top-level Link encoded as string JSON fragment." let encoded = try JSONEncoder().encode([link]) let decoded = try JSONDecoder().decode([Link].self, from: encoded)[0] let actual = try Document(decoded.description).render(format: .commonmark) let expected = try Document(link.description).render(format: .commonmark) XCTAssertEqual(actual, expected) } } ================================================ FILE: Tests/CommonMarkTests/Fixtures.swift ================================================ public enum Fixtures { public static let udhr: String = #""" # [Universal Declaration of Human Rights][udhr] ## Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. [udhr]: https://www.un.org/en/universal-declaration-human-rights/ "View full version" """# } ================================================ FILE: Tests/CommonMarkTests/NodeTests.swift ================================================ import XCTest import CommonMark final class NodeTests: XCTestCase { // MARK: - Equality func testNodesEquality() { let text = #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# let firstNode = Paragraph(text: "\(text)", replacingNewLinesWithBreaks: true) let secondNode = Paragraph(text: "\(text)", replacingNewLinesWithBreaks: true) XCTAssertNotEqual(firstNode, secondNode) XCTAssertEqual(firstNode, firstNode) XCTAssertEqual(secondNode, secondNode) } // MARK: - Hashable func testNodesHashable() { let text = #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """# let firstNode = Paragraph(text: "\(text)", replacingNewLinesWithBreaks: true) let secondNode = Paragraph(text: "\(text)", replacingNewLinesWithBreaks: true) var map = [Node: String]() map[firstNode] = "first" map[secondNode] = "second" XCTAssertEqual(map[firstNode], "first") XCTAssertEqual(map[secondNode], "second") } func testHashValueConsistentAfterNodeIsModified() { let paragraph = Paragraph(text: #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience """#, replacingNewLinesWithBreaks: true) var nodes = Set() nodes.insert(paragraph) paragraph.append(child: Text(literal: "and should act towards one another in a spirit of brotherhood.")) XCTAssertTrue(nodes.contains(paragraph)) XCTAssertEqual(paragraph.description, #""" All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. """#) } } ================================================ FILE: Tests/CommonMarkTests/ProtocolTests.swift ================================================ import XCTest import CommonMark /// Make sure element types do not conform to more protocols than they should. /// /// - An inline element should not also be a block element and vice versa. /// - A leaf block element should not also be a container block element and vice versa. /// /// Breaking these invariants would be a breaking change for the `Visitor`'s assumptions about element sub-typing. final class ProtocolTests: XCTestCase { func XCTAssertValidInline(_ type: T.Type, file: StaticString = #file, line: UInt = #line) { XCTAssertTrue(T.self is Inline.Type, "Expected `Inline`", file: file, line: line) XCTAssertFalse(T.self is Block.Type, "Did not expect `Block`", file: file, line: line) } func XCTAssertValidLeafBlock(_ type: T.Type, file: StaticString = #file, line: UInt = #line) { XCTAssertTrue(T.self is LeafBlock.Type, "Expected `LeafBlock`", file: file, line: line) XCTAssertFalse(T.self is ContainerBlock.Type, "Did not expect `ContainerBlock`", file: file, line: line) XCTAssertFalse(T.self is Inline.Type, "Did not expect `Inline`", file: file, line: line) } func XCTAssertValidContainerBlock(_ type: T.Type, file: StaticString = #file, line: UInt = #line) { XCTAssertTrue(T.self is ContainerBlock.Type, "Expected `ContainerBlock`", file: file, line: line) XCTAssertFalse(T.self is LeafBlock.Type, "Did not expect `LeafBlock`", file: file, line: line) XCTAssertFalse(T.self is Inline.Type, "Did not expect `Inline`", file: file, line: line) } // MARK: - Node func testNode(){ typealias ConcreteType = Node XCTAssertFalse(ConcreteType.self is Inline.Type) XCTAssertFalse(ConcreteType.self is Block.Type) XCTAssertFalse(ConcreteType.self is LeafBlock.Type) XCTAssertFalse(ConcreteType.self is ContainerBlock.Type) } // MARK: - Inline func testInline(){ XCTAssertValidInline(HardLineBreak.self) XCTAssertValidInline(SoftLineBreak.self) XCTAssertValidInline(RawHTML.self) XCTAssertValidInline(Code.self) XCTAssertValidInline(Image.self) XCTAssertValidInline(Link.self) XCTAssertValidInline(Emphasis.self) XCTAssertValidInline(Text.self) XCTAssertValidInline(Strong.self) } // MARK: - Leaf Block func testLeafBlock(){ XCTAssertValidLeafBlock(ThematicBreak.self) XCTAssertValidLeafBlock(CodeBlock.self) XCTAssertValidLeafBlock(HTMLBlock.self) XCTAssertValidLeafBlock(Paragraph.self) XCTAssertValidLeafBlock(Heading.self) } // MARK: - Container Block func testContainerBlock(){ XCTAssertValidContainerBlock(List.Item.self) XCTAssertValidContainerBlock(List.self) XCTAssertValidContainerBlock(BlockQuote.self) } } ================================================ FILE: Tests/CommonMarkTests/StatisticsVisitor.swift ================================================ import CommonMark struct DocumentStatistics: Equatable { var documents: Int = 0 // Node: var nodes: Int = 0 // Blocks: var blocks: Int = 0 // Container Blocks: var containerBlocks: Int = 0 var blockQuotes: Int = 0 var lists: Int = 0 var listItems: Int = 0 // Leaf Blocks: var leafBlocks: Int = 0 var headings: Int = 0 var paragraphs: Int = 0 var htmlBlocks: Int = 0 var codeBlocks: Int = 0 var thematicBreaks: Int = 0 // Inline: var inlines: Int = 0 var texts: Int = 0 var strongs: Int = 0 var emphasises: Int = 0 var links: Int = 0 var images: Int = 0 var codes: Int = 0 var rawHTMLs: Int = 0 var softLineBreaks: Int = 0 var hardLineBreaks: Int = 0 } class StatisticsVisitor: Visitor { var statistics: DocumentStatistics = .init() func visit(document: Document) -> VisitorContinueKind { self.statistics.documents += 1 return .inherit } // MARK: - Node func visit(node: Node) -> VisitorContinueKind { self.statistics.nodes += 1 return .inherit } // MARK: - Blocks func visit(block: Block) -> VisitorContinueKind { self.statistics.blocks += 1 return .inherit } // MARK: - Container Blocks func visit(containerBlock: ContainerBlock) -> VisitorContinueKind { self.statistics.containerBlocks += 1 return .inherit } func visit(blockQuote: BlockQuote) -> VisitorContinueKind { self.statistics.blockQuotes += 1 return .inherit } func visit(list: List) -> VisitorContinueKind { self.statistics.lists += 1 return .inherit } func visit(listItem: List.Item) -> VisitorContinueKind { self.statistics.listItems += 1 return .inherit } // MARK: - Leaf Blocks /// A block that can only contain inline elements. func visit(leafBlock: LeafBlock) -> VisitorContinueKind { self.statistics.leafBlocks += 1 return .inherit } func visit(heading: Heading) -> VisitorContinueKind { self.statistics.headings += 1 return .inherit } func visit(paragraph: Paragraph) -> VisitorContinueKind { self.statistics.paragraphs += 1 return .inherit } func visit(htmlBlock: HTMLBlock) -> VisitorContinueKind { self.statistics.htmlBlocks += 1 return .inherit } func visit(codeBlock: CodeBlock) -> VisitorContinueKind { self.statistics.codeBlocks += 1 return .inherit } func visit(thematicBreak: ThematicBreak) -> VisitorContinueKind { self.statistics.thematicBreaks += 1 return .inherit } // MARK: - Inline func visit(inline: Inline) -> VisitorContinueKind { self.statistics.inlines += 1 return .inherit } func visit(text: Text) -> VisitorContinueKind { self.statistics.texts += 1 return .inherit } func visit(strong: Strong) -> VisitorContinueKind { self.statistics.strongs += 1 return .inherit } func visit(emphasis: Emphasis) -> VisitorContinueKind { self.statistics.emphasises += 1 return .inherit } func visit(link: Link) -> VisitorContinueKind { self.statistics.links += 1 return .inherit } func visit(image: Image) -> VisitorContinueKind { self.statistics.images += 1 return .inherit } func visit(code: Code) -> VisitorContinueKind { self.statistics.codes += 1 return .inherit } func visit(rawHTML: RawHTML) -> VisitorContinueKind { self.statistics.rawHTMLs += 1 return .inherit } func visit(softLineBreak: SoftLineBreak) -> VisitorContinueKind { self.statistics.softLineBreaks += 1 return .inherit } func visit(hardLineBreak: HardLineBreak) -> VisitorContinueKind { self.statistics.hardLineBreaks += 1 return .inherit } } ================================================ FILE: Tests/CommonMarkTests/VisitorTests.swift ================================================ import XCTest import CommonMark final class VisitorTests: XCTestCase { func testVisitorVisitingChildren() throws { typealias TestVisitor = StatisticsVisitor // Document nodes: // Document // ├─ Heading // │ └─ Link // │ └─ Text // ├─ Heading // │ └─ Text // └─ Paragraph // ├─ Text // ├─ SoftLineBreak // ├─ Text // ├─ SoftLineBreak // └─ Text let document = try Document(Fixtures.udhr) // Visited nodes: // Document // ├─ Heading // │ └─ Link // │ └─ Text // ├─ Heading // │ └─ Text // └─ Paragraph // ├─ Text // ├─ SoftLineBreak // ├─ Text // ├─ SoftLineBreak // └─ Text let visitor = TestVisitor() visitor.walk(document) let expedted = DocumentStatistics( documents: 1, nodes: 12, blocks: 3, leafBlocks: 3, headings: 2, paragraphs: 1, inlines: 8, texts: 5, links: 1, softLineBreaks: 2 ) XCTAssertEqual(visitor.statistics, expedted) } func testVisitorSkippingChildren() throws { final class TestVisitor: StatisticsVisitor { override func visit(link: Link) -> VisitorContinueKind { let _ = super.visit(link: link) return .skipChildren } override func visit(paragraph: Paragraph) -> VisitorContinueKind { let _ = super.visit(paragraph: paragraph) return .skipChildren } } // Document nodes: // Document // ├─ Heading // │ └─ Link // │ └─ Text // ├─ Heading // │ └─ Text // └─ Paragraph // ├─ Text // ├─ SoftLineBreak // ├─ Text // ├─ SoftLineBreak // └─ Text let document = try Document(Fixtures.udhr) // Visited nodes: // Document // ├─ Heading // │ └─ Link (children skipped) // ├─ Heading // │ └─ Text // └─ Paragraph (children skipped) let visitor = TestVisitor() visitor.walk(document) let expedted = DocumentStatistics( documents: 1, nodes: 6, blocks: 3, leafBlocks: 3, headings: 2, paragraphs: 1, inlines: 2, texts: 1, links: 1, softLineBreaks: 0 ) XCTAssertEqual(visitor.statistics, expedted) } func testVisitorOverrides() throws { final class TestVisitor: StatisticsVisitor { override func visit(block: Block) -> VisitorContinueKind { let _ = super.visit(block: block) return .skipChildren } // Given that `Paragraph` is a subtype of `Block` it overrides: override func visit(paragraph: Paragraph) -> VisitorContinueKind { let _ = super.visit(paragraph: paragraph) return .visitChildren } } // Document nodes: // Document // ├─ Heading // │ └─ Link // │ └─ Text // ├─ Heading // │ └─ Text // └─ Paragraph // ├─ Text // ├─ SoftLineBreak // ├─ Text // ├─ SoftLineBreak // └─ Text let document = try Document(Fixtures.udhr) // Visited nodes: // Document // ├─ Heading (children skipped) // ├─ Heading (children skipped) // └─ Paragraph // ├─ Text // ├─ SoftLineBreak // ├─ Text // ├─ SoftLineBreak // └─ Text let visitor = TestVisitor() visitor.walk(document) let expected = DocumentStatistics( documents: 1, nodes: 9, blocks: 3, leafBlocks: 3, headings: 2, paragraphs: 1, inlines: 5, texts: 3, links: 0, softLineBreaks: 2 ) XCTAssertEqual(visitor.statistics, expected) } } ================================================ FILE: Tests/LinuxMain.swift ================================================ fatalError("Run with `swift test --enable-test-discovery`")