{"id":16015023,"url":"https://github.com/kiranshila/cybermonday","last_synced_at":"2025-04-12T13:34:55.477Z","repository":{"id":40382993,"uuid":"264554335","full_name":"kiranshila/cybermonday","owner":"kiranshila","description":"Markdown as Clojure Data","archived":false,"fork":false,"pushed_at":"2024-10-10T20:11:55.000Z","size":1090,"stargazers_count":106,"open_issues_count":7,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-15T15:23:27.881Z","etag":null,"topics":["ast","clojure","clojurescript","commonmark","markdown"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiranshila.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-17T00:32:34.000Z","updated_at":"2024-08-23T01:09:27.000Z","dependencies_parsed_at":"2023-12-11T23:25:18.732Z","dependency_job_id":"359d616d-7077-468e-9aaf-2cea399ebe52","html_url":"https://github.com/kiranshila/cybermonday","commit_stats":{"total_commits":176,"total_committers":8,"mean_commits":22.0,"dds":"0.17613636363636365","last_synced_commit":"feb47d27c94a6db8c9a2b415bc9ed24307275a5a"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranshila%2Fcybermonday","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranshila%2Fcybermonday/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranshila%2Fcybermonday/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranshila%2Fcybermonday/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiranshila","download_url":"https://codeload.github.com/kiranshila/cybermonday/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573735,"owners_count":21126893,"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":["ast","clojure","clojurescript","commonmark","markdown"],"created_at":"2024-10-08T15:05:56.520Z","updated_at":"2025-04-12T13:34:55.458Z","avatar_url":"https://github.com/kiranshila.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cybermonday\n\n\u003e What if markdown was _just data_\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/kiranshila/cybermonday/main.yml?branch=master)\n[![codecov](https://codecov.io/gh/kiranshila/cybermonday/branch/master/graph/badge.svg?token=U0130A9B8Y)](https://codecov.io/gh/kiranshila/cybermonday)\n[![Clojars Project](https://img.shields.io/clojars/v/com.kiranshila/cybermonday.svg)](https://clojars.org/com.kiranshila/cybermonday)\n[![cljdoc badge](https://cljdoc.org/badge/com.kiranshila/cybermonday)](https://cljdoc.org/d/com.kiranshila/cybermonday/CURRENT)\n\nCybermonday provides a Clojure(Script) interface to working with markdown as a hiccup AST. Beyond CommonMark, GFM tables, tasklists and a few other features are added. A default implementation is provided to transform this markdown IR to HTML hiccup for rendering.\n\nTry it out here on the [test app](https://kiranshila.github.io/cybermonday-test-app/)!\n\n## Usage\n\nSimply add this library to your Clojure(Script) project, grab some markdown as a string (or as an opened reader (JVM)), and run\n\n```clojure\n(cybermonday.core/parse-md my-markdown)\n```\n\nto get an HTML hiccup representation of your markdown.\n\nIf you want the IR directly:\n\n```clojure\n(cybermonday.ir/md-to-ir my-markdown-str)\n```\n\nExtending the lowering step is easy, with an options map provided to set default attributes for the HTML tags and custom lowering fns.\nFor example, say we want to use a react component from Reagent to render math and make all paragraph tags use my custom class. This is as simple as\n\n```clojure\n(ns main.core\n  (:require\n   [cybermonday.core :as cm]\n   [\"@matejmazur/react-katex\" :as TeX]))\n\n(defn lower-inline-math [[_ _ math]]\n  [:\u003e TeX {:math math}])\n\n(cm/parse-md markdown {:default-attrs {:p {:class [\"my-class\"]}}\n                       :lower-fns {:markdown/inline-math lower-inline-math}}\n```\n\n## Ecosysytem Compatibility\n\nAs of 0.6.x, cybermonday supports compilation to a native-image with GraalVM! See [the cli example](https://github.com/kiranshila/cybermonday-cli-graal) for more information.\n\nWe also support CLJS/NBB.\n\n## Motivation\n\nI've been frustrated with the space of Markdown manipulation in Clojure. Most\nlibraries provide parsing to raw html, which is fine if you have a\nstraightforward way to include that in whatever you are targeting. If however,\nyou would want to manipulate the AST of the markdown directly, or convert it\ninto a format that frontend frameworks (like Reagent) can consume, you would\nhave to convert the HTML to clojure data (like Hiccup). There are a few html to\nhiccup parsers, but as anyone who has tried to parse html will tell you, there\nare edge cases that can break the whole thing. It also seems backwards to go\nfrom markdown to html to hiccup to html when you consider the entire rendering\npipeline.\n\nTo overcome this, I wrote `cybermonday`! It was originally going to be a parser\nfor blackfriday markdown, but as I realized the markdown spec is insane, it made\nmore sense to wrap the excellent Flexmark (java) and Remark (js) markdown parsers. At the\nmost basic level, `cybermonday` provides a top level function `parse-md`\nthat gives you a nice, reagent-renderable representation of your source. This\nincludes all of the CommonMark spec as well as the best features of popular extensions such as tables,\nstrikethroughs, footnotes, math, and more! This\neven supports inline html and html around markdown-formated text.\n\nHowever, `cybermonday` also provides access to a hiccup representation of the\nFlexmark (and remark) AST and the methods to provide the final pass transformation from\nthis intermediate representation to HTML. This allows the user to customize how the raw markdown AST\ngets transformed into html, allowing for easy extension and customization.\n\nI'm using this library on my blog at kiranshila.com - please let me know if you\nrun into any issues.\n\nFor more details, check out the docs!\n\n## Major Caveats\n\nThe inline html parser is really rudimentary. Please be gentle. They pretty much must follow the `\u003ctag foo=\"bar\"\u003e Content \u003c/tag\u003e` syntax to be properly rendered.\n\nAnother breaking example is if the attributes of a tag contain `=` in the value of the attribute. I'm splitting the attributes up by the `=`, so any random `=` that doesn't separate the key and the value will break the parser.\n\n## JVM Compat\n\nFlexmark now has a hard dependency on Java 11 - for which is carried over here. If you need Java 8, pin the flexmark deps to 0.62.2\n\n## License\n\nCopyright © 2023 Kiran Shila\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranshila%2Fcybermonday","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiranshila%2Fcybermonday","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranshila%2Fcybermonday/lists"}