Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
plastex/
|
||||||
|
gerby-website/
|
||||||
|
document/*
|
||||||
|
*.swp
|
||||||
70
.travis.yml
Normal file
70
.travis.yml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
language: python
|
||||||
|
|
||||||
|
python:
|
||||||
|
- "3.6"
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get update
|
||||||
|
- sudo apt install dvipng
|
||||||
|
# install plasTeX
|
||||||
|
- git clone https://github.com/gerby-project/plastex.git
|
||||||
|
- cd plastex
|
||||||
|
- git checkout gerby
|
||||||
|
- pip install .
|
||||||
|
- cd ..
|
||||||
|
|
||||||
|
# install Gerby
|
||||||
|
- git clone https://github.com/gerby-project/gerby-website.git
|
||||||
|
- cd gerby-website/gerby/static
|
||||||
|
- git clone https://github.com/sonoisa/XyJax.git
|
||||||
|
- sed -i -e 's@\[MathJax\]@/static/XyJax@' XyJax/extensions/TeX/xypic.js
|
||||||
|
|
||||||
|
- git clone https://github.com/aexmachina/jquery-bonsai
|
||||||
|
- cp jquery-bonsai/jquery.bonsai.css css/
|
||||||
|
|
||||||
|
- cd ../..
|
||||||
|
- pip install -e .
|
||||||
|
- cd ..
|
||||||
|
|
||||||
|
# setup configuration
|
||||||
|
- mv configuration.py gerby-website/gerby/configuration.py
|
||||||
|
|
||||||
|
# setup soft links for plasTeX output
|
||||||
|
- cd gerby-website/gerby/tools
|
||||||
|
- ln -s ../../../document document
|
||||||
|
- ln -s ../../../document.paux document.paux
|
||||||
|
- ln -s ../../../tags tags
|
||||||
|
- cd ../../..
|
||||||
|
|
||||||
|
# setup soft links for database
|
||||||
|
- cd gerby-website
|
||||||
|
- ln -s gerby/tools/hello-world.sqlite hello-world.sqlite
|
||||||
|
- ln -s gerby/tools/comments.sqlite comments.sqlite
|
||||||
|
- cd ..
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
script:
|
||||||
|
# update tags file with new tags
|
||||||
|
# in real life: first run it without writing it to the tags file to check for errors
|
||||||
|
- python3 tagger.py >> tags
|
||||||
|
|
||||||
|
# convert to HTML: output goes to document/ folder
|
||||||
|
- plastex --renderer=Gerby ./document.tex
|
||||||
|
|
||||||
|
# import database
|
||||||
|
- cd gerby-website/gerby/tools
|
||||||
|
- python3 update.py
|
||||||
|
- cd ../..
|
||||||
|
|
||||||
|
# run Flask
|
||||||
|
- export FLASK_APP=gerby
|
||||||
|
- python3 -m flask run &
|
||||||
|
- sleep 1
|
||||||
|
|
||||||
|
- wget http://127.0.0.1:5000/tag/0001
|
||||||
|
- cat 0001
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
12
configuration.py
Normal file
12
configuration.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# configuration for the website
|
||||||
|
COMMENTS = "comments.sqlite"
|
||||||
|
DATABASE = "hello-world.sqlite"
|
||||||
|
UNIT = "section"
|
||||||
|
DEPTH = 0
|
||||||
|
|
||||||
|
# configuration for the import
|
||||||
|
PATH = "document"
|
||||||
|
PAUX = "document.paux"
|
||||||
|
TAGS = "tags"
|
||||||
|
PDF = ""
|
||||||
|
|
||||||
47
document.tex
Normal file
47
document.tex
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
\documentclass{report}
|
||||||
|
\usepackage{amssymb, amsmath, hyperref}
|
||||||
|
|
||||||
|
\theoremstyle{plain}
|
||||||
|
\newtheorem{theorem}[subsection]{Theorem}
|
||||||
|
\newtheorem{proposition}[subsection]{Proposition}
|
||||||
|
\newtheorem{lemma}[subsection]{Lemma}
|
||||||
|
|
||||||
|
\theoremstyle{definition}
|
||||||
|
\newtheorem{definition}[subsection]{Definition}
|
||||||
|
\newtheorem{example}[subsection]{Example}
|
||||||
|
\newtheorem{exercise}[subsection]{Exercise}
|
||||||
|
\newtheorem{situation}[subsection]{Situation}
|
||||||
|
|
||||||
|
\theoremstyle{remark}
|
||||||
|
\newtheorem{remark}[subsection]{Remark}
|
||||||
|
\newtheorem{remarks}[subsection]{Remarks}
|
||||||
|
|
||||||
|
\numberwithin{equation}{subsection}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\chapter{A first chapter}
|
||||||
|
\label{chapter:first}
|
||||||
|
|
||||||
|
\section{A first section}
|
||||||
|
\label{section:first}
|
||||||
|
|
||||||
|
\begin{lemma}
|
||||||
|
\label{lemma:pythagoras}
|
||||||
|
$a^2=b^2+c^2$
|
||||||
|
\end{lemma}
|
||||||
|
|
||||||
|
\section{A second section}
|
||||||
|
\label{section:second}
|
||||||
|
|
||||||
|
|
||||||
|
\chapter{A second chapter}
|
||||||
|
\label{chapter:second}
|
||||||
|
|
||||||
|
\section{A third section}
|
||||||
|
\label{section:third}
|
||||||
|
|
||||||
|
\section{A fourth section}
|
||||||
|
\label{section:fourth}
|
||||||
|
|
||||||
|
\end{document}
|
||||||
67
tagger.py
Normal file
67
tagger.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import glob
|
||||||
|
import re
|
||||||
|
|
||||||
|
# no I, no O
|
||||||
|
CHARACTERS = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
|
||||||
|
|
||||||
|
# convert integer to tag
|
||||||
|
def tobase(i):
|
||||||
|
global CHARACTERS
|
||||||
|
|
||||||
|
assert i >= 0
|
||||||
|
|
||||||
|
if i < len(CHARACTERS):
|
||||||
|
return CHARACTERS[i]
|
||||||
|
else:
|
||||||
|
return tobase(i // len(CHARACTERS)) + CHARACTERS[i % len(CHARACTERS)]
|
||||||
|
|
||||||
|
def totag(i):
|
||||||
|
return tobase(i).rjust(4, "0")
|
||||||
|
|
||||||
|
# convert tag to integer
|
||||||
|
def toint(tag):
|
||||||
|
global CHARACTERS
|
||||||
|
return sum([CHARACTERS.index(tag[i]) * len(CHARACTERS)**(4-i-1) for i in range(4)])
|
||||||
|
|
||||||
|
tags = dict()
|
||||||
|
labels = dict()
|
||||||
|
inactive = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open("tags") as f:
|
||||||
|
for line in f:
|
||||||
|
# actual tag
|
||||||
|
if not line.startswith("#"):
|
||||||
|
tags[line.split(",")[0]] = line.strip().split(",")[1]
|
||||||
|
labels[line.strip().split(",")[1]] = line.strip().split(",")[0]
|
||||||
|
|
||||||
|
# check for inactive tags too
|
||||||
|
elif len(line.split(",")) == 2 and len(line.split(",")[0]) == 4:
|
||||||
|
inactive.append(line.split(",")[0])
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# determine last assigned tag
|
||||||
|
try:
|
||||||
|
last = toint(sorted(list(tags.keys()) + inactive)[-1])
|
||||||
|
except IndexError:
|
||||||
|
last = -1
|
||||||
|
|
||||||
|
|
||||||
|
#filenames = glob.glob("*.tex")
|
||||||
|
filenames = ["document.tex"]
|
||||||
|
|
||||||
|
# where we should start
|
||||||
|
i = last + 1
|
||||||
|
|
||||||
|
for filename in filenames:
|
||||||
|
with open(filename) as f:
|
||||||
|
# do this line per line to deal with comments
|
||||||
|
for line in f:
|
||||||
|
matches = re.findall("\\\\label{([^}]+)}", line.split("%")[0])
|
||||||
|
for label in matches:
|
||||||
|
if not label in labels:
|
||||||
|
tag = tobase(i).rjust(4, "0")
|
||||||
|
print("%s,%s" % (tag, label))
|
||||||
|
i = i + 1
|
||||||
Reference in New Issue
Block a user