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

exmarkdown-code-utility

Package Overview
Dependencies
Maintainers
0
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exmarkdown-code-utility

❏ Code utility plugin for svelte-exmarkdown

  • 3.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by57.14%
Maintainers
0
Weekly downloads
 
Created
Source

exmarkdown-code-utility

npm-version npm-license npm-download-month npm-min-size ci.yml website

❏ Code utility plugin for svelte-exmarkdown

Demo

This plugin adds the following utility to code section in svelte-exmarkdown

  • Code Copy Button
  • Show Filename
  • Code Highlighting by svelte-highlight

Installation

npm i exmarkdown-code-utility

Example

<script>
  import { codeUtility } from 'exmarkdown-code-utility'
  import { Markdown } from 'svelte-exmarkdown'
</script>

<Markdown
  plugins={[
    // ...
    codeUtility({
      // Plugin Options
    })
  ]}
/>

<style>
  .exmarkdown-code-filename {
    /* Style of Filename section (<div/>) */
  }
</style>

Full Plugin Options

This will result in the following conversions

Markdown

```html:filename
<!-- ... -->
```

HTML

<div class="exmarkdown-code-filename">filename</div>
<div>
  <button class="exmarkdown-code-copy"></button>
  <pre>
    <code>
      <!-- ... -->
    </code>
  </pre>
</div>

Code Highlighting

This plugin uses svelte-highlight for code highlighting.

Usage

  1. Enable the highlight option
<script>
  import { Markdown } from 'svelte-exmarkdown'
  import { codeUtility } from 'exmarkdown-code-utility'
</script>

<Markdown
  plugins={[
    codeUtility({
      highlight: true
    })
  ]}
/>
  1. Import the stylesheet

[!TIP] See svelte-highlight/styling for details.

<script>
  import 'exmarkdown-code-utility/styles/github.css'
</script>

or

<script lang="ts">
  import github from 'exmarkdown-code-utility/styles/github'
</script>

<svelte:head>
  {@html github}
</svelte:head>

[!CAUTION] > @html is dangerous.
If you need to switch dynamic styles, use of svelte-highlight-switcher is recommended to prevent unexpected accidents.

Migration from v2

Now internal using to svelte-code-copy for code copy button.

  • onCopy option has been merged into codeCopy.
  • codeButton option has been merged into copy.
  • Omit styling by exmarkdown-code-copy. Use instead codeCopy option.

License

MIT

Keywords

FAQs

Package last updated on 19 Jan 2025

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