Skip to content

Commit

Permalink
Merge pull request #76 from kengruven/capitalization
Browse files Browse the repository at this point in the history
Use lower-case Swift 3 convention for DownOptions
  • Loading branch information
rob phillips authored Feb 24, 2018
2 parents c3a1504 + 44cb143 commit a6a67fd
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:`,
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions Source/Enums & Options/DownOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:`,
Expand All @@ -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)

}
4 changes: 2 additions & 2 deletions Source/Extensions/String+ToHTML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownASTRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<cmark_node> {
public func toAST(_ options: DownOptions = .default) throws -> UnsafeMutablePointer<cmark_node> {
return try DownASTRenderer.stringToAST(markdownString, options: options)
}
}
Expand All @@ -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<cmark_node> {
public static func stringToAST(_ string: String, options: DownOptions = .default) throws -> UnsafeMutablePointer<cmark_node> {
var tree: UnsafeMutablePointer<cmark_node>?
string.withCString {
let stringLength = Int(strlen($0))
Expand Down
4 changes: 2 additions & 2 deletions Source/Renderers/DownAttributedStringRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownCommonMarkRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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

- 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)
Expand All @@ -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
Expand All @@ -59,7 +59,7 @@ public struct DownCommonMarkRenderer {
*/

public static func astToCommonMark(_ ast: UnsafeMutablePointer<cmark_node>,
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
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownGroffRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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

- 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)
Expand All @@ -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
Expand All @@ -59,7 +59,7 @@ public struct DownGroffRenderer {
*/

public static func astToGroff(_ ast: UnsafeMutablePointer<cmark_node>,
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
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownHTMLRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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<cmark_node>, options: DownOptions = .Default) throws -> String {
public static func astToHTML(_ ast: UnsafeMutablePointer<cmark_node>, options: DownOptions = .default) throws -> String {
guard let cHTMLString = cmark_render_html(ast, options.rawValue) else {
throw DownErrors.astRenderingError
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownLaTeXRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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

- 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)
Expand All @@ -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
Expand All @@ -59,7 +59,7 @@ public struct DownLaTeXRenderer {
*/

public static func astToLaTeX(_ ast: UnsafeMutablePointer<cmark_node>,
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
Expand Down
8 changes: 4 additions & 4 deletions Source/Renderers/DownXMLRenderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<cmark_node>, options: DownOptions = .Default) throws -> String {
public static func astToXML(_ ast: UnsafeMutablePointer<cmark_node>, options: DownOptions = .default) throws -> String {
guard let cXMLString = cmark_render_xml(ast, options.rawValue) else {
throw DownErrors.astRenderingError
}
Expand Down

0 comments on commit a6a67fd

Please sign in to comment.