-
Notifications
You must be signed in to change notification settings - Fork 32
Add footnotes #2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add footnotes #2275
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
226f930
Add footnotes
theletterf 0555485
Merge branch 'main' into add-footnotes
theletterf f64a88d
Add footnotes to nav
theletterf 550ecc5
Fix footnotes rendering
theletterf b1f50e3
Edits
theletterf fb4be73
Remove debug HttpContext parameters
theletterf 8feac16
Remove decoration
theletterf f1f0b4c
Fix CSS
theletterf f3e39b7
Format CSS
theletterf 07ff94a
Formatting
theletterf 6149d9f
Improve CSS
theletterf 6a248f5
Visual tweaks
theletterf b91e346
Fix tests
theletterf 818ebd4
Margins
theletterf 15bf4a6
Prettify CSS
theletterf 6e5663d
Edit multiple example
theletterf 80388cf
Fix docs and clickable area
theletterf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| # Footnotes | ||
|
|
||
| Footnotes allow you to add notes and references without cluttering the main text. They're automatically numbered and linked, providing an elegant way to include supplementary information, citations, or explanations. | ||
|
|
||
| ## Plain paragraph test | ||
|
|
||
| This is a plain footnote test[^plain]. No directives involved. | ||
|
|
||
| [^plain]: This footnote is in a plain paragraph, outside any directive. | ||
|
|
||
| ## Basic footnotes | ||
|
|
||
| ::::{tab-set} | ||
|
|
||
| :::{tab-item} Output | ||
|
|
||
| Here's a simple footnote[^1] and another one[^2]. | ||
|
|
||
| You can also use named identifiers[^my-note] which can be more descriptive in your source files. | ||
|
|
||
| ::: | ||
|
|
||
| :::{tab-item} Markdown | ||
|
|
||
| ```markdown | ||
| Here's a simple footnote[^1] and another one[^2]. | ||
|
|
||
| You can also use named identifiers[^my-note] which can be more descriptive in your source files. | ||
|
|
||
| [^1]: This is the first footnote. | ||
| [^2]: This is the second footnote. | ||
| [^my-note]: This footnote uses a named identifier instead of a number. | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| [^1]: This is the first footnote. | ||
| [^2]: This is the second footnote. | ||
| [^my-note]: This footnote uses a named identifier instead of a number. | ||
|
|
||
| ## Multiple references | ||
|
|
||
| You can reference the same footnote multiple times throughout your document. | ||
|
|
||
| ::::{tab-set} | ||
|
|
||
| :::{tab-item} Output | ||
|
|
||
| First reference to the concept[^concept]. Some more text here. Second reference to the same concept[^concept]. | ||
|
|
||
| ::: | ||
|
|
||
| :::{tab-item} Markdown | ||
|
|
||
| ```markdown | ||
| First reference to the concept[^concept]. Some more text here. Second reference to the same concept[^concept]. | ||
|
|
||
| [^concept]: This explains an important concept that's referenced multiple times. | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| [^concept]: This explains an important concept that's referenced multiple times. | ||
|
|
||
| ## Complex footnotes | ||
|
|
||
| Footnotes can contain multiple paragraphs, lists, blockquotes, and code blocks. Subsequent content must be indented to be included in the footnote. | ||
|
|
||
| ::::{tab-set} | ||
|
|
||
| :::{tab-item} Output | ||
|
|
||
| This has a complex footnote[^complex]. | ||
|
|
||
| ::: | ||
|
|
||
| :::{tab-item} Markdown | ||
|
|
||
| ```markdown | ||
| This has a complex footnote[^complex]. | ||
|
|
||
| [^complex]: This footnote has multiple elements. | ||
|
|
||
| It has multiple paragraphs with detailed explanations. | ||
|
|
||
| > This is a blockquote inside the footnote. | ||
| > It can span multiple lines. | ||
|
|
||
| - List item one | ||
| - List item two | ||
| - List item three | ||
|
|
||
| You can even include code: | ||
|
|
||
| ```python | ||
| def example(): | ||
| return "Hello from footnote" | ||
| ``` | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| [^complex]: This footnote has multiple elements. | ||
|
|
||
| It has multiple paragraphs with detailed explanations. | ||
|
|
||
| > This is a blockquote inside the footnote. | ||
| > It can span multiple lines. | ||
|
|
||
| - List item one | ||
| - List item two | ||
| - List item three | ||
|
|
||
| You can even include code: | ||
|
|
||
| ```python | ||
| def example(): | ||
| return "Hello from footnote" | ||
| ``` | ||
|
|
||
| ## Footnote placement | ||
|
|
||
| Footnote definitions should be placed at the document level (not inside directives like tab-sets, admonitions, or other containers). Footnote references can be used anywhere in your document, including inside directives. The footnote content will always be rendered at the bottom of the page. | ||
|
|
||
| ::::{tab-set} | ||
|
|
||
| :::{tab-item} Output | ||
|
|
||
| Here's text with a footnote[^early]. | ||
|
|
||
| More content here, and another footnote[^late]. | ||
|
|
||
| Even more content in between. | ||
|
|
||
| ::: | ||
|
|
||
| :::{tab-item} Markdown | ||
|
|
||
| ```markdown | ||
| Here's text with a footnote[^early]. | ||
|
|
||
| [^early]: This footnote is defined right after the reference. | ||
|
|
||
| More content here, and another footnote[^late]. | ||
|
|
||
| Even more content in between. | ||
|
|
||
| [^late]: This footnote is defined later in the document. | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| [^early]: This footnote is defined right after the reference. | ||
| [^late]: This footnote is defined later in the document. | ||
|
|
||
| ## Best practices | ||
|
|
||
| ### Use descriptive identifiers | ||
|
|
||
| While you can use simple numbers like `[^1]`, descriptive identifiers like `[^api-note]` make your source more maintainable. | ||
|
|
||
| ### Keep footnotes focused | ||
|
|
||
| Each footnote should contain a single, focused piece of information. If you find yourself writing very long footnotes, consider whether that content belongs in the main text. | ||
|
|
||
| ### Consider alternatives | ||
|
|
||
| Before adding footnotes, consider whether: | ||
| - The information is important enough to be in the main text. | ||
| - A link to external documentation would be more appropriate. | ||
| - An admonition (note, warning, etc.) would be clearer. | ||
|
|
||
| ### Numbering | ||
|
|
||
| Footnotes are automatically numbered in order of first reference, regardless of the identifier you use in your source. This means `[^zebra]` appearing before `[^apple]` will be numbered as footnote 1. | ||
|
|
||
| ## Technical notes | ||
|
|
||
| - Footnote identifiers are case-sensitive. | ||
| - Identifiers can contain letters, numbers, and hyphens. | ||
| - **Footnote definitions must be placed at the document level**, not inside directives (tab-sets, admonitions, etc.). Footnote references can be used anywhere. | ||
| - All footnotes are collected and displayed at the end of the page, regardless of where they're defined in the source. | ||
| - Multiple references to the same footnote will show multiple back-reference arrows (↩) in the footnote itself. |
47 changes: 47 additions & 0 deletions
47
src/Elastic.Documentation.Site/Assets/markdown/footnotes.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* Footnotes styling */ | ||
| .footnotes { | ||
| @apply border-grey-10 mt-12 border-t pt-6; | ||
| } | ||
|
|
||
| .footnotes hr { | ||
| @apply hidden; | ||
| } | ||
|
|
||
| .footnotes ol { | ||
| @apply list-decimal space-y-3 pl-6; | ||
| } | ||
|
|
||
| .footnotes li { | ||
| @apply text-ink-light text-sm leading-relaxed; | ||
| } | ||
|
|
||
| .footnotes li p { | ||
| @apply inline; | ||
| } | ||
|
|
||
| .footnotes li p:not(:last-child) { | ||
| @apply mb-3; | ||
| } | ||
|
|
||
| /* Footnote reference (superscript link in text) */ | ||
| .footnote-ref { | ||
| @apply text-blue-elastic hover:text-blue-elastic-100 font-semibold no-underline; | ||
| text-decoration: none !important; | ||
| } | ||
|
|
||
| .footnote-ref sup { | ||
| @apply font-sans; | ||
| text-decoration: none !important; | ||
| } | ||
|
|
||
| /* Back reference (return arrow in footnote) */ | ||
| .footnote-back-ref { | ||
| @apply text-blue-elastic hover:text-blue-elastic-100 ml-2 no-underline; | ||
| text-decoration: none; | ||
| font-family: monospace; | ||
| } | ||
|
|
||
| /* Multiple back references */ | ||
| .footnote-back-ref + .footnote-back-ref { | ||
| @apply ml-1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.