Make mathjax work with sef-contained pandoc, fix a bug in script reader

pull/35/head
Matti Pastell 2016-04-22 13:18:33 +03:00
parent 680c089c1c
commit 2b5e8ee968
5 changed files with 20 additions and 13 deletions

View File

@ -51,17 +51,11 @@ end
#' Designing a lowpass FIR filter is very simple to do with DSP.jl, all you
#' need to do is to define the window length, cut off frequency and the
#' window.
#' We will define a lowpass filter with cut off frequency at 5Hz for a signal
#' window. We will define a lowpass filter with cut off frequency at 5Hz for a signal
#' sampled at 20 Hz.
#' The Hamming window is defined as:
#' We will use the Hamming window, which is defined as:
#' $w(n) = \alpha - \beta\cos\frac{2\pi n}{N-1}$, where $\alpha=0.54$ and $\beta=0.46$
#' The next code chunk is executed in term mode, see the [script](FIR_design.jl) for syntax.
#+ term=true
fs = 20
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
@ -70,11 +64,16 @@ h = FIRfreqz(f, w)
#' ## Plot the frequency and impulse response
#' The next code chunk is executed in term mode, see the [script](FIR_design.jl) for syntax.
#+ term=true
h_db = log10(abs(h))
ws = w/pi*(fs/2)
plot(y = h_db, x = ws, Geom.line,
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Magnitude (db)"))
#' And again with default options
h_phase = unwrap(-atan2(imag(h),real(h)))
plot(y = h_phase, x = ws, Geom.line,
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))

View File

@ -23,7 +23,7 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc)
try
#html = @compat readstring(
run(pipeline(`echo $formatted` ,
`pandoc -R -s --mathjax --self-contained --highlight-style=tango
`pandoc -R -s --mathjax="" --self-contained --highlight-style=tango
--template $html_template --include-in-header=$css_template
-V wversion=$wversion -V wtime=$wtime -V wsource=$wsource
-o $outname`))
@ -58,7 +58,7 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc)
info("Done executing code. Running xelatex")
try
run(pipeline(`echo $formatted` ,
`pandoc -R -s --self-contained --latex-engine=xelatex --highlight-style=tango
`pandoc -R -s --latex-engine=xelatex --highlight-style=tango
--include-in-header=$header_template
-V fontsize=12pt
-o $outname`))

View File

@ -183,10 +183,8 @@ function parse_doc(document::AbstractString, format::ScriptInput)
haskey(options, :name) || (options[:name] = nothing)
state = "code"
continue
elseif state == "doc" #&& strip(line) != "" && strip(read) != ""
elseif state == "doc" && strip(line) != "" && strip(read) != ""
state = "code"
(docno > 1) && (read = "\n" * read) # Add whitespace to doc chunk. Needed for markdown output
chunk = DocChunk(read, docno, start_line)

View File

@ -1,3 +1,12 @@
<script type="text/javascript">
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
document.getElementsByTagName("head")[0].appendChild(fileref)
</script>
<style type="text/css">
@font-face {
font-family: 'Raleway';

View File

@ -15,6 +15,7 @@ $if(keywords)$
$endif$
<title>$if(title-prefix)$$title-prefix$ $endif$$pagetitle$</title>
$if(math)$
$math$
$endif$