npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-katex-auto-render

v0.2.0

Published

A KaTeX auto render library for vue directive.

Downloads

669

Readme

Vue KaTeX Auto-render

KaTeX enables fast math typesetting for the web. Vue KaTeX Auto-render is a plugin to help you use KaTeX together with auto-render extension of KaTeX.

License: MIT

Requirements

Vue 2.x

Installation

npm install --save vue-katex-auto-render

Make it work with Vue

You have to import it and register it as a custom directive.

import Katex from 'vue-katex-auto-render'
Vue.directive('katex', Katex);

Usage

You can use the v-katex directive on any element of your template. And then put the content that you expect KaTeX to deal within some delimiters. The delimiters is a list of delimiters to look for math. Each delimiter has three properties:

  • left: A string which starts the math expression (i.e. the left delimiter).
  • right: A string which ends the math expression (i.e. the right delimiter).
  • display: A boolean of whether the math in the expression should be rendered in display mode or not.

The default value of delimiters for Vue KaTeX Auto-render is:

[
  {left: "$$", right: "$$", display: true},
  {left: "$", right: "$", display: false},
  {left: "\\(", right: "\\)", display: false},
  {left: "\\[", right: "\\]", display: true}
]

Any content within given delimiters in the tags with v-katex marked will then be treated as something need to be processed by KaTeX.

For example,

<template>
  <div v-katex>
    $$% Here is some comment
    f({x}) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi$$
  </div>
</template>

The code above will have the following as an output.

image

More Configurations

You may also pass some configurations to customize the result. For example, if you only want to support rendering KaTeX within same mark like [KaTeX_start]...[Katex_end] you can do something like:

<template>
  <div v-katex="options">
    [KaTeX_start]f({x}) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi[KaTeX_end]
  </div>
</template>
<script>
export default {
  data: function() {
    return {
      options: {
        delimiters: [
          {left: "[KaTeX_start]", right: "[KaTeX_end]", display: true}
        ]
      }
    };
  }
}
</script>

Beside the option of delimiters, you can set ignoredTags, ignoredClasses, errorCallback, preProcess, etc as you need. You may refer to document of Auto-render Extension for further descriptions of the these options.

License

Vue KaTeX Auto-render is released under the MIT license.