Exact round trips
Read source-positioned nodes and return the original bytes with Document#to_s. Untouched formatting is never regenerated.
Markdown editing for Ruby
Beid changes the exact source range you choose. Everything else—spacing, syntax, and structure—stays as the author wrote it.
# Title
Keep this *formatting*.
## Title
Keep this *formatting*.
Use the parse tree for targeted edits, while the original Markdown remains the source of truth.
Read source-positioned nodes and return the original bytes with Document#to_s. Untouched formatting is never regenerated.
Work with half-open byte ranges, Unicode columns, and LSP UTF-16 positions for editor integrations.
Replace, insert, remove, or move content. Each operation returns a new document, leaving the original unchanged.
Beid requires Ruby 3.1 or newer and has no runtime dependencies beyond the standard library.
gem install beid
require "beid"
source = "# Title\n\nKeep this *formatting*.\n"
document = Beid::Document.parse(source)
heading = document.root.children.first
updated = Beid::Editing.set_attribute(document, heading, :level, 2)
puts updated.to_s
Beid is an editing view, not an HTML renderer. Read the editing API and limits.