Compare commits
16 Commits
c501f7cedc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3929f22f3 | ||
|
|
bad12160ac | ||
|
|
c43679fda9 | ||
|
|
9cc28f6f0d | ||
|
|
d2256b8333 | ||
|
|
fa8753077a | ||
|
|
0420f58d02 | ||
|
|
0250aa106e | ||
|
|
ca1c456571 | ||
|
|
4403980e2e | ||
|
|
dbfbce955d | ||
|
|
2e08d2e59a | ||
|
|
9f14534c10 | ||
|
|
4e34ebc29e | ||
|
|
8d85d5ef79 | ||
|
|
7d73a3c948 |
@@ -203,7 +203,7 @@ spec:
|
||||
- name: git-source
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
storageClassName: "nfs-client"
|
||||
storageClassName: "local-path"
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
|
||||
@@ -345,7 +345,7 @@ spec:
|
||||
- name: git-source
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
storageClassName: "nfs-client"
|
||||
storageClassName: "local-path"
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
|
||||
@@ -289,7 +289,7 @@ spec:
|
||||
- name: git-source
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
storageClassName: "nfs-client"
|
||||
storageClassName: "local-path"
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
|
||||
@@ -279,7 +279,7 @@ spec:
|
||||
- name: git-source
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
storageClassName: "nfs-client"
|
||||
storageClassName: "local-path"
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
|
||||
870
Cargo.lock
generated
870
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "natter"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
||||
description = "A static site generator using org source files."
|
||||
license = "0BSD"
|
||||
@@ -36,6 +36,16 @@ tree-sitter-highlight = "0.25.2"
|
||||
tree-sitter-nix = "0.0.2"
|
||||
tree-sitter-python = "0.23.6"
|
||||
url = "2.5.0"
|
||||
tracing = { version = "0.1.37", optional = true }
|
||||
tracing-opentelemetry = { version = "0.20.0", optional = true }
|
||||
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
||||
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
||||
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["tracing"]
|
||||
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
||||
|
||||
# Optimized build for any sort of release.
|
||||
[profile.release-lto]
|
||||
|
||||
7
TODO.org
7
TODO.org
@@ -1,4 +1,4 @@
|
||||
* Things to do [4/14]
|
||||
* Things to do [6/17]
|
||||
** DONE If the paragraph only contains an image, text-align center
|
||||
** DONE Syntax highlighting for code blocks
|
||||
** TODO Render gnuplot
|
||||
@@ -8,7 +8,7 @@
|
||||
** TODO Support references to code block lines
|
||||
** TODO Only include text up to first heading on homepage and include a "read more" link
|
||||
** DONE Make loading language-specific CSS files conditional on the presence of src blocks using those languages
|
||||
** TODO Set up tracing so I can use warning and such
|
||||
** DONE Set up tracing so I can use warning and such
|
||||
** TODO Make copying of language-specific CSS files conditional on the presence of src blocks using those languages
|
||||
** TODO Switch to an entirely lazily-evaluated output tree
|
||||
** TODO Add highlighting for languages [1/2]
|
||||
@@ -16,3 +16,6 @@
|
||||
*** TODO gnuplot
|
||||
https://github.com/dpezto/tree-sitter-gnuplot is not on crates.io so I'd have to add a git dependency to use it. This would prevent publishing this crate to crates.io.
|
||||
** DONE Bug: carry over highlight starts when breaking lines
|
||||
** TODO Add dates to posts
|
||||
** DONE Add support for unlisted posts (posts that do not show up on the homepage).
|
||||
** TODO Add support for showing file name where we currently show language
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
|
||||
--blog-post-background-color: #0a0a0a;
|
||||
|
||||
--src-font-family:
|
||||
ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
|
||||
"DejaVu Sans Mono", monospace;
|
||||
--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;
|
||||
@@ -23,6 +22,13 @@
|
||||
--table-border-color: #6a687a;
|
||||
--table-odd-background-color: #0a0a0a;
|
||||
--table-even-background-color: #141414;
|
||||
|
||||
--header-nav-regular-font-color: var(--site-text-color);
|
||||
--header-nav-regular-background-color: var(--site-background-color);
|
||||
--header-nav-hover-font-color: var(--site-background-color);
|
||||
--header-nav-hover-background-color: var(--site-text-color);
|
||||
--header-home-regular-font-color: var(--site-text-color);
|
||||
--header-home-hover-font-color: #6ccff6;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@@ -46,6 +52,13 @@
|
||||
--table-border-color: #959785;
|
||||
--table-odd-background-color: #f5f5f5;
|
||||
--table-even-background-color: #ebebeb;
|
||||
|
||||
--header-nav-regular-font-color: var(--site-text-color);
|
||||
--header-nav-regular-background-color: var(--site-background-color);
|
||||
--header-nav-hover-font-color: var(--site-background-color);
|
||||
--header-nav-hover-background-color: var(--site-text-color);
|
||||
--header-home-regular-font-color: var(--site-text-color);
|
||||
--header-home-hover-font-color: #933009;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +69,8 @@
|
||||
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;
|
||||
font-family: source-sans-pro, Seravek, "Gill Sans Nova", Ubuntu, Calibri,
|
||||
"DejaVu Sans", sans-serif;
|
||||
|
||||
a:link,
|
||||
a:visited {
|
||||
@@ -74,18 +86,57 @@ body {
|
||||
}
|
||||
|
||||
.page_header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
max-width: var(--main-max-width);
|
||||
border-bottom: 0.1rem solid var(--header-divider-color);
|
||||
|
||||
.home_link {
|
||||
display: block;
|
||||
font-size: 2rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
color: var(--header-home-regular-font-color);
|
||||
transition-property: color;
|
||||
transition-duration: 0.1s;
|
||||
transition-timing-function: ease-out;
|
||||
|
||||
&:hover {
|
||||
color: var(--header-home-hover-font-color) !important;
|
||||
}
|
||||
|
||||
&:link,
|
||||
&:visited {
|
||||
color: var(--site-text-color);
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.header_nav_bar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: end;
|
||||
align-items: stretch;
|
||||
column-gap: 1rem;
|
||||
|
||||
.nav_link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
color: var(--header-nav-regular-font-color);
|
||||
background: var(--header-nav-regular-background-color);
|
||||
padding: 0 0.5rem;
|
||||
transition-property: background, color;
|
||||
transition-duration: 0.1s;
|
||||
transition-timing-function: ease-out;
|
||||
|
||||
&:hover {
|
||||
color: var(--header-nav-hover-font-color);
|
||||
background: var(--header-nav-hover-background-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<header class="page_header">
|
||||
<a class="home_link" href="{.home_link}">{.website_title}</a>
|
||||
{! TODO: Additional links? Probably using the nav semantic element. !}
|
||||
<nav class="header_nav_bar">
|
||||
{#.nav_links}
|
||||
<a class="nav_link" href="{.url}"><div>{.text}</div></a>
|
||||
{/.nav_links}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use include_dir::include_dir;
|
||||
use include_dir::Dir;
|
||||
use include_dir::include_dir;
|
||||
use tokio::fs::DirEntry;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
@@ -15,14 +15,15 @@ use crate::context::RenderBlogStreamInput;
|
||||
use crate::context::RenderContext;
|
||||
use crate::context::RenderPage;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::intermediate::IPage;
|
||||
use crate::intermediate::PublishStatus;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::render::DusterRenderer;
|
||||
use crate::render::RendererIntegration;
|
||||
use crate::walk_fs::walk_fs;
|
||||
use crate::walk_fs::WalkAction;
|
||||
use crate::walk_fs::WalkFsFilterResult;
|
||||
use crate::walk_fs::walk_fs;
|
||||
|
||||
use super::stylesheet::Stylesheet;
|
||||
|
||||
@@ -84,7 +85,11 @@ impl SiteRenderer {
|
||||
pub(crate) async fn render_pages(&self, config: &Config) -> Result<(), CustomError> {
|
||||
let renderer_integration = self.init_renderer_integration()?;
|
||||
|
||||
for page in &self.pages {
|
||||
for page in self.pages.iter().filter(|page| match page.natter_publish {
|
||||
PublishStatus::Full => true,
|
||||
PublishStatus::Unlisted => true,
|
||||
PublishStatus::Unpublished => false,
|
||||
}) {
|
||||
let output_path = self.output_directory.join(page.get_output_path());
|
||||
let dependency_manager =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new()));
|
||||
@@ -115,7 +120,17 @@ impl SiteRenderer {
|
||||
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 in self.blog_posts.iter().filter(|blog_post| {
|
||||
match blog_post
|
||||
.get_index_page()
|
||||
.expect("Blog posts should have an index page.")
|
||||
.natter_publish
|
||||
{
|
||||
PublishStatus::Full => true,
|
||||
PublishStatus::Unlisted => true,
|
||||
PublishStatus::Unpublished => false,
|
||||
}
|
||||
}) {
|
||||
for blog_post_page in &blog_post.pages {
|
||||
let output_path = self
|
||||
.output_directory
|
||||
@@ -155,7 +170,21 @@ impl SiteRenderer {
|
||||
|
||||
// Sort blog posts by date, newest first.
|
||||
let sorted_blog_posts = {
|
||||
let mut sorted_blog_posts: Vec<_> = self.blog_posts.iter().collect();
|
||||
let mut sorted_blog_posts: Vec<_> = self
|
||||
.blog_posts
|
||||
.iter()
|
||||
.filter(|blog_post| {
|
||||
match blog_post
|
||||
.get_index_page()
|
||||
.expect("Blog posts should have an index page.")
|
||||
.natter_publish
|
||||
{
|
||||
PublishStatus::Full => true,
|
||||
PublishStatus::Unlisted => false,
|
||||
PublishStatus::Unpublished => false,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
sorted_blog_posts
|
||||
.sort_by_key(|blog_post| (blog_post.get_date(), blog_post.id.as_str()));
|
||||
sorted_blog_posts.reverse();
|
||||
|
||||
@@ -8,17 +8,17 @@ use crate::cli::parameters::BuildArgs;
|
||||
use crate::command::build::render::SiteRenderer;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_org_files;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::intermediate::IPage;
|
||||
use crate::intermediate::IntermediateContext;
|
||||
use crate::intermediate::PageInput;
|
||||
use crate::intermediate::Registry;
|
||||
use crate::walk_fs::walk_fs;
|
||||
use crate::intermediate::get_org_files;
|
||||
use crate::walk_fs::WalkAction;
|
||||
use crate::walk_fs::WalkFsFilterResult;
|
||||
use include_dir::include_dir;
|
||||
use crate::walk_fs::walk_fs;
|
||||
use include_dir::Dir;
|
||||
use include_dir::include_dir;
|
||||
use tokio::fs::DirEntry;
|
||||
|
||||
static DEFAULT_STYLESHEETS: Dir =
|
||||
|
||||
@@ -3,6 +3,8 @@ use serde::Serialize;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IAstNode;
|
||||
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
use super::angle_link::RenderAngleLink;
|
||||
use super::babel_call::RenderBabelCall;
|
||||
use super::bold::RenderBold;
|
||||
@@ -55,8 +57,6 @@ 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)]
|
||||
|
||||
@@ -5,15 +5,15 @@ use serde::Serialize;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::context::macros::push_file;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::intermediate::BlogPostPage;
|
||||
use crate::intermediate::get_web_path;
|
||||
|
||||
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||
use super::macros::render;
|
||||
use super::GlobalSettings;
|
||||
use super::PageHeader;
|
||||
use super::RenderDocumentElement;
|
||||
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct RenderBlogPostPageInput<'a> {
|
||||
@@ -61,6 +61,12 @@ render!(
|
||||
render_context.output_file,
|
||||
"",
|
||||
)?),
|
||||
Some(get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"about_me",
|
||||
)?),
|
||||
);
|
||||
let link_to_blog_post = get_web_path(
|
||||
render_context.config,
|
||||
|
||||
@@ -4,12 +4,12 @@ use serde::Serialize;
|
||||
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::context::macros::push_file;
|
||||
use crate::context::RenderDocumentElement;
|
||||
use crate::context::RenderRealFootnoteDefinition;
|
||||
use crate::context::macros::push_file;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::BlogPost;
|
||||
use crate::intermediate::get_web_path;
|
||||
|
||||
use super::GlobalSettings;
|
||||
use super::PageHeader;
|
||||
@@ -59,6 +59,12 @@ render!(
|
||||
render_context.output_file,
|
||||
"",
|
||||
)?),
|
||||
Some(get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"about_me",
|
||||
)?),
|
||||
);
|
||||
|
||||
let children = original
|
||||
|
||||
@@ -3,9 +3,9 @@ use serde::Serialize;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IBold;
|
||||
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Dependency {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Dependency::CssFile { name } => {
|
||||
Dependency::CssFile { name: _ } => {
|
||||
// We don't do anything because the CSS files are already copied into the output from natter's default environment.
|
||||
// TODO: When we add support for CSS outside the default environment, we should add support for dynamically picking which ones to copy here.
|
||||
Ok(())
|
||||
|
||||
@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDocumentElement;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
|
||||
@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IHeading;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderDocumentElement;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IItalic;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use super::GlobalSettings;
|
||||
use super::PageHeader;
|
||||
use super::RenderDocumentElement;
|
||||
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||
use super::macros::render;
|
||||
use super::render_context::RenderContext;
|
||||
use crate::context::macros::push_file;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::get_web_path;
|
||||
use crate::intermediate::IPage;
|
||||
use crate::intermediate::get_web_path;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -40,6 +40,12 @@ render!(RenderPage, IPage, original, render_context, {
|
||||
render_context.output_file,
|
||||
"",
|
||||
)?),
|
||||
Some(get_web_path(
|
||||
render_context.config,
|
||||
render_context.output_root_directory,
|
||||
render_context.output_file,
|
||||
"about_me",
|
||||
)?),
|
||||
);
|
||||
let link_to_blog_post = get_web_path(
|
||||
render_context.config,
|
||||
|
||||
@@ -7,13 +7,35 @@ use serde::Serialize;
|
||||
pub(crate) struct PageHeader {
|
||||
website_title: Option<String>,
|
||||
home_link: Option<String>,
|
||||
nav_links: Vec<NavLink>,
|
||||
}
|
||||
|
||||
/// A link in the top-right of the page.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "nav_link")]
|
||||
pub(crate) struct NavLink {
|
||||
text: Option<String>,
|
||||
url: Option<String>,
|
||||
}
|
||||
|
||||
impl PageHeader {
|
||||
pub(crate) fn new(website_title: Option<String>, home_link: Option<String>) -> PageHeader {
|
||||
pub(crate) fn new(
|
||||
website_title: Option<String>,
|
||||
home_link: Option<String>,
|
||||
about_me_link: Option<String>,
|
||||
) -> PageHeader {
|
||||
PageHeader {
|
||||
website_title,
|
||||
home_link,
|
||||
nav_links: about_me_link
|
||||
.map(|url| {
|
||||
vec![NavLink {
|
||||
text: Some("About Me".to_owned()),
|
||||
url: Some(url),
|
||||
}]
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IParagraph;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IPlainListItem;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderElement;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IPlainListSimpleItem;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
/// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag.
|
||||
#[derive(Debug, Serialize)]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IQuoteBlock;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderElement;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::error::CustomError;
|
||||
use crate::intermediate::IRegularLink;
|
||||
use crate::intermediate::LinkTarget;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ISection;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderElement;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -55,7 +55,7 @@ render!(RenderSrcBlock, ISrcBlock, original, render_context, {
|
||||
RenderSrcLine { children }
|
||||
})
|
||||
.collect();
|
||||
match original.language.as_ref().map(String::as_str) {
|
||||
match original.language.as_deref() {
|
||||
Some("bash") => {
|
||||
render_context
|
||||
.dependency_manager
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IStrikeThrough;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ITableCell;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IUnderline;
|
||||
|
||||
use super::macros::render;
|
||||
use super::RenderObject;
|
||||
use super::macros::render;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
||||
88
src/init_tracing.rs
Normal file
88
src/init_tracing.rs
Normal file
@@ -0,0 +1,88 @@
|
||||
#[cfg(feature = "tracing")]
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::warn;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::fmt;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
const SERVICE_NAME: &str = "natter";
|
||||
|
||||
// Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits.
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let log_to_console = fmt::layer();
|
||||
let subscriber = tracing_subscriber::Registry::default();
|
||||
let level_filter_layer = tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or(tracing_subscriber::EnvFilter::new("WARN"));
|
||||
|
||||
// by default it will hit http://localhost:4317 with a gRPC payload
|
||||
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
|
||||
let exporter = opentelemetry_otlp::new_exporter()
|
||||
.tonic()
|
||||
// Using "localhost" is broken inside the docker container when tracing
|
||||
.with_endpoint("http://127.0.0.1:4317/v1/traces");
|
||||
|
||||
let tracer = opentelemetry_otlp::new_pipeline()
|
||||
.tracing()
|
||||
.with_exporter(exporter)
|
||||
.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
|
||||
opentelemetry::sdk::Resource::new(vec![opentelemetry::KeyValue::new(
|
||||
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
|
||||
SERVICE_NAME.to_string(),
|
||||
)]),
|
||||
))
|
||||
// If I do install_batch then 1K+ spans will get orphaned off into their own trace and I get the error message "OpenTelemetry trace error occurred. cannot send message to batch processor as the channel is closed"
|
||||
//
|
||||
// If I do install_simple then it only creates 1 trace (which is good!) but my console gets spammed with this concerning log message that makes me think it might be dropping the extra spans on the floor: "OpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (Unknown error): , detailed error message: Service was not ready: transport error"
|
||||
//
|
||||
// I suspect it is related to this bug: https://github.com/open-telemetry/opentelemetry-rust/issues/888
|
||||
//
|
||||
// .install_simple()
|
||||
.install_batch(opentelemetry::runtime::Tokio);
|
||||
|
||||
let tracing_layer = tracer.map(|tracer| tracing_opentelemetry::layer().with_tracer(tracer));
|
||||
|
||||
opentelemetry::global::set_text_map_propagator(
|
||||
opentelemetry::sdk::propagation::TraceContextPropagator::new(),
|
||||
);
|
||||
|
||||
match tracing_layer {
|
||||
Ok(tracing_layer) => {
|
||||
subscriber
|
||||
.with(level_filter_layer)
|
||||
.with(tracing_layer)
|
||||
.with(log_to_console)
|
||||
.try_init()?;
|
||||
}
|
||||
Err(e) => {
|
||||
subscriber
|
||||
.with(level_filter_layer)
|
||||
.with(fmt::layer())
|
||||
.try_init()?;
|
||||
warn!("Failed initialize OpenTelemetry tracing: {}", e);
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||
opentelemetry::global::shutdown_tracer_provider();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,28 +1,3 @@
|
||||
use super::angle_link::IAngleLink;
|
||||
use super::bold::IBold;
|
||||
use super::citation::ICitation;
|
||||
use super::citation_reference::ICitationReference;
|
||||
use super::code::ICode;
|
||||
use super::comment::IComment;
|
||||
use super::entity::IEntity;
|
||||
use super::export_snippet::IExportSnippet;
|
||||
use super::footnote_reference::IFootnoteReference;
|
||||
use super::inline_babel_call::IInlineBabelCall;
|
||||
use super::inline_source_block::IInlineSourceBlock;
|
||||
use super::italic::IItalic;
|
||||
use super::keyword::IKeyword;
|
||||
use super::latex_fragment::ILatexFragment;
|
||||
use super::line_break::ILineBreak;
|
||||
use super::org_macro::IOrgMacro;
|
||||
use super::plain_link::IPlainLink;
|
||||
use super::plain_text::IPlainText;
|
||||
use super::radio_link::IRadioLink;
|
||||
use super::radio_target::IRadioTarget;
|
||||
use super::regular_link::IRegularLink;
|
||||
use super::statistics_cookie::IStatisticsCookie;
|
||||
use super::strike_through::IStrikeThrough;
|
||||
use super::subscript::ISubscript;
|
||||
use super::superscript::ISuperscript;
|
||||
use super::IBabelCall;
|
||||
use super::ICenterBlock;
|
||||
use super::IClock;
|
||||
@@ -52,6 +27,31 @@ use super::IUnderline;
|
||||
use super::IVerbatim;
|
||||
use super::IVerseBlock;
|
||||
use super::IntermediateContext;
|
||||
use super::angle_link::IAngleLink;
|
||||
use super::bold::IBold;
|
||||
use super::citation::ICitation;
|
||||
use super::citation_reference::ICitationReference;
|
||||
use super::code::ICode;
|
||||
use super::comment::IComment;
|
||||
use super::entity::IEntity;
|
||||
use super::export_snippet::IExportSnippet;
|
||||
use super::footnote_reference::IFootnoteReference;
|
||||
use super::inline_babel_call::IInlineBabelCall;
|
||||
use super::inline_source_block::IInlineSourceBlock;
|
||||
use super::italic::IItalic;
|
||||
use super::keyword::IKeyword;
|
||||
use super::latex_fragment::ILatexFragment;
|
||||
use super::line_break::ILineBreak;
|
||||
use super::org_macro::IOrgMacro;
|
||||
use super::plain_link::IPlainLink;
|
||||
use super::plain_text::IPlainText;
|
||||
use super::radio_link::IRadioLink;
|
||||
use super::radio_target::IRadioTarget;
|
||||
use super::regular_link::IRegularLink;
|
||||
use super::statistics_cookie::IStatisticsCookie;
|
||||
use super::strike_through::IStrikeThrough;
|
||||
use super::subscript::ISubscript;
|
||||
use super::superscript::ISuperscript;
|
||||
use crate::error::CustomError;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ use tokio::fs::DirEntry;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IntermediateContext;
|
||||
use crate::intermediate::blog_post_page::BlogPostPageInput;
|
||||
use crate::intermediate::registry::Registry;
|
||||
use crate::intermediate::IntermediateContext;
|
||||
use crate::walk_fs::walk_fs;
|
||||
use crate::walk_fs::WalkAction;
|
||||
use crate::walk_fs::WalkFsFilterResult;
|
||||
use crate::walk_fs::walk_fs;
|
||||
|
||||
use super::BlogPostPage;
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::error::CustomError;
|
||||
|
||||
use super::footnote_definition::IRealFootnoteDefinition;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IDocumentElement;
|
||||
use super::IHeading;
|
||||
use super::ISection;
|
||||
use super::macros::intermediate;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct BlogPostPageInput<'b, 'parse> {
|
||||
@@ -48,6 +48,16 @@ pub(crate) struct BlogPostPage {
|
||||
pub(crate) children: Vec<IDocumentElement>,
|
||||
|
||||
pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
|
||||
|
||||
pub(crate) natter_publish: PublishStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) enum PublishStatus {
|
||||
#[default]
|
||||
Full,
|
||||
Unlisted,
|
||||
Unpublished,
|
||||
}
|
||||
|
||||
intermediate!(
|
||||
@@ -93,6 +103,7 @@ intermediate!(
|
||||
date: get_date(original.document),
|
||||
children,
|
||||
footnotes,
|
||||
natter_publish: get_publish_status(original.document).unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
);
|
||||
@@ -129,3 +140,25 @@ pub(crate) fn get_date(document: &organic::types::Document<'_>) -> Option<String
|
||||
.last()
|
||||
.map(|kw| kw.value.to_owned())
|
||||
}
|
||||
|
||||
pub(crate) fn get_publish_status(document: &organic::types::Document<'_>) -> Option<PublishStatus> {
|
||||
let publish_string = organic::types::AstNode::from(document)
|
||||
.iter_all_ast_nodes()
|
||||
.filter_map(|node| match node {
|
||||
organic::types::AstNode::Keyword(kw)
|
||||
if kw.key.eq_ignore_ascii_case("natter_publish") =>
|
||||
{
|
||||
Some(kw)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.last()
|
||||
.map(|kw| kw.value);
|
||||
match publish_string {
|
||||
Some("full") => Some(PublishStatus::Full),
|
||||
Some("unlisted") => Some(PublishStatus::Unlisted),
|
||||
Some("unpublished") => Some(PublishStatus::Unpublished),
|
||||
Some(status) => panic!("Unrecognized publish status: {}", status),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::IPlainListSimpleItem;
|
||||
use super::comment::IComment;
|
||||
use super::keyword::IKeyword;
|
||||
use super::macros::iselector;
|
||||
use super::IPlainListSimpleItem;
|
||||
|
||||
use super::IBabelCall;
|
||||
use super::ICenterBlock;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::macros::intermediate;
|
||||
use super::registry::register_footnote_definition;
|
||||
use super::IAstNode;
|
||||
use super::IntermediateContext;
|
||||
use super::macros::intermediate;
|
||||
use super::registry::register_footnote_definition;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
@@ -32,6 +32,7 @@ pub(crate) struct IRealFootnoteDefinition {
|
||||
}
|
||||
|
||||
impl IRealFootnoteDefinition {
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
pub(crate) async fn new<'orig, 'parse>(
|
||||
_intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
footnote_id: usize,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IDocumentElement;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ macro_rules! inoop {
|
||||
}
|
||||
|
||||
impl $istruct {
|
||||
#[allow(clippy::extra_unused_lifetimes)]
|
||||
pub(crate) async fn new<'reg, 'orig, 'parse>(
|
||||
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
||||
original: &'orig organic::types::$pstruct<'parse>,
|
||||
|
||||
@@ -71,9 +71,10 @@ mod verse_block;
|
||||
pub(crate) use angle_link::IAngleLink;
|
||||
pub(crate) use ast_node::IAstNode;
|
||||
pub(crate) use babel_call::IBabelCall;
|
||||
pub(crate) use blog_post::get_org_files;
|
||||
pub(crate) use blog_post::BlogPost;
|
||||
pub(crate) use blog_post::get_org_files;
|
||||
pub(crate) use blog_post_page::BlogPostPage;
|
||||
pub(crate) use blog_post_page::PublishStatus;
|
||||
pub(crate) use bold::IBold;
|
||||
pub(crate) use center_block::ICenterBlock;
|
||||
pub(crate) use citation::ICitation;
|
||||
|
||||
@@ -21,6 +21,7 @@ use super::plain_text::IPlainText;
|
||||
use super::radio_link::IRadioLink;
|
||||
use super::radio_target::IRadioTarget;
|
||||
|
||||
use super::ITarget;
|
||||
use super::regular_link::IRegularLink;
|
||||
use super::statistics_cookie::IStatisticsCookie;
|
||||
use super::strike_through::IStrikeThrough;
|
||||
@@ -29,7 +30,6 @@ use super::superscript::ISuperscript;
|
||||
use super::timestamp::ITimestamp;
|
||||
use super::underline::IUnderline;
|
||||
use super::verbatim::IVerbatim;
|
||||
use super::ITarget;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use super::blog_post_page::get_date;
|
||||
use super::blog_post_page::get_title;
|
||||
use super::footnote_definition::IRealFootnoteDefinition;
|
||||
use super::macros::intermediate;
|
||||
use super::IDocumentElement;
|
||||
use super::IHeading;
|
||||
use super::ISection;
|
||||
use super::PublishStatus;
|
||||
use super::blog_post_page::get_date;
|
||||
use super::blog_post_page::get_publish_status;
|
||||
use super::blog_post_page::get_title;
|
||||
use super::footnote_definition::IRealFootnoteDefinition;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -24,6 +26,8 @@ pub(crate) struct IPage {
|
||||
pub(crate) children: Vec<IDocumentElement>,
|
||||
|
||||
pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
|
||||
|
||||
pub(crate) natter_publish: PublishStatus,
|
||||
}
|
||||
|
||||
intermediate!(
|
||||
@@ -69,6 +73,7 @@ intermediate!(
|
||||
date: get_date(original.document),
|
||||
children,
|
||||
footnotes,
|
||||
natter_publish: get_publish_status(original.document).unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use std::any::Any;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
@@ -33,6 +31,7 @@ intermediate!(
|
||||
);
|
||||
|
||||
impl IParagraph {
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
pub(crate) async fn artificial<'orig, 'parse>(
|
||||
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
||||
children: Vec<IObject>,
|
||||
@@ -52,19 +51,19 @@ impl IParagraph {
|
||||
.children
|
||||
.iter()
|
||||
.filter(|c| match c {
|
||||
IObject::RegularLink(iregular_link) => match &iregular_link.target {
|
||||
super::LinkTarget::Image { src, alt } => true,
|
||||
_ => false,
|
||||
},
|
||||
IObject::RegularLink(iregular_link) => matches!(
|
||||
&iregular_link.target,
|
||||
super::LinkTarget::Image { src: _, alt: _ }
|
||||
),
|
||||
_ => false,
|
||||
})
|
||||
.count();
|
||||
num_images == 1
|
||||
&& self.children.iter().all(|c| match c {
|
||||
IObject::RegularLink(iregular_link) => match &iregular_link.target {
|
||||
super::LinkTarget::Image { src, alt } => true,
|
||||
_ => false,
|
||||
},
|
||||
IObject::RegularLink(iregular_link) => matches!(
|
||||
&iregular_link.target,
|
||||
super::LinkTarget::Image { src: _, alt: _ }
|
||||
),
|
||||
IObject::PlainText(iplain_text) => {
|
||||
iplain_text.source.chars().all(|c| c.is_ascii_whitespace())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IPlainListItem;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IPlainListSimpleItem;
|
||||
use super::macros::intermediate;
|
||||
|
||||
use super::IElement;
|
||||
use super::IObject;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IElement;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ use organic::types::Element;
|
||||
use organic::types::Object;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::ast_node::IAstNode;
|
||||
use super::ast_node::IntoIAstNode;
|
||||
use super::IObject;
|
||||
use super::IParagraph;
|
||||
use super::IntermediateContext;
|
||||
use super::ast_node::IAstNode;
|
||||
use super::ast_node::IntoIAstNode;
|
||||
|
||||
type IdCounter = u16;
|
||||
|
||||
@@ -180,6 +180,7 @@ async fn convert_definition_contents<'orig, 'parse>(
|
||||
}
|
||||
|
||||
/// Take a footnote definition that has not yet received a reference and move it into the active footnotes.
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
|
||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
label: &'parse str,
|
||||
|
||||
@@ -5,9 +5,9 @@ use organic::types::LinkType;
|
||||
use organic::types::StandardProperties;
|
||||
use url::Url;
|
||||
|
||||
use super::IntermediateContext;
|
||||
use super::get_web_path;
|
||||
use super::macros::intermediate;
|
||||
use super::IntermediateContext;
|
||||
|
||||
use super::IObject;
|
||||
use crate::context::RenderContext;
|
||||
@@ -186,7 +186,7 @@ impl LinkTarget {
|
||||
if path.is_absolute() {
|
||||
return Ok(format!("file://{}", input));
|
||||
}
|
||||
return Ok(input.into_owned());
|
||||
Ok(input.into_owned())
|
||||
}
|
||||
|
||||
/// Get file name from the last segment of an image path.
|
||||
@@ -199,7 +199,7 @@ impl LinkTarget {
|
||||
let path = Path::new(input.as_ref());
|
||||
match path
|
||||
.components()
|
||||
.last()
|
||||
.next_back()
|
||||
.ok_or("Images should have at least one component in their path.")?
|
||||
{
|
||||
std::path::Component::Prefix(_) => {
|
||||
@@ -209,9 +209,7 @@ impl LinkTarget {
|
||||
std::path::Component::RootDir
|
||||
| std::path::Component::CurDir
|
||||
| std::path::Component::ParentDir => {
|
||||
return Err(
|
||||
"Final component of an image path should be a normal component.".into(),
|
||||
);
|
||||
Err("Final component of an image path should be a normal component.".into())
|
||||
}
|
||||
std::path::Component::Normal(file_name) => Ok(file_name
|
||||
.to_str()
|
||||
@@ -236,6 +234,7 @@ mod tests {
|
||||
let registry = Registry::new();
|
||||
let registry = Arc::new(Mutex::new(registry));
|
||||
let intermediate_context = IntermediateContext::new(registry)?;
|
||||
#[allow(clippy::single_element_loop)]
|
||||
for (inp, typ) in [(
|
||||
"https://test.example/foo",
|
||||
LinkType::Protocol(Cow::from("https")),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IElement;
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use std::borrow::Borrow;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use crate::error::CustomError;
|
||||
use organic::types::StandardProperties;
|
||||
use tree_sitter_highlight::Highlight;
|
||||
use tree_sitter_highlight::HighlightConfiguration;
|
||||
use tree_sitter_highlight::HighlightEvent;
|
||||
use tree_sitter_highlight::Highlighter;
|
||||
@@ -79,7 +77,7 @@ intermediate!(
|
||||
.collect();
|
||||
let language = original.language.map(str::to_owned);
|
||||
|
||||
match language.as_ref().map(String::as_str) {
|
||||
match language.as_deref() {
|
||||
Some(lang @ "bash") => {
|
||||
let highlighted = highlight_bash(&lines);
|
||||
if let Ok(highlighted) = highlighted {
|
||||
@@ -153,7 +151,7 @@ where
|
||||
std::string::String: for<'a> From<&'a L>,
|
||||
{
|
||||
Ok(lines
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|l| {
|
||||
let mut line = ISrcLine::new();
|
||||
line.children.push(ISrcSegment::RawText(l.into()));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::macros::inoop;
|
||||
use super::macros::intermediate;
|
||||
use super::util::coalesce_whitespace;
|
||||
use crate::error::CustomError;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use organic::types::StandardProperties;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::IObject;
|
||||
use super::macros::intermediate;
|
||||
|
||||
use crate::error::CustomError;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#![feature(let_chains)]
|
||||
use std::process::ExitCode;
|
||||
|
||||
use clap::Parser;
|
||||
@@ -8,11 +7,14 @@ use self::cli::parameters::Commands;
|
||||
use self::command::build::build_site;
|
||||
use self::command::init::init_natter_folder;
|
||||
use self::error::CustomError;
|
||||
use self::init_tracing::init_telemetry;
|
||||
use self::init_tracing::shutdown_telemetry;
|
||||
mod cli;
|
||||
mod command;
|
||||
mod config;
|
||||
mod context;
|
||||
mod error;
|
||||
mod init_tracing;
|
||||
mod intermediate;
|
||||
mod render;
|
||||
mod walk_fs;
|
||||
@@ -23,6 +25,7 @@ fn main() -> Result<ExitCode, CustomError> {
|
||||
}
|
||||
|
||||
async fn main_body() -> Result<ExitCode, CustomError> {
|
||||
init_telemetry().expect("Telemetry should initialize successfully.");
|
||||
let args = Cli::parse();
|
||||
match args.command {
|
||||
Commands::Init(args) => {
|
||||
@@ -32,5 +35,6 @@ async fn main_body() -> Result<ExitCode, CustomError> {
|
||||
build_site(args).await?;
|
||||
}
|
||||
};
|
||||
shutdown_telemetry().expect("Telemetry should shutdown successfully.");
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user