error/warning added to example
This commit is contained in:
parent
6d23b39e98
commit
b3315e3a4d
216
example.html
216
example.html
|
@ -17,9 +17,10 @@ div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|||
ul.task-list{list-style: none;}
|
||||
ul.task-list li input[type="checkbox"] {
|
||||
width: 0.8em;
|
||||
margin: 0 0.8em 0.2em -1.6em;
|
||||
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* CSS for syntax highlighting */
|
||||
pre > code.sourceCode { white-space: pre; position: relative; }
|
||||
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
||||
pre > code.sourceCode > span:empty { height: 1.2em; }
|
||||
|
@ -46,43 +47,13 @@ pre.numberSource code > span > a:first-child::before
|
|||
-khtml-user-select: none; -moz-user-select: none;
|
||||
-ms-user-select: none; user-select: none;
|
||||
padding: 0 4px; width: 4em;
|
||||
color: #aaaaaa;
|
||||
}
|
||||
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
||||
pre.numberSource { margin-left: 3em; padding-left: 4px; }
|
||||
div.sourceCode
|
||||
{ }
|
||||
@media screen {
|
||||
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
||||
}
|
||||
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
||||
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
||||
code span.at { color: #7d9029; } /* Attribute */
|
||||
code span.bn { color: #40a070; } /* BaseN */
|
||||
code span.bu { color: #008000; } /* BuiltIn */
|
||||
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
||||
code span.ch { color: #4070a0; } /* Char */
|
||||
code span.cn { color: #880000; } /* Constant */
|
||||
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
||||
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
||||
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
||||
code span.dt { color: #902000; } /* DataType */
|
||||
code span.dv { color: #40a070; } /* DecVal */
|
||||
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
||||
code span.ex { } /* Extension */
|
||||
code span.fl { color: #40a070; } /* Float */
|
||||
code span.fu { color: #06287e; } /* Function */
|
||||
code span.im { color: #008000; font-weight: bold; } /* Import */
|
||||
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
||||
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
||||
code span.op { color: #666666; } /* Operator */
|
||||
code span.ot { color: #007020; } /* Other */
|
||||
code span.pp { color: #bc7a00; } /* Preprocessor */
|
||||
code span.sc { color: #4070a0; } /* SpecialChar */
|
||||
code span.ss { color: #bb6688; } /* SpecialString */
|
||||
code span.st { color: #4070a0; } /* String */
|
||||
code span.va { color: #19177c; } /* Variable */
|
||||
code span.vs { color: #4070a0; } /* VerbatimString */
|
||||
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
||||
</style>
|
||||
|
||||
|
||||
|
@ -97,17 +68,16 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
|
|||
<link href="example_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
||||
<link href="example_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
||||
<link href="example_files/libs/quarto-contrib/ansicolors/ansicolor.css" rel="stylesheet">
|
||||
|
||||
|
||||
|
||||
<link href="example_files/libs/quarto-contrib/juliamonofont/juliamono.css" rel="stylesheet">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="fullcontent">
|
||||
<body>
|
||||
|
||||
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
|
||||
|
||||
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
||||
<div class="quarto-alternate-formats"><h2>Other Formats</h2><ul><li><a href="example.pdf"><i class="bi bi-file-pdf"></i>PDF (julia)</a></li></ul></div></div>
|
||||
<main class="content" id="quarto-document-content">
|
||||
|
||||
<header id="title-block-header" class="quarto-title-block default">
|
||||
|
@ -128,27 +98,27 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
|
|||
</header>
|
||||
|
||||
<section id="colored-console-graphs-produced-by-benchmarktools.jl" class="level2">
|
||||
<h2 class="anchored" data-anchor-id="colored-console-graphs-produced-by-benchmarktools.jl">colored console graphs produced by <code>Benchmarktools.jl</code></h2>
|
||||
<h2 class="anchored" data-anchor-id="colored-console-graphs-produced-by-benchmarktools.jl">Colored console graphs produced by <code>Benchmarktools.jl</code></h2>
|
||||
<div class="cell" data-execution_count="2">
|
||||
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">BenchmarkTools</span></span>
|
||||
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="pp">@benchmark</span> <span class="fu">sum</span>(<span class="fu">rand</span>(<span class="fl">1000</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-display" data-execution_count="38">
|
||||
<pre class="ansi"><code class="ansi">BenchmarkTools.Trial: 10000 samples with 17 evaluations.
|
||||
Range <span class="ansi-black-intense-fg">(</span><span class="ansi-cyan-intense-fg ansi-bold">min</span> … <span class="ansi-magenta-fg">max</span><span class="ansi-black-intense-fg">): </span><span class="ansi-cyan-intense-fg ansi-bold">922.412 ns</span> … <span class="ansi-magenta-fg">62.270 μs</span> <span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>min … max<span class="ansi-black-intense-fg">): </span>0.00% … 95.68%
|
||||
Time <span class="ansi-black-intense-fg">(</span><span class="ansi-blue-intense-fg ansi-bold">median</span><span class="ansi-black-intense-fg">): </span><span class="ansi-blue-intense-fg ansi-bold"> 1.006 μs </span><span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>median<span class="ansi-black-intense-fg">): </span>0.00%
|
||||
Time <span class="ansi-black-intense-fg">(</span><span class="ansi-green-intense-fg ansi-bold">mean</span> ± <span class="ansi-green-fg">σ</span><span class="ansi-black-intense-fg">): </span><span class="ansi-green-intense-fg ansi-bold"> 1.258 μs</span> ± <span class="ansi-green-fg"> 2.330 μs</span> <span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>mean ± σ<span class="ansi-black-intense-fg">): </span>9.38% ± 5.03%
|
||||
<div class="cell-output cell-output-display" data-execution_count="2">
|
||||
<pre class="ansi"><code class="ansiansi">BenchmarkTools.Trial: 10000 samples with 15 evaluations.
|
||||
Range <span class="ansi-black-intense-fg">(</span><span class="ansi-cyan-intense-fg ansi-bold">min</span> … <span class="ansi-magenta-fg">max</span><span class="ansi-black-intense-fg">): </span><span class="ansi-cyan-intense-fg ansi-bold">915.067 ns</span> … <span class="ansi-magenta-fg">102.184 μs</span> <span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>min … max<span class="ansi-black-intense-fg">): </span>0.00% … 97.41%
|
||||
Time <span class="ansi-black-intense-fg">(</span><span class="ansi-blue-intense-fg ansi-bold">median</span><span class="ansi-black-intense-fg">): </span><span class="ansi-blue-intense-fg ansi-bold"> 1.020 μs </span><span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>median<span class="ansi-black-intense-fg">): </span>0.00%
|
||||
Time <span class="ansi-black-intense-fg">(</span><span class="ansi-green-intense-fg ansi-bold">mean</span> ± <span class="ansi-green-fg">σ</span><span class="ansi-black-intense-fg">): </span><span class="ansi-green-intense-fg ansi-bold"> 1.298 μs</span> ± <span class="ansi-green-fg"> 2.710 μs</span> <span class="ansi-black-intense-fg">┊</span> GC <span class="ansi-black-intense-fg">(</span>mean ± σ<span class="ansi-black-intense-fg">): </span>9.11% ± 4.40%
|
||||
|
||||
▃▇█<span class="ansi-blue-fg">█</span>▇▅▂ <span class="ansi-green-fg"> </span> ▁▂▂▄▃▃▂ ▂
|
||||
███<span class="ansi-blue-fg">█</span>███▇▇▇▆▆▄▄<span class="ansi-green-fg">▃</span>▃▃▃▃▄▃▃▁▃▁▄▁▁▃▁▁▁▁▃▄▄▄▁▃▄▁▄▄▃▁▃▁▄▃▁▇█████████ █
|
||||
922 ns<span class="ansi-black-intense-fg"> </span><span class="ansi-black-intense-fg">Histogram: </span><span class="ansi-black-intense-fg ansi-bold">log(</span><span class="ansi-black-intense-fg">frequency</span><span class="ansi-black-intense-fg ansi-bold">)</span><span class="ansi-black-intense-fg"> by time</span> 2.41 μs <span class="ansi-bold"><</span>
|
||||
▁▆██<span class="ansi-blue-fg">▇</span>▄▁ <span class="ansi-green-fg"> </span> ▂▂▃▂▂▂▁▁▁▁ ▂
|
||||
████<span class="ansi-blue-fg">█</span>██▇▆▆▆▆▅<span class="ansi-green-fg">▅</span>▆▄▃▁▄▄▃▃▃▄▃▃▃▃▃▁▁▄▄▅▄▄▄▃▁▁▄▁▃▃▁▃▄▁▄▇▇██████████ █
|
||||
915 ns<span class="ansi-black-intense-fg"> </span><span class="ansi-black-intense-fg">Histogram: </span><span class="ansi-black-intense-fg ansi-bold">log(</span><span class="ansi-black-intense-fg">frequency</span><span class="ansi-black-intense-fg ansi-bold">)</span><span class="ansi-black-intense-fg"> by time</span> 2.74 μs <span class="ansi-bold"><</span>
|
||||
|
||||
Memory estimate<span class="ansi-black-intense-fg">: </span><span class="ansi-yellow-fg">7.94 KiB</span>, allocs estimate<span class="ansi-black-intense-fg">: </span><span class="ansi-yellow-fg">1</span>.</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="structure-of-floating-point-numbers" class="level2">
|
||||
<h2 class="anchored" data-anchor-id="structure-of-floating-point-numbers">structure of floating point numbers</h2>
|
||||
<h2 class="anchored" data-anchor-id="structure-of-floating-point-numbers">Structure of floating point numbers</h2>
|
||||
<div class="cell" data-execution_count="3">
|
||||
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span> <span class="fu">printbitsf64</span>(x<span class="op">::</span><span class="dt">Float64</span>)</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> s <span class="op">=</span> <span class="fu">bitstring</span>(x)</span>
|
||||
|
@ -160,11 +130,11 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
|
|||
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="fu">printbitsf64</span>(<span class="fl">27.56640625</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre class="ansi"><code class="ansi"><span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">10000000011</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">1011100100010000000000000000000000000000000000000000</span></code></pre>
|
||||
<pre class="ansi"><code class="ansiansi"><span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">10000000011</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">1011100100010000000000000000000000000000000000000000</span></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<section id="illustrate-machine-epsilon" class="level3">
|
||||
<h3 class="anchored" data-anchor-id="illustrate-machine-epsilon">illustrate machine epsilon…</h3>
|
||||
<h3 class="anchored" data-anchor-id="illustrate-machine-epsilon">Illustrate machine epsilon…</h3>
|
||||
<div class="cell" data-execution_count="4">
|
||||
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>Eps<span class="op">=</span><span class="fl">0.5</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="cf">while</span> <span class="fl">1</span> <span class="op">!=</span> <span class="fl">1</span> <span class="op">+</span> Eps</span>
|
||||
|
@ -172,7 +142,7 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
|
|||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">printbitsf64</span>(<span class="fl">1</span><span class="op">+</span>Eps)</span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre class="ansi"><code class="ansi"><span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">01111111111</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">0100000000000000000000000000000000000000000000000000</span>
|
||||
<pre class="ansi"><code class="ansiansi"><span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">01111111111</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">0100000000000000000000000000000000000000000000000000</span>
|
||||
<span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">01111111111</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">0010000000000000000000000000000000000000000000000000</span>
|
||||
<span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">01111111111</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">0001000000000000000000000000000000000000000000000000</span>
|
||||
<span class="ansi-default-inverse-fg ansi-blue-bg">0</span><span class="ansi-default-inverse-fg ansi-green-bg">01111111111</span><span class="ansi-default-inverse-fg ansi-red-intense-bg ansi-bold">0000100000000000000000000000000000000000000000000000</span>
|
||||
|
@ -240,11 +210,51 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
|
|||
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="fu">printbits2f64</span>(<span class="fl">27.56640625</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre class="ansi"><code class="ansi"><span class="ansi-default-inverse-fg" style="background-color: rgb(175,175,55)">0</span><span class="ansi-underline" style="color: rgb(215,255,55)">10000000011</span><span class="ansi-default-inverse-fg ansi-bold" style="background-color: rgb(55,95,255)">1011100100010000000000000000000000000000000000000000</span></code></pre>
|
||||
<pre class="ansi"><code class="ansiansi"><span class="ansi-default-inverse-fg" style="background-color: rgb(175,175,55)">0</span><span class="ansi-underline" style="color: rgb(215,255,55)">10000000011</span><span class="ansi-default-inverse-fg ansi-bold" style="background-color: rgb(55,95,255)">1011100100010000000000000000000000000000000000000000</span></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<section id="errors-and-warnings" class="level2">
|
||||
<h2 class="anchored" data-anchor-id="errors-and-warnings">Errors and Warnings</h2>
|
||||
<div class="cell" data-warn="true" data-execution_count="6">
|
||||
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="cn">π</span><span class="op">^</span><span class="fl">2</span>)</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">ceil</span>(<span class="fl">2.3</span><span class="op">+</span><span class="fl">5.6im</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre class="ansi"><code class="ansiansi">9.869604401089358
|
||||
LoadError: MethodError: no method matching ceil(::ComplexF64)
|
||||
Closest candidates are:
|
||||
ceil(<span class="ansi-red-intense-fg">::Union{Dates.Day, Dates.Week, Dates.TimePeriod}</span>, <span class="ansi-red-intense-fg">::Union{Dates.Day, Dates.Week, Dates.TimePeriod}</span>) at ~/.julia/juliaup/julia-1.8.5+0.x64.linux.gnu/share/julia/stdlib/v1.8/Dates/src/rounding.jl:184
|
||||
ceil(<span class="ansi-red-intense-fg">::Union{Dates.Day, Dates.Week, Dates.TimePeriod, Dates.TimeType}</span>, <span class="ansi-red-intense-fg">::Type{P}</span>) where P<:Dates.Period at ~/.julia/juliaup/julia-1.8.5+0.x64.linux.gnu/share/julia/stdlib/v1.8/Dates/src/rounding.jl:286
|
||||
ceil(<span class="ansi-red-intense-fg">::Real</span>; kwargs...) at floatfuncs.jl:155
|
||||
...
|
||||
|
||||
Stacktrace:
|
||||
[1] top-level scope
|
||||
@ In[6]:2
|
||||
[2] eval
|
||||
@ ./boot.jl:368 [inlined]
|
||||
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
|
||||
@ Base ./loading.jl:1428</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<p>The <code>@warn</code> macro writes to the <code>stderr</code> channel:</p>
|
||||
<div class="cell" data-warn="true" data-execution_count="7">
|
||||
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="cn">π</span><span class="op">^</span><span class="fl">2</span>)</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="pp">@warn</span> <span class="st">"Last warning!"</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="fl">1</span> <span class="op">+</span> <span class="fl">41</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
||||
<div class="cell-output cell-output-stdout">
|
||||
<pre class=""><code class="ansi">9.869604401089358</code></pre>
|
||||
</div>
|
||||
<div class="cell-output cell-output-stderr">
|
||||
<pre class=" julia-stderr"><code class=" julia-stderransi">┌ Warning: Last warning!
|
||||
└ @ Main In[7]:2</code></pre>
|
||||
</div>
|
||||
<div class="cell-output cell-output-display" data-execution_count="7">
|
||||
<pre class=""><code class="ansi">42</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
<!-- /main column -->
|
||||
|
@ -275,9 +285,23 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
|||
icon: icon
|
||||
};
|
||||
anchorJS.add('.anchored');
|
||||
const isCodeAnnotation = (el) => {
|
||||
for (const clz of el.classList) {
|
||||
if (clz.startsWith('code-annotation-')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const clipboard = new window.ClipboardJS('.code-copy-button', {
|
||||
target: function(trigger) {
|
||||
return trigger.previousElementSibling;
|
||||
text: function(trigger) {
|
||||
const codeEl = trigger.previousElementSibling.cloneNode(true);
|
||||
for (const childEl of codeEl.children) {
|
||||
if (isCodeAnnotation(childEl)) {
|
||||
childEl.remove();
|
||||
}
|
||||
}
|
||||
return codeEl.innerText;
|
||||
}
|
||||
});
|
||||
clipboard.on('success', function(e) {
|
||||
|
@ -342,6 +366,92 @@ window.document.addEventListener("DOMContentLoaded", function (event) {
|
|||
return note.innerHTML;
|
||||
});
|
||||
}
|
||||
let selectedAnnoteEl;
|
||||
const selectorForAnnotation = ( cell, annotation) => {
|
||||
let cellAttr = 'data-code-cell="' + cell + '"';
|
||||
let lineAttr = 'data-code-annotation="' + annotation + '"';
|
||||
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
|
||||
return selector;
|
||||
}
|
||||
const selectCodeLines = (annoteEl) => {
|
||||
const doc = window.document;
|
||||
const targetCell = annoteEl.getAttribute("data-target-cell");
|
||||
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
|
||||
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
|
||||
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
|
||||
const lineIds = lines.map((line) => {
|
||||
return targetCell + "-" + line;
|
||||
})
|
||||
let top = null;
|
||||
let height = null;
|
||||
let parent = null;
|
||||
if (lineIds.length > 0) {
|
||||
//compute the position of the single el (top and bottom and make a div)
|
||||
const el = window.document.getElementById(lineIds[0]);
|
||||
top = el.offsetTop;
|
||||
height = el.offsetHeight;
|
||||
parent = el.parentElement.parentElement;
|
||||
if (lineIds.length > 1) {
|
||||
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
|
||||
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
|
||||
height = bottom - top;
|
||||
}
|
||||
if (top !== null && height !== null && parent !== null) {
|
||||
// cook up a div (if necessary) and position it
|
||||
let div = window.document.getElementById("code-annotation-line-highlight");
|
||||
if (div === null) {
|
||||
div = window.document.createElement("div");
|
||||
div.setAttribute("id", "code-annotation-line-highlight");
|
||||
div.style.position = 'absolute';
|
||||
parent.appendChild(div);
|
||||
}
|
||||
div.style.top = top - 2 + "px";
|
||||
div.style.height = height + 4 + "px";
|
||||
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
|
||||
if (gutterDiv === null) {
|
||||
gutterDiv = window.document.createElement("div");
|
||||
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
|
||||
gutterDiv.style.position = 'absolute';
|
||||
const codeCell = window.document.getElementById(targetCell);
|
||||
const gutter = codeCell.querySelector('.code-annotation-gutter');
|
||||
gutter.appendChild(gutterDiv);
|
||||
}
|
||||
gutterDiv.style.top = top - 2 + "px";
|
||||
gutterDiv.style.height = height + 4 + "px";
|
||||
}
|
||||
selectedAnnoteEl = annoteEl;
|
||||
}
|
||||
};
|
||||
const unselectCodeLines = () => {
|
||||
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
|
||||
elementsIds.forEach((elId) => {
|
||||
const div = window.document.getElementById(elId);
|
||||
if (div) {
|
||||
div.remove();
|
||||
}
|
||||
});
|
||||
selectedAnnoteEl = undefined;
|
||||
};
|
||||
// Attach click handler to the DT
|
||||
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
|
||||
for (const annoteDlNode of annoteDls) {
|
||||
annoteDlNode.addEventListener('click', (event) => {
|
||||
const clickedEl = event.target;
|
||||
if (clickedEl !== selectedAnnoteEl) {
|
||||
unselectCodeLines();
|
||||
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
|
||||
if (activeEl) {
|
||||
activeEl.classList.remove('code-annotation-active');
|
||||
}
|
||||
selectCodeLines(clickedEl);
|
||||
clickedEl.classList.add('code-annotation-active');
|
||||
} else {
|
||||
// Unselect the line
|
||||
unselectCodeLines();
|
||||
clickedEl.classList.remove('code-annotation-active');
|
||||
}
|
||||
});
|
||||
}
|
||||
const findCites = (el) => {
|
||||
const parentEl = el.parentElement;
|
||||
if (parentEl) {
|
||||
|
|
BIN
example.pdf
BIN
example.pdf
Binary file not shown.
32
example.qmd
32
example.qmd
|
@ -5,10 +5,13 @@ keep-tex: true
|
|||
cache: true
|
||||
format:
|
||||
julia-html: default
|
||||
julia-pdf: default
|
||||
julia-pdf:
|
||||
pdf-engine: xelatex
|
||||
papersize: a4
|
||||
code-block-bg: "#e0e0e0"
|
||||
---
|
||||
|
||||
## colored console graphs produced by `Benchmarktools.jl`
|
||||
## Colored console graphs produced by `Benchmarktools.jl`
|
||||
|
||||
```{julia}
|
||||
using BenchmarkTools
|
||||
|
@ -16,7 +19,7 @@ using BenchmarkTools
|
|||
@benchmark sum(rand(1000))
|
||||
```
|
||||
|
||||
## structure of floating point numbers
|
||||
## Structure of floating point numbers
|
||||
|
||||
```{julia}
|
||||
function printbitsf64(x::Float64)
|
||||
|
@ -30,7 +33,7 @@ end
|
|||
printbitsf64(27.56640625)
|
||||
```
|
||||
|
||||
### illustrate machine epsilon...
|
||||
### Illustrate machine epsilon...
|
||||
|
||||
```{julia}
|
||||
Eps=0.5
|
||||
|
@ -52,3 +55,24 @@ end
|
|||
|
||||
printbits2f64(27.56640625)
|
||||
```
|
||||
|
||||
|
||||
## Errors and Warnings
|
||||
|
||||
```{julia}
|
||||
#| error: true
|
||||
#| warn: true
|
||||
println(π^2)
|
||||
ceil(2.3+5.6im)
|
||||
```
|
||||
|
||||
The `@warn` macro writes to the `stderr` channel:
|
||||
|
||||
```{julia}
|
||||
#| error: true
|
||||
#| warn: true
|
||||
println(π^2)
|
||||
@warn "Last warning!"
|
||||
1 + 41
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue