New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-showdown-shiki

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-showdown-shiki

Adds Shiki syntax highlighting for showdown-based markdown code blocks.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-13.33%
Maintainers
0
Weekly downloads
 
Created
Source

ember-showdown-shiki

ember-showdown-shiki is a drop-in addon that automatically adds Shiki syntax highlighting to code blocks if you are using showdown to render your Markdown.

This addon also provides filename wrappers to the code block if a code block is marked with a data-filename attribute:

````gjs {data-filename=app/components/blog-post.gjs}
<template>
  <h1>{{@model.title}}</h1>
  <h2>by {{@model.author}}</h2>

  <div class="intro">
    {{@model.intro}}
  </div>
  <hr>
  <div class="body">
    {{@model.body}}
  </div>
</template>
``` 

You will also notice that the code sample has line numbers, this is built-in behaviour and they will be added to all code blocks.

This is also specifically designed to work in Node environments so that it can run effectively in Fastboot and prember 🎉 and as it is a drop-in addon it will automatically start working if added to any Empress projects, so it can be used to add syntax highlighting to your empress-blog if your template doesn't already provide syntax highlighting.

This addon is inspired by the great work of ember-showdown-prism.

Compatibility

  • Ember.js v4.8 or above
  • Embroider or ember-auto-import v2
  • Fastboot v4 or above
  • Prember v2 or above
  • Ember-cli-showdown v7 or above

Installation

ember install ember-showdown-shiki

Usage

When running this addon in Fastboot you have to configure the environment to make the globals used by Shiki available. To do this, create a config/fastboot.js with the following contents:

module.exports = function () {
  return {
    buildSandboxGlobals(defaultGlobals) {
      return Object.assign({}, defaultGlobals, {
        atob: atob,
      });
    },
  };
};

Configuration

In config/environment.js you can configure the following options:

module.exports = function (environment) {
  const ENV = {
    // Other options ...
    'ember-showdown-shiki': {
      theme: 'github-dark', // The theme to use for highlighting
      languages: ['javascript', 'handlebars'], // The languages to highlight
      colorReplacements: {
        '#24292e': '#1c1e24',
      }, // A map of colors to replace in the theme (see https://shiki.style/guide/theme-colors#color-replacements)
    },
  };
  return ENV;
};

By default the theme used is github-dark and all languages are loaded.

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 29 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc