{"id":13872107,"url":"https://github.com/DoccZz/SwiftMarkdownBuilder","last_synced_at":"2025-07-16T01:32:58.723Z","repository":{"id":63908414,"uuid":"417491087","full_name":"DoccZz/SwiftMarkdownBuilder","owner":"DoccZz","description":"`resultBuilder` support for `swift-markdown`","archived":false,"fork":false,"pushed_at":"2021-10-15T13:05:47.000Z","size":19,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-11-17T17:36:52.294Z","etag":null,"topics":["markdown","swift","swiftpackage"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DoccZz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-15T12:26:40.000Z","updated_at":"2024-01-25T16:16:10.000Z","dependencies_parsed_at":"2022-11-28T22:57:32.046Z","dependency_job_id":null,"html_url":"https://github.com/DoccZz/SwiftMarkdownBuilder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoccZz%2FSwiftMarkdownBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoccZz%2FSwiftMarkdownBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoccZz%2FSwiftMarkdownBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoccZz%2FSwiftMarkdownBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DoccZz","download_url":"https://codeload.github.com/DoccZz/SwiftMarkdownBuilder/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226090030,"owners_count":17572114,"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":["markdown","swift","swiftpackage"],"created_at":"2024-08-05T23:00:34.210Z","updated_at":"2024-11-23T19:31:38.158Z","avatar_url":"https://github.com/DoccZz.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003ch2\u003eSwiftMarkdownBuilder\n  \u003cimg src=\"http://zeezide.com/img/docz/DocCArchive100.png\"\n           align=\"right\" width=\"100\" height=\"100\" /\u003e\n\u003c/h2\u003e\n\n`resultBuilder` support for\n[swift-markdown](https://github.com/apple/swift-markdown).\n\nThe default way to build Markdown in swift-markdown is to use varargs \ninitializers, e.g. as in the example from the README.md:\n\n```swift\nlet document = Document(\n    Paragraph(\n        Text(\"This is a \"),\n        Emphasis(\n            Text(\"paragraph.\"))))\n```\n\nWouldn't it be nice to be able to use a SwiftUI like \"resultBuilder\" syntax,\nlike:\n```swift\nlet document = Document {\n  Paragraph {\n    \"This is a \"\n    \"paragraph\"\n      .emphasis()\n  }\n}\n```\n\nAnd maybe even control structures like:\n```swift\nlet document = Document {\n  \"Our Tasks:\"\n    .font(.largeTitle)\n  \n  List {\n    ForEach(todos) { todo in\n      Text(todo.title)\n    }\n  }\n}\n```\n\nOr custom Markdown \"views\":\n```swift\nstruct TOC: DynamicMarkdownBlock {\n  let pages : [ Page ]\n  \n  var body: [ MarkdownBlock ] {\n    \"Table of Contents\"\n      .font(.title)\n    \n    ForEach(pages) { page in\n      Paragraph {\n        Text(page.title)\n          .font(.title2)\n        \n        Text(page.abstract)\n      }\n    }\n  }\n}\n```\n\nThat's what we play with here.\n\nMaybe we can get it to a state suitable for a PR on swift-markdown itself.\n\n\n### Status\n\nAn experiment for curious people. Work in progress.\n\nIt is not entirely clear how useful this thing is. Is there really\na usecase for building Markdown *in* Swift? 😃\n\nA goal is/was to not come up with protocols/structures specific\nto the resultBuilders, but to directly attach to the ones provided by\nswift-markdown already.\n\nIf that would be internal to the Markdown module, a few hacky things\ncould be dropped (i.e. because the API could be accessed).\n\nThe implementation also doesn't have to resort to the type-safyness\nattached to SwiftUI style setups, because the swift-markdown \nprotocols do not use associated types.\nAlso, it doesn't need two-way setups like `Binding`.\n\nThings missing:\n- [ ] table stuff (needs an own builder for scoping the contents), but could be similar to the macOS SwiftUI table\n- [ ] `List`\n- [ ] conditionals\n- [ ] finish the ForEach\n- [ ] an Environment maybe\n- [ ] also add an HTML resultBuilder?\n- [ ] many more things?\n\nMaybe more things from [SwiftBlocksUI](https://github.com/SwiftBlocksUI/SwiftBlocksUI)\ncould be used (it generates Slack JSON block structures, but those \nare essentially just fancy markdown).\n\n\n### Usage in a Swift Package\n\nExample Package.swift:\n\n```swift\n// swift-tools-version:5.3\n\nimport PackageDescription\n\nlet package = Package(\n  name         : \"MyWebsite\",\n  products     : [ .executable(name: \"MyWebsite\", targets: [ \"MyWebsite\" ]) ],\n  dependencies : [\n    .package(url: \"https://github.com/DoccZz/SwiftMarkdownBuilder.git\", from: \"0.1.0\")\n  ],\n  targets: [ \n    .target(name: \"MyWebsite\", dependencies: [ \n      .product(name: \"MarkdownBuilder\", package: \"SwiftMarkdownBuilder\") \n    ])\n  ]\n)\n```\n\n\n### Who\n\n**SwiftMarkdownBuilder** is brought to you by\nthe\n[Always Right Institute](http://www.alwaysrightinstitute.com)\nand\n[ZeeZide](http://zeezide.de).\nWe like \n[feedback](https://twitter.com/ar_institute), \nGitHub stars, \ncool [contract work](http://zeezide.com/en/services/services.html),\npresumably any form of praise you can think of.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDoccZz%2FSwiftMarkdownBuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDoccZz%2FSwiftMarkdownBuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDoccZz%2FSwiftMarkdownBuilder/lists"}