mirror of https://github.com/mpastell/Weave.jl
Make mathjax work with sef-contained pandoc, fix a bug in script reader
parent
680c089c1c
commit
2b5e8ee968
|
@ -51,17 +51,11 @@ end
|
||||||
|
|
||||||
#' Designing a lowpass FIR filter is very simple to do with DSP.jl, all you
|
#' 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
|
#' need to do is to define the window length, cut off frequency and the
|
||||||
#' window.
|
#' window. We will define a lowpass filter with cut off frequency at 5Hz for a signal
|
||||||
|
|
||||||
#' We will define a lowpass filter with cut off frequency at 5Hz for a signal
|
|
||||||
#' sampled at 20 Hz.
|
#' sampled at 20 Hz.
|
||||||
|
#' We will use the Hamming window, which is defined as:
|
||||||
#' The Hamming window is defined as:
|
|
||||||
#' $w(n) = \alpha - \beta\cos\frac{2\pi n}{N-1}$, where $\alpha=0.54$ and $\beta=0.46$
|
#' $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
|
fs = 20
|
||||||
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
f = digitalfilter(Lowpass(5, fs = fs), FIRWindow(hamming(61)))
|
||||||
|
@ -70,11 +64,16 @@ h = FIRfreqz(f, w)
|
||||||
|
|
||||||
#' ## Plot the frequency and impulse response
|
#' ## 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))
|
h_db = log10(abs(h))
|
||||||
ws = w/pi*(fs/2)
|
ws = w/pi*(fs/2)
|
||||||
plot(y = h_db, x = ws, Geom.line,
|
plot(y = h_db, x = ws, Geom.line,
|
||||||
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Magnitude (db)"))
|
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Magnitude (db)"))
|
||||||
|
|
||||||
|
#' And again with default options
|
||||||
|
|
||||||
h_phase = unwrap(-atan2(imag(h),real(h)))
|
h_phase = unwrap(-atan2(imag(h),real(h)))
|
||||||
plot(y = h_phase, x = ws, Geom.line,
|
plot(y = h_phase, x = ws, Geom.line,
|
||||||
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
Guide.xlabel("Frequency (Hz)"), Guide.ylabel("Phase (radians)"))
|
||||||
|
|
|
@ -23,7 +23,7 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc)
|
||||||
try
|
try
|
||||||
#html = @compat readstring(
|
#html = @compat readstring(
|
||||||
run(pipeline(`echo $formatted` ,
|
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
|
--template $html_template --include-in-header=$css_template
|
||||||
-V wversion=$wversion -V wtime=$wtime -V wsource=$wsource
|
-V wversion=$wversion -V wtime=$wtime -V wsource=$wsource
|
||||||
-o $outname`))
|
-o $outname`))
|
||||||
|
@ -58,7 +58,7 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc)
|
||||||
info("Done executing code. Running xelatex")
|
info("Done executing code. Running xelatex")
|
||||||
try
|
try
|
||||||
run(pipeline(`echo $formatted` ,
|
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
|
--include-in-header=$header_template
|
||||||
-V fontsize=12pt
|
-V fontsize=12pt
|
||||||
-o $outname`))
|
-o $outname`))
|
||||||
|
|
|
@ -183,10 +183,8 @@ function parse_doc(document::AbstractString, format::ScriptInput)
|
||||||
haskey(options, :name) || (options[:name] = nothing)
|
haskey(options, :name) || (options[:name] = nothing)
|
||||||
|
|
||||||
state = "code"
|
state = "code"
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
elseif state == "doc" && strip(line) != "" && strip(read) != ""
|
||||||
elseif state == "doc" #&& strip(line) != "" && strip(read) != ""
|
|
||||||
state = "code"
|
state = "code"
|
||||||
(docno > 1) && (read = "\n" * read) # Add whitespace to doc chunk. Needed for markdown output
|
(docno > 1) && (read = "\n" * read) # Add whitespace to doc chunk. Needed for markdown output
|
||||||
chunk = DocChunk(read, docno, start_line)
|
chunk = DocChunk(read, docno, start_line)
|
||||||
|
|
|
@ -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">
|
<style type="text/css">
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Raleway';
|
font-family: 'Raleway';
|
||||||
|
|
|
@ -15,6 +15,7 @@ $if(keywords)$
|
||||||
$endif$
|
$endif$
|
||||||
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
|
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
|
||||||
|
|
||||||
|
|
||||||
$if(math)$
|
$if(math)$
|
||||||
$math$
|
$math$
|
||||||
$endif$
|
$endif$
|
||||||
|
|
Loading…
Reference in New Issue