Source file report.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
open Core
open Bistro
module Md = struct
let picture_elt format file =
[%workflow
let format = match format with
| `svg -> "svg+xml"
| `png -> "png"
in
let contents =
In_channel.read_all [%path file]
|> Base64.encode_exn
in
sprintf {|<img src="data:image/%s;base64,%s"/>|} format contents]
let svg x = Template_dsl.string_dep (picture_elt `svg x)
let png x = Template_dsl.string_dep (picture_elt `png x)
let html_template = Template_dsl.string {|<!DOCTYPE html>
<html $if(lang)$ lang="$lang$" $endif$ dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>$if(title)$$title$$endif$</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon.png">
$if(template_css)$
<link rel="stylesheet" href="$template_css$">
$else$
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.26.4/css/uikit.gradient.css">
$endif$
<!-- <link rel="stylesheet" href="style.css"> -->
<link rel="stylesheet" href="https://cdn.rawgit.com/diversen/pandoc-uikit/master/style.css">
<link href="https://vjs.zencdn.net/5.4.4/video-js.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<!-- <script src="uikit.js"></script> -->
<script src="https://cdn.rawgit.com/diversen/pandoc-uikit/master/uikit.js"></script>
<!-- <script src="scripts.js"></script> -->
<script src="https://cdn.rawgit.com/diversen/pandoc-uikit/master/scripts.js"></script>
<!-- <script src="jquery.sticky-kit.js "></script> -->
<script src="https://cdn.rawgit.com/diversen/pandoc-uikit/master/jquery.sticky-kit.js"></script>
<meta name="generator" content="pandoc-uikit" />
$for(author-meta)$
<meta name="author" content="$author-meta$" />
$endfor$
$if(date-meta)$
<meta name="date" content="$date-meta$" />
$endif$
<title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title>
<style type="text/css">code{white-space: pre;}</style>
$if(quotes)$
<style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>
$endif$
$if(highlighting-css)$
<style type="text/css">
$highlighting-css$
</style>
$endif$
$for(css)$
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
$endfor$
$if(math)$
$math$
$endif$
$for(header-includes)$
$header-includes$
$endfor$
</head>
<body>
<div class="uk-container uk-container-center uk-margin-top uk-margin-large-bottom">
$if(title)$
<div class="uk-grid" data-uk-grid-margin>
<div class="uk-width-1-1">
<h1 class="uk-heading-large">$title$</h1>
$if(date)$
<h3 class="uk-heading-large">$date$</p></h3>
$endif$
$for(author)$
<p class="uk-text-large">$author$</p>
$endfor$
</div>
</div>
$endif$
<div class="uk-grid" data-uk-grid-margin >
<div class="uk-width-medium-1-4">
<div class="uk-overflow-container" data-uk-sticky="{top:25,media: 768}">
<div class="uk-panel uk-panel-box menu-begin" >
$if(toc)$
$toc$
$endif$
</div>
</div>
</div>
<div class="uk-width-medium-3-4">
$body$
</div>
</div>
$if(analytics)$
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '$analytics$', 'auto');
ga('send', 'pageview');
$endif$
<script src="https://vjs.zencdn.net/5.4.4/video.js"></script>
</div>
</body>
</html>
|}
let to_html doc =
Workflow.shell ~descr:"bistro_utils.report.to_html" Bistro.Shell_dsl.[
cmd "ln" [ string "-s" ; file_dump html_template ; tmp // "template.html5" ] ;
cmd "pandoc" [
opt' "--from" string "markdown+tex_math_single_backslash+tex_math_dollars" ;
opt' "--to" string "html5" ;
string "--katex" ;
opt' "--template" Fn.id (tmp // "template.html5") ;
opt' "--output" Fn.id dest ;
string "--toc" ;
file_dump doc ;
]
]
end