From 7889328076c19f79f2be357a360025ccf75e66cf Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Tue, 29 Nov 2022 18:44:11 +0530 Subject: [PATCH] Update v0.4.0 \## New Features: - Inbuilt changing content and style of inline citations via `style_citations` - `apply_css_fixes` now allows you to turn off certain fixes \## Fixes - Tiny UI fixes - allow break-inside for reference list --- Manifest.toml | 34 +++++------ Project.toml | 2 +- docs/Manifest.toml | 42 +++++++------- docs/src/example.html | 10 ++-- examples/notebook.jl | 68 +++++++++++++++------- src/PlutoReport.jl | 53 ++++++++--------- src/references.jl | 128 ++++++++++++++++++++++++++++++++++++------ 7 files changed, 228 insertions(+), 109 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index dc12c80..75dc0b0 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.2" +julia_version = "1.8.3" manifest_format = "2.0" project_hash = "73079b8eb332c5740c784bcfc9140e840924e18b" @@ -38,9 +38,9 @@ uuid = "f1be7e48-bf82-45af-a471-ae754a193061" version = "0.2.19" [[deps.BitFlags]] -git-tree-sha1 = "84259bb6172806304b9101094a7cc4bc6f56dbc6" +git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" -version = "0.1.5" +version = "0.1.7" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] @@ -56,9 +56,9 @@ version = "0.11.4" [[deps.Compat]] deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "3ca828fe1b75fa84b021a7860bd039eaea84d2f2" +git-tree-sha1 = "00a2cccc7f098ff3b66806862d275ca3db9e6e5a" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.3.0" +version = "4.5.0" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -97,9 +97,9 @@ version = "0.8.4" [[deps.HTTP]] deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "8c7e6b82abd41364b8ffe40ffc63b33e590c8722" +git-tree-sha1 = "e1acc37ed078d99a714ed8376446f92a5535ca65" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.5.3" +version = "1.5.5" [[deps.Hyperscript]] deps = ["Test"] @@ -142,9 +142,9 @@ version = "0.21.3" [[deps.JSON3]] deps = ["Dates", "Mmap", "Parsers", "SnoopPrecompile", "StructTypes", "UUIDs"] -git-tree-sha1 = "65edf3850efb9cb4ca3b0bf488e29c6c38a23d2d" +git-tree-sha1 = "84b10656a41ef564c39d2d477d7236966d2b5683" uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" -version = "1.11.1" +version = "1.12.0" [[deps.JSONSchema]] deps = ["HTTP", "JSON", "URIs"] @@ -189,9 +189,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] -git-tree-sha1 = "5d4d2d9904227b8bd66386c1138cf4d5ffa826bf" +git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" -version = "0.4.9" +version = "1.0.0" [[deps.MIMEs]] git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" @@ -231,9 +231,9 @@ version = "0.3.20+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] -git-tree-sha1 = "5628f092c6186a80484bfefdf89ff64efdaec552" +git-tree-sha1 = "df6830e37943c7aaa10023471ca47fb3065cc3c4" uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" -version = "1.3.1" +version = "1.3.2" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -248,9 +248,9 @@ version = "1.4.1" [[deps.Parsers]] deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "cceb0257b662528ecdf0b4b4302eb00e767b38e7" +git-tree-sha1 = "b64719e8b4504983c7fca6cc9db3ebc8acc2a4d6" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.0" +version = "2.5.1" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] @@ -358,9 +358,9 @@ uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" version = "0.1.6" [[deps.URIs]] -git-tree-sha1 = "e59ecc5a41b000fa94423a578d29290c7266fc10" +git-tree-sha1 = "ac00576f90d8a259f2c9d823e91d1de3fd44d348" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.4.0" +version = "1.4.1" [[deps.UUIDs]] deps = ["Random", "SHA"] diff --git a/Project.toml b/Project.toml index 01b219b..f8167a6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlutoReport" uuid = "ab5eb977-4f23-42a0-954d-2743fb6218c4" authors = ["Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com>"] -version = "0.3.0" +version = "0.4.0" [deps] Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061" diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 35ae3a4..d8fe052 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.2" +julia_version = "1.8.3" manifest_format = "2.0" project_hash = "b040565e2da45dca130d51b23d3150d740fc31cb" @@ -37,9 +37,9 @@ uuid = "c9fd44ac-77b5-486c-9482-9798bd063cc6" version = "0.1.5" [[deps.BitFlags]] -git-tree-sha1 = "629c6e4a7be8f427d268cebef2a5e3de6c50d462" +git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" -version = "0.1.6" +version = "0.1.7" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] @@ -74,9 +74,9 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" [[deps.Deno_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "970da1e64a94f13b51c81691c376a1d5a83a0b3c" +git-tree-sha1 = "64cb698de672b627f887ced4b2a722d217e73c10" uuid = "04572ae6-984a-583e-9378-9577a1c2574d" -version = "1.20.4+0" +version = "1.28.1+0" [[deps.Distributed]] deps = ["Random", "Serialization", "Sockets"] @@ -156,9 +156,9 @@ version = "1.3.0" [[deps.HTTP]] deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "8c7e6b82abd41364b8ffe40ffc63b33e590c8722" +git-tree-sha1 = "e1acc37ed078d99a714ed8376446f92a5535ca65" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.5.3" +version = "1.5.5" [[deps.HypertextLiteral]] deps = ["Tricks"] @@ -246,9 +246,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] -git-tree-sha1 = "5d4d2d9904227b8bd66386c1138cf4d5ffa826bf" +git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" -version = "0.4.9" +version = "1.0.0" [[deps.MIMEs]] git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" @@ -294,9 +294,9 @@ version = "0.3.20+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] -git-tree-sha1 = "5628f092c6186a80484bfefdf89ff64efdaec552" +git-tree-sha1 = "df6830e37943c7aaa10023471ca47fb3065cc3c4" uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" -version = "1.3.1" +version = "1.3.2" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -316,9 +316,9 @@ version = "10.40.0+0" [[deps.Parsers]] deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "cceb0257b662528ecdf0b4b4302eb00e767b38e7" +git-tree-sha1 = "b64719e8b4504983c7fca6cc9db3ebc8acc2a4d6" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.0" +version = "2.5.1" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] @@ -327,15 +327,15 @@ version = "1.8.0" [[deps.Pluto]] deps = ["Base64", "Configurations", "Dates", "Distributed", "FileWatching", "FuzzyCompletions", "HTTP", "HypertextLiteral", "InteractiveUtils", "Logging", "MIMEs", "Markdown", "MsgPack", "Pkg", "PrecompileSignatures", "REPL", "RegistryInstances", "RelocatableFolders", "Sockets", "TOML", "Tables", "URIs", "UUIDs"] -git-tree-sha1 = "c3f344a915bc1d67455ecc5e38f4a184ffc4ad96" +git-tree-sha1 = "43d4448b5a568ee4bca8c77d6af2cedd721999f6" uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781" -version = "0.19.14" +version = "0.19.16" [[deps.PlutoSliderServer]] deps = ["AbstractPlutoDingetjes", "Base64", "BetterFileWatching", "Configurations", "Distributed", "FromFile", "Git", "GitHubActions", "Glob", "HTTP", "JSON", "Logging", "Pkg", "Pluto", "SHA", "Sockets", "TOML", "TerminalLoggers", "UUIDs"] -git-tree-sha1 = "f5ddc0e2e3cc50c0a9a1e48b4c527cf402ad9640" +git-tree-sha1 = "b326c3bbacaae704c1fe0c94d1d7b00e492de70e" uuid = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4" -version = "0.3.18" +version = "0.3.19" [[deps.PrecompileSignatures]] git-tree-sha1 = "18ef344185f25ee9d51d80e179f8dad33dc48eb1" @@ -374,9 +374,9 @@ version = "0.1.0" [[deps.RelocatableFolders]] deps = ["SHA", "Scratch"] -git-tree-sha1 = "22c5201127d7b243b9ee1de3b43c408879dff60f" +git-tree-sha1 = "90bc7a7c96410424509e4263e277e43250c05691" uuid = "05181044-ff0b-4ac5-8273-598c1e38db00" -version = "0.3.0" +version = "1.0.0" [[deps.Requires]] deps = ["UUIDs"] @@ -454,9 +454,9 @@ uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" version = "0.1.6" [[deps.URIs]] -git-tree-sha1 = "e59ecc5a41b000fa94423a578d29290c7266fc10" +git-tree-sha1 = "ac00576f90d8a259f2c9d823e91d1de3fd44d348" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.4.0" +version = "1.4.1" [[deps.UUIDs]] deps = ["Random", "SHA"] diff --git a/docs/src/example.html b/docs/src/example.html index 7d4c95c..ec4aa87 100644 --- a/docs/src/example.html +++ b/docs/src/example.html @@ -5,15 +5,15 @@ - -
\ No newline at end of file +
\ No newline at end of file diff --git a/examples/notebook.jl b/examples/notebook.jl index a548739..8879632 100644 --- a/examples/notebook.jl +++ b/examples/notebook.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.19.14 +# v0.19.16 #> [frontmatter] #> title = "Example Notebook" @@ -107,7 +107,7 @@ Other markdown can also be used! Make [Links](https://github.com/fonsp/Pluto.jl) $(Resource("https://raw.githubusercontent.com/fonsp/Pluto.jl/dd0ead4caa2d29a3a2cfa1196d31e3114782d363/frontend/img/logo_white_contour.svg", :width=>"55%")) -The $(cite"Or_s_2014::following") is a great introduction to Tensor Network States. +The following $(cite"Or_s_2014") is a great introduction to Tensor Network States. """ # ╔═╡ 972dbb43-7774-4ed9-8d2d-f62341d6cb3f @@ -126,6 +126,14 @@ md""" # ╔═╡ 28ef6ac5-4475-402f-a963-420e4b320f4b @bind refs References() +# ╔═╡ 14e81c39-c046-43a3-859d-39c1b5fa17d5 +md""" + We can also style the citations according to our choice. See the documentation +""" + +# ╔═╡ 393f352d-cf58-4102-ac7d-c8c7d74f67bb +style_citations(refs, "bibliography.bib", content=By_Number, css=Superscript) + # ╔═╡ 831ff4e4-ab3f-4251-83ab-189c10360fd2 md""" Now let us display the references using `display_bibliography`, parametrized by a local file and the bound variable. @@ -137,12 +145,26 @@ md""" # ╔═╡ 59902dd5-63e3-4c90-a70e-3023e8529eac md""" - It would be nice if we could see atleast the abstract of the references. `bind` a variable to `display_bibliography`, and let `show_abstract` react to that. Now, clicking on any of the citations' id will result in the abstract being shown in the abstract panel (possibly collapsed) + It would be nice if we could see atleast the abstract of the references. `bind` a variable to `display_bibliography`, and let `show_abstract` react to that. Now, clicking on any of the citations' id will result in the abstract being shown in the abstract panel (possibly collapsed). This is a feature in alpha stage. """ # ╔═╡ c7db3e28-6767-49b1-ba34-4cfe8bd2d134 show_abstract(abstractlink) +# ╔═╡ 31a4e944-c047-4268-87b4-1b604ae50f1f +md""" + Finally you can always just hack your way through and override any css/js to make your report look exactly like you want it. +""" + +# ╔═╡ 9fdf69e0-0957-4c76-9465-7728040e01d7 +html""" + +""" + # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] @@ -156,7 +178,7 @@ PlutoReport = "~0.3.0" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.8.2" +julia_version = "1.8.3" manifest_format = "2.0" project_hash = "804e38e0a54be4d1cdd82936cfb95482108590bc" @@ -194,9 +216,9 @@ uuid = "f1be7e48-bf82-45af-a471-ae754a193061" version = "0.2.19" [[deps.BitFlags]] -git-tree-sha1 = "629c6e4a7be8f427d268cebef2a5e3de6c50d462" +git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" -version = "0.1.6" +version = "0.1.7" [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] @@ -212,9 +234,9 @@ version = "0.11.4" [[deps.Compat]] deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "3ca828fe1b75fa84b021a7860bd039eaea84d2f2" +git-tree-sha1 = "00a2cccc7f098ff3b66806862d275ca3db9e6e5a" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.3.0" +version = "4.5.0" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -253,9 +275,9 @@ version = "0.8.4" [[deps.HTTP]] deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "8c7e6b82abd41364b8ffe40ffc63b33e590c8722" +git-tree-sha1 = "e1acc37ed078d99a714ed8376446f92a5535ca65" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.5.3" +version = "1.5.5" [[deps.Hyperscript]] deps = ["Test"] @@ -298,9 +320,9 @@ version = "0.21.3" [[deps.JSON3]] deps = ["Dates", "Mmap", "Parsers", "SnoopPrecompile", "StructTypes", "UUIDs"] -git-tree-sha1 = "65edf3850efb9cb4ca3b0bf488e29c6c38a23d2d" +git-tree-sha1 = "84b10656a41ef564c39d2d477d7236966d2b5683" uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" -version = "1.11.1" +version = "1.12.0" [[deps.JSONSchema]] deps = ["HTTP", "JSON", "URIs"] @@ -345,9 +367,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] -git-tree-sha1 = "5d4d2d9904227b8bd66386c1138cf4d5ffa826bf" +git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" -version = "0.4.9" +version = "1.0.0" [[deps.MIMEs]] git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb" @@ -387,9 +409,9 @@ version = "0.3.20+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] -git-tree-sha1 = "5628f092c6186a80484bfefdf89ff64efdaec552" +git-tree-sha1 = "df6830e37943c7aaa10023471ca47fb3065cc3c4" uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" -version = "1.3.1" +version = "1.3.2" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -404,9 +426,9 @@ version = "1.4.1" [[deps.Parsers]] deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "cceb0257b662528ecdf0b4b4302eb00e767b38e7" +git-tree-sha1 = "b64719e8b4504983c7fca6cc9db3ebc8acc2a4d6" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.0" +version = "2.5.1" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] @@ -520,9 +542,9 @@ uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" version = "0.1.6" [[deps.URIs]] -git-tree-sha1 = "e59ecc5a41b000fa94423a578d29290c7266fc10" +git-tree-sha1 = "ac00576f90d8a259f2c9d823e91d1de3fd44d348" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.4.0" +version = "1.4.1" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -570,7 +592,7 @@ version = "17.4.0+0" # ╟─cfe70a7a-1642-48a0-b66f-349ccee2c571 # ╠═aae13cfb-9002-4c69-b2d1-1675ecddcfba # ╟─b6d930a1-575f-4927-aeb3-46eacd9a50c4 -# ╠═a0ccb87e-3911-4dba-9114-b4633b34c621 +# ╟─a0ccb87e-3911-4dba-9114-b4633b34c621 # ╠═dc6812d6-7dc2-459a-9ccf-495aac0942f0 # ╟─ea35d808-db03-492a-8f36-32b0cf77419b # ╠═5a392c22-b692-48ac-a0d2-5577c238f927 @@ -578,9 +600,13 @@ version = "17.4.0+0" # ╠═6fbce86e-65da-4d59-ad49-3a1d00a1af5f # ╟─2f295bf7-5bef-4ed6-9014-93ed8fcf12fb # ╠═28ef6ac5-4475-402f-a963-420e4b320f4b +# ╟─14e81c39-c046-43a3-859d-39c1b5fa17d5 +# ╠═393f352d-cf58-4102-ac7d-c8c7d74f67bb # ╟─831ff4e4-ab3f-4251-83ab-189c10360fd2 # ╠═6f58d88f-1cbd-4190-a5fd-234ddb0b64b0 # ╟─59902dd5-63e3-4c90-a70e-3023e8529eac # ╠═c7db3e28-6767-49b1-ba34-4cfe8bd2d134 +# ╟─31a4e944-c047-4268-87b4-1b604ae50f1f +# ╟─9fdf69e0-0957-4c76-9465-7728040e01d7 # ╟─00000000-0000-0000-0000-000000000001 # ╟─00000000-0000-0000-0000-000000000002 diff --git a/src/PlutoReport.jl b/src/PlutoReport.jl index 7bc1c14..489bf2e 100644 --- a/src/PlutoReport.jl +++ b/src/PlutoReport.jl @@ -31,44 +31,45 @@ using Reexport import Downloads import JSON3 -export apply_css_fixes, +export apply_css_fixes, slidebreak, topslidebreak, centerslidebreak, Title, make_title, PresentationControls, presentation_ui, presentation_controls, References, display_bibliography, @cite_str, cite, + style_citations, + CiteCSS, Superscript, Highlighted, JustBold, + CiteStyle, By_Id, By_Number, By_AuthorDate, show_abstract """ - apply_css_fixes() + apply_css_fixes(;helpbox=true, logs=true, footer=true, print=true) Apply fixes to Pluto's UI to make it better for reports and presentations. +Set any of the parameters to false if you do not want to apply those. Must be the last statement in a cell. """ -function apply_css_fixes() - return html""" - """ end diff --git a/src/references.jl b/src/references.jl index 89f70d7..b0c2bec 100644 --- a/src/references.jl +++ b/src/references.jl @@ -1,8 +1,14 @@ +""" + nice_title(raw_title::String)::String + +Removes any curly braces in titles +""" +nice_bib(raw_bib::String)::String = replace(raw_bib, '{'=>"", '}'=>"") + """ display_bibentry(entry::Bibliography.BibInternal.Entry)::HypertextLiteral.Result Returns a display for a bibentry. -Must be the last statement in a cell. See also [`display_bibliography`](@ref) """ @@ -11,10 +17,10 @@ function display_bibentry(entry::Bibliography.BibInternal.Entry)::HypertextLiter """
  • [$(entry.id)]: - [$(Bibliography.xyear(entry))] - $(Bibliography.xtitle(entry)); - $(Bibliography.xnames(entry)); - DOI:$(entry.access.doi) + $(isnothing(Bibliography.xyear(entry)) ? "" : "[$(Bibliography.xyear(entry))]") + $(nice_bib(Bibliography.xtitle(entry))); + $(nice_bib(Bibliography.xnames(entry))); + $(isnothing(entry.access.doi) ? "" : "DOI: $(entry.access.doi)")
  • """ ) @@ -45,6 +51,7 @@ function display_bibliography(bibtexpath::String, citations)::HypertextLiteral.R e.preventDefault() }) }) + currentScript.parentElement.parentElement.parentElement.style.breakInside='auto'
      $(display_bibentry.(values(entries)))
    @@ -54,19 +61,9 @@ end function cite(s::String)::HypertextLiteral.Result @htl """ - - [$(last(split(s, "::")))] + [$(first(split(s, "::")))] """ end @@ -88,6 +85,102 @@ macro cite_str(s) end +""" + CiteStyle + +An `Enum` with values By_Number and By_Id to control content +of inline citations. + +See also [`style_citations`](@ref) +""" +@enum CiteStyle By_Number By_Id By_AuthorDate + +""" + CiteCSS + +An `Enum` with values Superscript and Highlighted to control styling +of inline citations. + +See also [`style_citations`](@ref) +""" +@enum CiteCSS Superscript Highlighted JustBold + +""" + style_citations(citations, bibtexpath::String; css::Union{CiteCSS, HypertextLiteral.Result}=Superscript, content::Union{CiteStyle, Function}=By_Id) :: HypertextLiteral.Result + +Style inline citations. `citations` is a Bond to [`References`](@ref), `bibtexpath` is path to the bibtex file. +`content` can either be a [`CiteStyle`](@ref) or a Function, that is of the form +`(citeid::String, bibtexpath::String)::String`, whose output will replace the id in the citations + +See also [`CiteStyle`](@ref) + +""" +function style_citations(citations, bibtexpath::String; css::Union{CiteCSS, HypertextLiteral.Result}=Superscript, content::Union{CiteStyle, Function}=By_Id) :: HypertextLiteral.Result + if !(citations isa Vector{String}) + return htl"No references yet" + end + csshtl = if css == Superscript + @htl """ + + """ + elseif css == Highlighted + @htl """ + + """ + elseif css == JustBold + @htl """ """ + else + css + end + + function js_replacecontent(ls) + @htl (""" + + """) + end + + contenthtl = if content == By_Id + @htl """""" + elseif content == By_Number + ls = collect.(enumerate(unique(citations))) + js_replacecontent(ls) + elseif content == By_AuthorDate + bibs = import_bibtex(bibtexpath) + ls = map(unique(citations)) do c + authors = split(Bibliography.xnames(bibs[c], names=:last), ",") + year = Bibliography.xyear(bibs[c]) + return [authors[1] * (length(authors)>1 ? " et. al, " : ", ") * string(year), c] + end + js_replacecontent(ls) + else + cs = unique(citations) + js_replacecontent(collect.(zip(content.(cs, bibtexpath), cs))) + end + @htl "$(csshtl)\n$(contenthtl)" +end + """ References() :: HypertextLiteral.Result @@ -104,8 +197,7 @@ function References()