Coder Social home page Coder Social logo

sichanghe / mdbook_katex_static_css Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.08 MB

Example repository for mdbook-katex configuration with static CSS

Home Page: https://sichanghe.github.io/mdbook_katex_static_css/

Python 26.16% Batchfile 10.11% VBScript 63.72%

mdbook_katex_static_css's Introduction

mdbook-katex Static CSS Example

Steps in this repository using Python3

Download CSS and fonts by running the Python script download_static_css.py at the root of this repository.

Python 3.5 or higher version is required.

Depending on your system, you may need to use python or python3 for the command.

$ python3 download_static_css.py
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css to katex.min.css
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_AMS-Regular.woff2 to theme/fonts/KaTeX_AMS-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_AMS-Regular.woff to theme/fonts/KaTeX_AMS-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_AMS-Regular.ttf to theme/fonts/KaTeX_AMS-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Bold.woff2 to theme/fonts/KaTeX_Caligraphic-Bold.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Bold.woff to theme/fonts/KaTeX_Caligraphic-Bold.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Bold.ttf to theme/fonts/KaTeX_Caligraphic-Bold.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Regular.woff2 to theme/fonts/KaTeX_Caligraphic-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Regular.woff to theme/fonts/KaTeX_Caligraphic-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Regular.ttf to theme/fonts/KaTeX_Caligraphic-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Bold.woff2 to theme/fonts/KaTeX_Fraktur-Bold.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Bold.woff to theme/fonts/KaTeX_Fraktur-Bold.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Bold.ttf to theme/fonts/KaTeX_Fraktur-Bold.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Regular.woff2 to theme/fonts/KaTeX_Fraktur-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Regular.woff to theme/fonts/KaTeX_Fraktur-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Fraktur-Regular.ttf to theme/fonts/KaTeX_Fraktur-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Bold.woff2 to theme/fonts/KaTeX_Main-Bold.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Bold.woff to theme/fonts/KaTeX_Main-Bold.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Bold.ttf to theme/fonts/KaTeX_Main-Bold.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-BoldItalic.woff2 to theme/fonts/KaTeX_Main-BoldItalic.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-BoldItalic.woff to theme/fonts/KaTeX_Main-BoldItalic.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-BoldItalic.ttf to theme/fonts/KaTeX_Main-BoldItalic.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Italic.woff2 to theme/fonts/KaTeX_Main-Italic.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Italic.woff to theme/fonts/KaTeX_Main-Italic.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Italic.ttf to theme/fonts/KaTeX_Main-Italic.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Regular.woff2 to theme/fonts/KaTeX_Main-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Regular.woff to theme/fonts/KaTeX_Main-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Regular.ttf to theme/fonts/KaTeX_Main-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-BoldItalic.woff2 to theme/fonts/KaTeX_Math-BoldItalic.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-BoldItalic.woff to theme/fonts/KaTeX_Math-BoldItalic.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-BoldItalic.ttf to theme/fonts/KaTeX_Math-BoldItalic.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-Italic.woff2 to theme/fonts/KaTeX_Math-Italic.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-Italic.woff to theme/fonts/KaTeX_Math-Italic.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-Italic.ttf to theme/fonts/KaTeX_Math-Italic.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Bold.woff2 to theme/fonts/KaTeX_SansSerif-Bold.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Bold.woff to theme/fonts/KaTeX_SansSerif-Bold.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Bold.ttf to theme/fonts/KaTeX_SansSerif-Bold.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Italic.woff2 to theme/fonts/KaTeX_SansSerif-Italic.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Italic.woff to theme/fonts/KaTeX_SansSerif-Italic.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Italic.ttf to theme/fonts/KaTeX_SansSerif-Italic.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Regular.woff2 to theme/fonts/KaTeX_SansSerif-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Regular.woff to theme/fonts/KaTeX_SansSerif-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_SansSerif-Regular.ttf to theme/fonts/KaTeX_SansSerif-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Script-Regular.woff2 to theme/fonts/KaTeX_Script-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Script-Regular.woff to theme/fonts/KaTeX_Script-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Script-Regular.ttf to theme/fonts/KaTeX_Script-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size1-Regular.woff2 to theme/fonts/KaTeX_Size1-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size1-Regular.woff to theme/fonts/KaTeX_Size1-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size1-Regular.ttf to theme/fonts/KaTeX_Size1-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size2-Regular.woff2 to theme/fonts/KaTeX_Size2-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size2-Regular.woff to theme/fonts/KaTeX_Size2-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size2-Regular.ttf to theme/fonts/KaTeX_Size2-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size3-Regular.woff2 to theme/fonts/KaTeX_Size3-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size3-Regular.woff to theme/fonts/KaTeX_Size3-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size3-Regular.ttf to theme/fonts/KaTeX_Size3-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size4-Regular.woff2 to theme/fonts/KaTeX_Size4-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size4-Regular.woff to theme/fonts/KaTeX_Size4-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size4-Regular.ttf to theme/fonts/KaTeX_Size4-Regular.ttf
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Typewriter-Regular.woff2 to theme/fonts/KaTeX_Typewriter-Regular.woff2
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Typewriter-Regular.woff to theme/fonts/KaTeX_Typewriter-Regular.woff
Downloading from https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Typewriter-Regular.ttf to theme/fonts/KaTeX_Typewriter-Regular.ttf

Build the book using mdbook build.

Steps for your repository using Python3

  1. Copy download_static_css.py in this repository to the root of your mdBook project.

  2. Run the above script using Python 3.5 or a higher version to download the CSS and fonts.

  3. Include katex.min.css as additional CSS in book.toml:

    [output.html]
    #
    additional-css = ["katex.min.css"]
  4. (Optional) ignore the KaTeX CSS and fonts in .gitignore:

    katex.min.css
    theme/fonts/KaTeX_*.*
  5. (Optional) Set up GitHub CI and GitHub Pages.

    • Check out .github/workflows/deploy.yml for a working example.
    • To enable Git pushes in CI, go to Settings > Code and automation > Actions > General > Workflow permissions, choose Read and write permissions, and save.
    • To enable GitHub Pages, go to Settings > Code and automation > Pages.

Solution using a Rust executable

Replace the first two steps in Steps for your repository using Python3 with:

  1. Install mdbook_katex_css_download.
  2. Run the above executable at the root of your mdBook project.

Windows setup using VBScript

  1. Clone the repository on Windows
  2. Run build.vbs to build the book. It downloads these automatically if they are not present:
    • The mdbook and mdbook-katex binary executables.
    • KaTeX CSS and fonts.

mdbook_katex_static_css's People

Contributors

sichanghe avatar expikr avatar

Stargazers

Denis Kolodin avatar

Watchers

 avatar

mdbook_katex_static_css's Issues

Request: Add demo URL to repository

Thank you for creating and sharing this repository.

I think it would be really helpful if there was a demo URL available so that users could see the functionality of the project in action. Would it be possible to add one?

My setup scripts on Windows

Folder Structure

root
|- .gitignore
|- build.vbs
|- mdbook
   |- download.cmd
|- theme
   |- fonts
      |- stub.txt     

Files

mdbook/download.cmd

cd mdbook
(
    start "download mdbook" cmd /C "curl -o mdbook.zip https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-pc-windows-msvc.zip -O -J -L && tar -xf mdbook.zip"
    start "download katex" cmd /C "curl -o mdbook-katex.zip https://github.com/lzanini/mdbook-katex/releases/download/v0.3.13/mdbook-katex-v0.3.13-x86_64-pc-windows-msvc.zip -O -J -L && tar -xf mdbook-katex.zip"
) | pause

build.vbs

Set fso = CreateObject("Scripting.FileSystemObject")
folder = fso.GetParentFolderName(Wscript.ScriptFullName)

' download mdbook and mdbook-katex if no executable
If fso.FileExists("mdbook\mdbook.exe") AND fso.FileExists("mdbook\mdbook-katex.exe") Then
Else
   result = CreateObject("Wscript.Shell").Run(".\mdbook\download",1,1)
End If

' download katex theme if not found
If fso.FileExists("katex.min.css") Then
Else
   CDNROOT = "https://cdn.jsdelivr.net/npm/[email protected]/dist/"
   CSSPATH = "katex.min.css"
   CURLCMD = "curl " & CDNROOT & CSSPATH & " -O -J -L"
   result = CreateObject("Wscript.Shell").Run(CURLCMD,1,True)
   Set objFileToRead = fso.OpenTextFile("./" & CSSPATH,1)
   strFileText = objFileToRead.ReadAll()
   objFileToRead.Close
   Set objFileToRead = Nothing
   Set re = New RegExp
   With re
   .Pattern    = "url\((fonts\/[^()]+)\)"
   .Global = True
   .IgnoreCase = True
   End With
   Set colMatch = re.Execute(strFileText)
   For each objMatch  in colMatch
      namelen = Len(objMatch.Value)
      filename = Mid(objMatch.Value, 5,nameLen-5)
      CURLCMD = "curl -o theme/" & filename & " " & CDNROOT & filename & " -O -J -L"
      result = CreateObject("Wscript.Shell").Run(CURLCMD,0)
   Next 
End If

' run mdbook init if no book.toml
If fso.FileExists("book.toml") Then
Else
   result = CreateObject("Wscript.Shell").Run( folder & "/mdbook/mdbook init" & " --ignore=none --title=''")
End If

' build and open book
result = CreateObject("Wscript.Shell").Run( folder & "/mdbook/mdbook build" & " --open")

.gitignore

book
mdbook
katex.min.css
theme/fonts/KaTeX_*.*

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.