{"id":21065053,"url":"https://github.com/prolificinteractive/marker","last_synced_at":"2025-05-16T02:32:58.208Z","repository":{"id":8411534,"uuid":"58142805","full_name":"prolificinteractive/Marker","owner":"prolificinteractive","description":"A light wrapper around NSAttributedString.","archived":false,"fork":false,"pushed_at":"2022-04-21T17:40:22.000Z","size":396,"stargazers_count":15,"open_issues_count":2,"forks_count":4,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-23T05:42:11.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prolificinteractive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T15:53:03.000Z","updated_at":"2022-04-21T17:40:07.000Z","dependencies_parsed_at":"2022-08-07T04:16:32.851Z","dependency_job_id":null,"html_url":"https://github.com/prolificinteractive/Marker","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FMarker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FMarker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FMarker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prolificinteractive%2FMarker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prolificinteractive","download_url":"https://codeload.github.com/prolificinteractive/Marker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254456231,"owners_count":22074131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T17:53:18.597Z","updated_at":"2025-05-16T02:32:57.486Z","avatar_url":"https://github.com/prolificinteractive.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Marker](Images/Marker_Banner.jpg)\n\n[![Travis build status](https://img.shields.io/travis/prolificinteractive/Marker.svg?style=flat-square)](https://travis-ci.org/prolificinteractive/Marker)\n[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/Marker.svg?style=flat-square)](https://img.shields.io/cocoapods/v/Marker.svg)\n[![Platform](https://img.shields.io/cocoapods/p/Marker.svg?style=flat-square)](http://cocoadocs.org/docsets/Marker)\n[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/Marker.svg?style=flat-square)](http://cocoadocs.org/docsets/Marker)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n![Swift Version](https://img.shields.io/badge/Swift-4.2-orange.svg)\n\n## Description\n\nMarker is a light wrapper for creating and setting `NSAttributedString` values.\n\n## Requirements\n\n* iOS 8.0+\n\n## Installation\n\n### Cocoapods (Deprecated 1.2.2)\nMarker is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:\n\n```ruby\npod \"Marker\"\n```\n### Swift Package Manager\n\nReleases \u003e1.2.2 are available through SPM.\n\n## Usage\n\n### TextStyle\n\nMarker abstracts the most common attributed text properties into a data object called `TextStyle`, which it can use to create `NSAttributedString`s. A `TextStyle` can have:\n\n* Text color\n* Regular font\n* Italic font\n* Bold font\n* Character spacing\n* Line spacing\n* Line height\n* Paragraph and line indentations\n* Paragraph spacing\n* Text alignment\n* Line break mode\n* Strikethrough style and color\n* Underline style and color\n* Text transformation option\n\n`TextStyle` objects are a simple way of aggregating style information. For example:\n\n```swift\nvar headlineTextStyle: TextStyle {\n\n    let font: UIFont = UIFont.systemFontOfSize(23)\n    let emFont: UIFont = UIFont.italicSystemFontOfSize(23)\n    let strongFont: UIFont = UIFont.boldSystemFontOfSize(23)\n    let characterSpacing: CGFloat? = 2\n    let strikethroughStyle: NSUnderlineStyle = .styleSingle\n\n    return TextStyle(font: regularFont,\n                     emFont: emFont,\n                     strongFont: strongFont,\n                     characterSpacing: characterSpacing,\n                     strikethroughStyle: strikethroughStyle)\n\n}\n```\n\n### Setting Attributed Text\n\nMarker has convenience extensions for setting `attributedText` on common UI elements:\n\n* `UIButton`\n* `UILabel`\n* `UITextField`\n* `UITextView`\n\nTo set text on these elements, use `setText(_:using:customMarkup:)` (or `setTitleText(_:using:customMarkup:)` in the case of `UIButton`) function.\n\n```swift\nlabel.setText(\"Hello World\", using: headlineTextStyle)\n```\n\nOptionally, you can pass custom markup information to selectively style segments of the specified text with custom `TextStyle`.\n\n```swift\nvar blueTextStyle = headlineTextStyle\nblueTextStyle.textColor = UIColor.blue\n\nlabel.setText(\"The sky is #blue#.\",\n              using: headlineTextStyle,\n              customMarkup: [\"#\": blueTextStyle])\n```\n\n#### Markdown\n\nMarker also supports setting text with common Markdown tags:\n\n* Bold (`__` or `**`)\n* Italic (`_` or `*`)\n* Links (`[]()`)\n\nAs well as convenient Markdown tags specific to Marker:\n\n* Strikethrough (`~~`)\n* Underline (`==`)\n\nTo set Markdown text on these elements, use `setMarkdownText(_:using:)` (or `setMarkdownTitleText(_:using:)` for buttons) function. **NOTE**: Setting Markdown links work only in text views whereas other Markdown tags can be applied to any UI element with aforementioned `setMarkdownText(_using:)` function.\n\n```swift\ntextField.setMarkdownText(\"_Hello World_\", using: headlineTextStyle)\n```\n\n#### Backslash Escaping\n\nBoth Markdown and custom markup functions support backslash escaping for generating literal characters which are otherwise reserved for mark up purposes. For instance, URLs with \")\" character in them would not be parsed correctly without backslash escapes.\n\n```\n[Wiki](https://en.wikipedia.org/wiki/Wiki_(disambiguation))\n```\n\nBy default, the parser produces `https://en.wikipedia.org/wiki/Wiki_(disambiguation` as the URL for the above link.\n\n```\n[Wiki](https://en.wikipedia.org/wiki/Wiki_(disambiguation\\))\n```\n\nBy backslash escaping the \")\" character, the parser will treat it as a literal and produce the correct URL, `https://en.wikipedia.org/wiki/Wiki_(disambiguation))`.\n\n\n#### Best Practices\n\nParsing operation for custom markup and Markdown strings can be too slow to use for performance-critical views such as `UITableViewCell`. In these cases, it's recommended to cache and reuse `NSAttributedString`'s returned from `Marker` functions instead of calling either `setText(_:using:customMarkup:)` or `setMarkdownText(_:using:)` directly.\n\n## Contributing to Marker\n\nTo report a bug or enhancement request, feel free to file an issue under the respective heading.\n\nIf you wish to contribute to the project, fork this repo and submit a pull request. Code contributions should follow the standards specified in the [Prolific Swift Style Guide](https://github.com/prolificinteractive/swift-style-guide).\n\n## License\n\n![prolific](https://s3.amazonaws.com/prolificsitestaging/logos/Prolific_Logo_Full_Color.png)\n\nCopyright (c) 2019 Prolific Interactive\n\nMarker is maintained and sponsored by Prolific Interactive. It may be redistributed under the terms specified in the [LICENSE] file.\n\n[LICENSE]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fmarker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprolificinteractive%2Fmarker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprolificinteractive%2Fmarker/lists"}