éçãµã€ããžã§ãã¬ãŒã¿ãŒ Franklin.jl
æ¬ãµã€ãã®äœæã«ããã£ãŠåèã«ãããµã€ãã¯ãã¡ãã§ãã
MathSeminar.jl ä»ã®ãšããå¯äžïŒã®æ¥æ¬èªãœãŒã¹
䜿ã£ãŠã¿ã
ã€ã³ã¹ããŒã«æ¹æ³
ãŸãREPLã®ããã±ãŒãžã¢ãŒãããFranklinãã€ã³ã¹ããŒã«ããŸãã
julia>]
(pkg)>add Franklin
ãã¢ãµã€ããäœã£ãŠã¿ãã
以äžã®ã³ãŒããå®è¡ãããšãmySiteãšãããã©ã«ããŒäœæåŸã«ããŒã«ã«ãµãŒããŒãç«ã¡äžããã http://localhost:8000/ã«ã¢ã¯ã»ã¹ãããšãã¢ãµã€ãã確èªããããšãã§ããŸãã
using Franklin
newsite("mySite",template="vela")
serve()
ãã³ãã¬ãŒãã¯ããã§ç¢ºèªã§ããŸãã
mySiteãã©ã«ããŒä»¥äžã«ããŒã¯ããŠã³ãã¡ã€ã«ãçŽ æãå ¥ã£ãŠããŸãã ãã³ãã¬ãŒããã¡ã€ã«ãããããªãã䜿ã£ãŠè¡ãããšã«ãªããŸãã ã©ã€ãã¬ã³ããªã³ã°ã«ãã£ãŠç·šéåŸã®çµæãããã«ç¢ºèªã§ããã®ã§ã åå¿è ã§ã䜿ãããããšæããŸãã ãµãŒããŒåæ¢åŸã«ããäžåºŠèµ·åããæã¯ãmySiteãã©ã«ããŒã§REPLãç«ã¡äžããŠã
using Franklin;serve()
ãšã¿ã€ãããŸãã
åºæ¬çãªææ³
ããŒã¯ããŠã³ã®èšæ³ã«ãããã£ãŠæç« ãæžããŸãã
# h1ã¿ã°
## h2ã¿ã°
### h3ã¿ã°
1. çªå·ä»ããªã¹ã
1. çªå·ä»ããªã¹ã
1. çªå·ä»ããªã¹ã
- çªå·ãªããªã¹ã
- çªå·ãªããªã¹ã
- çªå·ãªããªã¹ã
[ãªã³ã¯å](ãªã³ã¯å
)
ãŸããKatexã«ããæ°åŒã¬ã³ããªã³ã°ãæšæºã§ãµããŒãããŠããŸãã TeXã®èšæ³ã«æ £ãã人ã«ã¯ãæ°åŒå ¥åã楜ã ã§ãã
$$ \int_{a}^{b} f(x) = F(b) - F(a)$$
juliaã®ã³ãŒããæžããŠã¿ãã
ããŒã¯ããŠã³ã®äžã§æ¬¡ã®ãããªã³ãŒããå®è¡ãããšããŸãã
```julia:test
println("Hello Franklin")
```
\show{test}
ãããšãã®ã³ãŒããå®è¡ãããçµæãåºåã§ããŸãã
println("Hello Franklin")
Hello Franklin
次ã®ããã«æžããŠããã°ã°ã©ããåºåã§ããŸãã
```julia:plot
using Plots
p = plot(x->sin(x),xlabel="x",ylabel="y")
savefig(p,joinpath(@OUTPUT,"figplot.svg"))
```
\figpop{figplot}
using Plots
p = plot(x->sin(x),xlabel="x",ylabel="y")
savefig(p,joinpath(@OUTPUT,"figplot.svg"))
泚æããããã€ã³ã
\
èšå·ã«æ°ãä»ããã
\
ã®èšå·ãMarkdownã®äžã§äœ¿ããšãã¯æ³šæãå¿
èŠã§ãã Franklinã¯Markdownã®ãªãã§æ¡åŒµãããã³ãã³ãã䜿ãããšãã§ããŸãã ããšãã°ããããªå
·åã§ãã
<!-- ã³ãã³ãã®å®çŸ© -->
\newcommand{\bolditaliccenter}[1]{ ~~~
<div
style="font-size:xx-large;text-align:center;font-style:italic; font-weight:bold"
>
#1
</div>
~~~ }
<!-- ã³ãã³ãã®å®è¡ -->
\bolditaliccenter{ç¡é§ïŒ}
Franklinã¯ã\
ãä»ããšãããã³ãã³ãã ãšã¿ãªãã®ã§ãäžæã«\
ã䜿ãã ãã®ãªã\newcommand
ã§å®çŸ©ãããŠããªãã³ãã³ããšã¿ãªããã ãµãŒããŒãèœã¡ãŠã©ã€ãã¬ã³ããªã³ã°ã§ããªããªããŸãã
éåžžã®ããŒã¯ããŠã³ãæžããŠãããšãã¯ãã¹ããã«ãããšæããŸãããLiterate.jlãšé£æºããŠããã¥ã¡ã³ããæžããŠãããšãã¯ã æç« ãã³ã¡ã³ãã¢ãŠããããŠãã¹ã«æ°ã¥ãã«ããã®ã§æ³šæãå¿ èŠã§ãã
juliaã³ãŒãå ã®å€æ°ã®ã¹ã³ãŒã
juliaã䜿ããšãã¯ãã«ãŒããé¢æ°å éšããã°ããŒãã«å€æ°ãäœã®æãããªãåç §ããã®ã¯ ã¢ãŠãã ãšç¥ã£ãŠãã人ãå€ããšæããŸãã
ãã®çœ ã¯ãREPLãjupyterã䜿ã£ãŠãããã¿ã€ãã³ã°ãããŠãããšãã«ã¯æ°ã«ããªããŠãããã§ãããpowershellãªã©ã§julia hoge.jl
ãšãããšãã¯ã¢ãŠãã«ãªããŸãã
Franklinã§juliaã®ã³ãŒããå®è¡ãããšãã¯ããã®ç¶æ³ã«ãªãããã§ãå®éã«è©ŠããŠã¿ããš
a = 1
for i in 1:2
a += 1
end
UndefVarError: `a` not defined
ãšãªã£ãŠããŸããŸãã ãããé²ãã«ã¯ãletç°å¢ã«å
¥ã蟌ãã§ããŸããã
let
a = 1
for i in 1:2
a += 1
end
a
end
3
ã³ã³ãããŒã«ã®äžã§ã°ããŒãã«å€æ°ã§ããããšãæèšããå¿ èŠããããŸãã[1]
a = 1
for i in 1:2
global a += 1
end
a
3
[1] | global a #hide ã®ããã«æžãã°ãã³ãŒããé ãããšãã§ããŸãã |
GitHub actions ã®çœ
GitHub pagesã䜿ãã°ãç¡æã§ããŒã ããŒãžãäœãããšãã§ããŸããFranklin.jlã§ã¯ GitHub actionsïŒGitHubã®ã¬ããžããªã®äžã§èªåçã«å®è¡ãããåŠçïŒãå©çšããŠã ãµã€ããæ§æããããšãæšå¥šãããŠããŸãã
Franklin ã®å Žåã¯ã .github\workflows\deploy.yml
ã«ã³ãŒããèšèŒãããŠããŠã ãªã¢ãŒãã¬ããžããªãžpushãããšãã«åŠçãå®è¡ãããŸãã deploy.ymlã®äžèº«ãèŠãã°é°å²æ°ãããããšæããŸãããåŠçã®æµãããã£ãã説æãããš
GitHubäžã§OSãç«ã¡äžããŠãjuliaããäœããå¿ èŠãªãã®ãã€ã³ã¹ããŒã«
Franklinãå®è¡ããŠããµã€ãïŒ__siteãã©ã«ããŒä»¥äžïŒãäœã
gh-pagesãã©ã³ãã«ã§ãããµã€ããã¶ã¡ãã ãšããããšã«ãªããŸãã
åå¥ã®ç¶æ³ã«ãããŸããããã®deploy.ymlã¯ä¿®æ£ããå¿ èŠããããŸãã ç§ãããã£ãç¹ãæžããŠãããŸãã
master or main?
2020幎ã«GitHubã®ããã©ã«ããã©ã³ãåãmasterããmainã«å€æŽãããŸããã ããã«äŒŽã£ãŠãFranklinã§ãdeploy.ymlã«ã¯ãmainãã©ã³ãã«ããã·ã¥ããããšåäœããããã«ãªã£ãŠããŸãã
åœããåã§ããããã®ç¶æ ã§masterãã©ã³ãã«ããã·ã¥ããŠãäœãèµ·ãããŸããã deploy.ymlã®ãã©ã³ãåãå®éã®ãã©ã³ãåãšåãããå¿ èŠããããŸãã
gh-pages ã®èšå®ãããŠããããš
ã¬ããžããªã®ããŒãžã®Settingsã¿ãã®äžã®æ¹ã«GitHub Pages ã®æ¬ããããŸãã ãœãŒã¹ã®ãã©ã³ãã«gh-pagesãéžæããŠããå¿ èŠããããŸãã
ã©ã®ã¬ããžããªã«ããã·ã¥ããã
username.github.io以å€ã®ã¬ããžããªã«ããã·ã¥ãããšãã¯ãdeploy.yml ã®äžã«æžããŠããoptimize()ã optimize(;prepath="ã¬ããžããªå")ã«ããŠããå¿ èŠããããŸãã
ããããªããšããªã³ã¯åããèµ·ãããŠããŸããŸãã
Project.toml ãå ¥ããŠãããã
GitHub actionsã§ã®ãããã€æã«ã¯ãjuliaã³ãŒãã®äžã§äœ¿çšããããã±ãŒãžããããããã«ã æããŠããå¿ èŠããããŸããããŒã«ã«ã¬ããžããªã§ã以äžã®ããã«åŠçããŠãããšã
julia>]
(pkg)>activate .
(pkg)>add Plots # 䜿çšããããã±ãŒãž
Project.toml ãäœæãããã®ã§ãdeploy.yml ã®ãªãã§ãã¡ãã¡ Pkg.add(ïœïœ)ããå¿ èŠã¯ãªããªããŸãã
ããããã®xylabelãåãã
localãµãŒããŒäžã§ã¯åé¡ãªãããããã衚瀺ã§ããã®ã§ããã gh-pagesã§è¡šç€ºã確èªãããšãã°ã©ãã®ããŒãžã³èšå®ãäžæãã§ããªãå ŽåããããŸãã 以äžã®ãããªã³ãŒããæžããŠããŒãžã³ãèšå®ããŠããã°è§£æ±ºããããšãã§ããŸããã
using Plots.PlotMeasures
Plots.reset_defaults()
default(
left_margin = 30px,
bottom_margin = 30px
)
ãã£ãããªã®ã§ãæ¡åŒµããŠã¿ãã
htmlãcssã«é¢ããç¥èãå€å°ããã°ããã³ãã¬ãŒããã¡ã€ã«ãããã£ãŠæ©èœãæ¡åŒµ[1]ããããšãå¯èœã§ãã ç§ã¯adomonitionã®èšå®ããããã«æ»ããã¿ã³ãmermaid.jsã«ãããããŒãã£ãŒãæç»ã®æ©èœãªã©ãè¿œå ããŠã¿ãŸããã
ãã©ã³ããè¿œå ããäŸãæžããŠãããŸãã
ã³ãŒãã®ãã©ã³ãã«ã¯ juliamono ã䜿ãã
juliamonoãã©ã³ãã䜿ãã°ãjuliaã®ã³ãŒããæŽç·ŽãããèŠæ ãã«å€æŽã§ããŸãã ->ã->
ã«ãªã£ããã|>ã|>
ã«ãªãã®ã§ããã€ãæŒç®åãç¡åé¢æ°ãå€çšãã人ã¯ãæ°ã«å
¥ãã®ã§ã¯ãªãã§ããããïŒ Cormullion ã®ããã°(ãã®ãµã€ããFranklinã§äœãããŠããã)ã«ã€ã³ã¹ããŒã«æ¹æ³ã¯èŒã£ãŠããŸãã
cssã§webãã©ã³ããšããŠäœ¿ãã®ãç°¡åã§ãã¡ãã«ããæ¹ãèŒã£ãŠããŸãã å°ãæ¹å€ãããã®ã以äžã«ãªããŸãããŸããcssãã¡ã€ã«ã«
@font-face {
font-family: JuliaMono-Regular;
src: url("https://cdn.jsdelivr.net/gh/cormullion/juliamono/webfonts/JuliaMono-Regular.woff2");
}
ãšæžããŠã次ã«cssã»ã¬ã¯ã¿ãŒã®ãªãã§ãcodeãæ¢ããŠã
code {
font-family: "JuliaMono-Regular", Monaco, Consolas, "Lucida Console",
monospace;
}
ãªã©ãšããŠããã°è¯ãã§ããïŒfont-familyã®äžçªå·Šã«æžãããšãéèŠïŒ
ãŸãšã
Franklin.jl ã䜿ãã°ããã³ãã¬ãŒããµã€ããããã£ãŠç°¡åã«èªåã ãã®ãµã€ããäœããã
èªåã ãã®ã³ãã³ããäœãããã
\
ã®èšå·ã«ã¯æ³šæãå¿ èŠãjulia ã³ãŒããå®è¡ãããšãã¯å€æ°ã®ã¹ã³ãŒãã«æ³šæããã
GitHub-pagesãå©çšããŠç¡æã§ããŒã ããŒãžãäœããã
GitHub-pagesã䜿ããšãã¯ãdeploy.ymlãProject.tomlããœãŒã¹ãã©ã³ãã®èšå®ã«æ³šæã
cssãjavascriptãããã£ãŠèªåã§æ¡åŒµã§ããã
ãã§ãããã§ãã