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

markdown-hljs

v0.1.11

Published

markdown with code highlight

Downloads

25

Readme

This build on top of marked and highlightjs

So you markdown with code syntax highlighting version 0.1.1

installation

npm i markdown-hljs

cdn link

<script src="https://cdn.jsdelivr.net/npm/markdown-hljs"></script>

SVLETE REPL DEMO

SVLETE REPL DEMO with liquidjs

Docs

  • not that needed you just have to understand markdown
  • for code syntax hightlighting you need to import a theme
  • if you wanted to declare a variable:
    • $CAPS= any - they are not visible
    • eg: $NAME= MyName
    • can be access anywhere in the markdown as: {$NAME}
  • by default it will be able to highlight 35 common languages including svelte
["xml", "bash", "c", "cpp", "csharp", "css", "markdown", "diff", "ruby", "go", "ini", "java", "javascript", "json", "kotlin", "less", "lua", "makefile", "perl", "objectivec", "php", "php-template", "plaintext", "python", "python-repl", "r", "rust", "scss", "shell", "sql", "swift", "yaml", "typescript", "vbnet", "svelte"]
  • get lang(s)

    import { getLang} from 'markdown-hljs';
    getLang() // for a list of all language names
    getLang(languageAndOrAliases: Array<string> | string, options?: { getMatch?: boolean; error?: boolean }) // for a Language object
  • if you want to add another language(s)

    import customLang from './path-to-customLang'
    import xml from 'highlight.js/lib/languages/xml.js';
    
    import Markdown,{setLang} from 'markdown-hljs';
    
    setLang({language: 'xml', defineLanguage: xml, aliases: ['html'] })
    // to define a language you need to pass the defineLanguage function
    // if you pass only language and aliases it will just add aliases for the language if it exists
    
    setLang({language: 'customLang', defineLanguage: customLang})
    
    result=Markdown(markdown string,error=false)
    // error is false by default;
    // meaning is if highlight language is not recognised throw or don't throw error
    
  • add another language(s) but without defaults

    import hljs from 'highlight.js/lib/core';
    
    import customLang from './path-to-customLang'
    import xml from 'highlight.js/lib/languages/xml.js';
    
    
    import Markdown from 'markdown-hljs';
    import {Highlight,setHljs,setLang} from 'markdown-hljs';
    
    setHljs(hljs)
    
    setLang({language:'xml', defineLanguage: xml, alias: ['html']})
    
    setLang({language: 'customLang', defineLanguage: customLang})
    
    result=Markdown(markdown string)
    
  • to use all languages by highlight.js

import { setHljs } from 'markdown-hljs';
import hljs from 'highlight.js';

setHljs(hljs);
  • markdown without code syntax highlight:

    import {marked} from 'markdown-hljs';
    
    // marked is just the marked lib + variable support
    
    result=marked(markdown string)
    
  • highlight code with defaults

    import {Highlight, highlightCode} from 'markdown-hljs';
    
    result=Highlight(code string, languageAndOrAliases, error=false) // code in <pre><code>
    // error is false by default;
    
    OR
    
    result=highlightCode(code string, languageAndOrAliases, error=true) // only code str
    // error is true by default;
    
    //error: meaning is if highlight language is not recognised throw or don't throw error

    for languageAndOrAliases we can pass in an Array or string in the form js, cjs, javascript or ['js','javacript'] or 'js' it will try to find the language by both languageName and aliases

    so in markdown you can also do

    ```js,javascript

    code..

    ```

Get started

clone repo

npm install
npm run build

then

cd tests/svelte
npm install
npm run dev

Navigate to localhost:5000. You should see your app running. Edit a component file in src, save it, and reload the page to see your changes.

markdown-hljs