GithubHelp home page GithubHelp logo

dancespiele / yew_prism Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 855 KB

highlighter code component based in Prism

Home Page: https://docs.rs/crate/yew_prism

License: MIT License

JavaScript 22.39% TypeScript 0.99% Rust 72.10% HTML 4.53%
yew rustwasm codehighlight

yew_prism's Introduction

Yew Prism

Yew Prism is a highlighter code component based in Prism for yew

How it works

  1. Install the prismjs node module

    npm install prismjs

  2. Import the prismjs module and styles, and all the languages component which you want to use for highlighting, in your javascript/typescript main file yew project

import 'prismjs/themes/prism.css';
import 'prismjs';
import 'prismjs/components/prism-markup';
import 'prismjs/components/prism-rust';
import module from '../crate/Cargo.toml';

module.run();

Note: You can use yew-parcel-template or another template described here to create a yew project

  1. Add yew_prism in your cargo.toml
[dependencies]
yew = { version = "0.17", features = ["web_sys"]}
yew_prism="0.4"
  1. Now you are ready to use the component ๐Ÿš€

Example

use yew::prelude::*;
use yew_prism::Prism;

pub struct App;
impl Component for App {
    type Message = ();
    type Properties = ();

    fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
        App {}
    }

    fn update(&mut self, _: Self::Message) -> ShouldRender {
        false
    }

    fn change(&mut self, _props: Self::Properties) -> ShouldRender {
        false
    }

    fn view(&self) -> Html {
        html! {
            <Prism
                code="let greeting: &str = \"Hello World\";"
                language="rust"
            />
        }
    }
}

Run documentation page

  1. git clone https://github.com/spielrs/yew_prism.git
  2. cd yew_prism
  3. npm install
  4. npm start

License

Yew Prism is MIT licensed. See license

yew_prism's People

Contributors

carlosmiei avatar dancespiele avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fitzgen avatar iamcodemaker avatar mappum avatar meain avatar sendilkumarn avatar walfie avatar xtuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

carlosmiei

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.