Skip to content

Commit

Permalink
Add example of using ShortCodes.jl with footnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenJ committed Sep 24, 2024
1 parent f553abb commit 02348bf
Showing 1 changed file with 89 additions and 11 deletions.
100 changes: 89 additions & 11 deletions example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try
Base.loaded_modules[Base.PkgId(
Base.UUID("6e696c72-6542-2067-7265-42206c756150"),
"AbstractPlutoDingetjes",
)].Bonds.initial_value
catch
b -> missing
end
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
Expand All @@ -27,6 +20,9 @@ using PlutoUI
# ╔═╡ 3f8dc975-b091-4dbe-bd48-c33236e61ece
using LaTeXStrings

# ╔═╡ 537f8ef3-a66f-4da3-a4f7-8c5b1eb58225
using ShortCodes, MarkdownLiteral

# ╔═╡ cd581a51-fb2b-4579-9a7d-0d723ad5d467
md"# [PlutoTeachingTools.jl](https://github.com/JuliaPluto/PlutoTeachingTools.jl) Examples"

Expand Down Expand Up @@ -379,6 +375,23 @@ FootnotesNumbered()
#FootnotesInlineNumbered()
#FootnotesBottomNumbered()

# ╔═╡ 4d70269c-fd59-43f3-b63d-1b45d2386ceb
md"""
### Citations with [`ShortCodes.jl`](https://github.com/hellemo/ShortCodes.jl)
One common use-case is to quickly cite something in a footnote. Why write out or copy the citation manually when you can do it automatically? Doing so requires [`ShortCodes.jl`](https://github.com/hellemo/ShortCodes.jl) and [`MarkdownLiteral.jl`](https://github.com/JuliaPluto/MarkdownLiteral.jl)
> When discussing whether a machine can think, it is important to first decide what a "machine" is, and what "thinking" means.[^turing]
"""

# ╔═╡ 9c53984f-0632-4bdf-a041-6e0df4beb43a
MarkdownLiteral.@markdown(
"""
[^turing]: $(DOI("10.1007/978-1-4020-6710-5_3"))
"""
)

# ╔═╡ f4201010-71d1-4889-99e7-abb774612a4d
begin
mls_link = "#" * (string(PlutoRunner.currently_running_cell_id[]))
Expand Down Expand Up @@ -431,22 +444,26 @@ hello()
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
MarkdownLiteral = "736d6165-7244-6769-4267-6b50796e6954"
PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
ShortCodes = "f62ebe17-55c5-4640-972f-b59c0dd11ccf"
[compat]
LaTeXStrings = "~1.3.1"
MarkdownLiteral = "~0.1.1"
PlutoTeachingTools = "~0.3.0"
PlutoUI = "~0.7.60"
ShortCodes = "~0.3.6"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.10.5"
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "b0bde7992e083dfb14dcc5b0de8cbd754c557ca3"
project_hash = "ab90d137919bfda3c1914147f8feb51a20cd1c02"
[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
Expand All @@ -470,17 +487,34 @@ git-tree-sha1 = "7eee164f122511d3e4e1ebadb7956939ea7e1c77"
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
version = "1.3.6"
[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "bce6804e5e6044c6daab27bb533d1295e4a2e759"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.6"
[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "b10d0b65641d57b8b4d5e234446582de5047050d"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.5"
[[deps.CommonMark]]
deps = ["Crayons", "JSON", "PrecompileTools", "URIs"]
git-tree-sha1 = "532c4185d3c9037c0237546d817858b23cf9e071"
uuid = "a80b9123-70ca-4bc0-993e-6e3bcb318db6"
version = "0.8.12"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.1+0"
[[deps.Crayons]]
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.1.1"
[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down Expand Up @@ -536,6 +570,18 @@ git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.4"
[[deps.JSON3]]
deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"]
git-tree-sha1 = "eb3edce0ed4fa32f75a0a11217433c31d56bd48b"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.14.0"
[deps.JSON3.extensions]
JSON3ArrowExt = ["ArrowTypes"]
[deps.JSON3.weakdeps]
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
[[deps.JuliaInterpreter]]
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
git-tree-sha1 = "2984284a8abcfcc4784d95a9e2ea4e352dd8ede7"
Expand Down Expand Up @@ -618,11 +664,23 @@ version = "0.5.13"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[deps.MarkdownLiteral]]
deps = ["CommonMark", "HypertextLiteral"]
git-tree-sha1 = "0d3fa2dd374934b62ee16a4721fe68c418b92899"
uuid = "736d6165-7244-6769-4267-6b50796e6954"
version = "0.1.1"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+1"
[[deps.Memoize]]
deps = ["MacroTools"]
git-tree-sha1 = "2b1dfcba103de714d31c033b5dacc2e4a12c7caa"
uuid = "c03570c3-d221-55d1-a50c-7939bbd78826"
version = "0.4.4"
[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
Expand Down Expand Up @@ -727,6 +785,12 @@ version = "0.7.0"
[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[deps.ShortCodes]]
deps = ["Base64", "CodecZlib", "Downloads", "JSON3", "Memoize", "URIs", "UUIDs"]
git-tree-sha1 = "5844ee60d9fd30a891d48bab77ac9e16791a0a57"
uuid = "f62ebe17-55c5-4640-972f-b59c0dd11ccf"
version = "0.3.6"
[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
Expand All @@ -740,6 +804,12 @@ deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
version = "1.10.0"
[[deps.StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "159331b30e94d7b11379037feeb9b690950cace8"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.11.0"
[[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
Expand All @@ -759,6 +829,11 @@ version = "1.10.0"
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.TranscodingStreams]]
git-tree-sha1 = "e84b3a11b9bece70d14cce63406bbc79ed3464d2"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.11.2"
[[deps.Tricks]]
git-tree-sha1 = "7822b97e99a1672bfb1b49b668a6d46d58d8cbcb"
uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
Expand All @@ -784,7 +859,7 @@ version = "1.2.13+1"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.11.0+0"
version = "5.8.0+1"
[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -886,6 +961,9 @@ version = "17.4.0+2"
# ╟─d98ea117-9aab-4fad-af19-0a8e69b0c251
# ╠═cb31500f-0cc4-49f0-a338-a75a34c95560
# ╠═f66b3b03-78ee-4eef-a0d6-43f4249d3332
# ╠═4d70269c-fd59-43f3-b63d-1b45d2386ceb
# ╠═537f8ef3-a66f-4da3-a4f7-8c5b1eb58225
# ╠═9c53984f-0632-4bdf-a041-6e0df4beb43a
# ╟─f4201010-71d1-4889-99e7-abb774612a4d
# ╠═ef32d891-0a7a-4803-95ae-a930787c243a
# ╠═d3762092-e31d-4b96-840a-3939b89f60b7
Expand Down

0 comments on commit 02348bf

Please sign in to comment.