Skip to content

Instantly share code, notes, and snippets.

View bpj's full-sized avatar

Benct Philip Jonsson bpj

View GitHub Profile
@bpj
bpj / pandoc-code2raw.py
Last active October 30, 2016 23:34
Pandoc filter to insert arbitrary raw output markup as Code/CodeBlocks with an attribute raw=<outputformat>.
#!/usr/bin/env python
r"""Pandoc filter to insert arbitrary raw output markup
as Code/CodeBlocks with an attribute raw=<outputformat>.
Especially useful for inserting LaTeX code which pandoc will
otherwise mangle:
````{raw=latex}
\let\Begin\begin
@bpj
bpj / steal-attrs.pl
Last active November 13, 2016 20:15
steal-attrs.pl - Let HTML elements steal their ancestor's attributes
#!/usr/bin/env perl
=encoding UTF-8
=head1 NAME
steal-attrs.pl - Let HTML elements steal their ancestor's attributes.
=head1 VERSION
@bpj
bpj / html-self-links.pl
Created November 23, 2016 23:15
Generate self links in headings with HTML or Pandoc filter
@bpj
bpj / hyperendnotes.sty
Created December 15, 2016 19:52
Load after endnotes, after hyperref to make endnote markers hyperlinks. I didn't write this. I just put it here to have a convenient place to grab it!
%%% hyperendnotes.sty
\makeatletter
\newif\ifenotelinks
\newcounter{Hendnote}
% Redefining portions of endnotes-package:
\let\savedhref\href
\let\savedurl\url
\def\endnotemark{%
\@ifnextchar[\@xendnotemark{%
\stepcounter{endnote}%
# Autogenerated LaTeX-related files
*.aux # An auxiliary file that saves information for the creation of ToC, references, indices, bibliographies and other things like that. It is reread in the next compiling to create the ToC, references etc.
*.toc # An auxiliary file that stores the Table of Contents, read in on subsequent runs to create the actual ToC.
*.log # Stors all messages of the compilation, like errors and warnings. It’s used by most Editors / LaTeX IDEs to show the errors in you document.
*.nav # contains the information needed for the navigation bar hyperlinks.
*.vrb # will contain the verbatim material when fragile (containing verbatim material) frames.
*.snm # will contain information that will be used by \pgfimage to include actual slides when using the beamerarticle package.
*.tuc # Data stored for multiple passes, ToC, etc.
# (La)TeX:
# Lists:
@bpj
bpj / pandoc-class2style.pl
Created March 11, 2017 17:47
Pandoc filter which 'converts' span and div classes with a trailing period into LaTeX commands/environments or DOCX styles
#!/usr/bin/env perl
=encoding UTF-8
=head1 DOCUMENTATION
# DESCRIPTION
Pandoc filter which 'converts' span and div classes with a
trailing period into LaTeX commands (for spans) or environments
#!/usr/bin/env perl
=encoding UTF-8
This is a Pandoc <http://pandoc.org> filter to turn
code blocks and code spans which have certain specified
classes into RawBlock or RawInline elements in specified
output formats, wrapping them in specified markup as needed.
It can be used e.g. to output LaTeX math in both LaTeX and HTML,
@bpj
bpj / bidibug.latex
Created June 7, 2017 16:05
Modified Pandoc LaTeX template which makes sure bidi is loaded as very late as possible
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(beamerarticle)$
\usepackage{beamerarticle} % needs to be loaded first
$endif$
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$
@bpj
bpj / pandoc-class2style.pl
Last active June 9, 2017 12:55
pandoc-class2style.pl - filter to translate single pandoc classes into attribute lists or LaTeX commands (with POD documentation)
#!/usr/bin/env perl
# pandoc-class2style.pl - filter to translate single span/div classes into LaTeX commands and attribute lists
# POD documentation below the code!
use utf8;
use autodie 2.29;
use 5.010001;
use strict;
@bpj
bpj / README.md
Last active October 29, 2017 17:59
Move inline CSS styles to a stylesheet