{"id":16699815,"url":"https://github.com/gonzalezreal/markup","last_synced_at":"2025-03-17T00:33:53.861Z","repository":{"id":56920887,"uuid":"97031637","full_name":"gonzalezreal/Markup","owner":"gonzalezreal","description":"Lightweight markup text formatting in Swift","archived":false,"fork":false,"pushed_at":"2020-01-12T19:52:15.000Z","size":3681,"stargazers_count":95,"open_issues_count":5,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-15T12:22:01.246Z","etag":null,"topics":["ios","macos","markup-language","parser","swift","tvos"],"latest_commit_sha":null,"homepage":null,"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/gonzalezreal.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":"2017-07-12T16:51:42.000Z","updated_at":"2023-12-05T12:25:36.000Z","dependencies_parsed_at":"2022-08-21T04:50:36.317Z","dependency_job_id":null,"html_url":"https://github.com/gonzalezreal/Markup","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FMarkup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FMarkup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FMarkup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FMarkup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonzalezreal","download_url":"https://codeload.github.com/gonzalezreal/Markup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"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":["ios","macos","markup-language","parser","swift","tvos"],"created_at":"2024-10-12T18:08:17.176Z","updated_at":"2025-03-17T00:33:52.758Z","avatar_url":"https://github.com/gonzalezreal.png","language":"Swift","readme":"# Markup\n![Swift 5.1](https://img.shields.io/badge/Swift-5.1-orange.svg)\n[![Platforms](https://img.shields.io/cocoapods/p/Markup.svg)](https://cocoapods.org/pods/Markup)\n[![Swift Package Manager](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods](https://img.shields.io/cocoapods/v/Markup.svg)](https://cocoapods.org/pods/Markup)\n[![Twitter: @gonzalezreal](https://img.shields.io/badge/twitter-@gonzalezreal-blue.svg?style=flat)](https://twitter.com/gonzalezreal)\n\nMarkup generates attributed strings using a familiar markup syntax:\n\n* To emphasize words or sentences, you can surround the text with \\*asterisks\\* to create bold text or \\_underscores\\_ for italic text.\n* To show corrections in the text, surround the text with \\~tildes\\~ to strike out the text.\n* You can combine formatting options.\n\nFor example, the following text:\n\n```\nThe *quick*, ~red~ brown fox jumps over a _*lazy dog*_.\n```\n\nwill be formatted like this:\n\nThe **quick**, ~red~ brown fox jumps over a ***lazy dog***.\n\nJust to give you an idea, here is a screenshot of the sample application displaying the markup text and the resulting attributed string:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/gonzalezreal/Markup/master/MarkupExample/Screenshot.png\" width=\"50%\" alt=\"Screenshot\" /\u003e\n\u003c/p\u003e\n\n## Examples\n**Render an attributed string**\n\nYou can use `MarkupRenderer` to generate an attributed string from a given markup text:\n\n```Swift\nimport Markup\n\nlet renderer = MarkupRenderer(baseFont: .systemFont(ofSize: 16))\nlet attributedText = renderer.render(text: \"The *quick*, ~red~ brown fox jumps over a _*lazy dog*_.\")\n```\n\n**Access the markup syntax tree**\n\nUse `MarkupParser` to generate an abstract syntax tree for a markup text:\n\n```Swift\nlet nodes = MarkupParser.parse(text: \"The *quick*, ~red~ brown fox jumps over a _*lazy dog*_\")\ndump(nodes)\n\n// Outputs:\n[\n  .text(\"The \"),\n  .strong([\n    .text(\"quick\")\n  ]),\n  .text(\", \"),\n  .delete([\n    .text(\"red\")\n  ]),\n  .text(\" brown fox jumps over a \"),\n  .emphasis([\n    .strong([\n       .text(\"lazy dog\")\n    ])\n  ])\n]\n```\n\n## Performance\nBoth the parsing and the rendering will take linear time to complete.\n\n[This post](https://gonzalezreal.github.io/2017/07/20/writing-a-lightweight-markup-parser-in-swift.html) explains how Markup internally works, in case you are curious about the implementation.\n\n## Installation\n**Using the Swift Package Manager**\n\nAdd Markup as a dependency to your `Package.swift` file. For more information, see the [Swift Package Manager documentation](https://github.com/apple/swift-package-manager/tree/master/Documentation).\n\n```\n.package(url: \"https://github.com/gonzalezreal/Markup\", from: \"2.3.0\")\n```\n\n**Using Carthage**\n\nAdd `github \"gonzalezreal/Markup\"` to your `Cartfile`\n\n**Using CocoaPods**\n\nAdd `pod Markup` to your `Podfile`\n\n## Help \u0026 Feedback\n- [Open an issue](https://github.com/gonzalezreal/Markup/issues/new) if you need help, if you found a bug, or if you want to discuss a feature request.\n- [Open a PR](https://github.com/gonzalezreal/Markup/pull/new/master) if you want to make some change to `Markup`.\n- Contact [@gonzalezreal](https://twitter.com/gonzalezreal) on Twitter.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fmarkup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonzalezreal%2Fmarkup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fmarkup/lists"}