Compare commits
10 Commits
bb5e988b2f
...
f859437560
Author | SHA1 | Date |
---|---|---|
xfnw | f859437560 | |
xfnw | 40b0cae06e | |
xfnw | c43a92ea86 | |
xfnw | 9562f5268f | |
xfnw | 45f2c71ca5 | |
xfnw | 52907f33d0 | |
xfnw | 6358761bc0 | |
xfnw | 19acf572fc | |
xfnw | a2af854289 | |
xfnw | e0929a9b86 |
|
@ -1,2 +1,3 @@
|
|||
/target
|
||||
/result
|
||||
*.profraw
|
||||
|
|
|
@ -42,9 +42,9 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.90"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
|
||||
checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
@ -52,9 +52,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.35"
|
||||
version = "0.4.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a"
|
||||
checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
@ -286,9 +286,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
|||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.1"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
|
@ -368,9 +368,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
|||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.13"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
|
@ -461,9 +461,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.55"
|
||||
version = "2.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
|
||||
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1698420672,
|
||||
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1712573573,
|
||||
"narHash": "sha256-xxon7WwNm4/EadMKg1eF40/5s0O78nXUy2ILZt6vT7E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0d28066770464d19d637f6e8e42e8688420b6ac6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1712573573,
|
||||
"narHash": "sha256-xxon7WwNm4/EadMKg1eF40/5s0O78nXUy2ILZt6vT7E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0d28066770464d19d637f6e8e42e8688420b6ac6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
naersk.url = "github:nix-community/naersk";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, flake-utils, naersk, nixpkgs }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = (import nixpkgs) { inherit system; };
|
||||
naersk' = pkgs.callPackage naersk { };
|
||||
in rec {
|
||||
packages.clam = naersk'.buildPackage { src = ./.; };
|
||||
|
||||
defaultPackage = packages.clam;
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [ rustc cargo clippy ];
|
||||
};
|
||||
});
|
||||
}
|
52
src/html.rs
52
src/html.rs
|
@ -1,5 +1,8 @@
|
|||
use orgize::export::{Container, Event, HtmlEscape, HtmlExport, TraversalContext, Traverser};
|
||||
use rowan::ast::AstNode;
|
||||
use orgize::{
|
||||
ast::{PropertyDrawer, TodoType},
|
||||
export::{Container, Event, HtmlEscape, HtmlExport, TraversalContext, Traverser},
|
||||
};
|
||||
use rowan::ast::{support, AstNode};
|
||||
use slugify::slugify;
|
||||
use std::cmp::min;
|
||||
|
||||
|
@ -15,13 +18,33 @@ impl Traverser for Handler {
|
|||
let lvl = 1 + min(lvl, 5);
|
||||
let txt = headline.title().map(|t| t.to_string()).collect::<String>();
|
||||
|
||||
let id = if let Some(Some(cid)) =
|
||||
support::children::<PropertyDrawer>(headline.syntax())
|
||||
.next()
|
||||
.map(|p| p.get("CUSTOM_ID"))
|
||||
{
|
||||
cid.to_string()
|
||||
} else {
|
||||
slugify!(&txt)
|
||||
};
|
||||
|
||||
self.0.push_str(format!(
|
||||
r##"<h{} id="{1}"><a role=none href="#{1}">{2}</a> "##,
|
||||
lvl,
|
||||
slugify!(&txt),
|
||||
lead
|
||||
lvl, id, lead
|
||||
));
|
||||
|
||||
if let Some(keyword) = headline.todo_keyword() {
|
||||
self.0.push_str(match headline.todo_type() {
|
||||
Some(TodoType::Todo) => {
|
||||
format!("<span class=todo>{}</span> ", HtmlEscape(keyword.as_ref()))
|
||||
}
|
||||
Some(TodoType::Done) => {
|
||||
format!("<span class=done>{}</span> ", HtmlEscape(keyword.as_ref()))
|
||||
}
|
||||
None => unreachable!(),
|
||||
});
|
||||
}
|
||||
|
||||
for e in headline.title() {
|
||||
self.element(e, ctx);
|
||||
}
|
||||
|
@ -34,9 +57,13 @@ impl Traverser for Handler {
|
|||
Event::Enter(Container::Link(link)) => {
|
||||
let path = link.path();
|
||||
let path = path.trim_start_matches("file:");
|
||||
let path = if let Some(p) = path.strip_prefix('*') {
|
||||
let mut p = slugify!(p);
|
||||
p.insert(0, '#');
|
||||
p
|
||||
// FIXME: breaks if linking to bare .org domain.
|
||||
// hopefully most have a trailing slash?
|
||||
let path = if let Some(p) = path.strip_suffix(".org") {
|
||||
} else if let Some(p) = path.strip_suffix(".org") {
|
||||
let mut p = p.to_string();
|
||||
p.push_str(".html");
|
||||
p
|
||||
|
@ -47,9 +74,16 @@ impl Traverser for Handler {
|
|||
};
|
||||
|
||||
if link.is_image() {
|
||||
// FIXME: needs alt text support
|
||||
self.0
|
||||
.push_str(format!("<img src=\"{}\">", HtmlEscape(&path)));
|
||||
if let Some(Some(caption)) = link.caption().map(|c| c.value()) {
|
||||
self.0.push_str(format!(
|
||||
r#"<img src="{}" alt="{}">"#,
|
||||
HtmlEscape(&path),
|
||||
HtmlEscape(caption.trim())
|
||||
));
|
||||
} else {
|
||||
self.0
|
||||
.push_str(format!("<img src=\"{}\">", HtmlEscape(&path)));
|
||||
}
|
||||
return ctx.skip();
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ fn main() {
|
|||
["TODO", "PENDING", "DELAYED", "RERUN"]
|
||||
.map(|s| s.to_string())
|
||||
.to_vec(),
|
||||
["DONE", "RESOLVED", "FIXED"]
|
||||
["DONE", "RESOLVED", "FIXED", "WONTFIX"]
|
||||
.map(|s| s.to_string())
|
||||
.to_vec(),
|
||||
),
|
||||
|
|
|
@ -120,11 +120,24 @@ img {
|
|||
max-width: 100%;
|
||||
}
|
||||
|
||||
.alert, .warning, .fixme {
|
||||
.todo, .done {
|
||||
color: #ddd;
|
||||
padding: 0 .3em;
|
||||
}
|
||||
|
||||
.todo {
|
||||
background: #b11;
|
||||
}
|
||||
|
||||
.done {
|
||||
background: #171;
|
||||
}
|
||||
|
||||
.alert, .warning, .fixme, .FIXME {
|
||||
background: #b01111;
|
||||
}
|
||||
|
||||
.fixme:before {
|
||||
.fixme:before, .FIXME:before {
|
||||
content: "[FIXME] ";
|
||||
font-weight: bold;
|
||||
float: left;
|
||||
|
@ -160,7 +173,7 @@ img {
|
|||
blockquote {
|
||||
border-left: 1px solid #ddd;
|
||||
}
|
||||
.alert, .warning, .fixme {
|
||||
.alert, .warning, .fixme, .FIXME {
|
||||
background: #f53838;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue