add katex support

This commit is contained in:
Lorin Werthen 2021-02-26 15:24:40 +01:00
parent ceac9fc66d
commit bc44220db3
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
6 changed files with 37 additions and 3 deletions

View file

@ -5,6 +5,12 @@ gem 'nanoc'
gem 'icalendar' # ical files gem 'icalendar' # ical files
gem 'kramdown' gem 'kramdown'
# Kramdown math mode gems
gem 'kramdown-math-katex'
# Also needed for autoprefixing
gem 'mini_racer'
gem 'sassc' gem 'sassc'
gem 'typogruby' gem 'typogruby'
@ -24,8 +30,6 @@ group :development do
end end
group :production do group :production do
# Faster css autoprefixing
gem 'mini_racer'
# Autoprefixing for class # Autoprefixing for class
gem 'autoprefixer-rails' gem 'autoprefixer-rails'
gem 'htmlcompressor' gem 'htmlcompressor'

View file

@ -53,8 +53,13 @@ GEM
ice_cube (0.16.3) ice_cube (0.16.3)
json (2.5.1) json (2.5.1)
json_schema (0.20.9) json_schema (0.20.9)
katex (0.6.1)
execjs (~> 2.7)
kramdown (2.3.0) kramdown (2.3.0)
rexml rexml
kramdown-math-katex (1.0.1)
katex (~> 0.4)
kramdown (~> 2.0)
libv8 (8.4.255.0) libv8 (8.4.255.0)
listen (3.4.0) listen (3.4.0)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
@ -161,6 +166,7 @@ DEPENDENCIES
htmlcompressor htmlcompressor
icalendar icalendar
kramdown kramdown
kramdown-math-katex
mini_racer mini_racer
nanoc nanoc
pandoc-ruby pandoc-ruby

3
Rules
View file

@ -4,6 +4,7 @@
require 'json' require 'json'
require 'icalendar' require 'icalendar'
# Important!!! # Important!!!
# First ignore the node_modules, we do not need any of it on the site directly. # First ignore the node_modules, we do not need any of it on the site directly.
ignore '/node_modules/**/*' ignore '/node_modules/**/*'
@ -103,7 +104,7 @@ end
compile '/blog/*/*.md' do compile '/blog/*/*.md' do
filter :erb filter :erb
layout '/blogpost.md' layout '/blogpost.md'
filter :kramdown filter :kramdown, {math_engine: :katex}
filter :typogruby filter :typogruby
layout '/blogpost.erb' layout '/blogpost.erb'

View file

@ -14,6 +14,9 @@
<!-- Animate.css --> <!-- Animate.css -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<!-- KaTeX math css -->
<link rel="stylesheet" type="text/css" href="/assets/stylesheets/katex.css">
<% end %> <% end %>
<div class="blog-heading"> <div class="blog-heading">

17
lib/data_sources/katex.rb Normal file
View file

@ -0,0 +1,17 @@
require 'katex'
class KatexDataSource < ::Nanoc::DataSource
identifier :katex
def items
katex_css_path = File.join(Katex.gem_path, 'vendor', 'katex', 'stylesheets', 'katex.css')
[
new_item(
File.open(katex_css_path).read,
{},
"/katex.css"
)
]
end
end

View file

@ -90,6 +90,9 @@ data_sources:
items_root: /about/verslagen/ items_root: /about/verslagen/
content_dir: drive/verslagen/ content_dir: drive/verslagen/
layouts_dir: null layouts_dir: null
-
type: katex
items_root: /assets/stylesheets
# Configuration for the “check” command, which run unit tests on the site. # Configuration for the “check” command, which run unit tests on the site.
checks: checks: