{"id":51120944,"url":"https://github.com/discourse/markbridge","last_synced_at":"2026-06-25T02:01:33.555Z","repository":{"id":348724617,"uuid":"1109260319","full_name":"discourse/markbridge","owner":"discourse","description":"Convert markup in multiple formats to Discourse-ready Markdown — via a predictable parse → AST → render pipeline.","archived":false,"fork":false,"pushed_at":"2026-06-10T16:21:53.000Z","size":1203,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-10T18:10:56.806Z","etag":null,"topics":["bbcode-parser","markdown","ruby"],"latest_commit_sha":null,"homepage":"https://markbridge.dev/","language":"Ruby","has_issues":false,"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/discourse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-03T15:00:15.000Z","updated_at":"2026-06-10T16:12:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/discourse/markbridge","commit_stats":null,"previous_names":["discourse/markbridge"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/discourse/markbridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmarkbridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmarkbridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmarkbridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmarkbridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discourse","download_url":"https://codeload.github.com/discourse/markbridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fmarkbridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34756206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"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":["bbcode-parser","markdown","ruby"],"created_at":"2026-06-25T02:01:32.597Z","updated_at":"2026-06-25T02:01:33.540Z","avatar_url":"https://github.com/discourse.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markbridge\n\nMarkbridge converts BBCode into Discourse-flavored Markdown through a clean parse → AST → render pipeline. It is intended for forum migrations and any workflow that needs predictable BBCode handling.\n\n## How it works\n\n1. **Parse BBCode** – `Markbridge::Parsers::BBCode::Parser` tokenizes input and builds an `AST::Document`, reconciling nesting and collecting raw content where needed.\n2. **Transform AST** – The AST captures semantic nodes such as text, formatting elements, lists, URLs, and code blocks that are renderer-agnostic.\n3. **Render to Markdown** – `Markbridge::Renderers::Discourse::Renderer` walks the tree with a tag library to emit Discourse-compatible Markdown, then normalizes spacing for final output.\n\nRefer to the component guides for more detail:\n\n* [BBCode parser](docs/parsers/bbcode.md)\n* [Discourse renderer](docs/renderers/discourse.md)\n\n## Installation\n\nAdd the gem to your project:\n\n```bash\nbundle add markbridge\n```\n\nOr install it directly:\n\n```bash\ngem install markbridge\n```\n\n## Quick start\n\n```ruby\nrequire \"markbridge/bbcode\"\n\nbbcode = \"[b]Hello[/b] [url=https://example.com]world[/url]!\"\nmarkdown = Markbridge.bbcode_to_markdown(bbcode)\n\nputs markdown\n# =\u003e \"**Hello** [world](https://example.com)!\"\n```\n\n## Configuration\n\n```ruby\nMarkbridge.configure do |config|\n  # Strip trailing spaces before newlines to prevent hard line breaks (\u003cbr/\u003e).\n  # Defaults to false (Discourse has this disabled by default).\n  config.escape_hard_line_breaks = true\nend\n```\n\nConfiguration applies to all `*_to_markdown` convenience methods (`bbcode_to_markdown`, `html_to_markdown`, etc.).\n\n## Learn more\n\n* See `examples/` for runnable scripts such as `examples/basic_usage.rb`.\n* Browse integration and unit coverage under `spec/` to understand supported tags and edge cases.\n* Use `bin/console` during development for interactive exploration.\n\n## Development\n\nThis repository is set up to run inside [silo](https://github.com/gschlager/silo), a lightweight dev-environment tool. The `.silo.yml` file provisions a Fedora container with JRuby and multiple CRuby versions (via [rv](https://rv.dev)), installs dependencies, and starts the playground daemon. If you prefer your own setup, `bin/setup` and `bundle install` are all you need.\n\n## Playground\n\nA local web UI for exploring parsers interactively:\n\n```bash\nbin/playground\n```\n\nOpen `http://127.0.0.1:4567` to select a parser (BBCode, HTML, TextFormatter XML, MediaWiki), pick an example, edit the input, and inspect the AST tree and Markdown output. Keyboard shortcuts: `1` Input, `2` Output, `3` AST, `Cmd/Ctrl+Enter` to render.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fmarkbridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscourse%2Fmarkbridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fmarkbridge/lists"}