Skip to content

Commit

Permalink
fixing tests & demos
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart committed Apr 16, 2024
1 parent 8c04325 commit 65429e4
Show file tree
Hide file tree
Showing 73 changed files with 105 additions and 21 deletions.
3 changes: 2 additions & 1 deletion demos/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Franklin = "713c75ef-9fc9-4b05-94a9-213340da978e"
JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
2 changes: 1 addition & 1 deletion demos/_layout/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{if hasmath}} {{insert head_katex.html }} {{end}}
{{if hasmath}} {{insert head_katex.html }} {{end}}
{{if hascode}}
{{insert head_highlight.html }}
<script src="/libs/clipboard.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions demos/_libs/katex_n/auto-render.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added demos/_libs/katex_n/fonts/KaTeX_AMS-Regular.ttf
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_AMS-Regular.woff
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_AMS-Regular.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Fraktur-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Bold.ttf
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Bold.woff
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Bold.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Italic.ttf
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Italic.woff
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Italic.woff2
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Regular.ttf
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Main-Regular.woff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Math-Italic.ttf
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Math-Italic.woff
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Math-Italic.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Size1-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Size2-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Size3-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added demos/_libs/katex_n/fonts/KaTeX_Size4-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions demos/_libs/katex_n/katex.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions demos/_libs/katex_n/katex.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions demos/foo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@def tags = ["foo"]
@def var = 5
+++
tags = ["foo"]
var = 5
+++

# Foo page

Expand Down
58 changes: 58 additions & 0 deletions demos/index.html

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions demos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title = "Franklin FAQ"
tags = ["index"]
auto_code_path = true
has_math = true
hasmath = true
+++

# Franklin Demos
Expand All @@ -29,11 +29,10 @@ and [`PrettyTables.jl`](https://github.com/ronisbr/PrettyTables.jl).
The following `Dataframe`:

```julia
val = rand(1:10, 5)
tag = rand('A':'Z', 5)
math = rand(["\$a + b\$", "\$\\frac{1}{2}\$", "\$\\sqrt{2\\pi}\$"], 5)
website = rand(["[Franklin home page](https://franklinjl.org)", "[Franklin Github](https://github.com/tlienart/Franklin.jl)"], 5)
DataFrame(; val, tag, math, website)
val = [1,2,3,4]
tag = ['a','b','c','d']
math = ["\$x\$", "\$y^2\$", "\$\\sqrt{z}\$", "\$\\Omega\$"]
DataFrame(; val, tag, math)
```

will be rendered as:
Expand All @@ -42,6 +41,8 @@ will be rendered as:

This done via a `hfun_render_table` which can be found in [`utils.jl`](https://github.com/tlienart/Franklin.jl/blob/master/demos/utils.jl).



## (018) collapsible block
How to make a section expand when clicked, so that content is initially hidden? (Based on [this html guide](https://www.w3schools.com/howto/howto_js_collapsible.asp).)

Expand Down Expand Up @@ -119,6 +120,7 @@ lists
And all other stuff processed by Franklin!
}
## (017) making cells work in their own path
Currently if you're saving a figure in a code block, you need to specify where to place that figure, if you don't it will go in the current directory which is the main site directory, typically you don't want that, so one trick is to use the `@OUTPUT` macro like so:
Expand Down Expand Up @@ -160,6 +162,7 @@ Note that it requires WebGL to work which might not be enabled on all browsers.
[Here's a page](/weave/) where the content is generated from a [Weave.jl](https://github.com/JunoLab/Weave.jl).
## (014) Using MathJax
If you prefer MathJax over KaTeX for maths rendering, you can use that. For now this is not fully supported and so taking this path may lead to issues, please report them and help fixing those is welcome.
Expand Down
4 changes: 3 additions & 1 deletion demos/mathjax.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@def mathjax = true
+++
mathjax = true
+++

# Mathjax v3

Expand Down
18 changes: 11 additions & 7 deletions demos/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,23 @@ end
###########

function hfun_render_table()
val = rand(1:10, 5)
tag = rand('A':'Z', 5)
math = rand(["\$a + b\$", "\$\\frac{1}{2}\$", "\$\\sqrt{2\\pi}\$"], 5)
website = rand(["[Franklin home page](https://franklinjl.org)", "[Franklin Github](https://github.com/tlienart/Franklin.jl)"], 5)
df = DataFrame(; val, tag, math, website)
val = [1,2,3,4]
tag = ['a','b','c','d']
math = ["\$x\$", "\$y^2\$", "\$\\sqrt{z}\$", "\$\\Omega\$"]
DataFrame(; val, tag, math)
df = DataFrame(; val, tag, math)
s = pretty_table(
String, # export table as a String
df;
nosubheader = true, # Remove the type from the column names
show_subheader = false, # Remove the type from the column names
tf = tf_html_default, # Use the default HTML rendered
alignment = :c, # Center alignment
formatters = ( # Convert every inner cell to html
(x, _, _) -> Franklin.fd2html(string(x), internal = true, nop = true),
(x, _, _) -> Franklin.fd2html(
string(x),
internal = true,
nop = true
),
(x, _, _) -> strip(x),
),
allow_html_in_cells = true, # needed given the previous rendering
Expand Down
5 changes: 4 additions & 1 deletion demos/wgl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title = "WGLMakie + JSServe"
+++

WGLMakie + JSServe doesn't support static export well at the moment, there used to be a demo here but we removed it. See [this issue](https://github.com/MakieOrg/Makie.jl/issues/3027).

<!--
```julia:ex
using WGLMakie, JSServe
io = IOBuffer()
Expand All @@ -18,4 +21,4 @@ show(io, MIME"text/html"(), app)
println(io, "~~~")
println(String(take!(io)))
```
\textoutput{ex}
\textoutput{ex} --> -->
8 changes: 7 additions & 1 deletion test/eval/eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,18 @@ end
global h
h = s |> seval
end
# error messages changed slightly
if VERSION < v"1.10"
estr = "sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x))."
else
estr = "sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x))."
end
@test h // """
<p>Simple code:</p>
<pre><code class="language-julia">$(F.htmlesc(raw"""sqrt(-1)"""))</code></pre>
<p>then:</p>
<pre><code class="plaintext code-output">DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
$estr
</code></pre>
<p>done.</p>"""
@test occursin("'DomainError' when", s)
Expand Down
4 changes: 3 additions & 1 deletion test/eval/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
exs = F.parse_code(c)
@test exs[1] == :(a = 7)
@test exs[2].head == :incomplete
@test exs[2].args[1] == "incomplete: premature end of input"
if VERSION < v"1.10"
@test exs[2].args[1] == "incomplete: premature end of input"
end
# empty code
c = ""
exs = F.parse_code(c)
Expand Down

0 comments on commit 65429e4

Please sign in to comment.