GithubHelp home page GithubHelp logo

rpeanut / frontend-interview-konwledge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dongyuanwai/frontend-interview-konwledge

0.0 0.0 0.0 1.58 MB

前端面试知识图谱

Home Page: https://frontend-interview-konwledge.vercel.app

JavaScript 93.63% CSS 6.37%

frontend-interview-konwledge's Introduction

前端知识图谱

logo

短小、精悍、直击要害

学习、面试必备之良器

安装 markdown-it 和hljs

npm i markdown-it

npm i  highlight.js

使用

import React, { useState,useEffect } from 'react'
// 1. 引入markdown-it库
import markdownIt from 'markdown-it'
import hljs from "highlight.js";
import 'highlight.js/styles/monokai-sublime.css'
// 2. 生成实例对象
const md = new markdownIt({
  highlight: function (str, lang) {
    if (lang && hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(str, { language: lang }).value;
      } catch (_) {}
    }
    return ""; // 使用额外的默认转义
  },
});

// 3. 解析markdown语法
    const parse = (text: string) => setHtmlString(md.render(text));
    useEffect(()=>{
        parse()
    },[])


 <div 
    className="show" 
    dangerouslySetInnerHTML={{ __html: htmlString }} // 将html字符串解析成真正的html标签
/>

env文件

frontend-interview-konwledge's People

Contributors

dongyuanwai avatar

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.