forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swiftlang#131 from google/format-markdown
Add `CommonMark` module for manipulating Markdown ASTs.
- Loading branch information
Showing
39 changed files
with
3,072 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Sources/CCommonMark/cmark"] | ||
path = Sources/CCommonMark/cmark | ||
url = https://github.com/apple/swift-cmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory contains hand-written versions of C headers for cmark that would | ||
normally be generated by CMake, and a module map that allows it to be imported | ||
from Swift. It is automatically added to clang's header search path by SwiftPM. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Formatter open source project. | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift Formatter project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Formatter project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CMARK_EXPORT_H | ||
#define CMARK_EXPORT_H | ||
|
||
#define CMARK_EXPORT | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Formatter open source project. | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift Formatter project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Formatter project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CMARK_VERSION_H | ||
#define CMARK_VERSION_H | ||
|
||
#define CMARK_VERSION ((0 << 16) | (22 << 8) | 0) | ||
#define CMARK_VERSION_STRING "0.22.0" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Formatter open source project. | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift Formatter project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Formatter project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define HAVE_STDBOOL_H | ||
|
||
#ifdef HAVE_STDBOOL_H | ||
#include <stdbool.h> | ||
#elif !defined(__cplusplus) | ||
typedef char bool; | ||
#endif | ||
|
||
#define HAVE___BUILTIN_EXPECT | ||
|
||
#define HAVE___ATTRIBUTE__ | ||
|
||
#ifdef HAVE___ATTRIBUTE__ | ||
#define CMARK_ATTRIBUTE(list) __attribute__ (list) | ||
#else | ||
#define CMARK_ATTRIBUTE(list) | ||
#endif | ||
|
||
#ifndef CMARK_INLINE | ||
#if defined(_MSC_VER) && !defined(__cplusplus) | ||
#define CMARK_INLINE __inline | ||
#else | ||
#define CMARK_INLINE inline | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module CCommonMark { | ||
header "../cmark/src/cmark.h" | ||
export * | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Formatter open source project. | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift Formatter project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Formatter project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// A Markdown node that represents block content; that is, content that occupies the full width of | ||
/// the viewport when rendered. | ||
/// | ||
/// Examples of block content include paragraphs, block quotes, and code blocks. | ||
/// | ||
/// At this time, the `BlockContent` protocol does not add any members of its own over what is | ||
/// already required by `MarkdownNode`. Instead, it is used as a means of enforcing containment | ||
/// relationships between nodes in the AST. | ||
public protocol BlockContent: MarkdownNode {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Formatter open source project. | ||
// | ||
// Copyright (c) 2018 Apple Inc. and the Swift Formatter project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Swift Formatter project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// A block element that represents a long quotation, typically rendered in a callout box. | ||
public struct BlockQuoteNode: BlockContent { | ||
|
||
/// The children of the receiver. | ||
public let children: [BlockContent] | ||
|
||
public let sourceRange: Range<SourceLocation>? | ||
|
||
public var primitiveRepresentation: PrimitiveNode { return .blockQuote(self) } | ||
|
||
/// Creates a new block quote node. | ||
/// | ||
/// - Parameters: | ||
/// - children: Block content nodes that are children of the new node. | ||
/// - sourceRange: The source range from which the node was parsed, if known. | ||
public init(children: [BlockContent], sourceRange: Range<SourceLocation>? = nil) { | ||
self.children = children | ||
self.sourceRange = sourceRange | ||
} | ||
|
||
/// Returns a new node equivalent to the receiver, but whose children have been replaced with the | ||
/// given list of nodes. | ||
/// | ||
/// - Parameter children: The new list of children. | ||
/// - Returns: The new node. | ||
public func replacingChildren(_ children: [BlockContent]) -> BlockQuoteNode { | ||
return BlockQuoteNode(children: children, sourceRange: sourceRange) | ||
} | ||
|
||
/// Returns a new node equivalent to the receiver, but whose source range has been replaced with | ||
/// the given value. | ||
/// | ||
/// - Parameter sourceRange: The new source range. | ||
/// - Returns: The new node. | ||
public func replacingSourceRange(_ sourceRange: Range<SourceLocation>?) -> BlockQuoteNode { | ||
return BlockQuoteNode(children: children, sourceRange: sourceRange) | ||
} | ||
} |
Oops, something went wrong.