-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7d2e3a
commit beddad8
Showing
4 changed files
with
282 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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,29 @@ | ||
// GitHub blockquote style | ||
blockquote { | ||
padding: 1em 1em; | ||
color: var(--pst-color-text-muted); | ||
border-left: 0.25em solid var(--pst-color-border); | ||
border-radius: $admonition-border-radius; | ||
position: relative; | ||
|
||
p { | ||
color: var(--pst-color-text-base); | ||
} | ||
|
||
// remove padding from included line-block to avoid duplication | ||
.line-block { | ||
margin: 0 0; | ||
} | ||
|
||
// remove margin bottom for the last p | ||
p:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
@include background-from-color-variable(--pst-color-on-background); | ||
|
||
//hack to make the text in the blockquote selectable | ||
&:before { | ||
z-index: -1; | ||
} | ||
} |
This file contains 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 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 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,252 @@ | ||
--- | ||
title: Blocks | ||
--- | ||
|
||
## Block Quotes | ||
|
||
Block quotes consist of indented body elements: | ||
|
||
> My theory by A. Elk. Brackets Miss, brackets. This theory goes as | ||
> follows and begins now. All brontosauruses are thin at one end, much | ||
> much thicker in the middle and then thin again at the far end. That is | ||
> my theory, it is mine, and belongs to me and I own it, and what it is | ||
> too. | ||
> | ||
> ---Anne Elk (Miss) | ||
<!-- | ||
### Epigraph | ||
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#epigraph> | ||
> My theory by A. Elk. Brackets Miss, brackets. This theory goes as | ||
> follows and begins now. All brontosauruses are thin at one end, much | ||
> much thicker in the middle and then thin again at the far end. That is | ||
> my theory, it is mine, and belongs to me and I own it, and what it is | ||
> too. | ||
> | ||
> \-- Anne Elk (Miss) | ||
### Pull quotes | ||
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#pull-quote> | ||
> My theory by A. Elk. Brackets Miss, brackets. This theory goes as | ||
> follows and begins now. All brontosauruses are thin at one end, much | ||
> much thicker in the middle and then thin again at the far end. That is | ||
> my theory, it is mine, and belongs to me and I own it, and what it is | ||
> too. | ||
> | ||
> \-- Anne Elk (Miss) | ||
### Highlights | ||
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#highlights> | ||
> My theory by A. Elk. Brackets Miss, brackets. This theory goes as | ||
> follows and begins now. All brontosauruses are thin at one end, much | ||
> much thicker in the middle and then thin again at the far end. That is | ||
> my theory, it is mine, and belongs to me and I own it, and what it is | ||
> too. | ||
> | ||
> \-- Anne Elk (Miss) | ||
## Line Blocks | ||
<https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks> | ||
This is a normal text paragraph. | ||
| This is a line block. It ends with a blank line. | ||
| Each new line begins with a vertical bar (\"\|\"). | ||
| Line breaks and initial indents are preserved. | ||
| Continuation lines are wrapped portions of long lines; they begin with | ||
a space in place of the vertical bar. | ||
| The left edge of a continuation line need not be aligned with the | ||
left edge of the text above it. | ||
| This is a second line block. | ||
| | ||
| Blank lines are permitted internally, but they must begin with a | ||
\"\|\". | ||
This is a normal text paragraph again. | ||
## Monospace Blocks | ||
Sphinx supports many kinds of monospace blocks. This section is meant to | ||
showcase *all* of them that as known to the author of this page, at the | ||
time of writing. | ||
### Production List | ||
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-productionlist> | ||
> This directive is used to enclose a group of productions. Each | ||
> production is given on a single line and consists of a name, separated | ||
> by a colon from the following definition. | ||
This just shows up as a vanilla `<pre>`, which is\... both nice and a | ||
bit annoying. | ||
::: productionlist | ||
try_stmt: try1_stmt \| try2_stmt try1_stmt: \"try\" \":\" | ||
[suite]{.title-ref} : (\"except\" \[[expression]{.title-ref} \[\",\" | ||
[target]{.title-ref}\]\] \":\" [suite]{.title-ref})+ : \[\"else\" \":\" | ||
[suite]{.title-ref}\] : \[\"finally\" \":\" [suite]{.title-ref}\] | ||
try2_stmt: \"try\" \":\" [suite]{.title-ref} : \"finally\" \":\" | ||
[suite]{.title-ref} : | ||
\"this-is-intentionally-very-stupidly-long-to-make-sure-that-this-has-a-proper-scrollbar\" | ||
::: | ||
### Literal Blocks | ||
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#literal-blocks> | ||
> contains a block of text where line breaks and whitespace are | ||
> significant and must be preserved | ||
This is a normal text paragraph. The next paragraph is a code sample: | ||
It is not processed in any way, except | ||
that the indentation is removed. | ||
It can span multiple lines. | ||
This is a normal text paragraph again. | ||
They can be quoted without indentation: | ||
>> Great idea! | ||
> | ||
> Why didn't I think of that? | ||
::: {.literalinclude language="python" caption="Literal includes can also have captions." linenos="" lines="10-20"} | ||
../../../src/pydata_sphinx_theme/\_\_init\_\_.py | ||
::: | ||
### Doctest Blocks | ||
<https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#doctest-blocks> | ||
> Doctest blocks are interactive Python sessions cut-and-pasted into | ||
> docstrings. They are meant to illustrate usage by example, and provide | ||
> an elegant and powerful testing environment via the doctest module in | ||
> the Python standard library. | ||
::: note | ||
::: title | ||
Note | ||
::: | ||
This is fine. | ||
::: | ||
\>\>\> print(\'Python-specific usage examples; begun with \"\>\>\>\"\') | ||
Python-specific usage examples; begun with \"\>\>\>\" \>\>\> | ||
print(\"(cut and pasted from interactive Python sessions)\") (cut and | ||
pasted from interactive Python sessions) \>\>\> print(\"This is an | ||
intentionally very long line because I want to make sure that we are | ||
handling scrollable code blocks correctly.\") This is an intentionally | ||
very long line because I want to make sure that we are handling | ||
scrollable code blocks correctly. | ||
### Parsed Literals | ||
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#parsed-literal-block> | ||
> It is equivalent to a line block with different rendering: typically | ||
> in a typewriter/monospaced typeface, like an ordinary literal block. | ||
> Parsed literal blocks are useful for adding hyperlinks to code | ||
> examples. | ||
::: parsed-literal | ||
\# parsed-literal test curl -O <http://someurl/release-0.1.0.tar-gz> | ||
echo \"This is an intentionally very long line because I want to make | ||
sure that we are handling scrollable code blocks correctly.\" | ||
::: | ||
### Code Block | ||
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#code> | ||
> The \"code\" directive constructs a literal block \[containing code\]. | ||
This has an alias of `code-block`. | ||
``` {.python linenos=""} | ||
from typing import Iterator | ||
# This is an example | ||
class Math: | ||
@staticmethod | ||
def fib(n: int) -> Iterator[int]: | ||
"""Fibonacci series up to n""" | ||
a, b = 0, 1 | ||
while a < n: | ||
yield a | ||
a, b = b, a + b | ||
result = sum(Math.fib(42)) | ||
print("The answer is {}".format(result)) | ||
``` | ||
#### With caption | ||
``` {.json caption="Code Blocks can have captions, which also adds a link to it."} | ||
{ | ||
"session_name": "shorthands", | ||
"windows": [ | ||
{ | ||
"panes": [ | ||
{ | ||
"shell_command": "echo 'This is an intentionally very long line because I want to make sure that we are handling scrollable code blocks correctly.'" | ||
} | ||
], | ||
"window_name": "long form" | ||
} | ||
] | ||
} | ||
``` | ||
#### With line numbers | ||
``` {.python linenos="" emphasize-lines="3,5"} | ||
def some_function(): | ||
interesting = False | ||
print("This line is highlighted.") | ||
print("This one is not...") | ||
print("...but this one is.") | ||
print( | ||
"This is an intentionally very long line because I want to make sure that we are handling scrollable code blocks correctly." | ||
) | ||
``` | ||
#### Without highlighting | ||
``` text | ||
# Taken from https://en.wikipedia.org/wiki/Pseudocode#Example | ||
algorithm ford-fulkerson is | ||
input: Graph G with flow capacity c, | ||
source node s, | ||
sink node t | ||
output: Flow f such that f is maximal from s to t | ||
(Note that f(u,v) is the flow from node u to node v, and c(u,v) is the flow capacity from node u to node v) | ||
for each edge (u, v) in GE do | ||
f(u, v) ← 0 | ||
f(v, u) ← 0 | ||
while there exists a path p from s to t in the residual network Gf do | ||
let cf be the flow capacity of the residual network Gf | ||
cf(p) ← min{cf(u, v) | (u, v) in p} | ||
for each edge (u, v) in p do | ||
f(u, v) ← f(u, v) + cf(p) | ||
f(v, u) ← −f(u, v) | ||
return f | ||
``` | ||
--> |