<commit_before># Escapement Swift

Render `NSAttributedString`s from the JSON structure generated by [escapement-rb](https://github.com/hodinkee/escapement-rb).

## Building

```sh
$ git clone https://github.com/hodinkee/escapement-swift
$ cd escapement-swift
$ carthage bootstrap
$ open Escapement.xcodeproj
```

## Installation

- [Carthage](https://github.com/carthage/carthage): `github "hodinkee/escapement-swift"`

## Usage

Escapement exposes two core types: `Document` and `Stylesheet`.

`Document`s can be converted from `JSON` using `DocumentDecoder`: `DocumentDecoder.decode(JSON)` and converted to `JSON` using `DocumentEncoder`: `DocumentEncoder.encode(document)`.

Now you can render an `NSAttributedString` with the following:

```swift
let stylesheet = Styleheet(rules: [
    Styleheet.Rule(selector: "*", attributes: [ NSFontAttributeName: UIFont(name: "TiemposText-Regular", size: 18)! ]),
    Styleheet.Rule(selector: "*", attributes: [ NSForegroundColorAttributeName: Theme.darkTextColor() ]),<commit_msg>Update README.md requirements and installation sections.<commit_after># Escapement Swift

[![Carthage Compatible](https://img.shields.io/badge/carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)

Render `NSAttributedString`s from the JSON structure generated by [escapement-rb](https://github.com/hodinkee/escapement-rb).

## Requirements

|  Xcode  |  Swift  |  iOS  |  tvOS  |
| :-----: | :-----: | :---: | :----: |
| 7.3     | 2.2     | 8.0   | 9.0    |

## Installation

##### [Carthage](https://github.com/carthage/carthage)
> `github "hodinkee/escapement-swift"`

## Usage

Escapement exposes two core types: `Document` and `Stylesheet`.

`Document`s can be converted from `JSON` using `DocumentDecoder`: `DocumentDecoder.decode(JSON)` and converted to `JSON` using `DocumentEncoder`: `DocumentEncoder.encode(document)`.

Now you can render an `NSAttributedString` with the following:

```swift
let stylesheet = Styleheet(rules: [
    Styleheet.Rule(selector: "*", attributes: [ NSFontAttributeName: UIFont(name: "TiemposText-Regular", size: 18)! ]),
    Styleheet.Rule(selector: "*", attributes: [ NSForegroundColorAttributeName: Theme.darkTextColor() ]),
{'fraction_non_alphanumeric': 0.1514052583862194, 'fraction_numerical': 0.006799637352674524, 'mean_word_length': 5.216901408450704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6552720', 'n_tokens_mistral': 753, 'n_tokens_neox': 705, 'n_words': 157}