diff --git a/docs/make.jl b/docs/make.jl index 3e9743f..20c3d6e 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -35,12 +35,28 @@ EditURL = "https://github.com/fverdugo/XM_40017/blob/main/docs/src/notebooks/SCR ``` """ +function convert_embedded_img_to_base64(notebook_path) + doc = open(io->read(io, String), notebook_path) + # Regex matching: extract filename and base64 code + regex = r"attachments\\\":\s*\{\s*\\\"(?.*).png\\\":\s*\{\s*\\\"image/png\\\":\s*\\\"(?.*)\\\"" + res = eachmatch(regex, doc) + matches = collect(res) + # Replace img src with base64 code + for m in matches + filename = m[:filename] + base64 = m[:base64code] + doc = replace(doc, "attachment:$filename.png" => "data:image/png;base64,$base64") + end + + write(notebook_path, doc); +end + # Write markdown file that includes notebook html function create_md_nb_file( notebook_path ) global md_nb_template; script_file = splitpath(notebook_path)[end] script_name = splitext(script_file)[1] - content = replace( md_nb_template, "SCRIPT_NAME" => script_name) + content = replace(md_nb_template, "SCRIPT_NAME" => script_name) md_path = joinpath(@__DIR__, "src", script_name * ".md" ) open(md_path, "w") do md_file write(md_file, content) @@ -87,6 +103,7 @@ end # Loop over notebooks and generate html and markdown notebook_files = glob("*.ipynb", "docs/src/notebooks/") for filepath in notebook_files + convert_embedded_img_to_base64(filepath) create_md_nb_file(filepath) filename_with_ext = splitpath(filepath)[end] filename = splitext(filename_with_ext)[1] @@ -109,7 +126,7 @@ makedocs(; "Julia Basics" => "julia_basics.md", "Julia Asynchronous" => "julia_async.md", "Julia Distributed" => "julia_distributed.md", - "Matrix Multiplication"=>"matrix_matrix.md", + "Matrix Multiplication"=>["Matrix Multiplication" => "matrix_matrix.md", "Solutions" => "sol_matrix_matrix.md"], "Jacobi/SOR" => "julia_jacobi.md" ]], ) diff --git a/docs/reformat_attached_images.jl b/docs/reformat_attached_images.jl new file mode 100644 index 0000000..72ede58 --- /dev/null +++ b/docs/reformat_attached_images.jl @@ -0,0 +1,17 @@ + +function convert_embedded_img_to_base64(notebook_path) + doc = open(io->read(io, String), notebook_path) + # Regex matching: extract filename and base64 code + regex = r"attachments\\\":\s*\{\s*\\\"(?.*).png\\\":\s*\{\s*\\\"image/png\\\":\s*\\\"(?.*)\\\"" + res = eachmatch(regex, doc) + matches = collect(res) + # Replace img src with base64 code + for m in matches + global doc; + filename = m[:filename] + base64 = m[:base64code] + doc = replace(doc, "attachment:$filename.png" => "data:image/png;base64,$base64") + end + + write(notebook_path, doc); +end \ No newline at end of file diff --git a/docs/src/julia_distributed_test.md b/docs/src/julia_distributed_test.md new file mode 100644 index 0000000..35655b0 --- /dev/null +++ b/docs/src/julia_distributed_test.md @@ -0,0 +1,30 @@ +```@meta +EditURL = "https://github.com/fverdugo/XM_40017/blob/main/docs/src/notebooks/julia_distributed_test.ipynb" +``` + +```@raw html +
+
Tip
+
+
    +
  • + Download this notebook and run it locally on your machine [recommended]. Click here. +
  • +
  • + You can also run this notebook in the cloud using Binder. Click here + . +
  • +
+
+
+``` + +```@raw html + + +``` diff --git a/docs/src/notebook-output/julia_Jacobi.html b/docs/src/notebook-output/julia_Jacobi.html index a82876f..58d3ef6 100644 --- a/docs/src/notebook-output/julia_Jacobi.html +++ b/docs/src/notebook-output/julia_Jacobi.html @@ -15185,7 +15185,7 @@ body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {