remove static-site-gen platform

This commit is contained in:
Luke Boswell 2024-05-22 12:35:43 +10:00
parent 33075285b7
commit a60fbfd366
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
16 changed files with 0 additions and 2415 deletions

View file

@ -1,22 +0,0 @@
# Static site generator
This is an example of how you might build a static site generator using Roc.
It searches for Markdown (`.md`) files in the `input` directory, inserts them
into a HTML template defined in Roc, and writes the result into the
corresponding file path in the `output` directory.
To run, `cd` into this directory and run this in your terminal:
If `roc` is on your PATH:
```bash
roc run static-site.roc -- input/ output/
```
If not, and you're building Roc from source:
```
cargo run -- static-site.roc -- input/ output/
```
The example in the `input` directory is a copy of the 2004 website
by John Gruber, introducing the Markdown format.
https://daringfireball.net/projects/markdown/

View file

@ -1,50 +0,0 @@
# Ira oculi amisere exsereret repetam corpora
## Superasque hanc horret
Lorem markdownum praecessit *cesserat suam multos* quam. Est Ulixis inter
fabricataque auxilioque fossae et *gravidis arbore*, una verum steterat conamina
videre negetur, ista. Isque nubibus et et iam postquam, madefacta cura lugenti
longique somnoque. Resurgere ceu [magnus et](http://example.org) Acheloe, Iovis
fatifero alias. In suo Venus nec fixerat Hercule quisve et coronat tauros sol
Erinys arces; postquam e natus, ille annis?
Hoc sedes. Ait ait! Clarum excidit collocat, inpluit lacrimabile
[herbis](http://example.org), et **quod** quid nutricis auctor pompa: anguigenae
quo at trahit dum? Me sponsa confundere orant fecit tendentem flamina veteris;
ut. Dabat fecit.
1. Ait est cauda noctisque scrobibus implesset vultu
2. Philomela metu
3. Partim inmemor
4. Lascivitque vietum potens
5. Addidit Troica tellusAndros induit rectum suos Aulidaque
## Nece ramos comites dierum
Et non miseranda eadem ferrum, mersaeque fossa lacrimam Dromas, tempore me iam
Perseus valido. Vinaque viderat habet curaque caelo sine *speluncae est* ignarus
Teucras quantum. Tanta timet auxilioque
[praecordia](http://example.org) unum: legi pondus nacta, est
est agnus erat solantia tenet?
Scire virgo felix grandior haut. Montibus illi: vir prior, indutus est contra
hos, semina saltuque: hoc radiis alter, intravit. Oravique sed ipsa
[cornu](http://example.org), flere unam suis vindicta spumigeroque
munere fertur figurae saecula mutentur. In suam corpus nare tumulos ignorat.
## Fraudo Sibyllae mare
Suspendit erat tincta artus tetigere caret, decoris meorum: parentis. Corporis
prius: que auras insequitur adversas; ab miserata dominam genitor.
aiff_bin_operating /= bsodMetadata;
terahertz_alignment_system.excel_bash_hdtv = saas_thread_character;
var server = lteHypermediaRom(menu_wan_of.coreNewbieGraphic(imapSector +
download_cluster_rate));
Oculos gravitate clipeum ab quid dubiaque apertum celerem vidit caput sine dant
*adstitit*. Acerbo in *bona verba* tutus est ullus metas primus: suo forte tuam
quaterque vincant Minos, [adverso](http://example.org).
Longa velut pietate. Erat felix avis Erinyn?

View file

@ -1,45 +0,0 @@
# Pete milite aura cuius laeva tenuerunt exprimit
## Semina pectora
Lorem markdownum auguror domos, tum cuspide induit officio Troia Propoetidas
fila Cyllenius retinacula. Progenies pepercit visa ausa amantes. Disertum sub,
et corpora, si credere cumque est meritumque moram videri levare praeterit
criminis quidem petita *ferreus*.
Achaidas traxit ad, iacuere iamdudum ab fecit: vestra evicere lacrimis labore:
gavisus forti turba. A vixque incesto et tanti paries, columnae est signis
munera? Grata Parcarum [Aetolius modo](http://example.org): meis quanto
amico oravit venit mihi vertit summam.
## Terras ab neque moveri mater oculos me
Qua solet grandia parente, femur *poenas exspectatas dedit* atros abstulit
sumpsere interdum adfusaque utrumque tostae. Regni et ostendit exanimes armis
nec armis lacesse fretumque silvarum fusca ante laevo suggerit matre, **non
caespes** urbes.
- Dixit qui amantis modo
- Pennas ut iaculo vellet in nec intellegit
- Summe ire annis tribusque haberet suo veteres
- Pede parvoque Tyrioque unum
- Terra traxisse meum Iuppiter in amato imagine
## Fraude stimulis
[Templis quotiens](http://example.org) tectus tuo ignara orbi
Zanclen hunc comprenditur *momordi*. Armis nymphae. Vocant rupe omnia
cognosceret fine; per sonant, deque magnum, suo.
- Quid lamina
- Gravidus pulchros sacris suis est audenti
- Sede quamvis orbata cerva plena tua Hymenaeus
- Nec Achaia deprensi baculo cessit nec mitius
- Fretoque in volucres repperit uda Ixionis etiamnum
- Auras Ceycis petit mundo ter sensi sacrum
Nosti et spem; tum illa parentes doctas nuntia **laeva virusque**. Magistris
[diversi](http://example.org) lacerare at data margine abesset inscribit
calidumque **copia vidit** attulerat altera incensaque crista versus. Fecit et
posco series dextra. Lacrimis inducta imis non apertos saeva **ripas sumpserat**
pariter quoque aequales.

View file

@ -1,74 +0,0 @@
# Resedit tenax Oleniae nitor trunco somnus recessit
## Quam quemque ensem mea scitusque iactatis ego
Lorem markdownum nubes, instruis virgo perque victa Lacinia parenti, foret ramis
incessit, frustra illa; adiecit. Agit **memor** ignes paternos exhalarunt
dumque.
> Fuit dotatissima Aeson curaque **gradu** cum quemque plures, quaque pater.
> Hanc iuvet, sententia inamabile: dum mollitaque plectro habent tacuit tibi.
## Thracum non quoque arisque Elinque et criminibusque
Deductus mihi lacrimaeque Apolline strictique, sanguine discite facinus se.
Livor nulla Pallantias virtutis fluctus testantia inponis et tenuerunt clipeo
non sacra date *partes* quoque fugae; cum. Audax contingere moresque dis
requirere senserit spectare generosos formatum modo edidit abluere his infixum
inductae dis concipe nisi redeuntia. Lutulenta [sublimibus pudori
iussis](http://example.org) volucrem recumbis foresque, tecum mater sidus est
imagine.
Et dea diebus me corpora nunc. Iam parte medium obscuraque **Acheloia** ad iubes
inferius altera nervus! Irasci pes facit Solem, credimus, est aqua regia terrae
mirarique spectabat, dixit. Tuta nimis Canache Quirini et fessa, de nodoso se
procul errant.
## Neptune longi bis lacertis tempore conpellat est
Habenas cur pinus; qui vera recurvam? Audieris ex modo Achilles est quamquam
Occupat, rettulit vindicat timentes.
- Non parere clamare
- Effigiem humana date deum duri
- Urbe minus
- Rettulit illud geminam curva Amuli furta scinditur
- Secutum infelix promissi boum latebras tamen
- Fata se felix poterant ter spoliantis in
## Quos quoque et posses sororum prodere
Candore fatebar *avertite abest* et fuerunt Nile inania domum: quid citius
quoque; pulsabant virum tamen ferro quaerens Osiris. Aethera acui regis exstat
ingeniis in pugna quadripedis glandes superos. Tanta quam, illo es prole est
telis **unus verba** quisquis iuvenci annis. Nec velox sed sacra gaudia vacuos,
Herculei undae calcata inmeriti quercus ignes parabant iam.
### Example Table
| Tables | Are | Cool |
| :------------ | :-----------: | ----: |
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
### Example Code Blocks
#### Something That Cannot Be Found
```sh
# This isn't fenced roc code so its not formatted
# Use a fence like ```roc to format code blocks
```
#### A Complete File
```roc
file:codeExample.roc
```
#### A Snippet Of Some File
```roc
file:codeExample.roc:snippet:view
```

View file

@ -1,72 +0,0 @@
## This is a documentation comment
# This is a comment
app [transformFileContent] { pf: platform "platform/main.roc" }
import pf.Html exposing [html, head, body, div, text, a, ul, li, link, meta]
import pf.Html.Attributes exposing [httpEquiv, content, href, rel, lang, class, title]
NavLink : {
# this is another comment
url : Str,
title : Str,
text : Str,
}
navLinks : List NavLink
navLinks = [
{ url: "apple.html", title: "Exempli Gratia Pagina Pomi", text: "Apple" },
{ url: "banana.html", title: "Exempli Gratia Pagina Musa", text: "Banana" },
{ url: "cherry.html", title: "Exempli Pagina Cerasus", text: "Cherry" },
]
transformFileContent : Str, Str -> Str
transformFileContent = \currentUrl, htmlContent ->
List.findFirst navLinks (\{ url } -> url == currentUrl)
|> Result.map (\currentNavLink -> view currentNavLink htmlContent)
|> Result.map Html.render
|> Result.withDefault ""
### start snippet view
view : NavLink, Str -> Html.Node
view = \currentNavLink, htmlContent ->
html [lang "en"] [
head [] [
meta [httpEquiv "content-type", content "text/html; charset=utf-8"] [],
Html.title [] [text currentNavLink.title],
link [rel "stylesheet", href "style.css"] [],
],
### start snippet body
body [] [
div [class "main"] [
div [class "navbar"] [
viewNavbar currentNavLink,
],
div [class "article"] [
# For now `text` is not escaped so we can use it to insert HTML
# We'll probably want something more explicit in the long term though!
text htmlContent,
],
],
],
### end snippet body
]
### end snippet view
viewNavbar : NavLink -> Html.Node
viewNavbar = \currentNavLink ->
ul
[]
(List.map navLinks \nl -> viewNavLink (nl == currentNavLink) nl)
viewNavLink : Bool, NavLink -> Html.Node
viewNavLink = \isCurrent, navlink ->
if isCurrent then
li [class "nav-link nav-link--current"] [
text navlink.text,
]
else
li [class "nav-link"] [
a
[href navlink.url, title navlink.title]
[text navlink.text],
]

View file

@ -1,135 +0,0 @@
.main {
display: flex;
max-width: 900px;
margin: 0 auto;
color: #222;
}
.navbar {
padding: 32px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.navbar ul {
margin: 0;
padding: 0;
}
.nav-link {
list-style: none;
margin: 8px;
padding: 8px 16px;
background-color: lightgray;
font-size: large;
}
.nav-link--current {
background-color: lightblue;
}
.article {
font-family: "Times New Roman", Times, serif;
}
.article h1, h2 {
font-family: Arial, Helvetica, sans-serif;
color: #444;
}
.article blockquote {
margin: 8px 0;
padding: 2px 8px;
border-radius: 8px;
background-color: #eee;
font-style: italic;
color: #444;
}
.article pre {
background-color: rgb(241, 241, 241);
color: rgb(27, 27, 27);
padding: 16px;
}
pre {
white-space: pre-wrap;
}
samp .ann {
/* type annotation - purple in the repl */
color: #f384fd;
}
samp .comment {
color: #338545;
}
samp .kw {
color: #004cc2;
}
samp .arrow, samp .backslash, samp .bar {
color: #0600c2;
}
samp .pipe {
color: #0600c2;
}
samp .op {
color: #0600c2;
}
samp .assign {
color: #48fd00;
}
samp .paren, samp .bracket, samp .brace {
color: #ff0000;
}
samp .comma {
color: #ff00fb;
}
samp .colon {
color: #9b0098;
}
samp .number {
/* number literals */
color: #9669ff;
}
samp .str {
/* string literals */
color: #1dbf00;
}
samp .str-esc, samp .str-interp {
/* escapes inside string literals, e.g. \t */
color: #3474db;
}
samp .dim {
opacity: 0.55;
}
samp .comment {
color: #005a13;
}
table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
border: 3px solid rgb(161, 64, 0);
}
tbody tr:nth-child(even) {
background-color: #c6f4ff;
}
th {
background-color: #ffabab;
}
th,
td {
padding: 2px;
}

View file

@ -1,814 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "arrayvec"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitmaps"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2"
dependencies = [
"typenum",
]
[[package]]
name = "bitvec"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]]
name = "bumpalo"
version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "cc"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
[[package]]
name = "deranged"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8810e7e2cf385b1e9b50d68264908ec367ba642c96d02edfe61c39e88e2a3c01"
[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "encode_unicode"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "flate2"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]]
name = "gimli"
version = "0.27.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "host"
version = "0.0.1"
dependencies = [
"libc",
"pulldown-cmark",
"roc_highlight",
"roc_std",
"syntect",
]
[[package]]
name = "html-escape"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476"
dependencies = [
"utf8-width",
]
[[package]]
name = "im"
version = "15.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9"
dependencies = [
"bitmaps",
"rand_core",
"rand_xoshiro",
"sized-chunks",
"typenum",
"version_check",
]
[[package]]
name = "im-rc"
version = "15.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe"
dependencies = [
"bitmaps",
"rand_core",
"rand_xoshiro",
"sized-chunks",
"typenum",
"version_check",
]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]]
name = "itoa"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "libc"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "line-wrap"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
dependencies = [
"safemem",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "miniz_oxide"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
[[package]]
name = "object"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "onig"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
"bitflags",
"libc",
"once_cell",
"onig_sys",
]
[[package]]
name = "onig_sys"
version = "69.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7"
dependencies = [
"cc",
"pkg-config",
]
[[package]]
name = "pkg-config"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "plist"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06"
dependencies = [
"base64",
"indexmap",
"line-wrap",
"quick-xml",
"serde",
"time",
]
[[package]]
name = "proc-macro2"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
dependencies = [
"unicode-ident",
]
[[package]]
name = "pulldown-cmark"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
dependencies = [
"bitflags",
"memchr",
"unicase",
]
[[package]]
name = "quick-xml"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "rand_xoshiro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
dependencies = [
"rand_core",
]
[[package]]
name = "regex-syntax"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
[[package]]
name = "roc_collections"
version = "0.0.1"
dependencies = [
"bitvec",
"bumpalo",
"fnv",
"hashbrown 0.14.3",
"im",
"im-rc",
"smallvec",
"wyhash",
]
[[package]]
name = "roc_error_macros"
version = "0.0.1"
[[package]]
name = "roc_highlight"
version = "0.0.1"
dependencies = [
"html-escape",
"roc_parse",
"roc_region",
]
[[package]]
name = "roc_ident"
version = "0.0.1"
[[package]]
name = "roc_module"
version = "0.0.1"
dependencies = [
"bumpalo",
"roc_collections",
"roc_error_macros",
"roc_ident",
"roc_region",
"snafu",
"static_assertions",
]
[[package]]
name = "roc_parse"
version = "0.0.1"
dependencies = [
"bumpalo",
"encode_unicode",
"roc_collections",
"roc_error_macros",
"roc_module",
"roc_region",
]
[[package]]
name = "roc_region"
version = "0.0.1"
dependencies = [
"static_assertions",
]
[[package]]
name = "roc_std"
version = "0.0.1"
dependencies = [
"arrayvec",
"static_assertions",
]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "ryu"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "serde"
version = "1.0.180"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.180"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.43",
]
[[package]]
name = "serde_json"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "sized-chunks"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e"
dependencies = [
"bitmaps",
"typenum",
]
[[package]]
name = "smallvec"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]]
name = "snafu"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6"
dependencies = [
"backtrace",
"doc-comment",
"snafu-derive",
]
[[package]]
name = "snafu-derive"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syntect"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91"
dependencies = [
"bincode",
"bitflags",
"flate2",
"fnv",
"once_cell",
"onig",
"plist",
"regex-syntax",
"serde",
"serde_json",
"thiserror",
"walkdir",
"yaml-rust",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "thiserror"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.43",
]
[[package]]
name = "time"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b79eabcd964882a646b3584543ccabeae7869e9ac32a46f6f22b7a5bd405308b"
dependencies = [
"deranged",
"itoa",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
[[package]]
name = "time-macros"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
dependencies = [
"time-core",
]
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "utf8-width"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wyhash"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf6e163c25e3fac820b4b453185ea2dea3b6a3e0a721d4d23d75bd33734c295"
dependencies = [
"rand_core",
]
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
[[package]]
name = "zerocopy"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.43",
]

View file

@ -1,29 +0,0 @@
[package]
name = "host"
authors = ["The Roc Contributors"]
edition = "2021"
license = "UPL-1.0"
version = "0.0.1"
links = "app"
[lib]
name = "host"
path = "src/lib.rs"
crate-type = ["staticlib", "lib"]
[[bin]]
name = "host"
path = "src/main.rs"
[dependencies]
libc = "0.2"
syntect = "5.0"
roc_highlight = { path = "../../../crates/highlight" }
roc_std = { path = "../../../crates/roc_std" }
# Default features include building a binary that we don't need
pulldown-cmark = { version = "0.9.2", default-features = false }
[workspace]

View file

@ -1,376 +0,0 @@
module [
Node,
Attribute,
render,
renderWithoutDocType,
element,
unclosedElem,
text,
attribute,
html,
base,
head,
link,
meta,
style,
title,
body,
address,
article,
aside,
footer,
header,
h1,
h2,
h3,
h4,
h5,
h6,
main,
nav,
section,
blockquote,
dd,
div,
dl,
dt,
figcaption,
figure,
hr,
li,
menu,
ol,
p,
pre,
ul,
a,
abbr,
b,
bdi,
bdo,
br,
cite,
code,
data,
dfn,
em,
i,
kbd,
mark,
q,
rp,
rt,
ruby,
s,
samp,
small,
span,
strong,
sub,
sup,
time,
u,
var,
wbr,
area,
audio,
img,
map,
track,
video,
embed,
iframe,
object,
picture,
portal,
source,
svg,
math,
canvas,
noscript,
script,
del,
ins,
caption,
col,
colgroup,
table,
tbody,
td,
tfoot,
th,
thead,
tr,
button,
datalist,
fieldset,
form,
input,
label,
legend,
meter,
optgroup,
option,
output,
progress,
select,
textarea,
details,
dialog,
summary,
slot,
template,
]
import Html.Attributes
Node : [
Text Str,
Element Str U64 (List Attribute) (List Node),
UnclosedElem Str U64 (List Attribute),
]
Attribute : Html.Attributes.Attribute
attribute : Str -> (Str -> Attribute)
attribute = Html.Attributes.attribute
text : Str -> Node
text = Text
## Define a non-standard HTML Element
##
## You can use this to add elements that are not already supported.
## For example, you could bring back the obsolete <blink> element,
## and add some 90's nostalgia to your web page!
##
## blink : List Attribute, List Node -> Node
## blink = element "blink"
##
## html = blink [] [ text "This text is blinking!" ]
##
element : Str -> (List Attribute, List Node -> Node)
element = \tagName ->
\attrs, children ->
# While building the node tree, calculate the size of Str it will render to
withTag = 2 * (3 + Str.countUtf8Bytes tagName)
withAttrs = List.walk attrs withTag \acc, Attribute name val ->
acc + Str.countUtf8Bytes name + Str.countUtf8Bytes val + 4
totalSize = List.walk children withAttrs \acc, child ->
acc + nodeSize child
Element tagName totalSize attrs children
unclosedElem : Str -> (List Attribute -> Node)
unclosedElem = \tagName ->
\attrs ->
# While building the node tree, calculate the size of Str it will render to
withTag = 2 * (3 + Str.countUtf8Bytes tagName)
totalSize = List.walk attrs withTag \acc, Attribute name val ->
acc + Str.countUtf8Bytes name + Str.countUtf8Bytes val + 4
UnclosedElem tagName totalSize attrs
# internal helper
nodeSize : Node -> U64
nodeSize = \node ->
when node is
Text content ->
Str.countUtf8Bytes content
Element _ size _ _ | UnclosedElem _ size _ ->
size
## Render a Node to an HTML string
##
## The output has no whitespace between nodes, to make it small.
## This is intended for generating full HTML documents, so it
## automatically adds `<!DOCTYPE html>` to the start of the string.
## See also `renderWithoutDocType`.
render : Node -> Str
render = \node ->
buffer = Str.reserve "<!DOCTYPE html>" (nodeSize node)
renderHelp buffer node
## Render a Node to a string, without a DOCTYPE tag
renderWithoutDocType : Node -> Str
renderWithoutDocType = \node ->
buffer = Str.reserve "" (nodeSize node)
renderHelp buffer node
# internal helper
renderHelp : Str, Node -> Str
renderHelp = \buffer, node ->
when node is
Text content ->
Str.concat buffer content
Element tagName _ attrs children ->
withTagName = "$(buffer)<$(tagName)"
withAttrs =
if List.isEmpty attrs then
withTagName
else
List.walk attrs "$(withTagName) " renderAttr
withTag = Str.concat withAttrs ">"
withChildren = List.walk children withTag renderHelp
"$(withChildren)</$(tagName)>"
UnclosedElem tagName _ attrs ->
if List.isEmpty attrs then
"$(buffer)<$(tagName)>"
else
attrs
|> List.walk "$(buffer)<$(tagName) " renderAttr
|> Str.concat ">"
# internal helper
renderAttr : Str, Attribute -> Str
renderAttr = \buffer, Attribute key val ->
"$(buffer) $(key)=\"$(val)\""
# Main root
html = element "html"
# Document metadata
base = element "base"
head = element "head"
link = unclosedElem "link"
meta = unclosedElem "meta"
style = element "style"
title = element "title"
# Sectioning root
body = element "body"
# Content sectioning
address = element "address"
article = element "article"
aside = element "aside"
footer = element "footer"
header = element "header"
h1 = element "h1"
h2 = element "h2"
h3 = element "h3"
h4 = element "h4"
h5 = element "h5"
h6 = element "h6"
main = element "main"
nav = element "nav"
section = element "section"
# Text content
blockquote = element "blockquote"
dd = element "dd"
div = element "div"
dl = element "dl"
dt = element "dt"
figcaption = element "figcaption"
figure = element "figure"
hr = element "hr"
li = element "li"
menu = element "menu"
ol = element "ol"
p = element "p"
pre = element "pre"
ul = element "ul"
# Inline text semantics
a = element "a"
abbr = element "abbr"
b = element "b"
bdi = element "bdi"
bdo = element "bdo"
br = element "br"
cite = element "cite"
code = element "code"
data = element "data"
dfn = element "dfn"
em = element "em"
i = element "i"
kbd = element "kbd"
mark = element "mark"
q = element "q"
rp = element "rp"
rt = element "rt"
ruby = element "ruby"
s = element "s"
samp = element "samp"
small = element "small"
span = element "span"
strong = element "strong"
sub = element "sub"
sup = element "sup"
time = element "time"
u = element "u"
var = element "var"
wbr = element "wbr"
# Image and multimedia
area = element "area"
audio = element "audio"
img = unclosedElem "img"
map = element "map"
track = element "track"
video = element "video"
# Embedded content
embed = element "embed"
iframe = element "iframe"
object = element "object"
picture = element "picture"
portal = element "portal"
source = element "source"
# SVG and MathML
svg = element "svg"
math = element "math"
# Scripting
canvas = element "canvas"
noscript = element "noscript"
script = element "script"
# Demarcating edits
del = element "del"
ins = element "ins"
# Table content
caption = element "caption"
col = element "col"
colgroup = element "colgroup"
table = element "table"
tbody = element "tbody"
td = element "td"
tfoot = element "tfoot"
th = element "th"
thead = element "thead"
tr = element "tr"
# Forms
button = element "button"
datalist = element "datalist"
fieldset = element "fieldset"
form = element "form"
input = element "input"
label = element "label"
legend = element "legend"
meter = element "meter"
optgroup = element "optgroup"
option = element "option"
output = element "output"
progress = element "progress"
select = element "select"
textarea = element "textarea"
# Interactive elements
details = element "details"
dialog = element "dialog"
summary = element "summary"
# Web Components
slot = element "slot"
template = element "template"

View file

@ -1,281 +0,0 @@
module [
Attribute,
attribute,
accept,
acceptCharset,
accesskey,
action,
align,
allow,
alt,
ariaLabel,
ariaLabelledBy,
ariaHidden,
async,
autocapitalize,
autocomplete,
autofocus,
autoplay,
background,
bgcolor,
border,
buffered,
capture,
challenge,
charset,
checked,
cite,
class,
code,
codebase,
color,
cols,
colspan,
content,
contenteditable,
contextmenu,
controls,
coords,
crossorigin,
csp,
data,
dataAttr,
datetime,
decoding,
default,
defer,
dir,
dirname,
disabled,
download,
draggable,
enctype,
enterkeyhint,
for,
form,
formaction,
formenctype,
formmethod,
formnovalidate,
formtarget,
headers,
height,
hidden,
high,
href,
hreflang,
httpEquiv,
icon,
id,
importance,
integrity,
intrinsicsize,
inputmode,
ismap,
itemprop,
keytype,
kind,
label,
lang,
language,
loading,
list,
loop,
low,
manifest,
max,
maxlength,
minlength,
media,
method,
min,
multiple,
muted,
name,
novalidate,
open,
optimum,
pattern,
ping,
placeholder,
poster,
preload,
radiogroup,
readonly,
referrerpolicy,
rel,
required,
reversed,
role,
rows,
rowspan,
sandbox,
scope,
scoped,
selected,
shape,
size,
sizes,
slot,
span,
spellcheck,
src,
srcdoc,
srclang,
srcset,
start,
step,
style,
summary,
tabindex,
target,
title,
translate,
type,
usemap,
value,
width,
wrap,
]
Attribute : [Attribute Str Str]
attribute : Str -> (Str -> Attribute)
attribute = \attrName ->
\attrValue -> Attribute attrName attrValue
accept = attribute "accept"
acceptCharset = attribute "accept-charset"
accesskey = attribute "accesskey"
action = attribute "action"
align = attribute "align"
allow = attribute "allow"
alt = attribute "alt"
ariaLabel = attribute "aria-label"
ariaLabelledBy = attribute "aria-labelledby"
ariaHidden = attribute "aria-label"
async = attribute "async"
autocapitalize = attribute "autocapitalize"
autocomplete = attribute "autocomplete"
autofocus = attribute "autofocus"
autoplay = attribute "autoplay"
background = attribute "background"
bgcolor = attribute "bgcolor"
border = attribute "border"
buffered = attribute "buffered"
capture = attribute "capture"
challenge = attribute "challenge"
charset = attribute "charset"
checked = attribute "checked"
cite = attribute "cite"
class = attribute "class"
code = attribute "code"
codebase = attribute "codebase"
color = attribute "color"
cols = attribute "cols"
colspan = attribute "colspan"
content = attribute "content"
contenteditable = attribute "contenteditable"
contextmenu = attribute "contextmenu"
controls = attribute "controls"
coords = attribute "coords"
crossorigin = attribute "crossorigin"
csp = attribute "csp"
data = attribute "data"
dataAttr = \dataName, dataVal -> Attribute "data-$(dataName)" dataVal
datetime = attribute "datetime"
decoding = attribute "decoding"
default = attribute "default"
defer = attribute "defer"
dir = attribute "dir"
dirname = attribute "dirname"
disabled = attribute "disabled"
download = attribute "download"
draggable = attribute "draggable"
enctype = attribute "enctype"
enterkeyhint = attribute "enterkeyhint"
for = attribute "for"
form = attribute "form"
formaction = attribute "formaction"
formenctype = attribute "formenctype"
formmethod = attribute "formmethod"
formnovalidate = attribute "formnovalidate"
formtarget = attribute "formtarget"
headers = attribute "headers"
height = attribute "height"
hidden = attribute "hidden"
high = attribute "high"
href = attribute "href"
hreflang = attribute "hreflang"
httpEquiv = attribute "http-equiv"
icon = attribute "icon"
id = attribute "id"
importance = attribute "importance"
integrity = attribute "integrity"
intrinsicsize = attribute "intrinsicsize"
inputmode = attribute "inputmode"
ismap = attribute "ismap"
itemprop = attribute "itemprop"
keytype = attribute "keytype"
kind = attribute "kind"
label = attribute "label"
lang = attribute "lang"
language = attribute "language"
loading = attribute "loading"
list = attribute "list"
loop = attribute "loop"
low = attribute "low"
manifest = attribute "manifest"
max = attribute "max"
maxlength = attribute "maxlength"
minlength = attribute "minlength"
media = attribute "media"
method = attribute "method"
min = attribute "min"
multiple = attribute "multiple"
muted = attribute "muted"
name = attribute "name"
novalidate = attribute "novalidate"
open = attribute "open"
optimum = attribute "optimum"
pattern = attribute "pattern"
ping = attribute "ping"
placeholder = attribute "placeholder"
poster = attribute "poster"
preload = attribute "preload"
radiogroup = attribute "radiogroup"
readonly = attribute "readonly"
referrerpolicy = attribute "referrerpolicy"
rel = attribute "rel"
required = attribute "required"
reversed = attribute "reversed"
role = attribute "role"
rows = attribute "rows"
rowspan = attribute "rowspan"
sandbox = attribute "sandbox"
scope = attribute "scope"
scoped = attribute "scoped"
selected = attribute "selected"
shape = attribute "shape"
size = attribute "size"
sizes = attribute "sizes"
slot = attribute "slot"
span = attribute "span"
spellcheck = attribute "spellcheck"
src = attribute "src"
srcdoc = attribute "srcdoc"
srclang = attribute "srclang"
srcset = attribute "srcset"
start = attribute "start"
step = attribute "step"
style = attribute "style"
summary = attribute "summary"
tabindex = attribute "tabindex"
target = attribute "target"
title = attribute "title"
translate = attribute "translate"
type = attribute "type"
usemap = attribute "usemap"
value = attribute "value"
width = attribute "width"
wrap = attribute "wrap"

View file

@ -1,9 +0,0 @@
fn main() {
#[cfg(not(windows))]
println!("cargo:rustc-link-lib=dylib=app");
#[cfg(windows)]
println!("cargo:rustc-link-lib=dylib=libapp");
println!("cargo:rustc-link-search=.");
}

View file

@ -1,3 +0,0 @@
extern int rust_main();
int main() { return rust_main(); }

View file

@ -1,9 +0,0 @@
platform "static-site-gen"
requires {} { transformFileContent : Str, Str -> Str }
exposes []
packages {}
imports []
provides [transformFileContentForHost]
transformFileContentForHost : Box Str, Box Str -> Str
transformFileContentForHost = \relPath, htmlContent -> transformFileContent (Box.unbox relPath) (Box.unbox htmlContent)

View file

@ -1,428 +0,0 @@
use core::ffi::c_void;
use libc;
use pulldown_cmark::{html, Options, Parser};
use roc_std::{RocBox, RocStr};
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use syntect::easy::HighlightLines;
use syntect::highlighting::{ThemeSet};
use syntect::html::{ClassStyle, ClassedHTMLGenerator};
use syntect::parsing::SyntaxSet;
use syntect::util::LinesWithEndings;
extern "C" {
#[link_name = "roc__transformFileContentForHost_1_exposed"]
fn roc_transformFileContentForHost(relPath: RocBox<RocStr>, content: RocBox<RocStr>) -> RocStr;
}
#[no_mangle]
pub unsafe extern "C" fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
libc::malloc(size)
}
#[no_mangle]
pub unsafe extern "C" fn roc_realloc(
c_ptr: *mut c_void,
new_size: usize,
_old_size: usize,
_alignment: u32,
) -> *mut c_void {
libc::realloc(c_ptr, new_size)
}
#[no_mangle]
pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
libc::free(c_ptr)
}
#[cfg(unix)]
#[no_mangle]
pub unsafe extern "C" fn roc_getppid() -> libc::pid_t {
libc::getppid()
}
#[cfg(unix)]
#[no_mangle]
pub unsafe extern "C" fn roc_mmap(
addr: *mut libc::c_void,
len: libc::size_t,
prot: libc::c_int,
flags: libc::c_int,
fd: libc::c_int,
offset: libc::off_t,
) -> *mut libc::c_void {
libc::mmap(addr, len, prot, flags, fd, offset)
}
#[cfg(unix)]
#[no_mangle]
pub unsafe extern "C" fn roc_shm_open(
name: *const libc::c_char,
oflag: libc::c_int,
mode: libc::mode_t,
) -> libc::c_int {
libc::shm_open(name, oflag, mode as libc::c_uint)
}
#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
let args: Vec<String> = env::args().collect();
if args.len() != 3 {
eprintln!("Usage: {} path/to/input/dir path/to/output/dir", args[0]);
return 1;
}
match run(&args[1], &args[2]) {
Err(e) => {
eprintln!("{}", e);
1
}
Ok(()) => 0,
}
}
#[no_mangle]
pub unsafe extern "C" fn roc_panic(msg: *mut RocStr, tag_id: u32) {
match tag_id {
0 => {
eprintln!("Roc standard library hit a panic: {}", &*msg);
}
1 => {
eprintln!("Application hit a panic: {}", &*msg);
}
_ => unreachable!(),
}
std::process::exit(1);
}
#[no_mangle]
pub unsafe extern "C" fn roc_dbg(loc: *mut RocStr, msg: *mut RocStr, src: *mut RocStr) {
eprintln!("[{}] {} = {}", &*loc, &*src, &*msg);
}
#[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n)
}
fn run(input_dirname: &str, output_dirname: &str) -> Result<(), String> {
let input_dir = strip_windows_prefix(
PathBuf::from(input_dirname)
.canonicalize()
.map_err(|e| format!("{}: {}", input_dirname, e))?,
);
let output_dir = {
let dir = PathBuf::from(output_dirname);
if !dir.exists() {
fs::create_dir_all(&dir).unwrap();
}
strip_windows_prefix(
dir.canonicalize()
.map_err(|e| format!("{}: {}", output_dirname, e))?,
)
};
if !input_dir.exists() {
return Err(format!("{} does not exist. The first argument should be the directory where your Markdown files are.", input_dir.display()));
}
if !output_dir.exists() {
return Err(format!("Could not create {}", output_dir.display()));
}
let mut input_files: Vec<PathBuf> = vec![];
find_files(&input_dir, &mut input_files)
.map_err(|e| format!("Error finding input files: {}", e))?;
println!("Processing {} input files...", input_files.len());
// TODO: process the files asynchronously
let num_files = input_files.len();
let mut num_errors = 0;
let mut num_successes = 0;
for input_file in input_files {
match input_file.extension() {
Some(s) if s.eq("md".into()) => {
match process_file(&input_dir, &output_dir, &input_file) {
Ok(()) => {
num_successes += 1;
}
Err(e) => {
eprintln!(
"Failed to process file:\n\n ({:?})with error:\n\n {}",
&input_file, e
);
num_errors += 1;
}
}
}
_ => {}
};
}
println!(
"Processed {} files with {} successes and {} errors",
num_files, num_successes, num_errors
);
if num_errors > 0 {
Err("Could not process all files".into())
} else {
Ok(())
}
}
fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Result<(), String> {
let input_relpath = input_file
.strip_prefix(input_dir)
.map_err(|e| e.to_string())?
.to_path_buf();
let mut output_relpath = input_relpath.clone();
output_relpath.set_extension("html");
let content_md = fs::read_to_string(input_file).map_err(|e| {
format!(
"Error reading {}: {}",
input_file.to_str().unwrap_or("an input file"),
e
)
})?;
let mut content_html = String::new();
let mut options = Options::all();
// In the tutorial, this messes up string literals in <samp> blocks.
// Those could be done as markdown code blocks, but the repl ones need
// a special class, and there's no way to add that class using markdown alone.
//
// We could make this option user-configurable if people actually want it!
options.remove(Options::ENABLE_SMART_PUNCTUATION);
let parser = Parser::new_ext(&content_md, options);
// We'll build a new vector of events since we can only consume the parser once
let mut parser_with_highlighting = Vec::new();
// As we go along, we'll want to highlight code in bundles, not lines
let mut code_to_highlight = String::new();
// And track a little bit of state
let mut in_code_block = false;
let mut is_roc_code = false;
let syntax_set: syntect::parsing::SyntaxSet = SyntaxSet::load_defaults_newlines();
let theme_set: syntect::highlighting::ThemeSet = ThemeSet::load_defaults();
for event in parser {
match event {
pulldown_cmark::Event::Code(code_str) => {
if code_str.starts_with("roc!") {
let stripped = code_str
.strip_prefix("roc!")
.expect("expected leading 'roc!'");
let highlighted_html =
roc_highlight::highlight_roc_code_inline(stripped.to_string().as_str());
parser_with_highlighting.push(pulldown_cmark::Event::Html(
pulldown_cmark::CowStr::from(highlighted_html),
));
} else {
let inline_code =
pulldown_cmark::CowStr::from(format!("<code>{}</code>", code_str));
parser_with_highlighting.push(pulldown_cmark::Event::Html(inline_code));
}
}
pulldown_cmark::Event::Start(pulldown_cmark::Tag::CodeBlock(cbk)) => {
in_code_block = true;
is_roc_code = is_roc_code_block(&cbk);
}
pulldown_cmark::Event::End(pulldown_cmark::Tag::CodeBlock(
pulldown_cmark::CodeBlockKind::Fenced(extention_str),
)) => {
if in_code_block {
match &code_to_highlight.split(':').collect::<Vec<_>>()[..] {
["file", replacement_file_name, "snippet", snippet_name] => {
code_to_highlight = read_replacement_snippet(
replacement_file_name.trim(),
snippet_name.trim(),
input_file,
);
}
["file", replacement_file_name] => {
code_to_highlight =
read_replacement_file(replacement_file_name.trim(), input_file);
}
_ => {}
}
// Format the whole multi-line code block as HTML all at once
let highlighted_html: String;
if is_roc_code {
highlighted_html = roc_highlight::highlight_roc_code(&code_to_highlight)
} else if let Some(syntax) = syntax_set.find_syntax_by_token(&extention_str) {
let mut h =
HighlightLines::new(syntax, &theme_set.themes["base16-ocean.dark"]);
let mut html_generator = ClassedHTMLGenerator::new_with_class_style(
syntax,
&syntax_set,
ClassStyle::Spaced,
);
for line in LinesWithEndings::from(&code_to_highlight) {
html_generator.parse_html_for_line_which_includes_newline(line);
}
highlighted_html =
format!("<pre><samp>{}</pre></samp>", html_generator.finalize())
} else {
highlighted_html = format!("<pre><samp>{}</pre></samp>", &code_to_highlight)
}
// And put it into the vector
parser_with_highlighting.push(pulldown_cmark::Event::Html(
pulldown_cmark::CowStr::from(highlighted_html),
));
code_to_highlight = String::new();
in_code_block = false;
}
}
pulldown_cmark::Event::Text(t) => {
if in_code_block {
// If we're in a code block, build up the string of text
code_to_highlight.push_str(&t);
} else {
parser_with_highlighting.push(pulldown_cmark::Event::Text(t))
}
}
e => {
parser_with_highlighting.push(e);
}
}
}
html::push_html(&mut content_html, parser_with_highlighting.into_iter());
let roc_relpath = RocStr::from(output_relpath.to_str().unwrap());
let roc_content_html = RocStr::from(content_html.as_str());
let roc_output_str = unsafe {
roc_transformFileContentForHost(RocBox::new(roc_relpath), RocBox::new(roc_content_html))
};
let output_file = output_dir.join(&output_relpath);
let rust_output_str: &str = &roc_output_str;
println!("{} -> {}", input_file.display(), output_file.display());
// Create parent directory if it doesn't exist
let parent_dir = output_file.parent().unwrap();
if !parent_dir.exists() {
fs::create_dir_all(&parent_dir).unwrap();
}
fs::write(output_file, rust_output_str).map_err(|e| format!("{}", e))
}
fn find_files(dir: &Path, file_paths: &mut Vec<PathBuf>) -> std::io::Result<()> {
for entry in fs::read_dir(dir)? {
let pathbuf = entry?.path();
if pathbuf.is_dir() {
find_files(&pathbuf, file_paths)?;
} else {
file_paths.push(pathbuf);
}
}
Ok(())
}
/// On windows, the path is prefixed with `\\?\`, the "verbatim" prefix.
/// Such a path does not works as an argument to `zig` and other command line tools,
/// and there seems to be no good way to strip it. So we resort to some string manipulation.
pub fn strip_windows_prefix(path_buf: PathBuf) -> std::path::PathBuf {
#[cfg(not(windows))]
{
path_buf
}
#[cfg(windows)]
{
let path_str = path_buf.display().to_string();
std::path::Path::new(path_str.trim_start_matches(r"\\?\")).to_path_buf()
}
}
fn is_roc_code_block(cbk: &pulldown_cmark::CodeBlockKind) -> bool {
match cbk {
pulldown_cmark::CodeBlockKind::Indented => false,
pulldown_cmark::CodeBlockKind::Fenced(cow_str) => cow_str.contains("roc")
}
}
fn read_replacement_file(replacement_file_name: &str, input_file: &Path) -> String {
if replacement_file_name.contains("../") {
panic!(
"ERROR File \"{}\" must be located within the input diretory.",
replacement_file_name
);
}
let input_dir = input_file.parent().unwrap();
let replacement_file_path = input_dir.join(replacement_file_name);
match fs::read(&replacement_file_path) {
Ok(content) => String::from_utf8(content).unwrap(),
Err(err) => {
panic!(
"ERROR File \"{}\" is unreadable:\n\t{}",
replacement_file_path.to_str().unwrap(),
err
);
}
}
}
fn remove_snippet_comments(input: &str) -> String {
let line_ending = if input.contains("\r\n") { "\r\n" } else { "\n" };
input
.lines()
.filter(|line| {
!line.contains("### start snippet") && !line.contains("### end snippet")
})
.collect::<Vec<&str>>()
.join(line_ending)
}
fn read_replacement_snippet(
replacement_file_name: &str,
snippet_name: &str,
input_file: &Path,
) -> String {
let start_marker = format!("### start snippet {}", snippet_name);
let end_marker = format!("### end snippet {}", snippet_name);
let replacement_file_content = read_replacement_file(replacement_file_name.trim(), input_file);
let start_position = replacement_file_content
.find(&start_marker)
.expect(format!("ERROR Failed to find snippet start \"{}\". ", &start_marker).as_str());
let end_position = replacement_file_content
.find(&end_marker)
.expect(format!("ERROR Failed to find snippet end \"{}\". ", &end_marker).as_str());
if start_position >= end_position {
let start_position_str = start_position.to_string();
let end_position_str = end_position.to_string();
panic!(
"ERROR Detected start position ({start_position_str}) of snippet \"{snippet_name}\" was greater than or equal to detected end position ({end_position_str})."
);
} else {
// We want to remove other snippet comments inside this one if they exist.
remove_snippet_comments(
&replacement_file_content[start_position + start_marker.len()..end_position]
)
}
}

View file

@ -1,3 +0,0 @@
fn main() {
std::process::exit(host::rust_main() as _);
}

View file

@ -1,65 +0,0 @@
app [transformFileContent] { pf: platform "platform/main.roc" }
import pf.Html exposing [html, head, body, div, text, a, ul, li, link, meta]
import pf.Html.Attributes exposing [httpEquiv, content, href, rel, lang, class, title]
NavLink : {
url : Str,
title : Str,
text : Str,
}
navLinks : List NavLink
navLinks = [
{ url: "subFolder/apple.html", title: "Exempli Gratia Pagina Pomi", text: "Apple" },
{ url: "banana.html", title: "Exempli Gratia Pagina Musa", text: "Banana" },
{ url: "cherry.html", title: "Exempli Pagina Cerasus", text: "Cherry" },
]
transformFileContent : Str, Str -> Str
transformFileContent = \currentUrl, htmlContent ->
List.findFirst navLinks (\{ url } -> url == currentUrl)
|> Result.map (\currentNavLink -> view currentNavLink htmlContent)
|> Result.map Html.render
|> Result.withDefault ""
view : NavLink, Str -> Html.Node
view = \currentNavLink, htmlContent ->
html [lang "en"] [
head [] [
meta [httpEquiv "content-type", content "text/html; charset=utf-8"],
Html.title [] [text currentNavLink.title],
link [rel "stylesheet", href "style.css"],
],
body [] [
div [class "main"] [
div [class "navbar"] [
viewNavbar currentNavLink,
],
div [class "article"] [
# For now `text` is not escaped so we can use it to insert HTML
# We'll probably want something more explicit in the long term though!
text htmlContent,
],
],
],
]
viewNavbar : NavLink -> Html.Node
viewNavbar = \currentNavLink ->
ul
[]
(List.map navLinks \nl -> viewNavLink (nl == currentNavLink) nl)
viewNavLink : Bool, NavLink -> Html.Node
viewNavLink = \isCurrent, navlink ->
if isCurrent then
li [class "nav-link nav-link--current"] [
text navlink.text,
]
else
li [class "nav-link"] [
a
[href navlink.url, title navlink.title]
[text navlink.text],
]