Skip to content

Commit

Permalink
Ship it!! (Pratt parsers)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janiczek committed Jul 3, 2023
1 parent 737ceb0 commit 14ea612
Show file tree
Hide file tree
Showing 90 changed files with 6,324 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_site
_site/
.DS_Store
Gemfile.lock
elm-stuff/
1 change: 1 addition & 0 deletions .ok
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
install: /opt/homebrew/opt/ruby/bin/bundle install
serve: /opt/homebrew/opt/ruby/bin/bundle exec jekyll serve --livereload
build: /opt/homebrew/opt/ruby/bin/bundle exec jekyll build
elm: for x in _scripts/*.elm; do BASE=$(basename "$x"); elm make "$x" --output "assets/js/$BASE.js"; done
8 changes: 4 additions & 4 deletions _includes/head-custom.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<link href="/assets/css/override.css" rel="stylesheet" type="text/css">

<!-- highlight.js support -->
<link rel="stylesheet" href="/js/highlightjs/styles/github.css">
<link rel="stylesheet" href="/js/highlightjs/styles/ssms.css" />
<script type="text/javascript" src="/js/highlightjs/highlight.min.js"></script>
<link rel="stylesheet" href="/assets/js/highlightjs/styles/github.css">
<link rel="stylesheet" href="/assets/js/highlightjs/styles/ssms.css" />
<script type="text/javascript" src="/assets/js/highlightjs/highlight.min.js"></script>
<script type="text/javascript"> hljs.highlightAll(); </script>
<!-- end highlight.js support -->

<script src="/js/new-window-fix.js"></script>
<script src="/assets/js/new-window-fix.js"></script>
35 changes: 35 additions & 0 deletions _plugins/elm_converter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Initially based on https://github.com/sonnym/jekyll_elm
#
# USAGE:
# Copy/paste this file into the `_plugins` directory of your Jekyll project.
# For every .elm file in your project, it will generate a .js file in your site
# using the same name and relative path.
#
# As-is, the converter expects the following directory structure:
#
# your-jekyll-project/
# ⌞ _plugins/
# ⌞ elm_converter.rb
# ⌞ elm.json

require "jekyll"
require "tempfile"

class ElmConverter < Jekyll::Converter
MODE = Jekyll.env == "development" ? "debug" : "optimize"

safe false
def matches(ext) ext == ".elm" end
def output_ext(ext) ".js" end

def convert(content)
Tempfile.open [ "source", ".elm" ] do |source|
Tempfile.open [ "output", ".js" ] do |output|
File.write source.path, content
raise unless system "cd #{@config["source"]} && \
npx elm make #{source.path} --#{MODE} --output #{output.path}"
output.read
end
end
end
end
Loading

0 comments on commit 14ea612

Please sign in to comment.