About this website
This was my first encounter with html, jekyll and scss.
Template and modifications
I modified the jekyll template portfolYOU. In particular:
- Landing page to have a background image.
- Changed the skills bar in the about page.
- I tweaked around various other configurations to make it more personal.
Landing page plot
I wanted to make a plot reminiscent of warped space-time or ripples in a water surface. To achieve this, I wrote a simple python script that:
- Generates 4 random sources in a square.
- Each source adds a radial sinusoidal displacement to a meshgrid (with different amplitudes in each coordinate).
- The overall result is the superposition of these 4 sources.
LaTeX to Markdown
I have implemented the classes definition, theorem, proposition, corollary, lemma, and example to be used directly in Markdown.
For example, this is a theorem.
And this is a corollary.
<div class=theorem>
For example, this is a theorem.
</div>
<div class=corollary>
And this is a corollary.
</div>
Proof
This is a proof by intimidation. Trivial! ◻
<details markdown="1"><summary markdown="span">*Proof*</summary>
<div class="proof">
This is a proof by intimidation. Trivial! ◻
</div></details>
Additionaly, I have created a script that uses pandoc to automatically convert a LaTeX file into the corresponding markdown format in such a way to be used directly in this website. This tool can be found here. Proofs are automatically converted into collapsable items as above.
The script is divided into 3 files:
run.sh
#!/bin/bash
python3 preserve_env_titles.py $1 > input.pre.tex
sed -E 's/\\\|/\\lvert \\lvert /g' input.pre.tex > input.fixed.tex
sed -E 's/\|/\\lvert /g' input.fixed.tex > input.fixed2.tex
pandoc input.fixed2.tex -f latex -t markdown --lua-filter=filters.lua -o $2
rm -rf input.pre.tex input.fixed.tex input.fixed2.tex
preserve_env_titles.py
"""
This moves optional theorem/definition names [Title] into the body as \textbf{(Title)}
so Pandoc will preserve them. For example,
\\begin{theorem}[Pitagoras]
a^2 + b^2 = c^2
\\end{theorem}
will become:
\\begin{theorem}\\textbf{(Pitagoras)}
a^2 + b^2 = c^2
\\end{theorem}
"""
import sys
import re
ENV_RE = re.compile(
r'(\\begin\{(theorem|lemma|definition|proposition|corollary)\})' # \begin{env}
r'(?:\s*\[(.*?)\])?' # optional [Title]
r'(\s*\\label\{[^}]*\})?', # optional \label{...} (right after)
flags=re.DOTALL
)
def repl(m):
begin = m.group(1) # \begin{env}
env = m.group(2)
title = m.group(3) # may be None
label = m.group(4) or "" # may be empty
if title:
insert = "\\textbf{(" + title + ")} "
else:
insert = ""
return begin + label + insert
def main():
if len(sys.argv) < 2:
print("Usage: preserve_theorem_titles.py input.tex > output.tex", file=sys.stderr)
sys.exit(1)
fname = sys.argv[1]
txt = open(fname, "r", encoding="utf8").read()
new = ENV_RE.sub(repl, txt)
sys.stdout.write(new)
if __name__ == "__main__":
main()
filters.lua
function Math(el)
return pandoc.RawInline("markdown", "$$" .. el.text .. "$$")
end
-- Helper to convert any Div with certain classes to HTML
local function convert_div_to_html(el, classname)
-- Pandoc may store theorem name in el.attributes["title"]
local content = pandoc.write(pandoc.Pandoc(el.content), "gfm")
return pandoc.RawBlock("html",
'<div class="' .. classname .. '">\n' ..
content ..
'\n</div>'
)
end
-- Convert custom theorem-like environments
function Div(el)
local class = el.classes[1]
if class == "theorem" or class == "definition"
or class == "proposition" or class == "corollary"
or class == "lemma" or class == "example" then
return convert_div_to_html(el, class)
elseif class == "proof" then
-- remove leading "Proof." from first paragraph
local content_blocks = el.content
if #content_blocks > 0 and content_blocks[1].t == "Para" then
local inlines = content_blocks[1].content
local i = 1
while i <= #inlines do
local txt = pandoc.utils.stringify(inlines[i]):gsub("^%s+", "")
if txt:lower():match("^proof[.:]?%s*$") then
table.remove(inlines, i)
else
break
end
end
content_blocks[1].content = inlines
end
-- Put into appropriate format
local content = pandoc.write(pandoc.Pandoc(el.content), "gfm")
return pandoc.RawBlock("html",
'<details markdown="1"><summary markdown="span">*Proof*</summary>\n' ..
'<div class="proof">\n' ..
content ..
'</div>' ..
'</details>\n\n' )
end
end
function Link(el)
-- If the link has attributes like reference-type, remove them
el.attributes = {}
return el
end