gaps outer 0
# startup scripts
-exec_always xrandr --output HDMI-0 --pos 0x0 --output DVI-D-0 --pos 240x1080
-exec_always feh --bg-fill /home/andrew/.wallpaper.png
-exec_always compton -f -b --config /home/andrew/.compton.conf
+exec_always --no-startup-id xrdb /home/andrew/.Xdefaults
+exec_always --no-startup-id xrandr --output HDMI-0 --pos 0x0 --output DVI-D-0 --pos 240x1080
+exec_always --no-startup-id feh --bg-fill /home/andrew/.wallpaper.png
+exec_always --no-startup-id compton -f -b --config /home/andrew/.compton.conf
exec --no-startup-id chromium
exec --no-startup-id spotify
--- /dev/null
+#! /usr/bin/env python3
+"""Pandoc filter to format simple chemical structures.
+
+Structures specified as in s:{CH3CH2O-}, s:{SO4^2-}
+are converted to formatted structures such as CH~3~CH~2~OH^-^,
+SO~4~^2−^.
+
+"""
+
+from pandocfilters import toJSONFilter, Str, Subscript, Superscript
+import re
+
+# Pattern for structures in md.
+ID_PAT = re.compile('(.*)ce\{(.*)\}(.*)')
+# Used to identify charges at end of formula.
+CHARGE_PAT = re.compile('(\w*)\^?([0-9]*[-–−+])')
+
+def chem_struct (key, val, fmt, meta):
+ if key == 'Str' and ID_PAT.match(val):
+ # Store punctuation after formula in end.
+ start, raw_formula, end = ID_PAT.match(val).groups()
+
+ if CHARGE_PAT.match(raw_formula):
+ formula, charge = CHARGE_PAT.match(raw_formula).groups()
+ # Replace hyphen with minus sign
+ charge = charge.replace('-', '−')
+ else:
+ formula, charge = raw_formula, None
+
+ formatted_formula = []
+
+ for d in formula:
+ if d.isdigit():
+ formatted_formula.append(Subscript([Str(d)]))
+ else:
+ formatted_formula.append(Str(d))
+
+ if charge:
+ formatted_charge = [Superscript([Str(charge)])]
+ else:
+ formatted_charge = []
+
+ formatted_start = [Str(start)]
+ formatted_end = [Str(end)]
+
+ return formatted_start + formatted_formula + formatted_charge \
+ + formatted_end
+
+if __name__ == '__main__':
+ toJSONFilter(chem_struct)