
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
marked-filter-blocks
Advanced tools
A plugin for marked that lets you conditionally exclude blocks of markdown content using custom handlebars-style tags.
A plugin for marked that lets you conditionally exclude blocks of markdown content using custom handlebars-style tags. Useful for rendering different output for platforms like a website vs. a newsletter — from the same markdown source.
Sometimes your content lives in one place and needs to show up differently depending on where you use it.
Think:
Instead of maintaining multiple markdown files or duplicating content, you can write once using block tags like:
{{#newsletter}}Only for email readers.{{/newsletter}}
{{#website}}Extra info for the web version.{{/website}}
Then render conditionally using marked-filter-blocks, depending on where you're publishing.
pnpm add marked-filter-blocks
npm i --save marked-filter-blocks
Given this markdown:
This is shared content.
{{#website}}
This only shows on the website.
{{/website}}
{{#newsletter}}
This only shows in the newsletter.
{{/newsletter}}
And this code:
import { marked } from 'marked';
import markedFilterBlocks from 'marked-filter-blocks';
marked.use(markedFilterBlocks({ without: ['newsletter'] }));
const output = marked(markdownSource);
The output will exclude the newsletter block but include and parse everything else.
<p>This is shared content.</p>
<p>This only shows on the website.</p>
It supports both block-level and inline-level filtering:
Hello from the {{#website}}website{{/website}}{{#newsletter}}newsletter{{/newsletter}}!
Will output:
<p>Hello from the website!</p>
markedFilterBlocks(options?: {
without?: string[] | string | null;
});
Property | Type | Required? | Description | Default |
---|---|---|---|---|
without | String | String[] | The block names you want to exclude. All blocks are included by default. | null |
{{#blockname}}
Some markdown content
{{/blockname}}
Nested block syntax is not supported — block names must be flat and balanced.
MIT License - fork, modify and use however you want.
FAQs
A plugin for marked that lets you conditionally exclude blocks of markdown content using custom handlebars-style tags.
We found that marked-filter-blocks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.