Compare commits
105 Commits
793789bdf2
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b06798f23f | ||
|
|
35dff5cdaf | ||
|
|
d641c8d638 | ||
|
|
7e2fd70212 | ||
|
|
4fb08bc7d0 | ||
|
|
01b55b7256 | ||
|
|
bd68681e44 | ||
|
|
27ff13e675 | ||
|
|
2914e42ba1 | ||
|
|
a8969f141d | ||
|
|
6f049e00d4 | ||
|
|
45a1076d18 | ||
|
|
775c88d67a | ||
|
|
efbf6cfc0c | ||
|
|
5af4a372ae | ||
|
|
72952adb6b | ||
|
|
8b85c02ef1 | ||
|
|
2ae4839ce0 | ||
|
|
5654c40d03 | ||
|
|
b538750287 | ||
|
|
65ed754bfe | ||
|
|
80cdf5166b | ||
|
|
3968121d54 | ||
|
|
a29b625631 | ||
|
|
e193fcc2ba | ||
|
|
050b426f6f | ||
|
|
da81f93e4a | ||
|
|
1581e5c401 | ||
|
|
2e1c979127 | ||
|
|
d4b290ebe6 | ||
|
|
4bb1f9983a | ||
|
|
261fe8a1a2 | ||
|
|
add267d616 | ||
|
|
cb3278aba5 | ||
|
|
94d9a95967 | ||
|
|
6511115b95 | ||
|
|
53cd55932b | ||
|
|
cbe2010407 | ||
|
|
2ba4a5e3d7 | ||
|
|
c3482cf1e4 | ||
|
|
fdf84e3d0b | ||
|
|
0a4376dfb8 | ||
|
|
e8ed4a4f4a | ||
|
|
60555999db | ||
|
|
6968a5b02c | ||
|
|
c84cfdc02b | ||
|
|
c98489cacb | ||
|
|
35dbab0ceb | ||
|
|
1ff41940a5 | ||
|
|
884215a7e1 | ||
|
|
20c55f0708 | ||
|
|
9e3d72972c | ||
|
|
806c45a453 | ||
|
|
270c42a509 | ||
|
|
e8963e107b | ||
|
|
0b64551a23 | ||
|
|
b654ca4859 | ||
|
|
386af57ce6 | ||
|
|
ef4d315bf2 | ||
|
|
2142b01967 | ||
|
|
159d8fb72a | ||
|
|
0fae417610 | ||
|
|
ae933b491e | ||
|
|
5e476e189a | ||
|
|
533997dbf5 | ||
|
|
8695cf17c5 | ||
|
|
e2f9938437 | ||
|
|
ada11816fb | ||
|
|
ff57242434 | ||
|
|
0da37b25e3 | ||
|
|
ff03140007 | ||
|
|
0ae492f8d3 | ||
|
|
613d49c6ec | ||
|
|
0f7e5eea25 | ||
|
|
2e7cfd5637 | ||
|
|
afe62de2b6 | ||
|
|
1f3b5262b8 | ||
|
|
f63620b547 | ||
|
|
671159cb82 | ||
|
|
f1e985fb32 | ||
|
|
a966be8122 | ||
|
|
24b9782146 | ||
|
|
3d44d20384 | ||
|
|
f98a09bc59 | ||
|
|
ba511b7f9e | ||
|
|
3720558d93 | ||
|
|
b66ec507ef | ||
|
|
645ae26701 | ||
|
|
6109902945 | ||
|
|
cd27869122 | ||
|
|
795945f0da | ||
|
|
cb7c28c1ae | ||
|
|
52ca300de3 | ||
|
|
06dcd22e69 | ||
|
|
f87c453459 | ||
|
|
e42edb3f49 | ||
|
|
6d83828012 | ||
|
|
eaea37f448 | ||
|
|
fb99fd2b39 | ||
|
|
313313ae53 | ||
|
|
d9a3b13780 | ||
|
|
8d9a50226a | ||
|
|
f164838953 | ||
|
|
fe3f2642fe | ||
|
|
3d89492518 |
39
Cargo.lock
generated
39
Cargo.lock
generated
@@ -179,7 +179,8 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
[[package]]
|
||||
name = "duster"
|
||||
version = "0.1.1"
|
||||
source = "git+https://code.fizz.buzz/talexander/duster.git?branch=master#3428a3f5097c7d2cc252d1bfd9aae7771553ab69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17d19cdf8e1ae4aead0978a30e99817af1c36abaf22f81901952b1310abb6989"
|
||||
dependencies = [
|
||||
"nom 6.1.2",
|
||||
"serde",
|
||||
@@ -386,6 +387,22 @@ dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "natter"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"duster",
|
||||
"futures",
|
||||
"include_dir",
|
||||
"organic",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"toml",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "6.1.2"
|
||||
@@ -430,7 +447,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "organic"
|
||||
version = "0.1.12"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61b01691695303b42f9a2ff318bec83853fbeb65c96569f2fb391e7636801c6"
|
||||
dependencies = [
|
||||
"nom 7.1.3",
|
||||
"walkdir",
|
||||
@@ -745,22 +764,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "writer"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"duster",
|
||||
"futures",
|
||||
"include_dir",
|
||||
"organic",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"toml",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wyz"
|
||||
version = "0.2.0"
|
||||
|
||||
24
Cargo.toml
24
Cargo.toml
@@ -1,18 +1,32 @@
|
||||
[package]
|
||||
name = "writer"
|
||||
name = "natter"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
||||
description = "A static site generator using org source files."
|
||||
license = "0BSD"
|
||||
repository = "https://code.fizz.buzz/talexander/natter"
|
||||
readme = "README.md"
|
||||
keywords = ["static", "site", "generator"]
|
||||
categories = ["command-line-utilities"]
|
||||
resolver = "2"
|
||||
include = [
|
||||
"LICENSE",
|
||||
"**/*.rs",
|
||||
"Cargo.toml",
|
||||
"Cargo.lock",
|
||||
"default_environment/"
|
||||
]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4.6", default-features = false, features = ["std", "color", "help", "derive"] }
|
||||
duster = { git = "https://code.fizz.buzz/talexander/duster.git", branch = "master" }
|
||||
duster = "0.1.1"
|
||||
futures = "0.3.29"
|
||||
include_dir = "0.7.3"
|
||||
# TODO: This is temporary to work on the latest organic code. Eventually switch back to using the published crate.
|
||||
organic = { path = "../organic" }
|
||||
# organic = "0.1.12"
|
||||
# organic = { path = "../organic" }
|
||||
organic = "0.1.13"
|
||||
serde = { version = "1.0.189", default-features = false, features = ["std", "derive"] }
|
||||
serde_json = "1.0.107"
|
||||
tokio = { version = "1.30.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util"] }
|
||||
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Natter
|
||||
|
||||
Natter is a static site generator for blogs using org as an input format. It is at a very early stage, and will have deep sweeping changes.
|
||||
187
default_environment/stylesheet/main.css
Normal file
187
default_environment/stylesheet/main.css
Normal file
@@ -0,0 +1,187 @@
|
||||
:root {
|
||||
--main-max-width: 800px;
|
||||
--site-background-color: #0a0a0a;
|
||||
--site-text-color: #fffffc;
|
||||
--header-divider-color: #6a687a;
|
||||
|
||||
--stream-divider-color: #6ccff6;
|
||||
|
||||
--src-font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
|
||||
|
||||
--src-block-background-color: #141414;
|
||||
--src-block-border-color: #84828f;
|
||||
--src-block-language-color: #0a0a0a;
|
||||
--src-block-language-background: #84828f;
|
||||
|
||||
--quote-block-border-color: #84828f;
|
||||
}
|
||||
|
||||
body {
|
||||
color: var(--site-text-color);
|
||||
background-color: var(--site-background-color);
|
||||
font-family: source-sans-pro, Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', sans-serif;
|
||||
|
||||
a:link, a:visited {
|
||||
/* TODO: Should I use a different color for links? */
|
||||
color: var(--site-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.page_centering {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.page_header {
|
||||
width: 100%;
|
||||
max-width: var(--main-max-width);
|
||||
border-bottom: 0.1rem solid var(--header-divider-color);
|
||||
|
||||
.home_link {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
|
||||
&:link, &:visited {
|
||||
color: var(--site-text-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.main_content {
|
||||
width: 100%;
|
||||
max-width: var(--main-max-width);
|
||||
font-size: 1.2rem;
|
||||
line-height: 1.2;
|
||||
|
||||
/* A stand-alone blog post (not in a blog stream). */
|
||||
.blog_post {
|
||||
padding: 1rem 0 3rem 0;
|
||||
}
|
||||
|
||||
.blog_stream {
|
||||
.stream_divider {
|
||||
color: var(--stream-divider-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* A blog post in a blog stream (for example, the homepage). */
|
||||
.blog_stream_post {
|
||||
background: #1F1F1F;
|
||||
padding: 1rem 0.2rem;
|
||||
}
|
||||
|
||||
.blog_post_title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
|
||||
p {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.src_block {
|
||||
background: var(--src-block-background-color);
|
||||
border-radius: 3px;
|
||||
border: 1px solid var(--src-block-border-color);
|
||||
font-size: 1rem;
|
||||
font-family: var(--src-font-family);
|
||||
margin: 1rem 0;
|
||||
|
||||
.src_language {
|
||||
display: inline-block;
|
||||
color: var(--src-block-language-color);
|
||||
background: var(--src-block-language-background);
|
||||
border-radius: 0 0 3px 0;
|
||||
padding: 0.1rem 0.5rem;
|
||||
font-size: 0.8rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.src_body {
|
||||
margin: 0.5rem;
|
||||
|
||||
.src_line {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.inline_source_block {
|
||||
font-family: var(--src-font-family);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.code, .verbatim {
|
||||
font-family: var(--src-font-family);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.quote_block {
|
||||
border-left: 1px solid var(--quote-block-border-color);
|
||||
padding: 0 0 0 1rem;
|
||||
margin: 1rem 0 1rem 2rem;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
margin: 1rem 0;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2.3rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2.1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.plain_list {
|
||||
&.unordered {
|
||||
list-style-type: disc;
|
||||
padding-left: 2.5rem;
|
||||
}
|
||||
|
||||
&.ordered {
|
||||
list-style-type: decimal;
|
||||
padding-left: 2.5rem;
|
||||
}
|
||||
|
||||
&.descriptive {
|
||||
font-size: 1rem;
|
||||
> dt {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
> dd {
|
||||
padding-left: 2.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footnote_reference {
|
||||
vertical-align: super;
|
||||
font-size: 80%;
|
||||
> a {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.footnote_definition {
|
||||
.label {
|
||||
text-decoration: none;
|
||||
}
|
||||
.definition {
|
||||
display: inline;
|
||||
|
||||
> p {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
default_environment/stylesheet/reset.css
Normal file
48
default_environment/stylesheet/reset.css
Normal file
@@ -0,0 +1,48 @@
|
||||
/* http://meyerweb.com/eric/tools/css/reset/
|
||||
v2.0 | 20110126
|
||||
License: none (public domain)
|
||||
*/
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
angle_link
|
||||
!!!!!!!! angle_link
|
||||
|
||||
57
default_environment/templates/html/ast_node.dust
Normal file
57
default_environment/templates/html/ast_node.dust
Normal file
@@ -0,0 +1,57 @@
|
||||
{@select key=.type}
|
||||
{@eq value="heading"}{>heading/}{/eq}
|
||||
{@eq value="section"}{>section/}{/eq}
|
||||
{@eq value="paragraph"}{>paragraph/}{/eq}
|
||||
{@eq value="plain_list"}{>plain_list/}{/eq}
|
||||
{@eq value="center_block"}{>center_block/}{/eq}
|
||||
{@eq value="quote_block"}{>quote_block/}{/eq}
|
||||
{@eq value="special_block"}{>special_block/}{/eq}
|
||||
{@eq value="dynamic_block"}{>dynamic_block/}{/eq}
|
||||
{@eq value="footnote_definition"}{>footnote_definition/}{/eq}
|
||||
{@eq value="comment"}{>comment/}{/eq}
|
||||
{@eq value="drawer"}{>drawer/}{/eq}
|
||||
{@eq value="property_drawer"}{>property_drawer/}{/eq}
|
||||
{@eq value="table"}{>table/}{/eq}
|
||||
{@eq value="verse_block"}{>verse_block/}{/eq}
|
||||
{@eq value="comment_block"}{>comment_block/}{/eq}
|
||||
{@eq value="example_block"}{>example_block/}{/eq}
|
||||
{@eq value="export_block"}{>export_block/}{/eq}
|
||||
{@eq value="src_block"}{>src_block/}{/eq}
|
||||
{@eq value="clock"}{>clock/}{/eq}
|
||||
{@eq value="diary_sexp"}{>diary_sexp/}{/eq}
|
||||
{@eq value="planning"}{>planning/}{/eq}
|
||||
{@eq value="fixed_width_area"}{>fixed_width_area/}{/eq}
|
||||
{@eq value="horizontal_rule"}{>horizontal_rule/}{/eq}
|
||||
{@eq value="keyword"}{>keyword/}{/eq}
|
||||
{@eq value="babel_call"}{>babel_call/}{/eq}
|
||||
{@eq value="latex_environment"}{>latex_environment/}{/eq}
|
||||
{@eq value="bold"}{>bold/}{/eq}
|
||||
{@eq value="italic"}{>italic/}{/eq}
|
||||
{@eq value="underline"}{>underline/}{/eq}
|
||||
{@eq value="strike_through"}{>strike_through/}{/eq}
|
||||
{@eq value="code"}{>code/}{/eq}
|
||||
{@eq value="verbatim"}{>verbatim/}{/eq}
|
||||
{@eq value="plain_text"}{>plain_text/}{/eq}
|
||||
{@eq value="regular_link"}{>regular_link/}{/eq}
|
||||
{@eq value="radio_link"}{>radio_link/}{/eq}
|
||||
{@eq value="radio_target"}{>radio_target/}{/eq}
|
||||
{@eq value="plain_link"}{>plain_link/}{/eq}
|
||||
{@eq value="angle_link"}{>angle_link/}{/eq}
|
||||
{@eq value="org_macro"}{>org_macro/}{/eq}
|
||||
{@eq value="entity"}{>entity/}{/eq}
|
||||
{@eq value="latex_fragment"}{>latex_fragment/}{/eq}
|
||||
{@eq value="export_snippet"}{>export_snippet/}{/eq}
|
||||
{@eq value="footnote_reference"}{>footnote_reference/}{/eq}
|
||||
{@eq value="citation"}{>citation/}{/eq}
|
||||
{@eq value="citation_reference"}{>citation_reference/}{/eq}
|
||||
{@eq value="inline_babel_call"}{>inline_babel_call/}{/eq}
|
||||
{@eq value="inline_source_block"}{>inline_source_block/}{/eq}
|
||||
{@eq value="line_break"}{>line_break/}{/eq}
|
||||
{@eq value="target"}{>target/}{/eq}
|
||||
{@eq value="statistics_cookie"}{>statistics_cookie/}{/eq}
|
||||
{@eq value="subscript"}{>subscript/}{/eq}
|
||||
{@eq value="superscript"}{>superscript/}{/eq}
|
||||
{@eq value="timestamp"}{>timestamp/}{/eq}
|
||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||
{/select}
|
||||
{! TODO: Maybe the final space should be conditional on end blank in the org source !}
|
||||
@@ -1 +1 @@
|
||||
babel_call
|
||||
!!!!!!!! babel_call
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<div class="blog_post">
|
||||
<div class="blog_post_intro">
|
||||
{?.title}{?.self_link}<a class="blog_post_title" href="{.link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
|
||||
{! TODO: date? !}
|
||||
</div>
|
||||
<article class="blog_post">
|
||||
{?.title}<h1 class="blog_post_title"><span>{.title}</span></h1>{/.title}
|
||||
{! TODO: date? !}
|
||||
|
||||
{! TODO: Table of contents? !}
|
||||
|
||||
@@ -10,5 +8,12 @@
|
||||
{#.children}
|
||||
{>document_element/}
|
||||
{/.children}
|
||||
|
||||
{?.footnotes}
|
||||
<h2>Footnotes:</h2>
|
||||
{#.footnotes}
|
||||
{>real_footnote_definition/}
|
||||
{/.footnotes}
|
||||
{/.footnotes}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
32
default_environment/templates/html/blog_stream.dust
Normal file
32
default_environment/templates/html/blog_stream.dust
Normal file
@@ -0,0 +1,32 @@
|
||||
<div class="blog_stream">
|
||||
{#.children}
|
||||
{@gt key=$idx value=0}<hr class="stream_divider" />{/gt}
|
||||
<div class="blog_stream_post">
|
||||
<div class="blog_post_intro">
|
||||
{?.title}{?.self_link}<a class="blog_post_title" href="{.self_link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
|
||||
{! TODO: date? !}
|
||||
</div>
|
||||
|
||||
{! TODO: Table of contents? !}
|
||||
|
||||
<div class="blog_post_body">
|
||||
{#.children}
|
||||
{>document_element/}
|
||||
{/.children}
|
||||
|
||||
{?.footnotes}
|
||||
<h2>Footnotes:</h2>
|
||||
{#.footnotes}
|
||||
{>real_footnote_definition/}
|
||||
{/.footnotes}
|
||||
{/.footnotes}
|
||||
</div>
|
||||
</div>
|
||||
{/.children}
|
||||
{#.stream_pagination}
|
||||
<div class="stream_nav">
|
||||
{?.older_link}<a href="{.older_link}">Older</a>{/.older_link}
|
||||
{?.newer_link}<a href="{.newer_link}">Newer</a>{/.newer_link}
|
||||
</div>
|
||||
{/.stream_pagination}
|
||||
</div>
|
||||
@@ -1 +1 @@
|
||||
center_block
|
||||
!!!!!!!! center_block
|
||||
|
||||
@@ -1 +1 @@
|
||||
citation
|
||||
!!!!!!!! citation
|
||||
|
||||
@@ -1 +1 @@
|
||||
citation_reference
|
||||
!!!!!!!! citation_reference
|
||||
|
||||
@@ -1 +1 @@
|
||||
clock
|
||||
!!!!!!!! clock
|
||||
|
||||
@@ -1 +1 @@
|
||||
<code>{.source}</code>
|
||||
<code class="code">{.contents}</code>
|
||||
|
||||
@@ -1 +1 @@
|
||||
diary_sexp
|
||||
!!!!!!!! diary_sexp
|
||||
|
||||
@@ -1 +1 @@
|
||||
drawer
|
||||
!!!!!!!! drawer
|
||||
|
||||
@@ -1 +1 @@
|
||||
dynamic_block
|
||||
!!!!!!!! dynamic_block
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{@select key=.type}
|
||||
{@eq value="paragraph"}{>paragraph/}{/eq}
|
||||
{@eq value="plain_list"}{>plain_list/}{/eq}
|
||||
{@eq value="plain_list_simple_item"}{>plain_list_simple_item/}{/eq}
|
||||
{@eq value="center_block"}{>center_block/}{/eq}
|
||||
{@eq value="quote_block"}{>quote_block/}{/eq}
|
||||
{@eq value="special_block"}{>special_block/}{/eq}
|
||||
|
||||
@@ -1 +1 @@
|
||||
example_block
|
||||
!!!!!!!! example_block
|
||||
|
||||
@@ -1 +1 @@
|
||||
export_block
|
||||
!!!!!!!! export_block
|
||||
|
||||
@@ -1 +1 @@
|
||||
export_snippet
|
||||
!!!!!!!! export_snippet
|
||||
|
||||
@@ -1 +1 @@
|
||||
fixed_width_area
|
||||
!!!!!!!! fixed_width_area
|
||||
|
||||
@@ -1 +1 @@
|
||||
footnote_definition
|
||||
{! noop !}
|
||||
|
||||
@@ -1 +1 @@
|
||||
footnote_reference
|
||||
<sup class="footnote_reference"><a id="{.reference_id}" href="{.definition_link}">{.label}</a></sup>
|
||||
|
||||
@@ -1 +1 @@
|
||||
global_settings
|
||||
!!!!!!!! global_settings
|
||||
|
||||
@@ -1 +1 @@
|
||||
horizontal_rule
|
||||
!!!!!!!! horizontal_rule
|
||||
|
||||
@@ -1 +1 @@
|
||||
inline_babel_call
|
||||
!!!!!!!! inline_babel_call
|
||||
|
||||
@@ -1 +1 @@
|
||||
inline_source_block
|
||||
<code class="inline_source_block">{.value}</code>
|
||||
|
||||
@@ -1 +1 @@
|
||||
latex_environment
|
||||
!!!!!!!! latex_environment
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
latex_fragment
|
||||
{! TODO: Should I be including MathJax somewhere? !}
|
||||
{.value}
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
{#global_settings.js_files}<script type="text/javascript" src="{.}"></script>{/global_settings.js_files}
|
||||
{?global_settings.page_title}<title>{global_settings.page_title}</title>{/global_settings.page_title}
|
||||
</head>
|
||||
<body>
|
||||
{! TODO: Header bar with links? !}
|
||||
<div class="main_content">
|
||||
<body class="page_centering">
|
||||
{#.page_header}{>page_header/}{/.page_header}
|
||||
<main class="main_content">
|
||||
{@select key=.type}
|
||||
{@eq value="blog_post_page"}{>blog_post_page/}{/eq}
|
||||
{@eq value="blog_stream"}{>blog_stream/}{/eq}
|
||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized page content type{/none}
|
||||
{/select}
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
{@eq value="superscript"}{>superscript/}{/eq}
|
||||
{@eq value="timestamp"}{>timestamp/}{/eq}
|
||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||
{/select}
|
||||
{/select}{@gt key=.post_blank value=0}{~s}{/gt}
|
||||
|
||||
@@ -1 +1 @@
|
||||
org_macro
|
||||
!!!!!!!! org_macro
|
||||
|
||||
4
default_environment/templates/html/page_header.dust
Normal file
4
default_environment/templates/html/page_header.dust
Normal file
@@ -0,0 +1,4 @@
|
||||
<header class="page_header">
|
||||
<a class="home_link" href="{.home_link}">{.website_title}</a>
|
||||
{! TODO: Additional links? Probably using the nav semantic element. !}
|
||||
</header>
|
||||
@@ -1 +1 @@
|
||||
plain_link
|
||||
!!!!!!!! plain_link
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{@select key=.list_type}
|
||||
{@eq value="unordered"}<ul>{#.children}{>plain_list_item/}{/.children}</ul>{/eq}
|
||||
{@eq value="ordered"}<ol>{#.children}{>plain_list_item/}{/.children}</ol>{/eq}
|
||||
{@eq value="descriptive"}<dl>{#.children}{>plain_list_item/}{/.children}</dl>{/eq}
|
||||
{@eq value="unordered"}<ul class="plain_list unordered">{#.children}{>plain_list_item/}{/.children}</ul>{/eq}
|
||||
{@eq value="ordered"}<ol class="plain_list ordered">{#.children}{>plain_list_item/}{/.children}</ol>{/eq}
|
||||
{@eq value="descriptive"}<dl class="plain_list descriptive">{#.children}{>plain_list_item/}{/.children}</dl>{/eq}
|
||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
|
||||
{/select}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{#.children}
|
||||
{>object/}
|
||||
{/.children}
|
||||
@@ -1 +1 @@
|
||||
planning
|
||||
!!!!!!!! planning
|
||||
|
||||
@@ -1 +1 @@
|
||||
property_drawer
|
||||
!!!!!!!! property_drawer
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<blockquote>{#.children}
|
||||
<blockquote class="quote_block">{#.children}
|
||||
{>element/}
|
||||
{/.children}</blockquote>
|
||||
|
||||
@@ -1 +1 @@
|
||||
radio_link
|
||||
!!!!!!!! radio_link
|
||||
|
||||
@@ -1 +1 @@
|
||||
radio_target
|
||||
!!!!!!!! radio_target
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<div class="footnote_definition"><a id="{.definition_id}" href="{.reference_link}" class="label">{.label}.</a> <div class="definition">{#.contents}{>ast_node/}{/.contents}</div></div>
|
||||
@@ -1 +1 @@
|
||||
regular_link
|
||||
<a href="{.raw_link}">{#.children}{>object/}{/.children}</a>
|
||||
|
||||
@@ -1 +1 @@
|
||||
special_block
|
||||
!!!!!!!! special_block
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
src_block
|
||||
<div class="src_block">
|
||||
{?.language}<div class="src_language">{.language}</div>{/.language}
|
||||
<table class="src_body">
|
||||
<tbody>
|
||||
{#.lines}
|
||||
<tr>
|
||||
<td><code class="src_line">{.}</code></td>
|
||||
</tr>
|
||||
{/.lines}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -1 +1 @@
|
||||
statistics_cookie
|
||||
!!!!!!!! statistics_cookie
|
||||
|
||||
@@ -1 +1 @@
|
||||
subscript
|
||||
!!!!!!!! subscript
|
||||
|
||||
@@ -1 +1 @@
|
||||
superscript
|
||||
!!!!!!!! superscript
|
||||
|
||||
@@ -1 +1 @@
|
||||
table
|
||||
<table>{#.children}{>table_row/}{/.children}</table>
|
||||
|
||||
1
default_environment/templates/html/table_cell.dust
Normal file
1
default_environment/templates/html/table_cell.dust
Normal file
@@ -0,0 +1 @@
|
||||
<td>{#.children}{>object/}{/.children}</td>
|
||||
1
default_environment/templates/html/table_row.dust
Normal file
1
default_environment/templates/html/table_row.dust
Normal file
@@ -0,0 +1 @@
|
||||
<tr>{#.children}{>table_cell/}{/.children}</tr>
|
||||
@@ -1 +1 @@
|
||||
timestamp
|
||||
!!!!!!!! timestamp
|
||||
|
||||
@@ -1 +1 @@
|
||||
<code>{.source}</code>
|
||||
<code class="verbatim">{.contents}</code>
|
||||
|
||||
@@ -1 +1 @@
|
||||
verse_block
|
||||
!!!!!!!! verse_block
|
||||
|
||||
21
org_test_documents/footnote/reference_in_definition.org
Normal file
21
org_test_documents/footnote/reference_in_definition.org
Normal file
@@ -0,0 +1,21 @@
|
||||
# This test shows that footnote references only count if the definition containing them is rendered.
|
||||
|
||||
foo[fn:a:bar]
|
||||
|
||||
[fn:a] lorem
|
||||
|
||||
[fn:b] ipsum
|
||||
|
||||
[fn:d] fizz
|
||||
|
||||
[fn:c] dolar
|
||||
|
||||
yo[fn:b]
|
||||
|
||||
|
||||
hello[fn:c]
|
||||
|
||||
|
||||
[fn:e] buzz
|
||||
|
||||
sup[fn:d]
|
||||
25
org_test_documents/footnote/simple.org
Normal file
25
org_test_documents/footnote/simple.org
Normal file
@@ -0,0 +1,25 @@
|
||||
# Test proves that:
|
||||
#
|
||||
# - Anonymous references with identical content get unique IDs.
|
||||
# - Unreferenced footnote definitions are dropped.
|
||||
# - Footnote definitions that come before their first reference are dropped.
|
||||
|
||||
foo[fn:2:something]
|
||||
|
||||
bar[fn::something]
|
||||
|
||||
baz[fn::something]
|
||||
|
||||
cat[fn::something]
|
||||
|
||||
dog[fn:3]
|
||||
|
||||
[fn:3] ipsum
|
||||
|
||||
[fn:4] lorem
|
||||
|
||||
[fn:3] dolar
|
||||
|
||||
[fn:5] not referenced
|
||||
|
||||
stuff[fn:4] and things
|
||||
36
org_test_documents/latex_fragment/notes.org
Normal file
36
org_test_documents/latex_fragment/notes.org
Normal file
@@ -0,0 +1,36 @@
|
||||
* Double dollar
|
||||
#+begin_src org
|
||||
$$CONTENTS$$
|
||||
#+end_src
|
||||
becomes
|
||||
#+begin_src text
|
||||
\[CONTENTS\]
|
||||
#+end_src
|
||||
|
||||
#+begin_src org
|
||||
$$1+1=2$$
|
||||
#+end_src
|
||||
|
||||
#+begin_src text
|
||||
\[1+1=2\]
|
||||
#+end_src
|
||||
|
||||
This gets interpreted by mathjax.
|
||||
* Single Dollar
|
||||
#+begin_src org
|
||||
PRE$BORDER1 BODY BORDER2$POST
|
||||
#+end_src
|
||||
becomes
|
||||
#+begin_src text
|
||||
\(BORDER1 BODY BORDER2\)
|
||||
#+end_src
|
||||
|
||||
#+begin_src org
|
||||
foo$a bar b$.
|
||||
#+end_src
|
||||
becomes
|
||||
#+begin_src text
|
||||
foo\(a bar b\).
|
||||
#+end_src
|
||||
|
||||
This gets interpreted by mathjax.
|
||||
@@ -4,7 +4,7 @@ use clap::Subcommand;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "Writer")]
|
||||
#[command(name = "Natter")]
|
||||
#[command(version = env!("CARGO_PKG_VERSION"))]
|
||||
#[command(about = "Generate a static site.", long_about = None)]
|
||||
#[command(propagate_version = true)]
|
||||
@@ -24,14 +24,14 @@ pub(crate) enum Commands {
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub(crate) struct InitArgs {
|
||||
/// Path where you want the initial writer structure to be located.
|
||||
/// Path where you want the initial natter structure to be located.
|
||||
#[arg(short, long)]
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub(crate) struct BuildArgs {
|
||||
/// Path to the writer config file.
|
||||
/// Path to the natter config file.
|
||||
#[arg(short, long)]
|
||||
pub(crate) config: PathBuf,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
mod render;
|
||||
mod runner;
|
||||
mod stylesheet;
|
||||
|
||||
pub(crate) use runner::build_site;
|
||||
|
||||
@@ -5,30 +5,41 @@ use include_dir::include_dir;
|
||||
use include_dir::Dir;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::context::RenderBlogPostPage;
|
||||
use crate::context::RenderBlogPostPageInput;
|
||||
use crate::context::RenderBlogStream;
|
||||
use crate::context::RenderBlogStreamInput;
|
||||
use crate::context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::convert_blog_post_page_to_render_context;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::render::DusterRenderer;
|
||||
use crate::render::RendererIntegration;
|
||||
|
||||
use super::stylesheet::Stylesheet;
|
||||
|
||||
static MAIN_TEMPLATES: Dir = include_dir!("$CARGO_MANIFEST_DIR/default_environment/templates/html");
|
||||
|
||||
pub(crate) struct SiteRenderer {
|
||||
output_directory: PathBuf,
|
||||
blog_posts: Vec<BlogPost>,
|
||||
stylesheets: Vec<Stylesheet>,
|
||||
}
|
||||
|
||||
impl SiteRenderer {
|
||||
pub(crate) fn new<P: Into<PathBuf>>(
|
||||
output_directory: P,
|
||||
blog_posts: Vec<BlogPost>,
|
||||
stylesheets: Vec<Stylesheet>,
|
||||
) -> SiteRenderer {
|
||||
SiteRenderer {
|
||||
output_directory: output_directory.into(),
|
||||
blog_posts,
|
||||
stylesheets,
|
||||
}
|
||||
}
|
||||
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
|
||||
|
||||
fn init_renderer_integration(&self) -> Result<DusterRenderer<'_>, CustomError> {
|
||||
let mut renderer_integration = DusterRenderer::new();
|
||||
|
||||
let sources: Vec<_> = MAIN_TEMPLATES
|
||||
@@ -56,21 +67,27 @@ impl SiteRenderer {
|
||||
renderer_integration.load_template(name, contents)?;
|
||||
}
|
||||
|
||||
Ok(renderer_integration)
|
||||
}
|
||||
|
||||
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
|
||||
let renderer_integration = self.init_renderer_integration()?;
|
||||
|
||||
for blog_post in &self.blog_posts {
|
||||
for blog_post_page in &blog_post.pages {
|
||||
let output_path = self
|
||||
.output_directory
|
||||
.join("posts")
|
||||
.join(&blog_post.id)
|
||||
.join(config.get_relative_path_to_post(&blog_post.id))
|
||||
.join(blog_post_page.get_output_path());
|
||||
|
||||
let render_context = convert_blog_post_page_to_render_context(
|
||||
let convert_input = RenderBlogPostPageInput::new(blog_post, blog_post_page);
|
||||
let render_context = RenderContext::new(
|
||||
config,
|
||||
&self.output_directory,
|
||||
&output_path,
|
||||
blog_post,
|
||||
blog_post_page,
|
||||
self.output_directory.as_path(),
|
||||
output_path.as_path(),
|
||||
None,
|
||||
)?;
|
||||
let render_context = RenderBlogPostPage::new(render_context, &convert_input)?;
|
||||
let rendered_output = renderer_integration.render(render_context)?;
|
||||
let parent_directory = output_path
|
||||
.parent()
|
||||
@@ -82,6 +99,103 @@ impl SiteRenderer {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn render_blog_stream(&self, config: &Config) -> Result<(), CustomError> {
|
||||
let renderer_integration = self.init_renderer_integration()?;
|
||||
|
||||
// Sort blog posts by date, newest first.
|
||||
let sorted_blog_posts = {
|
||||
let mut sorted_blog_posts: Vec<_> = self.blog_posts.iter().collect();
|
||||
sorted_blog_posts
|
||||
.sort_by_key(|blog_post| (blog_post.get_date(), blog_post.id.as_str()));
|
||||
sorted_blog_posts.reverse();
|
||||
sorted_blog_posts
|
||||
};
|
||||
|
||||
for blog_post in &sorted_blog_posts {
|
||||
if blog_post.get_date().is_none() {
|
||||
return Err(format!("Blog post {} does not have a date.", blog_post.id).into());
|
||||
}
|
||||
}
|
||||
|
||||
// Group blog posts based on # of posts per page.
|
||||
let stream_chunks: Vec<_> = sorted_blog_posts
|
||||
.chunks(config.get_stream_entries_per_page())
|
||||
.collect();
|
||||
|
||||
// For each group, create a RenderBlogStream.
|
||||
let num_stream_pages = stream_chunks.len();
|
||||
for (page_num, chunk) in stream_chunks.into_iter().enumerate() {
|
||||
let output_file = if page_num == 0 {
|
||||
self.output_directory.join("index.html")
|
||||
} else {
|
||||
self.output_directory
|
||||
.join("stream")
|
||||
.join(format!("{}.html", page_num))
|
||||
};
|
||||
let newer_link = if page_num == 0 {
|
||||
None
|
||||
} else if page_num == 1 {
|
||||
Some(get_web_path(
|
||||
config,
|
||||
&self.output_directory,
|
||||
&output_file,
|
||||
"index.html",
|
||||
)?)
|
||||
} else {
|
||||
Some(get_web_path(
|
||||
config,
|
||||
&self.output_directory,
|
||||
&output_file,
|
||||
format!("stream/{}.html", page_num - 1),
|
||||
)?)
|
||||
};
|
||||
let older_link = if page_num == (num_stream_pages - 1) {
|
||||
None
|
||||
} else {
|
||||
Some(get_web_path(
|
||||
config,
|
||||
&self.output_directory,
|
||||
&output_file,
|
||||
format!("stream/{}.html", page_num + 1),
|
||||
)?)
|
||||
};
|
||||
|
||||
let convert_input = RenderBlogStreamInput::new(chunk, older_link, newer_link);
|
||||
let render_context = RenderContext::new(
|
||||
config,
|
||||
self.output_directory.as_path(),
|
||||
output_file.as_path(),
|
||||
None,
|
||||
)?;
|
||||
let blog_stream = RenderBlogStream::new(render_context, &convert_input)?;
|
||||
|
||||
// Pass each RenderBlogStream to dust as the context to render index.html and any additional stream pages.
|
||||
let rendered_output = renderer_integration.render(blog_stream)?;
|
||||
let parent_directory = output_file
|
||||
.parent()
|
||||
.ok_or("Output file should have a containing directory.")?;
|
||||
tokio::fs::create_dir_all(parent_directory).await?;
|
||||
tokio::fs::write(output_file, rendered_output).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn render_stylesheets(&self) -> Result<(), CustomError> {
|
||||
let stylesheet_output_directory = self.output_directory.join("stylesheet");
|
||||
if !stylesheet_output_directory.exists() {
|
||||
tokio::fs::create_dir(&stylesheet_output_directory).await?;
|
||||
}
|
||||
for stylesheet in &self.stylesheets {
|
||||
let file_output_path = stylesheet_output_directory.join(&stylesheet.path);
|
||||
let parent_directory = file_output_path
|
||||
.parent()
|
||||
.ok_or("Output file should have a containing directory.")?;
|
||||
tokio::fs::create_dir_all(parent_directory).await?;
|
||||
tokio::fs::write(file_output_path, stylesheet.contents.as_bytes()).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn build_name_contents_pairs<'a>(
|
||||
|
||||
@@ -1,16 +1,30 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::stylesheet::Stylesheet;
|
||||
use crate::cli::parameters::BuildArgs;
|
||||
use crate::command::build::render::SiteRenderer;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::BlogPost;
|
||||
use include_dir::include_dir;
|
||||
use include_dir::Dir;
|
||||
|
||||
static DEFAULT_STYLESHEETS: Dir =
|
||||
include_dir!("$CARGO_MANIFEST_DIR/default_environment/stylesheet");
|
||||
|
||||
pub(crate) async fn build_site(args: BuildArgs) -> Result<(), CustomError> {
|
||||
let config = Config::load_from_file(args.config).await?;
|
||||
let blog_posts = load_blog_posts(&config).await?;
|
||||
let renderer = SiteRenderer::new(get_output_directory(&config).await?, blog_posts);
|
||||
let stylesheets = load_stylesheets().await?;
|
||||
let renderer = SiteRenderer::new(
|
||||
get_output_directory(&config).await?,
|
||||
blog_posts,
|
||||
stylesheets,
|
||||
);
|
||||
renderer.render_blog_posts(&config).await?;
|
||||
renderer.render_blog_stream(&config).await?;
|
||||
renderer.render_stylesheets().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -58,3 +72,18 @@ async fn load_blog_posts(config: &Config) -> Result<Vec<BlogPost>, CustomError>
|
||||
}
|
||||
Ok(blog_posts)
|
||||
}
|
||||
|
||||
async fn load_stylesheets() -> Result<Vec<Stylesheet>, CustomError> {
|
||||
let sources: Vec<_> = DEFAULT_STYLESHEETS
|
||||
.files()
|
||||
.filter(|f| f.path().extension() == Some(OsStr::new("css")))
|
||||
.collect();
|
||||
let mut ret = Vec::with_capacity(sources.len());
|
||||
for entry in sources {
|
||||
let path = entry.path().to_path_buf();
|
||||
let contents = String::from_utf8(entry.contents().to_vec())?;
|
||||
let stylesheet = Stylesheet::new(path, contents).await?;
|
||||
ret.push(stylesheet);
|
||||
}
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
15
src/command/build/stylesheet.rs
Normal file
15
src/command/build/stylesheet.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Stylesheet {
|
||||
pub(crate) path: PathBuf,
|
||||
pub(crate) contents: String,
|
||||
}
|
||||
|
||||
impl Stylesheet {
|
||||
pub(crate) async fn new(path: PathBuf, contents: String) -> Result<Stylesheet, CustomError> {
|
||||
Ok(Stylesheet { path, contents })
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
mod runner;
|
||||
|
||||
pub(crate) use runner::init_writer_folder;
|
||||
pub(crate) use runner::init_natter_folder;
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::cli::parameters::InitArgs;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
|
||||
pub(crate) async fn init_writer_folder(args: InitArgs) -> Result<(), CustomError> {
|
||||
pub(crate) async fn init_natter_folder(args: InitArgs) -> Result<(), CustomError> {
|
||||
if args.path.exists() && !args.path.is_dir() {
|
||||
return Err("The supplied path exists but is not a directory. Aborting.".into());
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::error::CustomError;
|
||||
use super::raw::RawConfig;
|
||||
|
||||
/// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Config {
|
||||
raw: RawConfig,
|
||||
config_path: PathBuf,
|
||||
@@ -16,7 +17,7 @@ pub(crate) struct Config {
|
||||
impl Config {
|
||||
pub(crate) fn new<P: AsRef<Path>>(root_dir: P) -> Result<Config, CustomError> {
|
||||
fn inner(root_dir: &Path) -> Result<Config, CustomError> {
|
||||
let file_path = root_dir.join("writer.toml");
|
||||
let file_path = root_dir.join("natter.toml");
|
||||
Ok(Config {
|
||||
raw: RawConfig::default(),
|
||||
config_path: file_path,
|
||||
@@ -56,6 +57,15 @@ impl Config {
|
||||
self.get_root_directory().join("posts")
|
||||
}
|
||||
|
||||
/// Get the relative path to the folder containing a blog post.
|
||||
///
|
||||
/// This could be appended to the output root directory to get the
|
||||
/// blog post output folder or it could be used to generate a link
|
||||
/// to the blog post.
|
||||
pub(crate) fn get_relative_path_to_post<P: AsRef<Path>>(&self, post_id: P) -> PathBuf {
|
||||
Path::new("posts").join(post_id)
|
||||
}
|
||||
|
||||
pub(crate) fn get_output_directory(&self) -> PathBuf {
|
||||
self.get_root_directory().join("output")
|
||||
}
|
||||
@@ -67,4 +77,17 @@ impl Config {
|
||||
pub(crate) fn get_web_root(&self) -> Option<&str> {
|
||||
self.raw.web_root.as_deref()
|
||||
}
|
||||
|
||||
pub(crate) fn get_site_title(&self) -> Option<&str> {
|
||||
self.raw.site_title.as_deref()
|
||||
}
|
||||
|
||||
pub(crate) fn get_stream_entries_per_page(&self) -> usize {
|
||||
self.raw
|
||||
.stream
|
||||
.as_ref()
|
||||
.map(|stream| stream.entries_per_page)
|
||||
.flatten()
|
||||
.unwrap_or(5)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,39 @@
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
/// This is the struct for the writer.toml config file that ends up in each site's root directory.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
/// This is the struct for the natter.toml config file that ends up in each site's root directory.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub(crate) struct RawConfig {
|
||||
site_title: String,
|
||||
pub(super) site_title: Option<String>,
|
||||
author: Option<String>,
|
||||
email: Option<String>,
|
||||
pub(super) use_relative_paths: Option<bool>,
|
||||
pub(super) web_root: Option<String>,
|
||||
pub(super) stream: Option<RawConfigStream>,
|
||||
}
|
||||
|
||||
impl Default for RawConfig {
|
||||
fn default() -> Self {
|
||||
RawConfig {
|
||||
site_title: "My super awesome website".to_owned(),
|
||||
site_title: None,
|
||||
author: None,
|
||||
email: None,
|
||||
use_relative_paths: None,
|
||||
web_root: None,
|
||||
stream: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub(crate) struct RawConfigStream {
|
||||
pub(super) entries_per_page: Option<usize>,
|
||||
}
|
||||
|
||||
impl Default for RawConfigStream {
|
||||
fn default() -> Self {
|
||||
RawConfigStream {
|
||||
entries_per_page: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IAngleLink;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "angle_link")]
|
||||
pub(crate) struct RenderAngleLink {}
|
||||
|
||||
impl RenderAngleLink {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IAngleLink,
|
||||
) -> Result<RenderAngleLink, CustomError> {
|
||||
Ok(RenderAngleLink {})
|
||||
}
|
||||
pub(crate) struct RenderAngleLink {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderAngleLink, IAngleLink);
|
||||
|
||||
327
src/context/ast_node.rs
Normal file
327
src/context/ast_node.rs
Normal file
@@ -0,0 +1,327 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IAstNode;
|
||||
|
||||
use super::angle_link::RenderAngleLink;
|
||||
use super::babel_call::RenderBabelCall;
|
||||
use super::bold::RenderBold;
|
||||
use super::center_block::RenderCenterBlock;
|
||||
use super::citation::RenderCitation;
|
||||
use super::citation_reference::RenderCitationReference;
|
||||
use super::clock::RenderClock;
|
||||
use super::code::RenderCode;
|
||||
use super::comment::RenderComment;
|
||||
use super::comment_block::RenderCommentBlock;
|
||||
use super::diary_sexp::RenderDiarySexp;
|
||||
use super::drawer::RenderDrawer;
|
||||
use super::dynamic_block::RenderDynamicBlock;
|
||||
use super::entity::RenderEntity;
|
||||
use super::example_block::RenderExampleBlock;
|
||||
use super::export_block::RenderExportBlock;
|
||||
use super::export_snippet::RenderExportSnippet;
|
||||
use super::fixed_width_area::RenderFixedWidthArea;
|
||||
use super::footnote_definition::RenderFootnoteDefinition;
|
||||
use super::footnote_reference::RenderFootnoteReference;
|
||||
use super::horizontal_rule::RenderHorizontalRule;
|
||||
use super::inline_babel_call::RenderInlineBabelCall;
|
||||
use super::inline_source_block::RenderInlineSourceBlock;
|
||||
use super::italic::RenderItalic;
|
||||
use super::keyword::RenderKeyword;
|
||||
use super::latex_environment::RenderLatexEnvironment;
|
||||
use super::latex_fragment::RenderLatexFragment;
|
||||
use super::line_break::RenderLineBreak;
|
||||
use super::org_macro::RenderOrgMacro;
|
||||
use super::paragraph::RenderParagraph;
|
||||
use super::plain_link::RenderPlainLink;
|
||||
use super::plain_list::RenderPlainList;
|
||||
use super::plain_text::RenderPlainText;
|
||||
use super::planning::RenderPlanning;
|
||||
use super::property_drawer::RenderPropertyDrawer;
|
||||
use super::quote_block::RenderQuoteBlock;
|
||||
use super::radio_link::RenderRadioLink;
|
||||
use super::radio_target::RenderRadioTarget;
|
||||
use super::regular_link::RenderRegularLink;
|
||||
use super::render_context::RenderContext;
|
||||
use super::special_block::RenderSpecialBlock;
|
||||
use super::src_block::RenderSrcBlock;
|
||||
use super::statistics_cookie::RenderStatisticsCookie;
|
||||
use super::strike_through::RenderStrikeThrough;
|
||||
use super::subscript::RenderSubscript;
|
||||
use super::superscript::RenderSuperscript;
|
||||
use super::table::RenderTable;
|
||||
use super::target::RenderTarget;
|
||||
use super::timestamp::RenderTimestamp;
|
||||
use super::underline::RenderUnderline;
|
||||
use super::verbatim::RenderVerbatim;
|
||||
use super::verse_block::RenderVerseBlock;
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderAstNode {
|
||||
Heading(RenderHeading),
|
||||
Section(RenderSection),
|
||||
Paragraph(RenderParagraph),
|
||||
PlainList(RenderPlainList),
|
||||
CenterBlock(RenderCenterBlock),
|
||||
QuoteBlock(RenderQuoteBlock),
|
||||
SpecialBlock(RenderSpecialBlock),
|
||||
DynamicBlock(RenderDynamicBlock),
|
||||
FootnoteDefinition(RenderFootnoteDefinition),
|
||||
Comment(RenderComment),
|
||||
Drawer(RenderDrawer),
|
||||
PropertyDrawer(RenderPropertyDrawer),
|
||||
Table(RenderTable),
|
||||
VerseBlock(RenderVerseBlock),
|
||||
CommentBlock(RenderCommentBlock),
|
||||
ExampleBlock(RenderExampleBlock),
|
||||
ExportBlock(RenderExportBlock),
|
||||
SrcBlock(RenderSrcBlock),
|
||||
Clock(RenderClock),
|
||||
DiarySexp(RenderDiarySexp),
|
||||
Planning(RenderPlanning),
|
||||
FixedWidthArea(RenderFixedWidthArea),
|
||||
HorizontalRule(RenderHorizontalRule),
|
||||
Keyword(RenderKeyword),
|
||||
BabelCall(RenderBabelCall),
|
||||
LatexEnvironment(RenderLatexEnvironment),
|
||||
Bold(RenderBold),
|
||||
Italic(RenderItalic),
|
||||
Underline(RenderUnderline),
|
||||
StrikeThrough(RenderStrikeThrough),
|
||||
Code(RenderCode),
|
||||
Verbatim(RenderVerbatim),
|
||||
PlainText(RenderPlainText),
|
||||
RegularLink(RenderRegularLink),
|
||||
RadioLink(RenderRadioLink),
|
||||
RadioTarget(RenderRadioTarget),
|
||||
PlainLink(RenderPlainLink),
|
||||
AngleLink(RenderAngleLink),
|
||||
OrgMacro(RenderOrgMacro),
|
||||
Entity(RenderEntity),
|
||||
LatexFragment(RenderLatexFragment),
|
||||
ExportSnippet(RenderExportSnippet),
|
||||
FootnoteReference(RenderFootnoteReference),
|
||||
Citation(RenderCitation),
|
||||
CitationReference(RenderCitationReference),
|
||||
InlineBabelCall(RenderInlineBabelCall),
|
||||
InlineSourceBlock(RenderInlineSourceBlock),
|
||||
LineBreak(RenderLineBreak),
|
||||
Target(RenderTarget),
|
||||
StatisticsCookie(RenderStatisticsCookie),
|
||||
Subscript(RenderSubscript),
|
||||
Superscript(RenderSuperscript),
|
||||
Timestamp(RenderTimestamp),
|
||||
}
|
||||
|
||||
pub(crate) trait IntoRenderAstNode {
|
||||
fn into_render_ast_node(
|
||||
&self,
|
||||
render_context: RenderContext<'_>,
|
||||
) -> Result<RenderAstNode, CustomError>;
|
||||
}
|
||||
|
||||
impl IntoRenderAstNode for IAstNode {
|
||||
fn into_render_ast_node(
|
||||
&self,
|
||||
render_context: RenderContext<'_>,
|
||||
) -> Result<RenderAstNode, CustomError> {
|
||||
match self {
|
||||
IAstNode::Heading(inner) => Ok(RenderAstNode::Heading(RenderHeading::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Section(inner) => Ok(RenderAstNode::Section(RenderSection::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Paragraph(inner) => Ok(RenderAstNode::Paragraph(RenderParagraph::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainList(inner) => Ok(RenderAstNode::PlainList(RenderPlainList::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CenterBlock(inner) => Ok(RenderAstNode::CenterBlock(RenderCenterBlock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::QuoteBlock(inner) => Ok(RenderAstNode::QuoteBlock(RenderQuoteBlock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::SpecialBlock(inner) => Ok(RenderAstNode::SpecialBlock(
|
||||
RenderSpecialBlock::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::DynamicBlock(inner) => Ok(RenderAstNode::DynamicBlock(
|
||||
RenderDynamicBlock::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::FootnoteDefinition(inner) => Ok(RenderAstNode::FootnoteDefinition(
|
||||
RenderFootnoteDefinition::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Comment(inner) => Ok(RenderAstNode::Comment(RenderComment::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Drawer(inner) => Ok(RenderAstNode::Drawer(RenderDrawer::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PropertyDrawer(inner) => Ok(RenderAstNode::PropertyDrawer(
|
||||
RenderPropertyDrawer::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Table(inner) => Ok(RenderAstNode::Table(RenderTable::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::VerseBlock(inner) => Ok(RenderAstNode::VerseBlock(RenderVerseBlock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CommentBlock(inner) => Ok(RenderAstNode::CommentBlock(
|
||||
RenderCommentBlock::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::ExampleBlock(inner) => Ok(RenderAstNode::ExampleBlock(
|
||||
RenderExampleBlock::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::ExportBlock(inner) => Ok(RenderAstNode::ExportBlock(RenderExportBlock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::SrcBlock(inner) => Ok(RenderAstNode::SrcBlock(RenderSrcBlock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Clock(inner) => Ok(RenderAstNode::Clock(RenderClock::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::DiarySexp(inner) => Ok(RenderAstNode::DiarySexp(RenderDiarySexp::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Planning(inner) => Ok(RenderAstNode::Planning(RenderPlanning::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::FixedWidthArea(inner) => Ok(RenderAstNode::FixedWidthArea(
|
||||
RenderFixedWidthArea::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::HorizontalRule(inner) => Ok(RenderAstNode::HorizontalRule(
|
||||
RenderHorizontalRule::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Keyword(inner) => Ok(RenderAstNode::Keyword(RenderKeyword::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::BabelCall(inner) => Ok(RenderAstNode::BabelCall(RenderBabelCall::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::LatexEnvironment(inner) => Ok(RenderAstNode::LatexEnvironment(
|
||||
RenderLatexEnvironment::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Bold(inner) => {
|
||||
Ok(RenderAstNode::Bold(RenderBold::new(render_context, inner)?))
|
||||
}
|
||||
IAstNode::Italic(inner) => Ok(RenderAstNode::Italic(RenderItalic::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Underline(inner) => Ok(RenderAstNode::Underline(RenderUnderline::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::StrikeThrough(inner) => Ok(RenderAstNode::StrikeThrough(
|
||||
RenderStrikeThrough::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Code(inner) => {
|
||||
Ok(RenderAstNode::Code(RenderCode::new(render_context, inner)?))
|
||||
}
|
||||
IAstNode::Verbatim(inner) => Ok(RenderAstNode::Verbatim(RenderVerbatim::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainText(inner) => Ok(RenderAstNode::PlainText(RenderPlainText::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RegularLink(inner) => Ok(RenderAstNode::RegularLink(RenderRegularLink::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RadioLink(inner) => Ok(RenderAstNode::RadioLink(RenderRadioLink::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RadioTarget(inner) => Ok(RenderAstNode::RadioTarget(RenderRadioTarget::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainLink(inner) => Ok(RenderAstNode::PlainLink(RenderPlainLink::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::AngleLink(inner) => Ok(RenderAstNode::AngleLink(RenderAngleLink::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::OrgMacro(inner) => Ok(RenderAstNode::OrgMacro(RenderOrgMacro::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Entity(inner) => Ok(RenderAstNode::Entity(RenderEntity::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::LatexFragment(inner) => Ok(RenderAstNode::LatexFragment(
|
||||
RenderLatexFragment::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::ExportSnippet(inner) => Ok(RenderAstNode::ExportSnippet(
|
||||
RenderExportSnippet::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::FootnoteReference(inner) => Ok(RenderAstNode::FootnoteReference(
|
||||
RenderFootnoteReference::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Citation(inner) => Ok(RenderAstNode::Citation(RenderCitation::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CitationReference(inner) => Ok(RenderAstNode::CitationReference(
|
||||
RenderCitationReference::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::InlineBabelCall(inner) => Ok(RenderAstNode::InlineBabelCall(
|
||||
RenderInlineBabelCall::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::InlineSourceBlock(inner) => Ok(RenderAstNode::InlineSourceBlock(
|
||||
RenderInlineSourceBlock::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::LineBreak(inner) => Ok(RenderAstNode::LineBreak(RenderLineBreak::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Target(inner) => Ok(RenderAstNode::Target(RenderTarget::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::StatisticsCookie(inner) => Ok(RenderAstNode::StatisticsCookie(
|
||||
RenderStatisticsCookie::new(render_context, inner)?,
|
||||
)),
|
||||
IAstNode::Subscript(inner) => Ok(RenderAstNode::Subscript(RenderSubscript::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Superscript(inner) => Ok(RenderAstNode::Superscript(RenderSuperscript::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Timestamp(inner) => Ok(RenderAstNode::Timestamp(RenderTimestamp::new(
|
||||
render_context,
|
||||
inner,
|
||||
)?)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IBabelCall;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "babel_call")]
|
||||
pub(crate) struct RenderBabelCall {}
|
||||
|
||||
impl RenderBabelCall {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IBabelCall,
|
||||
) -> Result<RenderBabelCall, CustomError> {
|
||||
Ok(RenderBabelCall {})
|
||||
}
|
||||
pub(crate) struct RenderBabelCall {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderBabelCall, IBabelCall);
|
||||
|
||||
@@ -1,34 +1,123 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::intermediate::BlogPostPage;
|
||||
|
||||
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||
use super::macros::render;
|
||||
use super::GlobalSettings;
|
||||
use super::PageHeader;
|
||||
use super::RenderDocumentElement;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RenderBlogPostPageInput<'a> {
|
||||
post: &'a BlogPost,
|
||||
page: &'a BlogPostPage,
|
||||
}
|
||||
|
||||
impl<'a> RenderBlogPostPageInput<'a> {
|
||||
pub(crate) fn new(post: &'a BlogPost, page: &'a BlogPostPage) -> RenderBlogPostPageInput<'a> {
|
||||
RenderBlogPostPageInput { post, page }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "blog_post_page")]
|
||||
pub(crate) struct RenderBlogPostPage {
|
||||
global_settings: GlobalSettings,
|
||||
|
||||
page_header: Option<PageHeader>,
|
||||
|
||||
/// The title that will be shown visibly on the page.
|
||||
title: Option<String>,
|
||||
|
||||
self_link: Option<String>,
|
||||
|
||||
children: Vec<RenderDocumentElement>,
|
||||
|
||||
footnotes: Vec<RenderRealFootnoteDefinition>,
|
||||
}
|
||||
|
||||
impl RenderBlogPostPage {
|
||||
pub(crate) fn new(
|
||||
global_settings: GlobalSettings,
|
||||
title: Option<String>,
|
||||
self_link: Option<String>,
|
||||
children: Vec<RenderDocumentElement>,
|
||||
) -> RenderBlogPostPage {
|
||||
RenderBlogPostPage {
|
||||
render!(
|
||||
RenderBlogPostPage,
|
||||
RenderBlogPostPageInput,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
let css_files = vec![
|
||||
get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"stylesheet/reset.css",
|
||||
)?,
|
||||
get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"stylesheet/main.css",
|
||||
)?,
|
||||
];
|
||||
let js_files = vec![get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"blog_post.js",
|
||||
)?];
|
||||
let global_settings = GlobalSettings::new(original.page.title.clone(), css_files, js_files);
|
||||
let page_header = PageHeader::new(
|
||||
render_context.config.get_site_title().map(str::to_string),
|
||||
Some(get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"",
|
||||
)?),
|
||||
);
|
||||
let link_to_blog_post = get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
render_context
|
||||
.output_file
|
||||
.strip_prefix(render_context.output_root_directory)?,
|
||||
)?;
|
||||
|
||||
let children = {
|
||||
let mut children = Vec::new();
|
||||
|
||||
for child in original.page.children.iter() {
|
||||
children.push(RenderDocumentElement::new(render_context.clone(), child)?);
|
||||
}
|
||||
|
||||
children
|
||||
};
|
||||
|
||||
let footnotes = {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
for footnote in original.page.footnotes.iter() {
|
||||
ret.push(RenderRealFootnoteDefinition::new(
|
||||
render_context.clone(),
|
||||
footnote,
|
||||
)?);
|
||||
}
|
||||
|
||||
ret
|
||||
};
|
||||
|
||||
let ret = RenderBlogPostPage {
|
||||
global_settings,
|
||||
title,
|
||||
self_link,
|
||||
page_header: Some(page_header),
|
||||
title: original.page.title.clone(),
|
||||
self_link: Some(link_to_blog_post),
|
||||
children,
|
||||
}
|
||||
footnotes,
|
||||
};
|
||||
Ok(ret)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
213
src/context/blog_stream.rs
Normal file
213
src/context/blog_stream.rs
Normal file
@@ -0,0 +1,213 @@
|
||||
use serde::Serialize;
|
||||
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::context::RenderDocumentElement;
|
||||
use crate::context::RenderRealFootnoteDefinition;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
|
||||
use super::GlobalSettings;
|
||||
use super::PageHeader;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RenderBlogStreamInput<'a, 'b> {
|
||||
original: &'a [&'b BlogPost],
|
||||
older_link: Option<String>,
|
||||
newer_link: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> RenderBlogStreamInput<'a, 'b> {
|
||||
pub(crate) fn new(
|
||||
original: &'a [&'b BlogPost],
|
||||
older_link: Option<String>,
|
||||
newer_link: Option<String>,
|
||||
) -> RenderBlogStreamInput<'a, 'b> {
|
||||
RenderBlogStreamInput {
|
||||
original,
|
||||
older_link,
|
||||
newer_link,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "blog_stream")]
|
||||
pub(crate) struct RenderBlogStream {
|
||||
global_settings: GlobalSettings,
|
||||
page_header: Option<PageHeader>,
|
||||
children: Vec<RenderBlogStreamEntry>,
|
||||
stream_pagination: Option<RenderBlogStreamPagination>,
|
||||
}
|
||||
|
||||
render!(
|
||||
RenderBlogStream,
|
||||
RenderBlogStreamInput,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
let css_files = vec![
|
||||
get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"stylesheet/reset.css",
|
||||
)?,
|
||||
get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"stylesheet/main.css",
|
||||
)?,
|
||||
];
|
||||
let js_files = vec![get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"blog_post.js",
|
||||
)?];
|
||||
let global_settings = GlobalSettings::new(
|
||||
render_context.config.get_site_title().map(str::to_string),
|
||||
css_files,
|
||||
js_files,
|
||||
);
|
||||
let page_header = PageHeader::new(
|
||||
render_context.config.get_site_title().map(str::to_string),
|
||||
Some(get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"",
|
||||
)?),
|
||||
);
|
||||
|
||||
let children = original
|
||||
.original
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(i, blog_post)| {
|
||||
RenderBlogStreamEntry::new(
|
||||
render_context.clone(),
|
||||
&RenderBlogStreamEntryInput::new(blog_post, i),
|
||||
)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let stream_pagination = if original.older_link.is_some() || original.newer_link.is_some() {
|
||||
Some(RenderBlogStreamPagination::new(
|
||||
original.older_link.clone(),
|
||||
original.newer_link.clone(),
|
||||
)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(RenderBlogStream {
|
||||
global_settings,
|
||||
page_header: Some(page_header),
|
||||
children,
|
||||
stream_pagination,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RenderBlogStreamEntryInput<'a> {
|
||||
original: &'a BlogPost,
|
||||
offset: usize,
|
||||
}
|
||||
|
||||
impl<'a> RenderBlogStreamEntryInput<'a> {
|
||||
fn new(original: &'a BlogPost, offset: usize) -> RenderBlogStreamEntryInput<'a> {
|
||||
RenderBlogStreamEntryInput { original, offset }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub(crate) struct RenderBlogStreamEntry {
|
||||
/// The title that will be shown visibly on the page.
|
||||
title: Option<String>,
|
||||
|
||||
self_link: Option<String>,
|
||||
|
||||
children: Vec<RenderDocumentElement>,
|
||||
|
||||
footnotes: Vec<RenderRealFootnoteDefinition>,
|
||||
}
|
||||
|
||||
render!(
|
||||
RenderBlogStreamEntry,
|
||||
RenderBlogStreamEntryInput,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
let offset_string = original.offset.to_string();
|
||||
let render_context = {
|
||||
let mut render_context = render_context.clone();
|
||||
render_context.id_addition = Some(offset_string.as_str());
|
||||
render_context
|
||||
};
|
||||
let link_to_blog_post = get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
render_context
|
||||
.config
|
||||
.get_relative_path_to_post(&original.original.id),
|
||||
)?;
|
||||
|
||||
// TODO: Should I guess an index page instead of erroring out?
|
||||
let index_page = original
|
||||
.original
|
||||
.get_index_page()
|
||||
.ok_or_else(|| format!("Blog post {} needs an index page.", original.original.id))?;
|
||||
|
||||
let title = index_page.title.clone();
|
||||
|
||||
let children = index_page
|
||||
.children
|
||||
.iter()
|
||||
.map(|child| RenderDocumentElement::new(render_context.clone(), child))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
let footnotes = {
|
||||
let mut ret = Vec::new();
|
||||
|
||||
for footnote in index_page.footnotes.iter() {
|
||||
ret.push(RenderRealFootnoteDefinition::new(
|
||||
render_context.clone(),
|
||||
footnote,
|
||||
)?);
|
||||
}
|
||||
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderBlogStreamEntry {
|
||||
title,
|
||||
self_link: Some(link_to_blog_post),
|
||||
children,
|
||||
footnotes,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub(crate) struct RenderBlogStreamPagination {
|
||||
older_link: Option<String>,
|
||||
newer_link: Option<String>,
|
||||
}
|
||||
|
||||
impl RenderBlogStreamPagination {
|
||||
fn new(
|
||||
older_link: Option<String>,
|
||||
newer_link: Option<String>,
|
||||
) -> Result<RenderBlogStreamPagination, CustomError> {
|
||||
Ok(RenderBlogStreamPagination {
|
||||
older_link,
|
||||
newer_link,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,31 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IBold;
|
||||
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "bold")]
|
||||
pub(crate) struct RenderBold {}
|
||||
|
||||
impl RenderBold {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IBold,
|
||||
) -> Result<RenderBold, CustomError> {
|
||||
Ok(RenderBold {})
|
||||
}
|
||||
pub(crate) struct RenderBold {
|
||||
children: Vec<RenderObject>,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
render!(RenderBold, IBold, original, render_context, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderObject::new(render_context.clone(), obj)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderBold {
|
||||
children,
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ICenterBlock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "center_block")]
|
||||
pub(crate) struct RenderCenterBlock {}
|
||||
|
||||
impl RenderCenterBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ICenterBlock,
|
||||
) -> Result<RenderCenterBlock, CustomError> {
|
||||
Ok(RenderCenterBlock {})
|
||||
}
|
||||
pub(crate) struct RenderCenterBlock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderCenterBlock, ICenterBlock);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ICitation;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "citation")]
|
||||
pub(crate) struct RenderCitation {}
|
||||
|
||||
impl RenderCitation {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICitation,
|
||||
) -> Result<RenderCitation, CustomError> {
|
||||
Ok(RenderCitation {})
|
||||
}
|
||||
pub(crate) struct RenderCitation {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderCitation, ICitation);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ICitationReference;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "citation_reference")]
|
||||
pub(crate) struct RenderCitationReference {}
|
||||
|
||||
impl RenderCitationReference {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICitationReference,
|
||||
) -> Result<RenderCitationReference, CustomError> {
|
||||
Ok(RenderCitationReference {})
|
||||
}
|
||||
pub(crate) struct RenderCitationReference {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderCitationReference, ICitationReference);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IClock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "clock")]
|
||||
pub(crate) struct RenderClock {}
|
||||
|
||||
impl RenderClock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IClock,
|
||||
) -> Result<RenderClock, CustomError> {
|
||||
Ok(RenderClock {})
|
||||
}
|
||||
pub(crate) struct RenderClock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderClock, IClock);
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ICode;
|
||||
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "code")]
|
||||
pub(crate) struct RenderCode {}
|
||||
|
||||
impl RenderCode {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICode,
|
||||
) -> Result<RenderCode, CustomError> {
|
||||
Ok(RenderCode {})
|
||||
}
|
||||
pub(crate) struct RenderCode {
|
||||
contents: String,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
render!(RenderCode, ICode, original, _render_context, {
|
||||
Ok(RenderCode {
|
||||
contents: original.contents.clone(),
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IComment;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "comment")]
|
||||
pub(crate) struct RenderComment {}
|
||||
|
||||
impl RenderComment {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IComment,
|
||||
) -> Result<RenderComment, CustomError> {
|
||||
Ok(RenderComment {})
|
||||
}
|
||||
pub(crate) struct RenderComment {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderComment, IComment);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ICommentBlock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "comment_block")]
|
||||
pub(crate) struct RenderCommentBlock {}
|
||||
|
||||
impl RenderCommentBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ICommentBlock,
|
||||
) -> Result<RenderCommentBlock, CustomError> {
|
||||
Ok(RenderCommentBlock {})
|
||||
}
|
||||
pub(crate) struct RenderCommentBlock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderCommentBlock, ICommentBlock);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDiarySexp;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "diary_sexp")]
|
||||
pub(crate) struct RenderDiarySexp {}
|
||||
|
||||
impl RenderDiarySexp {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDiarySexp,
|
||||
) -> Result<RenderDiarySexp, CustomError> {
|
||||
Ok(RenderDiarySexp {})
|
||||
}
|
||||
pub(crate) struct RenderDiarySexp {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderDiarySexp, IDiarySexp);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDocumentElement;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
|
||||
@@ -16,20 +15,19 @@ pub(crate) enum RenderDocumentElement {
|
||||
Section(RenderSection),
|
||||
}
|
||||
|
||||
impl RenderDocumentElement {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDocumentElement,
|
||||
) -> Result<RenderDocumentElement, CustomError> {
|
||||
render!(
|
||||
RenderDocumentElement,
|
||||
IDocumentElement,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
match original {
|
||||
IDocumentElement::Heading(inner) => Ok(RenderDocumentElement::Heading(
|
||||
RenderHeading::new(config, output_directory, output_file, inner)?,
|
||||
RenderHeading::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IDocumentElement::Section(inner) => Ok(RenderDocumentElement::Section(
|
||||
RenderSection::new(config, output_directory, output_file, inner)?,
|
||||
RenderSection::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDrawer;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "drawer")]
|
||||
pub(crate) struct RenderDrawer {}
|
||||
|
||||
impl RenderDrawer {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDrawer,
|
||||
) -> Result<RenderDrawer, CustomError> {
|
||||
Ok(RenderDrawer {})
|
||||
}
|
||||
pub(crate) struct RenderDrawer {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderDrawer, IDrawer);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDynamicBlock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "dynamic_block")]
|
||||
pub(crate) struct RenderDynamicBlock {}
|
||||
|
||||
impl RenderDynamicBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDynamicBlock,
|
||||
) -> Result<RenderDynamicBlock, CustomError> {
|
||||
Ok(RenderDynamicBlock {})
|
||||
}
|
||||
pub(crate) struct RenderDynamicBlock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderDynamicBlock, IDynamicBlock);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::plain_list_simple_item::RenderPlainListSimpleItem;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IElement;
|
||||
|
||||
@@ -21,6 +20,7 @@ use super::footnote_definition::RenderFootnoteDefinition;
|
||||
use super::horizontal_rule::RenderHorizontalRule;
|
||||
use super::keyword::RenderKeyword;
|
||||
use super::latex_environment::RenderLatexEnvironment;
|
||||
use super::macros::render;
|
||||
use super::paragraph::RenderParagraph;
|
||||
use super::plain_list::RenderPlainList;
|
||||
use super::planning::RenderPlanning;
|
||||
@@ -36,6 +36,7 @@ use super::verse_block::RenderVerseBlock;
|
||||
pub(crate) enum RenderElement {
|
||||
Paragraph(RenderParagraph),
|
||||
PlainList(RenderPlainList),
|
||||
PlainListSimpleItem(RenderPlainListSimpleItem),
|
||||
CenterBlock(RenderCenterBlock),
|
||||
QuoteBlock(RenderQuoteBlock),
|
||||
SpecialBlock(RenderSpecialBlock),
|
||||
@@ -60,131 +61,101 @@ pub(crate) enum RenderElement {
|
||||
LatexEnvironment(RenderLatexEnvironment),
|
||||
}
|
||||
|
||||
impl RenderElement {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
element: &IElement,
|
||||
) -> Result<RenderElement, CustomError> {
|
||||
match element {
|
||||
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::PlainList(inner) => Ok(RenderElement::PlainList(RenderPlainList::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::CenterBlock(inner) => Ok(RenderElement::CenterBlock(RenderCenterBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::QuoteBlock(inner) => Ok(RenderElement::QuoteBlock(RenderQuoteBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::SpecialBlock(inner) => Ok(RenderElement::SpecialBlock(
|
||||
RenderSpecialBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::DynamicBlock(inner) => Ok(RenderElement::DynamicBlock(
|
||||
RenderDynamicBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::FootnoteDefinition(inner) => Ok(RenderElement::FootnoteDefinition(
|
||||
RenderFootnoteDefinition::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::Comment(inner) => Ok(RenderElement::Comment(RenderComment::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Drawer(inner) => Ok(RenderElement::Drawer(RenderDrawer::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::PropertyDrawer(inner) => Ok(RenderElement::PropertyDrawer(
|
||||
RenderPropertyDrawer::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::Table(inner) => Ok(RenderElement::Table(RenderTable::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::VerseBlock(inner) => Ok(RenderElement::VerseBlock(RenderVerseBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::CommentBlock(inner) => Ok(RenderElement::CommentBlock(
|
||||
RenderCommentBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::ExampleBlock(inner) => Ok(RenderElement::ExampleBlock(
|
||||
RenderExampleBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::ExportBlock(inner) => Ok(RenderElement::ExportBlock(RenderExportBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::SrcBlock(inner) => Ok(RenderElement::SrcBlock(RenderSrcBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Clock(inner) => Ok(RenderElement::Clock(RenderClock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::DiarySexp(inner) => Ok(RenderElement::DiarySexp(RenderDiarySexp::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Planning(inner) => Ok(RenderElement::Planning(RenderPlanning::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::FixedWidthArea(inner) => Ok(RenderElement::FixedWidthArea(
|
||||
RenderFixedWidthArea::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::HorizontalRule(inner) => Ok(RenderElement::HorizontalRule(
|
||||
RenderHorizontalRule::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IElement::Keyword(inner) => Ok(RenderElement::Keyword(RenderKeyword::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::BabelCall(inner) => Ok(RenderElement::BabelCall(RenderBabelCall::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IElement::LatexEnvironment(inner) => Ok(RenderElement::LatexEnvironment(
|
||||
RenderLatexEnvironment::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
}
|
||||
render!(RenderElement, IElement, original, render_context, {
|
||||
match original {
|
||||
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::PlainList(inner) => Ok(RenderElement::PlainList(RenderPlainList::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::PlainListSimpleItem(inner) => Ok(RenderElement::PlainListSimpleItem(
|
||||
RenderPlainListSimpleItem::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IElement::CenterBlock(inner) => Ok(RenderElement::CenterBlock(RenderCenterBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::QuoteBlock(inner) => Ok(RenderElement::QuoteBlock(RenderQuoteBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::SpecialBlock(inner) => Ok(RenderElement::SpecialBlock(RenderSpecialBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::DynamicBlock(inner) => Ok(RenderElement::DynamicBlock(RenderDynamicBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::FootnoteDefinition(inner) => Ok(RenderElement::FootnoteDefinition(
|
||||
RenderFootnoteDefinition::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IElement::Comment(inner) => Ok(RenderElement::Comment(RenderComment::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Drawer(inner) => Ok(RenderElement::Drawer(RenderDrawer::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::PropertyDrawer(inner) => Ok(RenderElement::PropertyDrawer(
|
||||
RenderPropertyDrawer::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IElement::Table(inner) => Ok(RenderElement::Table(RenderTable::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::VerseBlock(inner) => Ok(RenderElement::VerseBlock(RenderVerseBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::CommentBlock(inner) => Ok(RenderElement::CommentBlock(RenderCommentBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::ExampleBlock(inner) => Ok(RenderElement::ExampleBlock(RenderExampleBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::ExportBlock(inner) => Ok(RenderElement::ExportBlock(RenderExportBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::SrcBlock(inner) => Ok(RenderElement::SrcBlock(RenderSrcBlock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Clock(inner) => Ok(RenderElement::Clock(RenderClock::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::DiarySexp(inner) => Ok(RenderElement::DiarySexp(RenderDiarySexp::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::Planning(inner) => Ok(RenderElement::Planning(RenderPlanning::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::FixedWidthArea(inner) => Ok(RenderElement::FixedWidthArea(
|
||||
RenderFixedWidthArea::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IElement::HorizontalRule(inner) => Ok(RenderElement::HorizontalRule(
|
||||
RenderHorizontalRule::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
IElement::Keyword(inner) => Ok(RenderElement::Keyword(RenderKeyword::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::BabelCall(inner) => Ok(RenderElement::BabelCall(RenderBabelCall::new(
|
||||
render_context.clone(),
|
||||
inner,
|
||||
)?)),
|
||||
IElement::LatexEnvironment(inner) => Ok(RenderElement::LatexEnvironment(
|
||||
RenderLatexEnvironment::new(render_context.clone(), inner)?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IEntity;
|
||||
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "entity")]
|
||||
pub(crate) struct RenderEntity {
|
||||
html: String,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
impl RenderEntity {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
entity: &IEntity,
|
||||
) -> Result<RenderEntity, CustomError> {
|
||||
Ok(RenderEntity {
|
||||
html: entity.html.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
render!(RenderEntity, IEntity, original, _render_context, {
|
||||
Ok(RenderEntity {
|
||||
html: original.html.clone(),
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IExampleBlock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "example_block")]
|
||||
pub(crate) struct RenderExampleBlock {}
|
||||
|
||||
impl RenderExampleBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IExampleBlock,
|
||||
) -> Result<RenderExampleBlock, CustomError> {
|
||||
Ok(RenderExampleBlock {})
|
||||
}
|
||||
pub(crate) struct RenderExampleBlock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderExampleBlock, IExampleBlock);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IExportBlock;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "export_block")]
|
||||
pub(crate) struct RenderExportBlock {}
|
||||
|
||||
impl RenderExportBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IExportBlock,
|
||||
) -> Result<RenderExportBlock, CustomError> {
|
||||
Ok(RenderExportBlock {})
|
||||
}
|
||||
pub(crate) struct RenderExportBlock {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderExportBlock, IExportBlock);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IExportSnippet;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "export_snippet")]
|
||||
pub(crate) struct RenderExportSnippet {}
|
||||
|
||||
impl RenderExportSnippet {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IExportSnippet,
|
||||
) -> Result<RenderExportSnippet, CustomError> {
|
||||
Ok(RenderExportSnippet {})
|
||||
}
|
||||
pub(crate) struct RenderExportSnippet {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderExportSnippet, IExportSnippet);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IFixedWidthArea;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "fixed_width_area")]
|
||||
pub(crate) struct RenderFixedWidthArea {}
|
||||
|
||||
impl RenderFixedWidthArea {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IFixedWidthArea,
|
||||
) -> Result<RenderFixedWidthArea, CustomError> {
|
||||
Ok(RenderFixedWidthArea {})
|
||||
}
|
||||
pub(crate) struct RenderFixedWidthArea {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderFixedWidthArea, IFixedWidthArea);
|
||||
|
||||
@@ -1,23 +1,54 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IFootnoteDefinition;
|
||||
use crate::intermediate::IRealFootnoteDefinition;
|
||||
|
||||
use super::ast_node::IntoRenderAstNode;
|
||||
use super::ast_node::RenderAstNode;
|
||||
use super::macros::render;
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "footnote_definition")]
|
||||
pub(crate) struct RenderFootnoteDefinition {}
|
||||
|
||||
impl RenderFootnoteDefinition {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IFootnoteDefinition,
|
||||
) -> Result<RenderFootnoteDefinition, CustomError> {
|
||||
Ok(RenderFootnoteDefinition {})
|
||||
}
|
||||
pub(crate) struct RenderFootnoteDefinition {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderFootnoteDefinition, IFootnoteDefinition);
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "real_footnote_definition")]
|
||||
pub(crate) struct RenderRealFootnoteDefinition {
|
||||
definition_id: String,
|
||||
reference_link: String,
|
||||
label: String,
|
||||
contents: Vec<RenderAstNode>,
|
||||
// TODO: Do I need post_blank for real footnote definitions?
|
||||
}
|
||||
|
||||
render!(
|
||||
RenderRealFootnoteDefinition,
|
||||
IRealFootnoteDefinition,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
let contents = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.contents.iter() {
|
||||
ret.push(obj.into_render_ast_node(render_context.clone())?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderRealFootnoteDefinition {
|
||||
definition_id: original.get_definition_id(render_context.id_addition),
|
||||
reference_link: format!("#{}", original.get_reference_id(render_context.id_addition)),
|
||||
label: original.get_display_label(),
|
||||
contents,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IFootnoteReference;
|
||||
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "footnote_reference")]
|
||||
pub(crate) struct RenderFootnoteReference {}
|
||||
|
||||
impl RenderFootnoteReference {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IFootnoteReference,
|
||||
) -> Result<RenderFootnoteReference, CustomError> {
|
||||
Ok(RenderFootnoteReference {})
|
||||
}
|
||||
pub(crate) struct RenderFootnoteReference {
|
||||
reference_id: String,
|
||||
definition_link: String,
|
||||
label: String,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
render!(
|
||||
RenderFootnoteReference,
|
||||
IFootnoteReference,
|
||||
original,
|
||||
render_context,
|
||||
{
|
||||
Ok(RenderFootnoteReference {
|
||||
reference_id: original.get_reference_id(render_context.id_addition),
|
||||
definition_link: format!(
|
||||
"#{}",
|
||||
original.get_definition_id(render_context.id_addition)
|
||||
),
|
||||
label: original.get_display_label(),
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IHeading;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderDocumentElement;
|
||||
use super::RenderObject;
|
||||
|
||||
@@ -16,45 +15,30 @@ pub(crate) struct RenderHeading {
|
||||
level: organic::types::HeadlineLevel,
|
||||
title: Vec<RenderObject>,
|
||||
children: Vec<RenderDocumentElement>,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
impl RenderHeading {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
heading: &IHeading,
|
||||
) -> Result<RenderHeading, CustomError> {
|
||||
let title = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in heading.title.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
render!(RenderHeading, IHeading, original, render_context, {
|
||||
let title = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.title.iter() {
|
||||
ret.push(RenderObject::new(render_context.clone(), obj)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in heading.children.iter() {
|
||||
ret.push(RenderDocumentElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderDocumentElement::new(render_context.clone(), obj)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderHeading {
|
||||
level: heading.level + 1, // Adding 1 because the page title is going to be h1.
|
||||
title,
|
||||
children,
|
||||
})
|
||||
}
|
||||
}
|
||||
Ok(RenderHeading {
|
||||
level: original.level + 1, // Adding 1 because the page title is going to be h1.
|
||||
title,
|
||||
children,
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IHorizontalRule;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "horizontal_rule")]
|
||||
pub(crate) struct RenderHorizontalRule {}
|
||||
|
||||
impl RenderHorizontalRule {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IHorizontalRule,
|
||||
) -> Result<RenderHorizontalRule, CustomError> {
|
||||
Ok(RenderHorizontalRule {})
|
||||
}
|
||||
pub(crate) struct RenderHorizontalRule {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderHorizontalRule, IHorizontalRule);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IInlineBabelCall;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "inline_babel_call")]
|
||||
pub(crate) struct RenderInlineBabelCall {}
|
||||
|
||||
impl RenderInlineBabelCall {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IInlineBabelCall,
|
||||
) -> Result<RenderInlineBabelCall, CustomError> {
|
||||
Ok(RenderInlineBabelCall {})
|
||||
}
|
||||
pub(crate) struct RenderInlineBabelCall {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderInlineBabelCall, IInlineBabelCall);
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IInlineSourceBlock;
|
||||
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "inline_source_block")]
|
||||
pub(crate) struct RenderInlineSourceBlock {}
|
||||
|
||||
impl RenderInlineSourceBlock {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IInlineSourceBlock,
|
||||
) -> Result<RenderInlineSourceBlock, CustomError> {
|
||||
Ok(RenderInlineSourceBlock {})
|
||||
}
|
||||
pub(crate) struct RenderInlineSourceBlock {
|
||||
value: String,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
render!(
|
||||
RenderInlineSourceBlock,
|
||||
IInlineSourceBlock,
|
||||
original,
|
||||
_render_context,
|
||||
{
|
||||
Ok(RenderInlineSourceBlock {
|
||||
value: original.value.clone(),
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IItalic;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "italic")]
|
||||
pub(crate) struct RenderItalic {}
|
||||
|
||||
impl RenderItalic {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IItalic,
|
||||
) -> Result<RenderItalic, CustomError> {
|
||||
Ok(RenderItalic {})
|
||||
}
|
||||
pub(crate) struct RenderItalic {
|
||||
children: Vec<RenderObject>,
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
render!(RenderItalic, IItalic, original, render_context, {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderObject::new(render_context.clone(), obj)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderItalic {
|
||||
children,
|
||||
post_blank: original.post_blank,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IKeyword;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "keyword")]
|
||||
pub(crate) struct RenderKeyword {}
|
||||
|
||||
impl RenderKeyword {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
keyword: &IKeyword,
|
||||
) -> Result<RenderKeyword, CustomError> {
|
||||
Ok(RenderKeyword {})
|
||||
}
|
||||
pub(crate) struct RenderKeyword {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderKeyword, IKeyword);
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ILatexEnvironment;
|
||||
|
||||
use super::macros::rnoop;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "latex_environment")]
|
||||
pub(crate) struct RenderLatexEnvironment {}
|
||||
|
||||
impl RenderLatexEnvironment {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ILatexEnvironment,
|
||||
) -> Result<RenderLatexEnvironment, CustomError> {
|
||||
Ok(RenderLatexEnvironment {})
|
||||
}
|
||||
pub(crate) struct RenderLatexEnvironment {
|
||||
post_blank: organic::types::PostBlank,
|
||||
}
|
||||
|
||||
rnoop!(RenderLatexEnvironment, ILatexEnvironment);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user