forked from Mirrors/bubbletea
Pager example
This commit is contained in:
parent
5ae602953c
commit
b6eeef2127
|
@ -0,0 +1,68 @@
|
|||
Glow
|
||||
====
|
||||
|
||||
A casual introduction. 你好世界!
|
||||
|
||||
## Let’s talk about artichokes
|
||||
|
||||
The _artichoke_ is mentioned as a garden plant in the 8th century BC by Homer
|
||||
**and** Hesiod. The naturally occurring variant of the artichoke, the cardoon,
|
||||
which is native the the Mediterranean area, also has records of use as a food
|
||||
among the ancient Greeks and Romans. Pliny the Elder mentioned growing of
|
||||
_carduus_ in Carthage and Cordoba.
|
||||
|
||||
> He holds him with a skinny hand,
|
||||
> ‘There was a ship,’ quoth he.
|
||||
> ‘Hold off! unhand me, grey-beard loon!’
|
||||
> An artichoke, dropt he.
|
||||
|
||||
--Samuel Taylor Coleridge, [The Rime of the Ancient Mariner][rime]
|
||||
|
||||
[rime]: https://poetryfoundation.org/poems/43997/
|
||||
|
||||
## Other foods worth mentioning
|
||||
|
||||
1. Carrots
|
||||
1. Celery
|
||||
1. Tacos
|
||||
* Soft
|
||||
* Hard
|
||||
1. Cucumber
|
||||
|
||||
## Things to eat today
|
||||
|
||||
* [x] Carrots
|
||||
* [x] Ramen
|
||||
* [ ] Currywurst
|
||||
|
||||
### Power levels of the aforementioned foods
|
||||
|
||||
| Name | Power | Comment |
|
||||
| --- | --- | --- |
|
||||
| Carrots | 9001 | It’s over 9000?! |
|
||||
| Ramen | 9002 | Also over 9000?! |
|
||||
| Currywurst | 10000 | What?! |
|
||||
|
||||
## Currying Artichokes
|
||||
|
||||
Here’s a bit of code in [Haskell](https://haskell.org), because we are fancy.
|
||||
Remember that to compile Haskell you’ll need `ghc`.
|
||||
|
||||
```haskell
|
||||
module Main where
|
||||
|
||||
import Data.Function ( (&) )
|
||||
import Data.List ( intercalculate )
|
||||
|
||||
hello :: String -> String
|
||||
hello s =
|
||||
"Hello, " ++ s ++ "."
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
map hello [ "artichoke", "alcachofa" ] & intercalculate "\n" & putStrLn
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
_Alcachofa_, if you were wondering, is artichoke in Spanish.
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/charmbracelet/tea"
|
||||
"github.com/charmbracelet/teaparty/pager"
|
||||
)
|
||||
|
||||
func main() {
|
||||
content, err := ioutil.ReadFile("artichoke.md")
|
||||
if err != nil {
|
||||
fmt.Println("could not load file:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
tea.AltScreen()
|
||||
defer tea.ExitAltScreen()
|
||||
if err := pager.NewProgram(string(content)).Start(); err != nil {
|
||||
fmt.Println("could not run program:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue