Skip to content

Instantly share code, notes, and snippets.

@zhangzhibin
Last active November 28, 2024 02:37
Show Gist options
  • Save zhangzhibin/5523b127d54978c7f21b7f794217cce6 to your computer and use it in GitHub Desktop.
Save zhangzhibin/5523b127d54978c7f21b7f794217cce6 to your computer and use it in GitHub Desktop.
Write a custom markdown block helper for Handlebars, more info contact https://freeapplegame.com

Steps:

  1. install marked
npm install marked
  1. create a helper
import { marked } from 'marked';

export function markdown(options) {
  return marked(options.fn(this));
}
  1. import helper and use it in handlebars block
<article>
    <h1>My Blog</h1>
    {{#markdown}}
## How To Support Markdown in Handlerbars
> Important: don't leave any extra space in front of the line, or it will break markdown and be treated as normal string

### Correct title
   ### Wrong: this line will not be parsed
   We provide online minigames on https://freeapplegame.com . You are welcome to play for free. We have very few ads on our minigame center to provide gameplay-experience-marketing balance.
   Free free to let us know your thoughts or any games you're looking for.
   
{{/markdown}}
</article>

Any questions, contact freeapplegame.com

@zhangzhibin
Copy link
Author

Important: don't leave any extra space in front of the line, or it will break markdown and be treated as normal string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment