{"id":15013656,"url":"https://github.com/robertmyles/writemdx","last_synced_at":"2025-04-12T05:45:18.691Z","repository":{"id":111840973,"uuid":"186700840","full_name":"RobertMyles/writeMDX","owner":"RobertMyles","description":"writes RMarkdown (.Rmd) files to MDX (.mdx) format. Used for R ➡️  RMarkdown ➡️ Markdown ➡️ MDX ➡️ JS ➡️ Gatsby blog","archived":false,"fork":false,"pushed_at":"2020-02-29T14:47:11.000Z","size":21,"stargazers_count":29,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T05:45:09.082Z","etag":null,"topics":["gatsbyjs","jsx","markdown","mdx-js","r","react","rmarkdown"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobertMyles.png","metadata":{"files":{"readme":"README.Rmd","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":"2019-05-14T21:09:07.000Z","updated_at":"2024-03-28T02:24:40.000Z","dependencies_parsed_at":"2023-04-15T02:30:59.698Z","dependency_job_id":null,"html_url":"https://github.com/RobertMyles/writeMDX","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"1f5561997f18186b12ac6b467d4c0b4cc1ba6b35"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertMyles%2FwriteMDX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertMyles%2FwriteMDX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertMyles%2FwriteMDX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobertMyles%2FwriteMDX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobertMyles","download_url":"https://codeload.github.com/RobertMyles/writeMDX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525154,"owners_count":21118616,"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":["gatsbyjs","jsx","markdown","mdx-js","r","react","rmarkdown"],"created_at":"2024-09-24T19:44:37.195Z","updated_at":"2025-04-12T05:45:18.666Z","avatar_url":"https://github.com/RobertMyles.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n# writeMDX :japanese_ogre:\n\n`writeMDX` writes Rmarkdown (`.Rmd`) files to [MDX](https://github.com/mdx-js/mdx). Nice and simple :sunglasses:\n\n## Install :open_hands:\n\nYou can install it with `remotes::install_github(\"RobertMyles/writeMDX\")`.\n\n## Use :point_down:\n\nWith a file named \"heyho.Rmd\":\n\n```{r eval=FALSE}\nwriteMDX(\"heyho.Rmd\")\n```\n\nIf you'd like to use it from the command line, first run `writeMDX::cli()`. Then it's just:\n\n```{bash eval = FALSE}\nwriteMDX heyho.Rmd\n```\n\n\nwriteMDX has a few defaults that are set up for me, but you can easily change them. The `config` argument accepts a list of two named lists: `inlcude` and `exclude`. These are the fields you'd like to remove, or for which you want to check for inclusion on the YAML header. The command line version isn't set up to take anything other than the defaults yet.  \n\n## Example\n\nI use this for my blog, for example [here](https://www.robertmylesmcdonnell.com/content/posts/UKelections2019/). \n\n\nMy workflow for my website is usually: \n\n- Open up new Rmarkdown document in RStudio;\n- Write something kewlz about R;\n- Do some repetitive boring stuff to get it into a suitable format for rendering with [Gatsby.js](https://www.gatsbyjs.org/).  \n\nwriteMDX helps with that last part. Let's say we open up a new .Rmd in RStudio, it will look like this in the YAML header (unless you use a template or some other format): \n\n```\n---\ntitle: \"MDXtest\"\nauthor: \"Robert McDonnell\"\ndate: \"2/29/2020\"\noutput: html_document\nfeaturedImage: \"image/png.png\"\n---\n```\nWell, it probably won't say `\"Robert McDonnell\"`, but you get the idea. `featuredImage` I put in. \n\nSo that's all fine, but the MDX that I use to include React on my Gatsby-powered blog has this YAML header:\n\n```\n---\ntitle: \"MDXtest\ndate: \"2020-02-29\"\nfeaturedImage: \"images/some_image.png\"\n---\n```\n\nChanging this manually every time I want to blog about something gets pretty old pretty quickly. So I use writeMDX, which will convert the former to the latter. It also creates a proper MDX document that follows pandoc's [markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) spec. So a full RMarkdown might be this (ignore the `#` at the code chunks, just for formatting the README correctly): \n\n```\n---\ntitle: \"MDXtest\"\nauthor: \"Robert McDonnell\"\ndate: \"2/29/2020\"\noutput: html_document\nfeaturedImage: \"image/png.png\"\n---\n\n#```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE)\n#```\n\n## writeMDX test\n\nThis is a test document for writeMDX. It has **bold**, *italic*  \n\n- lists \n  - sublists\n- and so on\n\nIt also has equations $y_{ij} = \\alpha_j * beta_i$\n\n$$y_{ij} = \\alpha_j * beta_i$$\n\nAnd it has code. For R:\n#```{r}\nx \u003c- 5\nprint(x)\n\nprint(head(mtcars))\n#```\n\nAnd Python: \n#```{python}\nx = 3\nprint(x)\n#```\n```\n\nAnd the MDX resulting from writeMDX will be: \n\n```\n---\ntitle: \"MDXtest\"\ndate: '2020-02-29'\nfeaturedImage: \"image/png.png\"\n---\n\nwriteMDX test\n-------------\n\nThis is a test document for writeMDX. It has **bold**, *italic*\n\n-   lists\n    -   sublists\n-   and so on\n\nIt also has equations $y_{ij} = \\alpha_j * beta_i$\n\n$$y_{ij} = \\alpha_j * beta_i$$\n\nAnd it has code. For R:\n\n#``` {.r}\nx \u003c- 5\nprint(x)\n#```\n\n    ## [1] 5\n\n#``` {.r}\nprint(head(mtcars))\n#```\n\n    ##                    mpg cyl disp  hp drat    wt  qsec vs am gear carb\n    ## Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4\n    ## Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4\n    ## Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1\n    ## Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1\n    ## Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2\n    ## Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1\n\nAnd Python:\n\n#``` {.python}\nx = 3\nprint(x)\n#```\n\n    ## 3\n```\n\nIt's not perfect, as you can see. The indentations could be removed, emojis work differently, and equations need a different set up. These are on my [to-do list](https://github.com/RobertMyles/writeMDX/projects/1); they may or may not get done. If you'd like to make a PR for any of these, feel free. \n\n\n## Why?? :confused:\n\nI love [React](https://reactjs.org/), and I just rebuilt my [website](https://www.robertmylesmcdonnell.com/) using [gatsby.js](https://www.gatsbyjs.org/), so now I want all the ease and power of MDX. The only missing piece of the puzzle was doing some stuff in R, and then writing it out to an `.mdx` file that I can use to add in all the other stuff I want, like D3 graphs. R + React + Markdown = :purple_heart: \n\n## No CRAN? :cry:\n\nThis won't go on CRAN, since it's mainly [rmarkdown package](https://rmarkdown.rstudio.com/) functions with an added format, which you can do yourself [quite easily](https://bookdown.org/yihui/rmarkdown/format-custom.html).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertmyles%2Fwritemdx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertmyles%2Fwritemdx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertmyles%2Fwritemdx/lists"}