Skip to content

Latest commit

 

History

History
189 lines (122 loc) · 6.08 KB

README.md

File metadata and controls

189 lines (122 loc) · 6.08 KB

Gitpod ready-to-code

Maintainer notes:

Markdown to email template generator

This simple and light tool generates email template from markdown. The command is npm run parse. The path to markdown file must be ./source/source.md, and output directory is generated/newEmail.html.

We tried to create our own wheel, then we failed. Arthur get bored trying to fix it and make it work properly. So he just decide to google a working version that can solve his problems.

Story: 0. I find this link https://gist.github.com/jbroadway/2836900

  1. then this link https://gist.github.com/budparr/112f08a3033dd878d0e271e2af61faef
  2. and then I added javascript into my google Search https://gist.github.com/renehamburger/12f14a9bd9297394e5bd
  3. then we tried different approaches, failed few times and find out how to fix some bugs.
  4. then I tried to google our repository and find out the latest version of this module - https://github.com/showdownjs/showdown
  5. then I find out that all template engines still sucks and decide to migrate "frontend" part to react
  6. i'm exploring the best known to me tools for markdown: remark and rehype. plus, as docusaurus using them and mdx format - we'll try it too

how to run a parser

yarn parse

if you need help with markdown - Great Online Preview tool https://dillinger.io/

Syntax

Parser uses no libraries, so it copies markdown syntax and based on opening tag generates email component (image, paragraph, subtitle, etc.). There is a list of existing tags:

Subject

#!

The subject of email, will be displayed in the email preview.

Preview text

#~

Preview text of email, will be displayed in the email preview.

Title

#

Title of email, by default at the top of email body.

Subtitle

##

Subtitle, can be seen anywhere in email body.

Sponsorship

~[content][href][src]

The first symbol should be tilde ~, and all other attributes should be not empty, or this will cause errors. src - absolute path to image or may be url, href - the link of sponsorship block, content - the text near the image (also link, wrapped in href). Where ever you place sponsorship block, it will be concatenated and parsed at the top and bottom of email body.

Image or GIF

![src][href][alt text]

The first symbol !, and all other attributes are required, or error will appear. src - absolute path to image or may be url, href - the link of image, alt text - the text, when image not rendered yet.

Paragraph

Default paragraph contains no special opening symbols, just straight text.

Link

[content](href)

Consist of two parameters - content, the text of the link and href - the url of link. Can be placed at default paragraph.

Divider

You may use empty line in email body, just in the markdown document leave line empty, it will be parsed as real line break.

Separator

add [separator]

Work principles

The parser reads source file from source/source.md and based on opening tag renders goes in layouts folder and chooses relevant typography or section (sponsorship) element. Supported tags displayed in this document.

mindmap

Reasons to use generator instead of pretending that human errors didnt exists(especially human reactions on deadlines)

oops

ooops2

Links

Stretch Goals (enchancements)

  • add html linter because it's hard to understand if everything is good or not

https://www.npmjs.com/package/eslint-plugin-html

we can use https://www.freeformatter.com/html-validator.html and see errors. not sure if they actually valid, but will be cool to pay attention to some of them

image

  • add links checker

image

good example is December/top1 newsletter

Check later:

"amazing tool that can solve a lot of issues": https://github.com/syntax-tree/mdast


https://www.npmjs.com/package//sanitize-html

https://www.npmjs.com/package/html-element-attributes

https://www.npmjs.com/package/html-tag

https://github.com/breakdance/breakdance

https://github.com/here-be/snapdragon

https://github.com/wooorm/html-element-attributes

https://www.npmjs.com/package/element-mold


https://www.npmjs.com/package/yargs

https://www.npmjs.com/package/commander




Cool projects to see