{"id":25806020,"url":"https://github.com/alipsa/mdr","last_synced_at":"2026-06-05T21:31:59.015Z","repository":{"id":57742894,"uuid":"325057309","full_name":"Alipsa/mdr","owner":"Alipsa","description":"Render mdr files as html","archived":false,"fork":false,"pushed_at":"2022-08-16T17:33:37.000Z","size":123,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-01T11:27:02.888Z","etag":null,"topics":["r-package","renjin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"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/Alipsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Alipsa"]}},"created_at":"2020-12-28T16:12:03.000Z","updated_at":"2024-05-01T11:27:02.889Z","dependencies_parsed_at":"2022-09-11T09:41:14.653Z","dependency_job_id":null,"html_url":"https://github.com/Alipsa/mdr","commit_stats":null,"previous_names":["pernyfelt/mdr2html"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fmdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fmdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fmdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fmdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alipsa","download_url":"https://codeload.github.com/Alipsa/mdr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241052529,"owners_count":19901043,"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":["r-package","renjin"],"created_at":"2025-02-27T19:52:40.897Z","updated_at":"2026-06-05T21:31:58.955Z","avatar_url":"https://github.com/Alipsa.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Alipsa"],"categories":[],"sub_categories":[],"readme":"# mdr\nA [Renjin](https://github.com/bedatadriven/renjin) package (extension) to render mdr files as markdown, html, or pdf\n\nThe *mdr* file format is somewhat similar to *rmd* (r markdown) in the sense that it enables enhancing markdown with r code to support\n[reproducible research](https://en.wikipedia.org/wiki/Reproducibility#Reproducible_research_method); but\nwhere rmd relies on knitr and \"magic rules\" for what and especially how to render r code, mdr puts the responsibility\nto generate markdown text from r code on you - and using the [r2md](https://github.com/perNyfelt/r2md) package\nthis becomes quite a pleasant experience giving you lots of control and power.\n\nThe mdr package is essentially a package (Renjin extension) that processes mdr text or files and produces html. \nThis is used in the [Munin](https://github.com/perNyfelt/munin) reports server to support mdr files as one of its supported report formats.\n\nUse the method `parseMdr()` to parse a mdr character vector (string), a mdr file, or a list of mdr lines into a r2md::Markdown object.\nTypically, you will use the `renderMdr()` to parse and render the mdr content into html (or markdown by adding the outputType parameter, \ne.g. `renderMdr(mdrFile, outputType=\"markdown\"`). Valid outputTypes are `html` (default), `markdown`, and `pdf`.\n\nTo use it, add the following dependency to your pom.xml\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ese.alipsa\u003c/groupId\u003e\n    \u003cartifactId\u003emdr\u003c/artifactId\u003e\n    \u003cversion\u003e1.5.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Example\nGiven a mdr document with the following content:\n\n````\n# Summary\n```{r}\nmd.add(summary(mtcars$qsec))\nmd.content()\n```\nHow about that?\n````\n...the code: `html \u003c- renderMdr(rmd)` will make the html variable contain the following html:\n```html\n\u003ch1\u003eSummary\u003c/h1\u003e\n\u003ctable\u003e\n    \u003cthead\u003e\n      \u003ctr\u003e\u003cth\u003eVar1\u003c/th\u003e\u003cth\u003eFreq\u003c/th\u003e\u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\u003ctd\u003eMin.\u003c/td\u003e\u003ctd\u003e14.5\u003c/td\u003e\u003c/tr\u003e\n        \u003ctr\u003e\u003ctd\u003e1st Qu.\u003c/td\u003e\u003ctd\u003e16.892\u003c/td\u003e\u003c/tr\u003e\n        \u003ctr\u003e\u003ctd\u003eMedian\u003c/td\u003e\u003ctd\u003e17.71\u003c/td\u003e\u003c/tr\u003e\n        \u003ctr\u003e\u003ctd\u003eMean\u003c/td\u003e\u003ctd\u003e17.849\u003c/td\u003e\u003c/tr\u003e\n        \u003ctr\u003e\u003ctd\u003e3rd Qu.\u003c/td\u003e\u003ctd\u003e18.9\u003c/td\u003e\u003c/tr\u003e\n        \u003ctr\u003e\u003ctd\u003eMax.\u003c/td\u003e\u003ctd\u003e22.9\u003c/td\u003e\u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eHow about that?\u003c/p\u003e\n```\n(Note: indentation above added to clarity, the actual result does not indent the html code)\n\nYou can do whatever you like in the R code block but whatever is returned from the block (the last expression) is \nassumed to be the markdown to render into html. So if you do:\n````\n# Summary\n```{r}\nmd.add(mtcars, attr=list(class=\"table\")\nmd.content()\n\"How about that?\"\n```\n````\n\n...none of the markdown code for mtcars will be run, the Markdown content that *will* be added is `\"How about that?\"`.\nHowever, the code is still executed and since the session for subsequent code blocks is the same, md.content() will\nstill contain the mtcars data.frame if you set the subsequent code block option `initialize=FALSE` and not start that \nsubsequent code block with md.clear() or md.new() - then it will be truly lost.\n\nSo to summarise the key [r2md](https://github.com/perNyfelt/r2md) methods:\n- md.new(x): begin a new markdown text\n- md.add(x): append to the existing markdown text or start a new one if there was none before. The content can be text,\na data.frame or matrix, a t-test etc.\n- md.plot({x}): append a series of plot commands \n- md.clear(): removes the content of an existing markdown text or creates a new one if none existed before\n\nwhere x is the content to add\n\n## Configuration\nThe following code block options are supported:\n\n- **echo**: Output the code before the result is outputted, defaults to FALSE \n- **eval**: Whether to run the code or not, defaults to TRUE\n- **include**: Whether the results of the evaluation should be outputted or not, defaults to TRUE\n- **initialize**: Whether a code block should \"start fresh\" i.e. with md.clear() automatically or not, defaults to TRUE\n\nExample:\n````\n# Summary\n```{r echo=TRUE}\nmd.add(summary(mtcars$qsec))\n\n# Return the markdown, technically md.add() and md.new() does that as well so we could have skipped the next line\nmd.content()\n```\n````\nThis results in\n````html\n\u003ch1\u003eSummary\u003c/h1\u003e\n\u003cpre\u003e\u003ccode\u003e\n```{r echo=TRUE}\nmd.add(summary(mtcars$qsec))\n```\n\u003c/code\u003e\u003c/pre\u003e\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\u003cth\u003eVar1\u003c/th\u003e\u003cth\u003eFreq\u003c/th\u003e\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003eMin.\u003c/td\u003e\u003ctd\u003e14.5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e1st Qu.\u003c/td\u003e\u003ctd\u003e16.892\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eMedian\u003c/td\u003e\u003ctd\u003e17.71\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eMean\u003c/td\u003e\u003ctd\u003e17.849\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e3rd Qu.\u003c/td\u003e\u003ctd\u003e18.9\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eMax.\u003c/td\u003e\u003ctd\u003e22.9\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n````\n\nFor multiple option, just separate them with comma, e.g:\n\n\\`\\`\\`{r echo=TRUE, include=FALSE}\n\nNote that if you set eval to FALSE, the 'include' parameter is ignored. \nSetting include to TRUE makes no sense in that case and will just be ignored as it has no meaning.\n\n[Here is an example](https://github.com/perNyfelt/mdr2html/blob/main/src/test/resources/research.mdr) of a mdr report.\n\nSee the [tests](https://github.com/perNyfelt/mdr2html/blob/main/src/test/R/Mdr2htmlTest.R) for more usage details.\n\n# Version History\n\n### Ver 1.5.3\n\n### Ver 1.5.2, Aug 16, 2022\n- upgrade maven plugins\n- upgrade to r2md 1.0.4\n- require java 11\n\n### Ver 1.5.1, Jan 17, 2022\n- Change default behavior of code blocks to default to do md.clear() in the beginning unless the `initialize` option\nis set to FALSE (i.e. the old behavior).\n\n### Ver 1.5.0, Dec 27, 2021\n- upgrade r2md to 1.0.3 to add support for `htest` classes\n- rename package to mdr\n- add support for pdf output\n\n### Ver 1.4.0, Dec 8, 2021\n- upgrade r2md to 1.0.1 to add the md.addPlot function for more versatile plotting.\n- switch to 3 position version scheme so bumping version to the 1.4.x range\n\n### Ver 1.3, Jan 31, 2021\n- add highlightJs code formatting\n\n### Ver 1.2, Jan 24, 2021\n- Remove dependency on htmlcreator\n- Add versions plugin with rules excluding beta versions\n- Add maven enforcer plugin to require minimum maven version\n\n### Ver 1.1, Jan 10, 2021\nRemove direct rendering to html with html.add and change to render into markdown and then to html.\nparseMdr now returns a r2md::Markdown object, use renderMdr to get either html (default) or markdown content.\n\n### Ver 1.0, 2021-Jan-08\n- Initial release","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Fmdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falipsa%2Fmdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Fmdr/lists"}