diff --git a/README.md b/README.md index 13c6741a..dd7ea899 100644 --- a/README.md +++ b/README.md @@ -165,19 +165,19 @@ Each protocol has options that will influence either rendering or parsing: /** Default options */ -public static let Default = DownOptions(rawValue: 0) +public static let `default` = DownOptions(rawValue: 0) // MARK: - Rendering Options /** Include a `data-sourcepos` attribute on all block elements */ -public static let SourcePos = DownOptions(rawValue: 1 << 1) +public static let sourcePos = DownOptions(rawValue: 1 << 1) /** Render `softbreak` elements as hard line breaks. */ -public static let HardBreaks = DownOptions(rawValue: 1 << 2) +public static let hardBreaks = DownOptions(rawValue: 1 << 2) /** Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`, @@ -186,25 +186,25 @@ public static let HardBreaks = DownOptions(rawValue: 1 << 2) by a placeholder HTML comment. Unsafe links are replaced by empty strings. */ -public static let Safe = DownOptions(rawValue: 1 << 3) +public static let safe = DownOptions(rawValue: 1 << 3) // MARK: - Parsing Options /** Normalize tree by consolidating adjacent text nodes. */ -public static let Normalize = DownOptions(rawValue: 1 << 4) +public static let normalize = DownOptions(rawValue: 1 << 4) /** Validate UTF-8 in the input before parsing, replacing illegal sequences with the replacement character U+FFFD. */ -public static let ValidateUTF8 = DownOptions(rawValue: 1 << 5) +public static let validateUTF8 = DownOptions(rawValue: 1 << 5) /** Convert straight quotes to curly, --- to em dashes, -- to en dashes. */ -public static let Smart = DownOptions(rawValue: 1 << 6) +public static let smart = DownOptions(rawValue: 1 << 6) ``` ### Supports diff --git a/Source/Enums & Options/DownOptions.swift b/Source/Enums & Options/DownOptions.swift index c3c545c4..3590c994 100644 --- a/Source/Enums & Options/DownOptions.swift +++ b/Source/Enums & Options/DownOptions.swift @@ -16,19 +16,19 @@ public struct DownOptions: OptionSet { /** Default options */ - public static let Default = DownOptions(rawValue: CMARK_OPT_DEFAULT) + public static let `default` = DownOptions(rawValue: CMARK_OPT_DEFAULT) // MARK: - Rendering Options /** Include a `data-sourcepos` attribute on all block elements */ - public static let SourcePos = DownOptions(rawValue: CMARK_OPT_SOURCEPOS) + public static let sourcePos = DownOptions(rawValue: CMARK_OPT_SOURCEPOS) /** Render `softbreak` elements as hard line breaks. */ - public static let HardBreaks = DownOptions(rawValue: CMARK_OPT_HARDBREAKS) + public static let hardBreaks = DownOptions(rawValue: CMARK_OPT_HARDBREAKS) /** Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`, @@ -37,24 +37,24 @@ public struct DownOptions: OptionSet { by a placeholder HTML comment. Unsafe links are replaced by empty strings. */ - public static let Safe = DownOptions(rawValue: CMARK_OPT_SAFE) + public static let safe = DownOptions(rawValue: CMARK_OPT_SAFE) // MARK: - Parsing Options /** Normalize tree by consolidating adjacent text nodes. */ - public static let Normalize = DownOptions(rawValue: CMARK_OPT_NORMALIZE) + public static let normalize = DownOptions(rawValue: CMARK_OPT_NORMALIZE) /** Validate UTF-8 in the input before parsing, replacing illegal sequences with the replacement character U+FFFD. */ - public static let ValidateUTF8 = DownOptions(rawValue: CMARK_OPT_VALIDATE_UTF8) + public static let validateUTF8 = DownOptions(rawValue: CMARK_OPT_VALIDATE_UTF8) /** Convert straight quotes to curly, --- to em dashes, -- to en dashes. */ - public static let Smart = DownOptions(rawValue: CMARK_OPT_SMART) + public static let smart = DownOptions(rawValue: CMARK_OPT_SMART) } diff --git a/Source/Extensions/String+ToHTML.swift b/Source/Extensions/String+ToHTML.swift index c73ef3d0..ce1a86b8 100644 --- a/Source/Extensions/String+ToHTML.swift +++ b/Source/Extensions/String+ToHTML.swift @@ -14,13 +14,13 @@ extension String { /** Generates an HTML string from the contents of the string (self), which should contain CommonMark Markdown - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `DownErrors` depending on the scenario - returns: HTML string */ - public func toHTML(_ options: DownOptions = .Default) throws -> String { + public func toHTML(_ options: DownOptions = .default) throws -> String { let ast = try DownASTRenderer.stringToAST(self, options: options) let html = try DownHTMLRenderer.astToHTML(ast, options: options) cmark_node_free(ast) diff --git a/Source/Renderers/DownASTRenderable.swift b/Source/Renderers/DownASTRenderable.swift index 263c4e81..dd9cd372 100644 --- a/Source/Renderers/DownASTRenderable.swift +++ b/Source/Renderers/DownASTRenderable.swift @@ -27,14 +27,14 @@ public extension DownASTRenderable { /** Generates an abstract syntax tree from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `MarkdownToASTError` if conversion fails - returns: An abstract syntax tree representation of the Markdown input */ - public func toAST(_ options: DownOptions = .Default) throws -> UnsafeMutablePointer { + public func toAST(_ options: DownOptions = .default) throws -> UnsafeMutablePointer { return try DownASTRenderer.stringToAST(markdownString, options: options) } } @@ -45,14 +45,14 @@ public struct DownASTRenderer { **Important:** It is the caller's responsibility to call `cmark_node_free(ast)` on the returned value - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `MarkdownToASTError` if conversion fails - returns: An abstract syntax tree representation of the Markdown input */ - public static func stringToAST(_ string: String, options: DownOptions = .Default) throws -> UnsafeMutablePointer { + public static func stringToAST(_ string: String, options: DownOptions = .default) throws -> UnsafeMutablePointer { var tree: UnsafeMutablePointer? string.withCString { let stringLength = Int(strlen($0)) diff --git a/Source/Renderers/DownAttributedStringRenderable.swift b/Source/Renderers/DownAttributedStringRenderable.swift index fd13484e..d6f45359 100644 --- a/Source/Renderers/DownAttributedStringRenderable.swift +++ b/Source/Renderers/DownAttributedStringRenderable.swift @@ -27,14 +27,14 @@ public extension DownAttributedStringRenderable { /** Generates an `NSAttributedString` from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `DownErrors` depending on the scenario - returns: An `NSAttributedString` */ - public func toAttributedString(_ options: DownOptions = .Default) throws -> NSAttributedString { + public func toAttributedString(_ options: DownOptions = .default) throws -> NSAttributedString { let html = try self.toHTML(options) return try NSAttributedString(htmlString: html) } diff --git a/Source/Renderers/DownCommonMarkRenderable.swift b/Source/Renderers/DownCommonMarkRenderable.swift index 8e8aca6f..96a0e63f 100644 --- a/Source/Renderers/DownCommonMarkRenderable.swift +++ b/Source/Renderers/DownCommonMarkRenderable.swift @@ -28,7 +28,7 @@ public extension DownCommonMarkRenderable { /** Generates a CommonMark Markdown string from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `DownErrors` depending on the scenario @@ -36,7 +36,7 @@ public extension DownCommonMarkRenderable { - returns: CommonMark Markdown string */ - public func toCommonMark(_ options: DownOptions = .Default, width: Int32 = 0) throws -> String { + public func toCommonMark(_ options: DownOptions = .default, width: Int32 = 0) throws -> String { let ast = try DownASTRenderer.stringToAST(markdownString, options: options) let commonMark = try DownCommonMarkRenderer.astToCommonMark(ast, options: options, width: width) cmark_node_free(ast) @@ -50,7 +50,7 @@ public struct DownCommonMarkRenderer { **Note:** caller is responsible for calling `cmark_node_free(ast)` after this returns - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `ASTRenderingError` if the AST could not be converted @@ -59,7 +59,7 @@ public struct DownCommonMarkRenderer { */ public static func astToCommonMark(_ ast: UnsafeMutablePointer, - options: DownOptions = .Default, + options: DownOptions = .default, width: Int32 = 0) throws -> String { guard let cCommonMarkString = cmark_render_commonmark(ast, options.rawValue, width) else { throw DownErrors.astRenderingError diff --git a/Source/Renderers/DownGroffRenderable.swift b/Source/Renderers/DownGroffRenderable.swift index 5850703c..f26bfd96 100644 --- a/Source/Renderers/DownGroffRenderable.swift +++ b/Source/Renderers/DownGroffRenderable.swift @@ -28,7 +28,7 @@ public extension DownGroffRenderable { /** Generates a groff man string from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `DownErrors` depending on the scenario @@ -36,7 +36,7 @@ public extension DownGroffRenderable { - returns: groff man string */ - public func toGroff(_ options: DownOptions = .Default, width: Int32 = 0) throws -> String { + public func toGroff(_ options: DownOptions = .default, width: Int32 = 0) throws -> String { let ast = try DownASTRenderer.stringToAST(markdownString, options: options) let groff = try DownGroffRenderer.astToGroff(ast, options: options, width: width) cmark_node_free(ast) @@ -50,7 +50,7 @@ public struct DownGroffRenderer { **Note:** caller is responsible for calling `cmark_node_free(ast)` after this returns - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `ASTRenderingError` if the AST could not be converted @@ -59,7 +59,7 @@ public struct DownGroffRenderer { */ public static func astToGroff(_ ast: UnsafeMutablePointer, - options: DownOptions = .Default, + options: DownOptions = .default, width: Int32 = 0) throws -> String { guard let cGroffString = cmark_render_man(ast, options.rawValue, width) else { throw DownErrors.astRenderingError diff --git a/Source/Renderers/DownHTMLRenderable.swift b/Source/Renderers/DownHTMLRenderable.swift index 4b09239a..c64c17ae 100644 --- a/Source/Renderers/DownHTMLRenderable.swift +++ b/Source/Renderers/DownHTMLRenderable.swift @@ -27,14 +27,14 @@ public extension DownHTMLRenderable { /** Generates an HTML string from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `DownErrors` depending on the scenario - returns: HTML string */ - public func toHTML(_ options: DownOptions = .Default) throws -> String { + public func toHTML(_ options: DownOptions = .default) throws -> String { return try markdownString.toHTML(options) } } @@ -45,14 +45,14 @@ public struct DownHTMLRenderer { **Note:** caller is responsible for calling `cmark_node_free(ast)` after this returns - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `ASTRenderingError` if the AST could not be converted - returns: HTML string */ - public static func astToHTML(_ ast: UnsafeMutablePointer, options: DownOptions = .Default) throws -> String { + public static func astToHTML(_ ast: UnsafeMutablePointer, options: DownOptions = .default) throws -> String { guard let cHTMLString = cmark_render_html(ast, options.rawValue) else { throw DownErrors.astRenderingError } diff --git a/Source/Renderers/DownLaTeXRenderable.swift b/Source/Renderers/DownLaTeXRenderable.swift index 0fe333cb..dc9d8997 100644 --- a/Source/Renderers/DownLaTeXRenderable.swift +++ b/Source/Renderers/DownLaTeXRenderable.swift @@ -28,7 +28,7 @@ public extension DownLaTeXRenderable { /** Generates a LaTeX string from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `DownErrors` depending on the scenario @@ -36,7 +36,7 @@ public extension DownLaTeXRenderable { - returns: LaTeX string */ - public func toLaTeX(_ options: DownOptions = .Default, width: Int32 = 0) throws -> String { + public func toLaTeX(_ options: DownOptions = .default, width: Int32 = 0) throws -> String { let ast = try DownASTRenderer.stringToAST(markdownString, options: options) let latex = try DownLaTeXRenderer.astToLaTeX(ast, options: options, width: width) cmark_node_free(ast) @@ -50,7 +50,7 @@ public struct DownLaTeXRenderer { **Note:** caller is responsible for calling `cmark_node_free(ast)` after this returns - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - parameter width: The width to break on, defaulting to 0 - throws: `ASTRenderingError` if the AST could not be converted @@ -59,7 +59,7 @@ public struct DownLaTeXRenderer { */ public static func astToLaTeX(_ ast: UnsafeMutablePointer, - options: DownOptions = .Default, + options: DownOptions = .default, width: Int32 = 0) throws -> String { guard let cLatexString = cmark_render_latex(ast, options.rawValue, width) else { throw DownErrors.astRenderingError diff --git a/Source/Renderers/DownXMLRenderable.swift b/Source/Renderers/DownXMLRenderable.swift index cb638a47..97a5a3ae 100644 --- a/Source/Renderers/DownXMLRenderable.swift +++ b/Source/Renderers/DownXMLRenderable.swift @@ -27,14 +27,14 @@ public extension DownXMLRenderable { /** Generates an XML string from the `markdownString` property - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `DownErrors` depending on the scenario - returns: XML string */ - public func toXML(_ options: DownOptions = .Default) throws -> String { + public func toXML(_ options: DownOptions = .default) throws -> String { let ast = try DownASTRenderer.stringToAST(markdownString, options: options) let xml = try DownXMLRenderer.astToXML(ast, options: options) cmark_node_free(ast) @@ -48,14 +48,14 @@ public struct DownXMLRenderer { **Note:** caller is responsible for calling `cmark_node_free(ast)` after this returns - - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.Default` + - parameter options: `DownOptions` to modify parsing or rendering, defaulting to `.default` - throws: `ASTRenderingError` if the AST could not be converted - returns: XML string */ - public static func astToXML(_ ast: UnsafeMutablePointer, options: DownOptions = .Default) throws -> String { + public static func astToXML(_ ast: UnsafeMutablePointer, options: DownOptions = .default) throws -> String { guard let cXMLString = cmark_render_xml(ast, options.rawValue) else { throw DownErrors.astRenderingError }