{"id":13800473,"url":"https://github.com/sparsetech/cmark-scala","last_synced_at":"2025-09-08T14:49:22.511Z","repository":{"id":47085714,"uuid":"91209453","full_name":"sparsetech/cmark-scala","owner":"sparsetech","description":"Parse, manipulate and render CommonMark in Scala Native","archived":false,"fork":false,"pushed_at":"2021-09-14T08:19:11.000Z","size":13,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-28T10:52:57.631Z","etag":null,"topics":["commonmark","scala","scala-native"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparsetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-14T00:02:35.000Z","updated_at":"2024-06-13T15:11:15.000Z","dependencies_parsed_at":"2022-09-24T22:33:24.181Z","dependency_job_id":null,"html_url":"https://github.com/sparsetech/cmark-scala","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sparsetech/cmark-scala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Fcmark-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Fcmark-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Fcmark-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Fcmark-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparsetech","download_url":"https://codeload.github.com/sparsetech/cmark-scala/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Fcmark-scala/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274202049,"owners_count":25240362,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["commonmark","scala","scala-native"],"created_at":"2024-08-04T00:01:12.898Z","updated_at":"2025-09-08T14:49:22.458Z","avatar_url":"https://github.com/sparsetech.png","language":"Scala","funding_links":[],"categories":["Bindings"],"sub_categories":[],"readme":"# \u003cimg src=\"http://sparse.tech/icons/cmark.svg\" width=\"50%\"\u003e\ncmark-scala provides [Scala Native](http://www.scala-native.org/) bindings for [cmark](https://github.com/commonmark/cmark). cmark allows to parse, manipulate and render CommonMark documents.\n\nThe bindings were directly derived from [cmark.h](https://github.com/commonmark/cmark/blob/master/src/cmark.h). Comments were retained and adapted if necessary. The naming of functions and their encapsulation follows Scala's conventions. Note that `*_new` functions were renamed to `create` as to prevent name collisions with the eponymous Scala keyword.\n\n## Example\n```scala\nimport cmark._\nimport scalanative.unsafe._\nimport scalanative.unsigned._\n\nvar level = -1\ndef onNode(eventType: EventType, node: Ptr[Node]): Unit = {\n  eventType match {\n    case EventType.Enter =\u003e level += 1\n    case EventType.Exit  =\u003e level -= 1\n  }\n\n  val levelStr = \"  \" * level\n  val startLine = Node.getStartLine(node)\n  val endLine   = Node.getEndLine(node)\n\n  Node.getType(node) match {\n    case NodeType.Text =\u003e\n      val text = fromCString(Node.getLiteral(node))\n      println(s\"${levelStr}text node @ line $startLine-$endLine: $text\")\n\n    case _ =\u003e\n      val nodeTypeStr = fromCString(Node.getTypeString(node))\n      println(s\"$levelStr$nodeTypeStr node @ $startLine-$endLine\")\n  }\n}\n\nval test =\n  \"\"\"# Chapter\n    |## Section\n    |### Sub-section\n    |\n    |Hello World from *cmark-scala*!\n  \"\"\".stripMargin\n\nprintln(\"cmark version: \" + fromCString(cmark.versionString()))\nprintln()\n\nval docNode = Parser.parseDocument(\n  toCString(test), test.length.toULong, Options.SourcePosition)\nval iter = Iter.create(docNode)\nvar evType = Iter.next(iter)\nwhile (evType != EventType.Done) {\n  onNode(evType, Iter.getNode(iter))\n  evType = Iter.next(iter)\n}\nIter.free(iter)\n\nval html = fromCString(Render.html(docNode, Options.Default))\nprintln()\nprintln(html)\n\nNode.free(docNode)\n```\n\n**Output:**\n\n```\ncmark version: 0.27.1\n\ndocument node @ 1-6\n  heading node @ 1-1\n    text node @ line 0-0: Chapter\n  heading node @ 1-1\n    heading node @ 2-2\n      text node @ line 0-0: Section\n    heading node @ 2-2\n      heading node @ 3-3\n        text node @ line 0-0: Sub-section\n      heading node @ 3-3\n        paragraph node @ 5-5\n          text node @ line 0-0: Hello World from \n            emph node @ 0-0\n              text node @ line 0-0: cmark-scala\n            emph node @ 0-0\n              text node @ line 0-0: !\n            paragraph node @ 5-5\n          document node @ 1-6\n\n\u003ch1\u003eChapter\u003c/h1\u003e\n\u003ch2\u003eSection\u003c/h2\u003e\n\u003ch3\u003eSub-section\u003c/h3\u003e\n\u003cp\u003eHello World from \u003cem\u003ecmark-scala\u003c/em\u003e!\u003c/p\u003e\n```\n\n## Dependency\n```scala\nlibraryDependencies += \"tech.sparse\" %%  \"cmark-scala\" % \"0.2.0-SNAPSHOT\"\n```\n\n## Install Native Library\nIn order to use this library you need to install `cmark` which installs `libcmark`.\n\n* macOS users can use the following command.\n\n```\n$ brew install cmark\n```\n\n* Linux/Ubuntu users can use the following commands.\n\n```\n$ sudo apt update\n$ sudo apt install cmark\n```\n\n## License\ncmark-scala is licensed under the terms of the Apache v2.0 license. Its function interfaces and comments were derived from `cmark.h`, which is licensed under BSD-2-Clause.\n\n## Authors\n* Tim Nieradzik\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsetech%2Fcmark-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparsetech%2Fcmark-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsetech%2Fcmark-scala/lists"}