Permalink
Browse files

organizing a bit

  • Loading branch information...
1 parent f86d80f commit a0164310760f42755031eb14bed1bec228f020e4 @cboettig committed Feb 5, 2013
View
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+
+for f in `grep -l '##* References$' *.markdown *.md`
+ # *md *.markdown
+ do
+ sed -i 's/##* References$/\n## References/g' $f
+ sed -i 's/<EM>/*/g' $f
+ sed -i 's/<\/EM>/*/g' $f
+ sed -i 's/<B>/**/g' $f
+ sed -i 's/<\/B>/**/g' $f
+ sed -i 's/\&rdquo;/"/g' $f
+ sed -i 's/\&ldquo;/"/g' $f
+ sed -i 's/<p>/\n- /g' $f
+done
+
+
View
@@ -0,0 +1,26 @@
+# Get a list of all files
+files <- system("ls *OWW*.markdown", intern=T)
+
+
+# Update syntax highlighted code block tags
+lapply(files, function(file){
+ content <- readLines(file)
+ subtitles <- grep("^-----*$", content) # Find the title lines
+ if(length(subtitles)>0){
+ title <- content[subtitles[1]-1] # Extract the title
+ content[(subtitles[1]-1):subtitles[1]] <- "" # delete the title
+ title <- gsub(":", "-", title) # colons not permitted
+ title <- gsub("/", "-", title) # colons not permitted
+ yaml <- grep("^---$", content) # Find YAML matter ending
+ content[yaml[2]] <- paste("title: ", title, "\n---\n", sep="")
+
+ # filename spaces as dashes
+ title <-gsub(" ", "-", title)
+ filename <- gsub("(20\\d\\d-\\d\\d-\\d\\d)-(.*).markdown",
+ paste("\\1-", title, ".markdown", sep=""),
+ file)
+ writeLines(content, filename)
+ }
+})
+
+
View
@@ -1,59 +0,0 @@
-
-
-Add mathjax script right into the markdown file like so:
-
-```html
-<!-- Equations using MathJax -->
-<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-<script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } }); </script>
-```
-
-
-<!-- Equations using MathJax -->
-<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-<script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } }); </script>
-
-
-Add knitr block into the markdown file.
-
-
-
-```r
-1 + 1
-```
-
-
-
-```
-## [1] 2
-```
-
-
-
-
-
-Display equations by delimiting with `<div>$$`
-
-<div>$$ J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} $$</div>
-
-And inline equations with `<span>$`, like <span>$e = mc^2$</span>
-
-
-### Now the following works:
-
-* Pandoc generated latex: `pandoc -s math.md -o math.tex`.
-* The Markdown file will be converted to valid html by almost any markdown converter, which ignores the div/span elements. The mathjax script added in the top will cause these to display correctly. (Note this works for the inline equation too, even though [mathjax says it shouldn't](http://www.mathjax.org/docs/2.0/start.html#tex-and-latex-input)?)
-* To get pandoc to run in this mode without touching the math syntax, use `--strict` option: `pandoc -s --strict math.md -o math.html`
-* Pandoc can handle the mathjax rendering itself, since without `strict` enabled, it reads inside the div/span elements and finds math syntax it recognizes. as does `pandoc -s --mathjax math.md -o math3.html`. Likewise for mathml: `pandoc -s --mathml -o math4.html`.
-* Simple html works too, though has no rendering engine: `pandoc -s math.md -o math2.html` so the result is not displayed properly.
-
-
-### See results
-* [math.md](https://github.com/cboettig/sandbox/blob/master/math.md)
-* [math.tex](https://github.com/cboettig/sandbox/blob/master/math.tex)
-* Pandoc strict (or most markdown intepreters): [math.html](http://cboettig.github.com/sandbox/math3.html)
-* Pandoc mathjax: [math3.html](http://cboettig.github.com/sandbox/math3.html)
-* mathml: [math4.html](http://cboettig.github.com/sandbox/math4.html)
-* Pandoc's plain html: [math2.html](http://cboettig.github.com/sandbox/math2.html)
-* Giving jekyll a copy of math.md, it creates [math-jekyll.html](http://cboettig.github.com/sandbox/math-jekyll.html)
-
View
@@ -1,132 +0,0 @@
-\documentclass[]{article}
-\usepackage{amssymb,amsmath}
-\usepackage{ifxetex,ifluatex}
-\ifxetex
- \usepackage{fontspec,xltxtra,xunicode}
- \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
-\else
- \ifluatex
- \usepackage{fontspec}
- \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
- \else
- \usepackage[utf8]{inputenc}
- \fi
-\fi
-\usepackage{color}
-\usepackage{fancyvrb}
-\DefineShortVerb[commandchars=\\\{\}]{\|}
-\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
-% Add ',fontsize=\small' for more characters per line
-\newenvironment{Shaded}{}{}
-\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
-\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
-\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
-\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
-\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
-\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
-\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
-\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
-\newcommand{\RegionMarkerTok}[1]{{#1}}
-\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
-\newcommand{\NormalTok}[1]{{#1}}
-\ifxetex
- \usepackage[setpagesize=false, % page size defined by xetex
- unicode=false, % unicode breaks when used with xetex
- xetex,
- colorlinks=true,
- linkcolor=blue]{hyperref}
-\else
- \usepackage[unicode=true,
- colorlinks=true,
- linkcolor=blue]{hyperref}
-\fi
-\hypersetup{breaklinks=true, pdfborder={0 0 0}}
-\setlength{\parindent}{0pt}
-\setlength{\parskip}{6pt plus 2pt minus 1pt}
-\setlength{\emergencystretch}{3em} % prevent overfull lines
-\setcounter{secnumdepth}{0}
-
-
-\begin{document}
-
-Add mathjax script right into the markdown file like so:
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\CommentTok{<!-- Equations using MathJax -->}
-\KeywordTok{<script}\OtherTok{ type=}\StringTok{"text/javascript"}\OtherTok{ src=}\StringTok{"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"}\KeywordTok{></script>}
-\KeywordTok{<script}\OtherTok{ type=}\StringTok{"text/x-mathjax-config"}\KeywordTok{>} \KeywordTok{MathJax.Hub}\NormalTok{.}\FunctionTok{Config}\NormalTok{(\{ }\DataTypeTok{TeX}\NormalTok{: \{ }\DataTypeTok{equationNumbers}\NormalTok{: \{}\DataTypeTok{autoNumber}\NormalTok{: }\StringTok{"all"}\NormalTok{\} \} \}); }\KeywordTok{</script>}
-\end{Highlighting}
-\end{Shaded}
-Add knitr block into the markdown file.
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\DecValTok{1} \NormalTok{+ }\DecValTok{1}
-\end{Highlighting}
-\end{Shaded}
-\begin{verbatim}
-## [1] 2
-\end{verbatim}
-Display equations by delimiting with
-\texttt{\textless{}div\textgreater{}\$\$}
-
-\[ J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} \]
-And inline equations with \texttt{\textless{}span\textgreater{}\$}, like
-$e = mc^2$
-
-\subsubsection{Now the following works:}
-
-\begin{itemize}
-\item
- Pandoc generated latex: \texttt{pandoc -s math.md -o math.tex}.\\
-\item
- The Markdown file will be converted to valid html by almost any
- markdown converter, which ignores the div/span elements. The mathjax
- script added in the top will cause these to display correctly. (Note
- this works for the inline equation too, even though
- \href{http://www.mathjax.org/docs/2.0/start.html\#tex-and-latex-input}{mathjax
- says it shouldn't}?)
-\item
- To get pandoc to run in this mode without touching the math syntax,
- use \texttt{-{}-strict} option:
- \texttt{pandoc -s -{}-strict math.md -o math.html}
-\item
- Pandoc can handle the mathjax rendering itself, since without
- \texttt{strict} enabled, it reads inside the div/span elements and
- finds math syntax it recognizes. as does
- \texttt{pandoc -s -{}-mathjax math.md -o math3.html}. Likewise for
- mathml: \texttt{pandoc -s -{}-mathml -o math4.html}.
-\item
- Simple html works too, though has no rendering engine:
- \texttt{pandoc -s math.md -o math2.html} so the result is not
- displayed properly.
-\end{itemize}
-\subsubsection{See results}
-
-\begin{itemize}
-\item
- \href{https://github.com/cboettig/sandbox/blob/master/math.md}{math.md}
-\item
- \href{https://github.com/cboettig/sandbox/blob/master/math.tex}{math.tex}
-\item
- Pandoc strict (or most markdown intepreters):
- \href{http://cboettig.github.com/sandbox/math3.html}{math.html}
-\item
- Pandoc mathjax:
- \href{http://cboettig.github.com/sandbox/math3.html}{math3.html}
-\item
- mathml:
- \href{http://cboettig.github.com/sandbox/math4.html}{math4.html}
-\item
- Pandoc's plain html:
- \href{http://cboettig.github.com/sandbox/math2.html}{math2.html}
-\item
- Giving jekyll a copy of math.md, it creates
- \href{http://cboettig.github.com/sandbox/math-jekyll.html}{math-jekyll.html}
-\end{itemize}
-
-\end{document}
View
@@ -0,0 +1,25 @@
+
+files <- system("ls *.markdown", intern=TRUE)
+library(knitcitations)
+library(gsubfn)
+
+
+ pattern = "\\[cite\\](\\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?![\"&\'<>])\\S)+)\\b)\\s?\\[\\/cite\\]"
+
+lapply(files, function(file){
+ content <- readLines(file)
+ lines <- grep(pattern, content, perl=TRUE)
+ if(length(lines > 0)){
+ print(file)
+ newbib()
+ content[lines] <- gsubfn(pattern, citep, backref=-1, content[lines], perl=TRUE)
+ bib <- bibliography("markdown")
+ if(length(bib)>0){
+ content <- c(content, "\n", bib)
+ writeLines(content, file)
+ }
+ }
+})
+
+
+
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+
+for f in `grep -l '##* References$' *.markdown *.md`
+ # *md *.markdown
+ do
+ sed -i 's/##* References/\n## References' $f
+ sed -n '/---/,/---/p' $f > yaml.md
+ sed '1,/^$/d' $f > body.md
+ ~/.cabal/bin/./pandoc -f markdown body.md -t html --mathjax -o body.html
+ ~/.cabal/bin/./pandoc body.html -t markdown_github --mathjax -o out.md
+ cat yaml.md out.md > $f
+ rm yaml.md body.md out.md body.html
+done
+
+
View
@@ -0,0 +1,25 @@
+
+files <- system("ls *.markdown", intern=TRUE)
+
+require(knitr)
+require(gsubfn)
+
+
+url_pattern <- "https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]"
+chunk_name <- "[-\\s\\da-zA-Z]*"
+pattern <- paste("!\\[", chunk_name, "\\]\\((", url_pattern, " ?)\\)", sep="")
+
+makeuri <- function(url){
+ download.file(url, destfile="temp.png")
+ uri <- image_uri("temp.png")
+ system("rm temp.png")
+ paste("![](", uri, ")", sep="")
+}
+
+lapply(files,
+ function(file){
+ content <- readLines(file)
+ content <- gsubfn(pattern, makeuri, content)
+ writeLines(content, file)
+})
+
File renamed without changes.
@@ -0,0 +1,23 @@
+
+#
+
+```{r include=FALSE}
+opts_knit$set(upload.fun = socialR::notebook.url)
+opts_chunk$set(dev.args=list(bg="transparent"))
+```
+
+```{r}
+require(ggplot2)
+theme_transparent <- theme_set(theme_bw(14))
+theme_transparent <- theme_update(
+ panel.grid.major=element_blank(), panel.grid.minor=element_blank(),
+ legend.title=element_blank(),
+ panel.background = element_rect(fill = "transparent",colour = NA),
+ plot.background = element_rect(fill = "transparent",colour = NA))
+```
+
+is this transparent?
+
+```{r}
+qplot(hp, mpg, data = mtcars) + geom_smooth()
+```
Oops, something went wrong.

0 comments on commit a016431

Please sign in to comment.