Giter Site home page Giter Site logo

vue-lexer's Introduction

vue-lexer

Build Status

PyPI version

A Vue lexer for Pygments (based on jsx-lexer)

Installation

$ pip install vue-lexer

Usage with Sphinx

To use within Sphinx, simply specify vue for your code-block:

.. code-block:: vue

    <template>
      <p>{{ greeting }} World!</p>
    </template>

    <script>
    module.exports = {
      data: function () {
        return {
          greeting: 'Hello'
        }
      }
    }
    </script>

    <style scoped>
    p {
      font-size: 2em;
      text-align: center;
    }
    </style>

Usage with mkdocs

First, you need to create the CSS for the highlighting:

$ pygmentize -S default -f html -a .codehilite > code/pygments.css

Then, add the following to your mkdocs.yml:

markdown_extensions:
  - codehilite
extra_css: [pygments.css]

Now, you can use vue in your code blocks:

```vue
<template>
  <p>{{ greeting }} World!</p>
</template>

<script>
module.exports = {
  data: function () {
    return {
      greeting: 'Hello'
    }
  }
}
</script>

<style scoped>
p {
  font-size: 2em;
  text-align: center;
}
</style>
```

Examples

Example 1:

Example 2:

Example 3:

vue-lexer's People

Contributors

mjhea0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-lexer's Issues

Error matching a v-for directive.

Hey there,

thank you for this lexer.

I am currently writing my thesis and was looking for a way to make the Latex code listings look nice. I use the minted package which uses pygmentize itself. But so far, the output does not yet satisfy my requirements.

Here is an example code snippet, where the lexer falsely marks =" and " in the second v-for loop as an error.

<template>
    <svg viewBox="-200, -200, 400, 400">
        <g id="nodes">
            <circle 
                v-for="node in graph.nodes"
                :key="node.id"
                :x="node.x"
                :y="node.y"
                :r="getNodeRadius(node)"
            >
        </g>
        <g id="links">
            <line
                v-for="link in graph.links"
                :key="link.id"
                :x1="link.source.x"
                :x2="link.target.x"
                :y1="link.source.y"
                :y2="link.target.y"
                :style="getLinkStyle(link)"
            />
        </g>
    </svg>
</template>

๐Ÿ‘ GitHubs Lexer does a good job ;)

The wrong output line looks like this:

<span class="na">v</span><span class="nt">-for</span><span class="err">=&quot;</span><span class="na">link</span> <span class="na">in</span> <span class="na">graph.links</span><span class="err">&quot;</span>

Bildschirmfoto 2019-10-19 um 12 29 03

I attached the full HTML output (as txt, Github doesnt support HTML ๐Ÿ˜ฉ).
test.txt

Cheers,
Lukas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.