Skip to content

Commit

Permalink
Updates for unsafe option (johnxnguyen#160)
Browse files Browse the repository at this point in the history
Updating README and DownOptions to show that safe mode is now the default, and to indicate that unsafe must be specified to allow HTML rendering.
  • Loading branch information
hbowie authored and iwasrobbed committed Jul 11, 2019
1 parent dcf86dc commit 7c5d45a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,18 @@ public static let hardBreaks = DownOptions(rawValue: 1 << 2)
`file:`, and `data:`, except for `image/png`, `image/gif`,
`image/jpeg`, or `image/webp` mime types). Raw HTML is replaced
by a placeholder HTML comment. Unsafe links are replaced by
empty strings.
empty strings. Note that this option is provided for backwards
compatibility, but safe mode is now the default.
*/
public static let safe = DownOptions(rawValue: 1 << 3)

/**
Allow raw HTML and unsafe links. Note that safe mode is now
the default, and the unsafe option must be used if rendering
of raw HTML and unsafe links is desired.
*/
public static let unsafe = DownOptions(rawValue: 1 << 17)

// MARK: - Parsing Options

/**
Expand All @@ -220,6 +228,11 @@ 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)

/**
Combine smart typography with HTML rendering.
*/
public static let smartUnsaFe = DownOptions(rawValue: (1 << 17) + (1 << 6))
```

### Supports
Expand Down
5 changes: 5 additions & 0 deletions Source/Enums & Options/DownOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ public struct DownOptions: OptionSet {

/// Convert straight quotes to curly, --- to em dashes, -- to en dashes.
public static let smart = DownOptions(rawValue: CMARK_OPT_SMART)

// MARK: - Combo Options

/// Combines 'unsafe' and 'smart' to render raw HTML and produce smart typography.
public static let smartUnsafe = DownOptions(rawValue: CMARK_OPT_SMART + CMARK_OPT_UNSAFE)

}

0 comments on commit 7c5d45a

Please sign in to comment.