require "commonmarker" class DocumentRenderer DOCUMENTS = { legal: "legal.md", statutes: "statutes.md" }.freeze def self.render(name) filename = DOCUMENTS.fetch(name) path = File.expand_path("../doc/#{filename}", __dir__) markdown = File.read(path, encoding: "UTF-8") Commonmarker.to_html( markdown, options: { render: { hardbreaks: false, unsafe: false } } ) end end