Browse Source

ditch the at-__NAME__ variable

pull/5/head
Fredrik Ekre 8 years ago
parent
commit
77dcb96986
  1. 6
      src/Examples.jl
  2. 6
      test/example.jl

6
src/Examples.jl

@ -121,13 +121,11 @@ function script(inputfile, outputdir; preprocess = identity, postprocess = ident
## - remove #md lines ## - remove #md lines
## - remove #nb lines ## - remove #nb lines
## - remove leading and trailing #jl ## - remove leading and trailing #jl
## - replace @__NAME__
for repl in Pair{Any,Any}[ for repl in Pair{Any,Any}[
r"^#md.*\n?"m => "", r"^#md.*\n?"m => "",
r"^#nb.*\n?"m => "", r"^#nb.*\n?"m => "",
r"^#jl "m => "", r"^#jl "m => "",
r" #jl$"m => "", r" #jl$"m => "",
"@__NAME__" => name,
] ]
content = replace(content, repl) content = replace(content, repl)
end end
@ -203,13 +201,11 @@ function markdown(inputfile, outputdir; preprocess = identity, postprocess = ide
## - remove #nb lines ## - remove #nb lines
## - remove leading and trailing #jl lines ## - remove leading and trailing #jl lines
## - remove leading #md ## - remove leading #md
## - replace @__NAME__
for repl in Pair{Any,Any}[ for repl in Pair{Any,Any}[
r"^#nb.*\n?"m => "", r"^#nb.*\n?"m => "",
r"^#jl.*\n?"m => "", r"^#jl.*\n?"m => "",
r".*#jl$\n?"m => "", r".*#jl$\n?"m => "",
r"^#md "m => "", r"^#md "m => "",
"@__NAME__" => name,
] ]
content = replace(content, repl) content = replace(content, repl)
end end
@ -306,14 +302,12 @@ function notebook(inputfile, outputdir; preprocess = identity, postprocess = ide
## - remove #md lines ## - remove #md lines
## - remove leading and trailing #jl lines ## - remove leading and trailing #jl lines
## - remove leading #nb ## - remove leading #nb
## - replace @__NAME__
## - replace ```math ... ``` with \begin{equation} ... \end{equation} ## - replace ```math ... ``` with \begin{equation} ... \end{equation}
for repl in Pair{Any,Any}[ for repl in Pair{Any,Any}[
r"^#md.*\n?"m => "", r"^#md.*\n?"m => "",
r"^#jl.*\n?"m => "", r"^#jl.*\n?"m => "",
r".*#jl$\n?"m => "", r".*#jl$\n?"m => "",
r"^#nb "m => "", r"^#nb "m => "",
"@__NAME__" => name,
] ]
content = replace(content, repl) content = replace(content, repl)
end end

6
test/example.jl

@ -0,0 +1,6 @@
#' # Examples.jl
#'
#' This file is an example of how to write an input file for Examples.jl.
#' The file will be used to render a markdown file, a notebook
1 + 1
Loading…
Cancel
Save