Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Jul 11, 2022
0 parents commit b95dc83
Show file tree
Hide file tree
Showing 48 changed files with 11,625 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (C) 2022 John MacFarlane

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
VERSION=0.1.0
REVISION=1
ROCKSPEC=djot-$(VERSION)-$(REVISION).rockspec
MODULES=djot/match.lua djot/attributes.lua djot/inline.lua djot/block.lua djot/ast.lua djot/emoji.lua djot/html.lua djot.lua
SOURCES=$(MODULES) bin/main.lua
TESTSOURCES=test.lua pathological_tests.lua
LIBLUA=/usr/local/lib/libluajit.a
LUAHEADERS=/usr/local/include/luajit-2.0
LUAOPTIONS=-O2
BUNDLE=djot
VIMDIR?=~/.vim

test:
LUA_PATH='./?.lua' lua test.lua
.PHONY: test

testall: test pathological fuzz
.PHONY: testall

fuzz:
@LUA_PATH='./?.lua' printf "Fuzz testing on 10 MB random input: " ; \
for i in 0 1 2 3 4 5 6 7 8 9 ; do \
head -c 1000000 /dev/random | lua bin/main.lua >/dev/null \
&& printf "."; \
done; \
printf "\n"
.PHONY: fuzz

pathological:
LUA_PATH='./?.lua' perl -e 'alarm shift; exec @ARGV' 10 lua pathological_tests.lua
.PHONY: pathological

bench: m.dj
-bench "LUA_PATH='./?.lua' luajit bin/main.lua m.dj"
-bench "LUA_PATH='./?.lua' lua bin/main.lua m.dj"
.PHONY: bench

m.dj:
pandoc -t djot-writer.lua https://raw.githubusercontent.com/jgm/pandoc/2.18/MANUAL.txt -o m.dj

linecount:
wc -l $(SOURCES)
.PHONY: linecount

check:
luacheck $(SOURCES) $(TESTSOURCES)
.PHONY: check

djotbin:
luastatic bin/main.lua $(MODULES) $(LIBLUA) -I$(LUAHEADERS) $(LUAOPTIONS) -pagezero_size 10000 -o djotbin

doc/syntax.html: doc/syntax.md
pandoc --lua-filter doc/code-examples.lua $< -t html -o $@ -s --css doc/syntax.css --self-contained --wrap=preserve --toc --section-divs -Vpagetitle="Djot syntax reference"

# luarocks packaging

install: $(ROCKSPEC)
luarocks make $(ROCKSPEC)
.PHONY: install

rock: $(ROCKSPEC)
luarocks --local make $(ROCKSPEC)
.PHONY: rock

vim:
cp editors/vim/syntax/djot.vim $(VIMDIR)/syntax/
cp editors/vim/ftdetect/djot.vim $(VIMDIR)/ftdetect/
.PHONY: vim

$(ROCKSPEC): rockspec.in
sed -e "s/_VERSION/$(VERSION)/g; s/_REVISION/$(REVISION)/g" $< > $@


Loading

0 comments on commit b95dc83

Please sign in to comment.