{"id":13721528,"url":"https://github.com/MarcL/markdown-to-mailchimp","last_synced_at":"2025-05-07T13:33:07.885Z","repository":{"id":37878602,"uuid":"160959566","full_name":"MarcL/markdown-to-mailchimp","owner":"MarcL","description":"Create Mailchimp newsletters using Markdown","archived":false,"fork":false,"pushed_at":"2023-01-06T02:15:51.000Z","size":2173,"stargazers_count":15,"open_issues_count":12,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-04T08:19:17.572Z","etag":null,"topics":["email","mailchimp","markdown","mjml"],"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/MarcL.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2018-12-08T16:54:46.000Z","updated_at":"2025-03-30T18:44:13.000Z","dependencies_parsed_at":"2023-02-05T02:46:11.194Z","dependency_job_id":null,"html_url":"https://github.com/MarcL/markdown-to-mailchimp","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcL%2Fmarkdown-to-mailchimp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcL%2Fmarkdown-to-mailchimp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcL%2Fmarkdown-to-mailchimp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcL%2Fmarkdown-to-mailchimp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcL","download_url":"https://codeload.github.com/MarcL/markdown-to-mailchimp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252887108,"owners_count":21819849,"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":["email","mailchimp","markdown","mjml"],"created_at":"2024-08-03T01:01:18.247Z","updated_at":"2025-05-07T13:33:07.578Z","avatar_url":"https://github.com/MarcL.png","language":"JavaScript","funding_links":[],"categories":["Github Repositories"],"sub_categories":["GitHub repositories related to email marketing"],"readme":"# Markdown To Mailchimp\n\n\u003e Create Mailchimp newsletters using Markdown\n\n**Note: This is still a Work In Progress**\n\n## Why?\n\nWriting emails in Mailchimp's WYSIWYG editor can be a pain. This library allows you to write Mailchimp campaign emails using [Markdown](https://en.wikipedia.org/wiki/Markdown) and format your emails using [MJML](https://mjml.io/) to create beautiful HTML emails. It offers both a command line (CLI) tool and a Node.js library.\n\n## Install\n\nUse `npm` or `yarn` to install the package:\n\n```bash\nnpm install markdown-to-mailchimp\n```\n\n_or_\n\n```bash\nyarn add markdown-to-mailchimp\n```\n\n## Usage\n\nThis library exposes a command line tool and a Node library.\n\n### CLI\n\n```bash\nmd2mc [options]\n```\n\n| Command | Description |\n| ------- | ----------- |\n| -m, --markdown | Path to markdown file to convert. |\n| -t, --template | Path to MJML email template file. |\n| -o, --output | _(Optional)_ Output directory to write HTML email to. |\n| -a, --apikey | _(Optional)_ Mailchimp API key. Also uses `MAILCHIMP_API_KEY` environment variable if set. |\n| -l, --listid | _(Optional)_ Mailchimp list ID. Also uses `MAILCHIMP_LIST_ID` environment variable if set. |\n| -k, --keeptags | _(Optional)_ Keep Mailchimp merge tags when converting from markdown to HTML. Defaults to `true`. |\n| -h, --help | _(Optional)_ Display help. |\n| --version | _(Optional)_ Display version number. |\n\n\n### Library\n\nImport the library:\n\n```js\n// CommonJS\nconst markdownToMailchimp = require('markdown-to-mailchimp');\n\n// OR for ESModules\nimport markdownToMailchimp from 'markdown-to-mailchimp';\n```\n\nCall the function with an object of expected parameters:\n\n```js\nconst options = {\n    // Mandatory\n    markdown: './path/to/markdown/file.md',\n    template: './path/to/mjml/template.mjml',\n\n    // Optional\n    keeptags: true,\n    output: './directory/to/output/html/to/'\n\n    // Optional if you want a Mailchimp campaign to be created\n    // The Mailchimp list ID can also be set as frontmatter in your markdown email\n    apikey: 'mailchimp-api-key',\n    listid: 'mailchimp-list-id',\n};\n\n// Returns a promise so you can use async/await or promises\n// to wait for a response\nconst data = await markdownToMailChimp(options);\n```\n\n### Emails in Markdown\n\nYour email should be created using Markdown in either the [CommonMark](https://spec.commonmark.org/0.29/) or [GitHub Flavoured](https://github.github.com/gfm/) markdown.\n\nThe parser allows for YAML frontmatter to be added to your markdown file, as you would when using a tool like [Jekyl](https://jekyllrb.com/docs/front-matter/). This frontmatter can contain any data you want to inject into your MJML template.\n\nIf you plan to create the Mailchimp campaign in addition to rendering an HTML template, you'll need the following frontmatter set in your markdown:\n\n* **subject** - The email campaign subject\n* **preview** - The email preview text\n* **title** - The title of the campaign\n* **fromName** - The name of the person that is sending the email\n* **replyTo** - The email address to reply to\n* **listId** - (Optional) Mailchimp List (Audience) identifier. If this is not set then the list ID should be passed in the `options` or as the `MAILCHIMP_LIST_ID` environment variable.\n\nYou can use [Mailchimp merge tags](https://mailchimp.com/help/all-the-merge-tags-cheat-sheet/) in your markdown but ensure that you set the `keeptags` option when converting. This allows you to keep a tag such as `*|MC:DATE|*` without it being converted to italic text.\n\nSee an example [here](./examples/markdown/test.md).\n\n### MJML Templates\n\nOnce the markdown is converted to HTML, it's injected into an MJML template. This template is converted using the [Handlebars](https://handlebarsjs.com/) templating language. This allows you to pass through any of your frontmatter variables using the `{{frontmatter.yourVariable}}` format. The markdown HTML content is given as the `{{content}}` variable.\n\nSee an example [here](./examples/templates/testTemplate.mjml).\n\n## Mailchimp Campaigns\n\nThis library will create a new campaign for you if no campaign already exists with the same title and subject. If it already exists then it updates with the new HTML, unless the campaign has either the `sent` (already delivered) or `sending` (for automations) status.\n\n## TODO\n\n* Ensure conversion allows all use of Mailchimp tags\n* Validate expected frontmatter for Mailchimp\n* Allow different campaign types\n* Sanitise output of Markdown conversion - use [Sanitize](https://github.com/apostrophecms/sanitize-html)?\n* Tests!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarcL%2Fmarkdown-to-mailchimp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMarcL%2Fmarkdown-to-mailchimp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarcL%2Fmarkdown-to-mailchimp/lists"}