Skip to content

Commit e161e60

Browse files
author
Pietro Vertechi
authored
Clean up and custom title support (#39)
* cleanup and customizable title * options cleanup * bump version
1 parent 93a77f7 commit e161e60

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Remark"
22
uuid = "79b45036-8e38-5d04-8f49-b9fb23ff5a0d"
33
authors = ["Pietro Vertechi <[email protected]>"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"

assets/indextemplate.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Title</title>
4+
<title>$title</title>
55
<meta charset="utf-8">
66
<link rel="stylesheet" type="text/css" href="styles.css">
77
</head>
88
<body>
99
<textarea id="source">
10-
sfTiCgvZnilxkAh6ccwvfYSrKb4PmBKK
10+
$presentation
1111
</textarea>
1212

1313
<script src="remark.min.js" type="text/javascript"></script>
1414
<script src="katex.min.js"></script>
1515
<script src="auto-render.min.js"></script>
1616
<link rel="stylesheet" href="katex.min.css">
1717
<script type="text/javascript">
18-
11JoqONykUJUYw2d2zoMrKzXIOIdQP83
18+
var options = $options;
1919
var renderMath = function() {
2020
// renderMathInElement(document.body);
2121
// or if you want to use $...$ for math,

src/Remark.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ const depfiles = joinpath.(_pkg_assets, depnames)
2323
const styles_css = joinpath(_pkg_assets, "styles.css")
2424

2525
function slideshow(inputfile, outputdir = dirname(inputfile);
26-
documenter = true, css = styles_css, options = Dict())
26+
title = "Title", documenter = true, css = styles_css, options = Dict())
27+
2728
inputfile = realpath(abspath(inputfile))
2829
outputdir = realpath(abspath(outputdir))
2930
css = realpath(abspath(css))
3031
mkpath.(joinpath.(outputdir, ("src", "build")))
3132
mk_file = _create_index_md(inputfile, outputdir; documenter = documenter)
32-
_create_index_html(outputdir, mk_file, options)
33+
_create_index_html(outputdir, mk_file, options; title = title)
3334
cp(css, joinpath(outputdir, "build", "styles.css"), force=true)
3435
rm(mk_file)
3536
return outputdir
@@ -65,16 +66,20 @@ function _create_index_md(inputfile, outputdir; documenter = true)
6566
end
6667

6768

68-
function _create_index_html(outputdir, md_file, options = Dict())
69+
function _create_index_html(outputdir, md_file, options = Dict(); title = "Title")
6970

7071
Base.open(joinpath(outputdir, "build", "index.html"), "w") do f
7172
template = Base.open(joinpath(_pkg_assets, "indextemplate.html"))
7273
for line in eachline(template, keep=true)
73-
if occursin(r"^(\s)*sfTiCgvZnilxkAh6ccwvfYSrKb4PmBKK", line)
74+
if occursin(r"\$title", line)
75+
title_line = replace(line, r"\$title" => title)
76+
write(f, title_line)
77+
elseif occursin(r"\$presentation", line)
7478
copytobuffer!(f, md_file)
75-
elseif occursin(r"^(\s)*11JoqONykUJUYw2d2zoMrKzXIOIdQP83", line)
79+
elseif occursin(r"\$options", line)
7680
optionsjs = JSON.json(options)
77-
write(f, "var options = $optionsjs;\n")
81+
option_line = replace(line, r"\$options" => optionsjs)
82+
write(f, option_line)
7883
else
7984
write(f, line)
8085
end

0 commit comments

Comments
 (0)