From be6901f8273de1ec128825af759824310e7db3fd Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 08:52:43 -0500 Subject: [PATCH 1/8] apply caption cleanup this commit won't work because i've mixed up cargo edition upgrades. whoops! --- crates/org-exporter/src/html.rs | 145 ++++++++++----------- crates/org-parser/src/element/keyword.rs | 91 ++++++++----- crates/org-parser/src/element/paragraph.rs | 12 ++ crates/org-parser/src/element/table.rs | 4 +- crates/org-parser/src/object/link.rs | 36 +++++ crates/org-parser/src/types.rs | 6 +- 6 files changed, 179 insertions(+), 115 deletions(-) diff --git a/crates/org-exporter/src/html.rs b/crates/org-exporter/src/html.rs index 894b7a1..2ace649 100644 --- a/crates/org-exporter/src/html.rs +++ b/crates/org-exporter/src/html.rs @@ -7,17 +7,17 @@ use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt::Write; -use latex2mathml::{latex_to_mathml, DisplayStyle}; +use latex2mathml::{DisplayStyle, latex_to_mathml}; use memchr::memchr3_iter; use org_parser::element::{Affiliated, Block, CheckBox, ListKind, TableRow}; use org_parser::object::{LatexFragment, PathReg, PlainOrRec}; -use org_parser::{parse_macro_call, parse_org, Expr, Node, NodeID, Parser}; +use org_parser::{Expr, Node, NodeID, Parser, parse_macro_call, parse_org}; +use crate::ExportError; use crate::include::include_handle; use crate::org_macros::macro_handle; use crate::types::{ConfigOptions, Exporter, ExporterInner, LogicErrorKind}; -use crate::utils::{process_toc, Options, TocItem}; -use crate::ExportError; +use crate::utils::{Options, TocItem, process_toc}; use phf::phf_set; macro_rules! w { @@ -25,15 +25,6 @@ macro_rules! w { $dst.write_fmt(format_args!($($arg)*)).expect("writing to buffer during export failed") }; } -// file types we can wrap an `img` around -static IMAGE_TYPES: phf::Set<&str> = phf_set! { - "jpeg", - "jpg", - "png", - "gif", - "svg", - "webp", -}; /// Directly convert these types when used in special blocks /// to named blocks, e.g.: @@ -68,9 +59,6 @@ static HTML5_TYPES: phf::Set<&str> = phf_set! { /// HTML Content Exporter pub struct Html<'buf> { buf: &'buf mut dyn fmt::Write, - // HACK: When we export a caption, insert the child id here to make sure - // it's not double exported - nox: HashSet, // no-export // used footnotes footnotes: Vec, footnote_ids: HashMap, @@ -142,7 +130,6 @@ impl<'buf> Exporter<'buf> for Html<'buf> { ) -> core::result::Result<(), Vec> { let mut obj = Html { buf, - nox: HashSet::new(), footnotes: Vec::new(), footnote_ids: HashMap::new(), conf, @@ -222,7 +209,6 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { let parsed = parse_macro_call(input); let mut obj = Html { buf, - nox: HashSet::new(), footnotes: Vec::new(), footnote_ids: HashMap::new(), conf, @@ -238,10 +224,6 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { } fn export_rec(&mut self, node_id: &NodeID, parser: &Parser) { - // avoid parsing this node - if self.nox.contains(node_id) { - return; - } let node = &parser.pool[*node_id]; match &node.obj { Expr::Root(inner) => { @@ -418,67 +400,59 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { // // handles the [[./hello]] case for us. // turning it into - if rita.is_empty() { - a.to_string() - } else { - rita - } + if rita.is_empty() { a.to_string() } else { rita } } PathReg::File(a) => format!("{a}"), }; - w!(self, r#""#, HtmlEscape(&path_link)); - if let Some(children) = &inner.description { - for id in children { - self.export_rec(id, parser); + + if inner.is_image(parser) { + w!(self, " = if let Some(slashed) = path_link.split('/').last() + { + slashed.into() + } else { + path_link.into() + }; + w!(self, "{}", HtmlEscape(alt_text)); } + w!(self, r#"">"#) } else { - w!(self, "{}", HtmlEscape(inner.path.to_str(parser.source))); + w!(self, r#""#, HtmlEscape(&path_link)); + if let Some(children) = &inner.description { + for id in children { + self.export_rec(id, parser); + } + } else { + w!(self, "{}", HtmlEscape(inner.path.to_str(parser.source))); + } + w!(self, ""); } - w!(self, ""); } Expr::Paragraph(inner) => { - if inner.0.len() == 1 { + if inner.is_image(parser) { if let Expr::RegularLink(link) = &parser.pool[inner.0[0]].obj { - let link_source: &str = match &link.path.obj { - PathReg::Unspecified(inner) => inner, - PathReg::File(inner) => inner, - PathReg::PlainLink(_) => link.path.to_str(parser.source), - _ => { - // HACK: we just want to jump outta here, everything else doesnt make sense - // in an image context - "".into() - } - }; - - // extract extension_type - let ending_tag = link_source.split('.').last(); - if let Some(extension) = ending_tag { - if IMAGE_TYPES.contains(extension) { - w!(self, "
\n = - if let Some(slashed) = link_source.split('/').last() { - slashed.into() - } else { - link_source.into() - }; - w!(self, "{}", HtmlEscape(alt_text)); - } - w!(self, "\">\n
"); - return; + if inner.is_image(&parser) { + w!(self, "
\n"); + if let Some(affiliate) = link.caption { + self.export_rec(&affiliate, parser); } + self.export_rec(&inner.0[0], parser); + w!(self, "\n
\n"); + return; } } } + w!(self, ""); @@ -803,16 +777,10 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { } Expr::Affiliated(inner) => match inner { Affiliated::Name(_id) => {} - Affiliated::Caption(id, contents) => { - if let Some(caption_id) = id { - w!(self, "
\n"); - self.export_rec(caption_id, parser); - w!(self, "
\n"); - self.export_rec(contents, parser); - w!(self, "
\n"); - w!(self, "
\n"); - self.nox.insert(*caption_id); - } + Affiliated::Caption(contents) => { + w!(self, "
\n"); + self.export_rec(contents, parser); + w!(self, "
\n"); } Affiliated::Attr { .. } => {} }, @@ -1443,4 +1411,23 @@ here "

yeah

\n

hello

\n

hi

\n

content

\n

here

\n" ); } + + #[test] + fn caption_with_child() { + let a = r#" +#+caption: yes +[[suki.jpg]] +"#; + + assert_eq!( + html_export(a), + r#"
+
+

yes

+
+suki.jpg +
+"# + ) + } } diff --git a/crates/org-parser/src/element/keyword.rs b/crates/org-parser/src/element/keyword.rs index b42d803..972a50d 100644 --- a/crates/org-parser/src/element/keyword.rs +++ b/crates/org-parser/src/element/keyword.rs @@ -1,8 +1,8 @@ use crate::constants::{DOLLAR, HYPHEN, NEWLINE, UNDERSCORE}; use crate::node_pool::NodeID; use crate::parse::parse_element; -use crate::types::{process_attrs, Cursor, Expr, MatchError, ParseOpts, Parseable, Parser, Result}; -use crate::utils::{bytes_to_str, Match}; +use crate::types::{Cursor, Expr, MatchError, ParseOpts, Parseable, Parser, Result, process_attrs}; +use crate::utils::{Match, bytes_to_str}; use super::Paragraph; @@ -15,7 +15,7 @@ pub struct Keyword<'a> { #[derive(Debug, Clone, PartialEq, Eq)] pub enum Affiliated<'a> { Name(Option), - Caption(Option, NodeID), + Caption(NodeID), // inside is a paragraph Attr { child_id: Option, backend: &'a str, @@ -134,31 +134,66 @@ impl<'a> Parseable<'a> for Keyword<'a> { let caption_id = parser.pool.reserve_id(); let temp_cursor = cursor.cut_off(val.end); let ret = Paragraph::parse(parser, temp_cursor, Some(caption_id), parse_opts)?; + parser.alloc_with_id( + Affiliated::Caption(ret), + start, + val.end + 1, + parent, + caption_id, + ); cursor.index = val.end; cursor.word("\n")?; - let child_id = loop { - if let Ok(child_id) = parse_element(parser, cursor, parent, parse_opts) { - let node = &mut parser.pool[child_id]; - if let Expr::Affiliated(aff) = &node.obj { - // skip affiliated objects - cursor.index = node.end; - } else { - break Some(child_id); + let c_id = parse_element(parser, cursor, parent, parse_opts)?; + + if matches!(&parser.pool[c_id].obj, Expr::Affiliated(_)) { + // skip affiliated objects + cursor.index = parser.pool[c_id].end; + continue; + } + + // HACK: normally would just do inspection and mutation in one go, + // but we'd be taking a mutable/immutable ref to the parser pool. + // + // split it up into two (with this enum to indicate behaviour) to + // work around that + enum Operation { + CaptionImage(NodeID), + Table, + None, + } + + // inspection phase + let operation = match &parser.pool[c_id].obj { + Expr::Paragraph(par) if par.is_image(&parser) => { + Operation::CaptionImage(par.0[0]) } - } else { - break None; + Expr::Table(_) => Operation::Table, + _ => Operation::None, }; - }; - return Ok(parser.alloc_with_id( - Affiliated::Caption(child_id, ret), - start, - val.end + 1, - parent, - caption_id, - )); + // mutation phase + match operation { + Operation::CaptionImage(link_id) => { + if let Expr::RegularLink(link) = &mut parser.pool[link_id].obj { + link.caption = Some(caption_id); + } + } + Operation::Table => { + if let Expr::Table(table) = &mut parser.pool[c_id].obj { + table.caption = Some(caption_id); + } + } + Operation::None => { + // TODO: warning system + dbg!("caption applied to invalid object"); + } + } + break c_id; + }; // caption end + + return Ok(child_id); } _ => {} } @@ -367,7 +402,7 @@ mod tests { let input = r#" #+caption:*hi* -yeah +[[yeah]] "#; @@ -375,7 +410,7 @@ yeah let cap = expr_in_pool!(parsed, Affiliated).unwrap(); match cap { - Affiliated::Caption(Some(child), id) => { + Affiliated::Caption(id) => { let Expr::Paragraph(para) = &parsed.pool[*id].obj else { unreachable!() }; @@ -387,14 +422,7 @@ yeah }; assert_eq!(letters, &"hi"); - let Expr::Paragraph(para) = &parsed.pool[*child].obj else { - unreachable!() - }; - - let Expr::Plain(letters) = &parsed.pool[para.0[0]].obj else { - unreachable!() - }; - assert_eq!(letters, &"yeah"); + let cap = expr_in_pool!(parsed, RegularLink).unwrap(); } _ => { panic!("oops") @@ -435,4 +463,3 @@ yeah }); } } - diff --git a/crates/org-parser/src/element/paragraph.rs b/crates/org-parser/src/element/paragraph.rs index fd50af1..2a186bc 100644 --- a/crates/org-parser/src/element/paragraph.rs +++ b/crates/org-parser/src/element/paragraph.rs @@ -1,3 +1,4 @@ +use crate::Expr; use crate::node_pool::NodeID; use crate::parse::parse_object; use crate::types::{Cursor, ParseOpts, Parseable, Parser, Result}; @@ -33,3 +34,14 @@ impl<'a> Parseable<'a> for Paragraph { )) } } + +impl Paragraph { + pub fn is_image(&self, parser: &Parser) -> bool { + if let [id] = self.0[..] + && let Expr::RegularLink(link) = &parser.pool[id].obj + { + return link.is_image(parser); + } + false + } +} diff --git a/crates/org-parser/src/element/table.rs b/crates/org-parser/src/element/table.rs index a547586..a661394 100644 --- a/crates/org-parser/src/element/table.rs +++ b/crates/org-parser/src/element/table.rs @@ -12,6 +12,7 @@ pub struct Table { pub rows: usize, pub cols: usize, pub children: Vec, + pub caption: Option, // will be filled by parent caption if exists } /// A row of a [`Table`] consisting of [`TableCell`]s or a [`TableRow::Rule`]. @@ -69,6 +70,7 @@ impl<'a> Parseable<'a> for Table { rows, cols, children, + caption: None, }, start, cursor.index, @@ -136,7 +138,7 @@ impl<'a> Parseable<'a> for TableRow { #[cfg(test)] mod tests { - use crate::{expr_in_pool, parse_org, Expr}; + use crate::{Expr, expr_in_pool, parse_org}; #[test] fn basic_table() { diff --git a/crates/org-parser/src/object/link.rs b/crates/org-parser/src/object/link.rs index f33bfe0..c624df9 100644 --- a/crates/org-parser/src/object/link.rs +++ b/crates/org-parser/src/object/link.rs @@ -1,6 +1,8 @@ use std::borrow::Cow; use std::fmt::Display; +use phf::phf_set; + use crate::constants::{ BACKSLASH, COLON, HYPHEN, LANGLE, LBRACK, LPAREN, POUND, RANGLE, RBRACK, RPAREN, SLASH, }; @@ -13,6 +15,16 @@ const ORG_LINK_PARAMETERS: [&str; 9] = [ "shell", "news", "mailto", "https", "http", "ftp", "help", "file", "elisp", ]; +// file types we can wrap an `img` around +static IMAGE_TYPES: phf::Set<&str> = phf_set! { + "jpeg", + "jpg", + "png", + "gif", + "svg", + "webp", +}; + #[derive(Debug, Clone)] pub struct RegularLink<'a> { pub path: Match>, @@ -22,6 +34,9 @@ pub struct RegularLink<'a> { // It can also contain another link, but only when it is a plain or angle link. // It can contain square brackets, so long as they are balanced. pub description: Option>, + // Captions will be filled in later. affiliated keywords are defined first, so the caption + // checks if the child is a link and then sticks it in + pub caption: Option, } impl Display for PathReg<'_> { @@ -203,6 +218,7 @@ impl<'a> Parseable<'a> for RegularLink<'a> { Self { path: pathreg, description: Some(content_vec), + caption: None, }, start, cursor.index + 2, // link end is 2 bytes long @@ -227,6 +243,7 @@ impl<'a> Parseable<'a> for RegularLink<'a> { Self { path: pathreg, description: None, + caption: None, }, start, cursor.index + 2, @@ -243,6 +260,25 @@ impl<'a> Parseable<'a> for RegularLink<'a> { } } +impl RegularLink<'_> { + pub fn is_image(&self, parser: &Parser) -> bool { + let link_source: &str = match &self.path.obj { + PathReg::Unspecified(inner) => inner, + PathReg::File(inner) => inner, + PathReg::PlainLink(inner) => &inner.path, + _ => { + // HACK: we just want to jump outta here, everything else doesnt make sense + // in an image context + "" + } + }; + link_source + .rsplit_once('.') // extract extension_type + .map(|(_, ext)| ext) + .is_some_and(|ext| IMAGE_TYPES.contains(ext)) + } +} + // REVIEW: // apparently a word constituent..isn't undescore?? // https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html diff --git a/crates/org-parser/src/types.rs b/crates/org-parser/src/types.rs index bf8cd7f..71406d0 100644 --- a/crates/org-parser/src/types.rs +++ b/crates/org-parser/src/types.rs @@ -9,7 +9,7 @@ use crate::constants::{ use crate::element::*; use crate::node_pool::{NodeID, NodePool}; use crate::object::*; -use crate::utils::{bytes_to_str, id_escape, Match}; +use crate::utils::{Match, bytes_to_str, id_escape}; use bitflags::bitflags; pub(crate) type Result = std::result::Result; @@ -815,9 +815,9 @@ impl<'a> Expr<'a> { Expr::ExportSnippet(inner) => print!("{inner:#?}"), Expr::Affiliated(inner) => match inner { Affiliated::Name(_) => print!("{inner:#?}"), - Affiliated::Caption(i1, i2) => { + Affiliated::Caption(i1) => { // pool[i1.unwrap()].obj.print_tree(pool); - pool[*i2].obj.print_tree(pool); + pool[*i1].obj.print_tree(pool); } Affiliated::Attr { child_id, From fc0b18c9ee4a230cf17d02d75c26463c0858177d Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 08:53:24 -0500 Subject: [PATCH 2/8] apply edition upgrade + cargo fmt --- .github/workflows/pages.yml | 2 +- Cargo.toml | 4 ++-- crates/org-cli/build.rs | 2 +- crates/org-cli/src/cli.rs | 2 +- crates/org-cli/src/main.rs | 4 ++-- crates/org-cli/src/utils.rs | 5 +---- crates/org-exporter/src/org.rs | 4 ++-- crates/org-exporter/src/org_macros.rs | 4 ++-- crates/org-exporter/src/utils.rs | 5 +++-- crates/org-parser/src/element/block.rs | 2 +- crates/org-parser/src/element/heading.rs | 4 ++-- crates/org-parser/src/element/item.rs | 15 ++++++++++++--- crates/org-parser/src/element/mod.rs | 2 +- crates/org-parser/src/element/plain_list.rs | 2 +- crates/org-parser/src/object/latex_frag.rs | 8 +++++--- crates/org-parser/src/object/mod.rs | 8 ++++---- crates/org-parser/src/object/org_macro.rs | 4 ++-- crates/org-parser/src/object/sup_sub.rs | 2 +- crates/org-parser/src/parse.rs | 8 ++++---- 19 files changed, 48 insertions(+), 39 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 7da4450..da375fb 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -59,7 +59,7 @@ jobs: - name: Install rust toolchain uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.81.0 + toolchain: 1.91.0 - name: Setup Node.js uses: actions/setup-node@v4 diff --git a/Cargo.toml b/Cargo.toml index fd414ff..972a9e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,9 @@ default-members=["crates/org-cli"] [workspace.package] version = "0.1.0" -rust-version = "1.74" # also change in ci.yml +rust-version = "1.91" # also change in ci.yml authors = ["Laith Bahodi "] -edition = "2021" +edition = "2024" homepage = "https://org-rust.pages.dev" repository = "https://github.com/hydrobeam/org-rust" readme = "README.org" diff --git a/crates/org-cli/build.rs b/crates/org-cli/build.rs index 5e12e4b..d38a1e2 100644 --- a/crates/org-cli/build.rs +++ b/crates/org-cli/build.rs @@ -1,5 +1,5 @@ use clap::CommandFactory; -use clap_complete::{generate_to, Shell}; +use clap_complete::{Shell, generate_to}; use std::{env, io}; include!("src/cli.rs"); diff --git a/crates/org-cli/src/cli.rs b/crates/org-cli/src/cli.rs index 47ef818..1bc0487 100644 --- a/crates/org-cli/src/cli.rs +++ b/crates/org-cli/src/cli.rs @@ -50,7 +50,7 @@ impl Backend { self, parsed: &org_parser::Parser, buf: &mut String, - conf: ConfigOptions + conf: ConfigOptions, ) -> Result<(), Vec> { match self { Backend::Html => org_exporter::Html::export_tree(parsed, buf, conf), diff --git a/crates/org-cli/src/main.rs b/crates/org-cli/src/main.rs index d318a52..3effdcd 100644 --- a/crates/org-cli/src/main.rs +++ b/crates/org-cli/src/main.rs @@ -1,7 +1,7 @@ use anyhow::bail; use org_exporter::ConfigOptions; -use std::fs::{self, read_to_string, OpenOptions}; -use std::io::{stdout, BufWriter, Read, Write}; +use std::fs::{self, OpenOptions, read_to_string}; +use std::io::{BufWriter, Read, Write, stdout}; use std::path::{Path, PathBuf}; use template::Template; use types::{CliError, InpType, OutType}; diff --git a/crates/org-cli/src/utils.rs b/crates/org-cli/src/utils.rs index 21c5336..4e2b070 100644 --- a/crates/org-cli/src/utils.rs +++ b/crates/org-cli/src/utils.rs @@ -60,10 +60,7 @@ pub fn relative_path_from<'a, 'b>( .map_err(|e| { CliError::from(e) .with_path(&src.parent().unwrap().join(added)) - .with_cause(&format!( - "Failed to locate path from: {}", - src.display() - )) + .with_cause(&format!("Failed to locate path from: {}", src.display())) })? .into()) } else { diff --git a/crates/org-exporter/src/org.rs b/crates/org-exporter/src/org.rs index 30489e1..d20b205 100644 --- a/crates/org-exporter/src/org.rs +++ b/crates/org-exporter/src/org.rs @@ -2,14 +2,14 @@ use std::borrow::Cow; use std::fmt; use std::fmt::Write; +use crate::ExportError; use crate::include::include_handle; use crate::org_macros::macro_handle; use crate::types::{ConfigOptions, Exporter, ExporterInner, LogicErrorKind}; -use crate::ExportError; use org_parser::element::{Block, BulletKind, CounterKind, Priority, TableRow, Tag}; use org_parser::object::{LatexFragment, PlainOrRec}; -use org_parser::{parse_org, Expr, NodeID, Parser}; +use org_parser::{Expr, NodeID, Parser, parse_org}; /// Org-Mode Content Exporter /// diff --git a/crates/org-exporter/src/org_macros.rs b/crates/org-exporter/src/org_macros.rs index 6b7fd49..0f1693e 100644 --- a/crates/org-exporter/src/org_macros.rs +++ b/crates/org-exporter/src/org_macros.rs @@ -1,15 +1,15 @@ +use org_parser::Parser; use org_parser::element::{ArgNumOrText, MacroDef}; use org_parser::object::MacroCall; -use org_parser::Parser; use std::borrow::Cow; use std::fs::read_to_string; use std::path::Path; use thiserror::Error; +use crate::ConfigOptions; use crate::types::FileError; use crate::utils::keyword_lookup; -use crate::ConfigOptions; pub(crate) fn macro_handle<'a>( parser: &'a Parser, diff --git a/crates/org-exporter/src/utils.rs b/crates/org-exporter/src/utils.rs index 7efdbb5..2be8bce 100644 --- a/crates/org-exporter/src/utils.rs +++ b/crates/org-exporter/src/utils.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::rc::Rc; -use org_parser::{element::Heading, NodeID, Parser}; +use org_parser::{NodeID, Parser, element::Heading}; pub(crate) fn keyword_lookup<'a>(parser: &'a Parser, name: &'a str) -> Option<&'a str> { parser.keywords.get(name).copied() @@ -181,7 +181,8 @@ ul { "#, ConfigOptions::default(), - ).unwrap(); + ) + .unwrap(); println!("{a}"); Ok(()) } diff --git a/crates/org-parser/src/element/block.rs b/crates/org-parser/src/element/block.rs index 0d21ae5..b965c4f 100644 --- a/crates/org-parser/src/element/block.rs +++ b/crates/org-parser/src/element/block.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use crate::node_pool::NodeID; use crate::parse::parse_element; -use crate::types::{process_attrs, Cursor, MatchError, ParseOpts, Parseable, Parser, Result}; +use crate::types::{Cursor, MatchError, ParseOpts, Parseable, Parser, Result, process_attrs}; use lazy_static::lazy_static; use regex::bytes::Regex; diff --git a/crates/org-parser/src/element/heading.rs b/crates/org-parser/src/element/heading.rs index 7fb455a..4d7a892 100644 --- a/crates/org-parser/src/element/heading.rs +++ b/crates/org-parser/src/element/heading.rs @@ -4,9 +4,9 @@ use crate::constants::{COLON, NEWLINE, RBRACK, SPACE, STAR}; use crate::node_pool::NodeID; use crate::parse::{parse_element, parse_object}; use crate::types::{Cursor, Expr, MatchError, ParseOpts, Parseable, Parser, Result}; -use crate::utils::{bytes_to_str, Match}; +use crate::utils::{Match, bytes_to_str}; -use super::{parse_property, PropertyDrawer}; +use super::{PropertyDrawer, parse_property}; const ORG_TODO_KEYWORDS: [&str; 2] = ["TODO", "DONE"]; diff --git a/crates/org-parser/src/element/item.rs b/crates/org-parser/src/element/item.rs index 977491e..90e3557 100644 --- a/crates/org-parser/src/element/item.rs +++ b/crates/org-parser/src/element/item.rs @@ -367,16 +367,25 @@ mod tests { let input = "1. "; let ret = parse_org(input); let item = expr_in_pool!(ret, Item).unwrap(); - assert!(matches!(item.bullet, BulletKind::Ordered(CounterKind::Number(1)))); + assert!(matches!( + item.bullet, + BulletKind::Ordered(CounterKind::Number(1)) + )); let input = "17. "; let ret = parse_org(input); let item = expr_in_pool!(ret, Item).unwrap(); - assert!(matches!(item.bullet, BulletKind::Ordered(CounterKind::Number(17)))); + assert!(matches!( + item.bullet, + BulletKind::Ordered(CounterKind::Number(17)) + )); let input = "a. "; let ret = parse_org(input); let item = expr_in_pool!(ret, Item).unwrap(); - assert!(matches!(item.bullet, BulletKind::Ordered(CounterKind::Letter(b'a')))); + assert!(matches!( + item.bullet, + BulletKind::Ordered(CounterKind::Letter(b'a')) + )); } } diff --git a/crates/org-parser/src/element/mod.rs b/crates/org-parser/src/element/mod.rs index f01dff3..5cfe947 100644 --- a/crates/org-parser/src/element/mod.rs +++ b/crates/org-parser/src/element/mod.rs @@ -17,9 +17,9 @@ mod table; pub use block::Block; pub use comment::Comment; -pub(crate) use drawer::parse_property; pub use drawer::Drawer; pub use drawer::PropertyDrawer; +pub(crate) use drawer::parse_property; pub use footnote_def::FootnoteDef; pub use heading::Heading; pub use heading::HeadingLevel; diff --git a/crates/org-parser/src/element/plain_list.rs b/crates/org-parser/src/element/plain_list.rs index fa80688..65edfba 100644 --- a/crates/org-parser/src/element/plain_list.rs +++ b/crates/org-parser/src/element/plain_list.rs @@ -97,7 +97,7 @@ fn find_kind(item: &Item) -> ListKind { #[cfg(test)] mod tests { - use crate::{parse_org, Expr}; + use crate::{Expr, parse_org}; #[test] fn basic_list() { diff --git a/crates/org-parser/src/object/latex_frag.rs b/crates/org-parser/src/object/latex_frag.rs index d1fa142..fbd8448 100644 --- a/crates/org-parser/src/object/latex_frag.rs +++ b/crates/org-parser/src/object/latex_frag.rs @@ -72,7 +72,9 @@ impl<'a> Parseable<'a> for LatexFragment<'a> { if cursor.curr() == DOLLAR { if cursor.peek(1)? == DOLLAR { cursor.index += 2; - double_ending!(parser, cursor, start, parse_opts, parent, DOLLAR, DOLLAR, Display) + double_ending!( + parser, cursor, start, parse_opts, parent, DOLLAR, DOLLAR, Display + ) } else if cursor.peek(2)? == DOLLAR && verify_single_char_latex_frag(cursor) { return Ok(parser.alloc( Self::Inline(cursor.clamp(cursor.index + 1, cursor.index + 2)), @@ -196,7 +198,7 @@ impl<'a> Parseable<'a> for LatexFragment<'a> { start, cursor.index + 1, parent, - )) + )); } _ => {} } @@ -212,7 +214,7 @@ impl<'a> Parseable<'a> for LatexFragment<'a> { start, cursor.index, parent, - )) + )); } } } diff --git a/crates/org-parser/src/object/mod.rs b/crates/org-parser/src/object/mod.rs index ed69482..58ef101 100644 --- a/crates/org-parser/src/object/mod.rs +++ b/crates/org-parser/src/object/mod.rs @@ -15,20 +15,20 @@ mod table_cell; mod target; pub use emoji::Emoji; -pub(crate) use entity::parse_entity; pub use entity::Entity; +pub(crate) use entity::parse_entity; pub use export_snippet::ExportSnippet; pub use footnote_ref::FootnoteRef; pub use inline_src::InlineSrc; pub use latex_frag::LatexFragment; -pub(crate) use link::parse_angle_link; -pub(crate) use link::parse_plain_link; pub use link::PathReg; pub use link::PlainLink; pub use link::RegularLink; +pub(crate) use link::parse_angle_link; +pub(crate) use link::parse_plain_link; pub use markup::*; -pub(crate) use node_property::parse_node_property; pub use node_property::NodeProperty; +pub(crate) use node_property::parse_node_property; pub use org_macro::MacroCall; pub use sup_sub::PlainOrRec; pub use sup_sub::Subscript; diff --git a/crates/org-parser/src/object/org_macro.rs b/crates/org-parser/src/object/org_macro.rs index 399264e..f89e51e 100644 --- a/crates/org-parser/src/object/org_macro.rs +++ b/crates/org-parser/src/object/org_macro.rs @@ -244,7 +244,7 @@ mod tests { l, &MacroCall { name: "poem", - args: vec![Cow::Borrowed("cool, three"), ] + args: vec![Cow::Borrowed("cool, three"),] } ) } @@ -258,7 +258,7 @@ mod tests { l, &MacroCall { name: "poem", - args: vec![Cow::Borrowed("cool, , , , three"), ] + args: vec![Cow::Borrowed("cool, , , , three"),] } ) } diff --git a/crates/org-parser/src/object/sup_sub.rs b/crates/org-parser/src/object/sup_sub.rs index 19f1012..9209a4d 100644 --- a/crates/org-parser/src/object/sup_sub.rs +++ b/crates/org-parser/src/object/sup_sub.rs @@ -73,7 +73,7 @@ macro_rules! parse_nscript { start, cursor.index + 2, parent, - )) + )); } chr if !chr.is_ascii_whitespace() => { // SIGN diff --git a/crates/org-parser/src/parse.rs b/crates/org-parser/src/parse.rs index dca97cd..d3cf4d1 100644 --- a/crates/org-parser/src/parse.rs +++ b/crates/org-parser/src/parse.rs @@ -9,9 +9,9 @@ use crate::element::{ Table, }; use crate::object::{ - parse_angle_link, parse_plain_link, Bold, Code, Emoji, ExportSnippet, FootnoteRef, InlineSrc, - Italic, LatexFragment, MacroCall, RegularLink, StrikeThrough, Subscript, Superscript, Target, - Underline, Verbatim, + Bold, Code, Emoji, ExportSnippet, FootnoteRef, InlineSrc, Italic, LatexFragment, MacroCall, + RegularLink, StrikeThrough, Subscript, Superscript, Target, Underline, Verbatim, + parse_angle_link, parse_plain_link, }; use crate::types::{Cursor, Expr, MarkupKind, MatchError, ParseOpts, Parseable, Parser, Result}; use crate::utils::verify_markup; @@ -421,6 +421,6 @@ mod tests { let src = " "; let parsed = parse_org(src); let plain = expr_in_pool!(parsed, Plain).unwrap(); - assert_eq!(plain, &" " ); + assert_eq!(plain, &" "); } } From 1a67a9f1cd19c0f694c79153f78a0161f25dd08c Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 08:56:12 -0500 Subject: [PATCH 3/8] comply with edition changes --- crates/org-parser/src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/org-parser/src/types.rs b/crates/org-parser/src/types.rs index 71406d0..34b4fc8 100644 --- a/crates/org-parser/src/types.rs +++ b/crates/org-parser/src/types.rs @@ -584,7 +584,7 @@ impl<'a> Expr<'a> { Expr::PlainList(pl) => Some(&mut pl.children), Expr::Item(item) => Some(&mut item.children), Expr::Table(inner) => Some(&mut inner.children), - Expr::TableRow(ref mut inner) => match inner { + Expr::TableRow(inner) => match inner { TableRow::Rule => None, TableRow::Standard(stan) => Some(stan), }, From 2368337c103193b16bee897e5435b92360dfa652 Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 09:47:15 -0500 Subject: [PATCH 4/8] implement clippy fixes --- crates/org-cli/src/cli.rs | 9 +-- crates/org-cli/src/main.rs | 30 ++++----- crates/org-cli/src/template.rs | 9 ++- crates/org-cli/src/utils.rs | 5 +- crates/org-exporter/src/html.rs | 72 ++++++++++----------- crates/org-exporter/src/include.rs | 25 +++----- crates/org-exporter/src/org.rs | 20 +++--- crates/org-exporter/src/utils.rs | 81 +++++++++++------------- crates/org-parser/src/element/drawer.rs | 2 +- crates/org-parser/src/element/keyword.rs | 4 +- crates/org-parser/src/element/table.rs | 18 +++--- crates/org-parser/src/node_pool.rs | 2 +- crates/org-parser/src/object/link.rs | 13 ++-- crates/org-parser/src/parse.rs | 21 +++--- 14 files changed, 143 insertions(+), 168 deletions(-) diff --git a/crates/org-cli/src/cli.rs b/crates/org-cli/src/cli.rs index 1bc0487..9bd1bcb 100644 --- a/crates/org-cli/src/cli.rs +++ b/crates/org-cli/src/cli.rs @@ -39,8 +39,9 @@ pub struct Cli { pub verbose: bool, } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Deserialize)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Deserialize, Default)] pub enum Backend { + #[default] Html, Org, } @@ -65,9 +66,3 @@ impl Backend { } } } - -impl Default for Backend { - fn default() -> Self { - Backend::Html - } -} diff --git a/crates/org-cli/src/main.rs b/crates/org-cli/src/main.rs index 3effdcd..3478093 100644 --- a/crates/org-cli/src/main.rs +++ b/crates/org-cli/src/main.rs @@ -9,9 +9,8 @@ use utils::{mkdir_recursively, relative_path_from}; use clap::Parser; -mod template; -use crate::cli::Backend; mod cli; +mod template; mod types; mod utils; @@ -45,12 +44,12 @@ fn run() -> anyhow::Result<()> { None => config_params.backend, r => r, }; - let output_path = if cli_params.output == "" { + let output_path = if cli_params.output.is_empty() { config_params.output } else { cli_params.output }; - let input_path = if cli_params.input == "" { + let input_path = if cli_params.input.is_empty() { config_params.input } else { cli_params.input @@ -62,10 +61,7 @@ fn run() -> anyhow::Result<()> { config_params.verbose }; - let backend = match backend { - Some(b) => b, - None => Backend::default(), - }; + let backend = backend.unwrap_or_default(); let f = Path::new(&input_path); if !f.exists() { @@ -129,11 +125,11 @@ fn run() -> anyhow::Result<()> { // main loop to export files for file_path in &paths { if verbose { - writeln!(stdout, "input: {}", file_path.display()).map_err(|e| CliError::from(e))?; + writeln!(stdout, "input: {}", file_path.display()).map_err(CliError::from)?; } if file_path.extension().is_some_and(|x| x == "org") { let mut input_file = std::fs::File::open(file_path) - .map_err(|e| CliError::from(e).with_path(&file_path))?; + .map_err(|e| CliError::from(e).with_path(file_path))?; let _num_bytes = input_file.read_to_string(&mut file_contents).map_err(|e| { CliError::from(e) .with_path(file_path) @@ -165,7 +161,7 @@ fn run() -> anyhow::Result<()> { let mut build_str = String::new(); for e in err_vec { build_str.push_str(&e.to_string()); - build_str.push_str("\n"); + build_str.push('\n'); } Err(CliError::new().with_cause(&build_str))? } @@ -192,7 +188,7 @@ fn run() -> anyhow::Result<()> { // the destination we are writing to let mut full_output_path: PathBuf; match dest { - OutType::File(ref output_file) => { + OutType::File(output_file) => { full_output_path = output_file.to_path_buf(); } OutType::Dir(dest_path) => { @@ -210,7 +206,7 @@ fn run() -> anyhow::Result<()> { } } - mkdir_recursively(&full_output_path.parent().unwrap())?; + mkdir_recursively(full_output_path.parent().unwrap())?; // truncate is needed to fully overwrite file contents OpenOptions::new() .create(true) @@ -222,7 +218,7 @@ fn run() -> anyhow::Result<()> { .with_path(&full_output_path) .with_cause("error in writing to destination file") })? - .write(exported_content.as_bytes())?; + .write_all(exported_content.as_bytes())?; if verbose { writeln!( @@ -257,12 +253,12 @@ fn run() -> anyhow::Result<()> { " -- symlinked: {}\n", &full_output_path.canonicalize()?.display() ) - .map_err(|e| CliError::from(e))?; + .map_err(CliError::from)?; } } else { fs::copy(file_path, &full_output_path).map_err(|e| { CliError::from(e) - .with_path(&file_path) + .with_path(file_path) .with_cause("error in copying file to destination") })?; if verbose { @@ -271,7 +267,7 @@ fn run() -> anyhow::Result<()> { " -- copied: {}\n", &full_output_path.canonicalize()?.display() ) - .map_err(|e| CliError::from(e))?; + .map_err(CliError::from)?; } } } diff --git a/crates/org-cli/src/template.rs b/crates/org-cli/src/template.rs index 9836513..9867005 100644 --- a/crates/org-cli/src/template.rs +++ b/crates/org-cli/src/template.rs @@ -69,7 +69,7 @@ impl<'a, 'template> Template<'a, 'template> { // ? => not greedy let re = regex::Regex::new(r#"\{\{\{(.*?)\}\}\}"#).unwrap(); // collect all matches to {{{.*}}} regex - things we want to replace with keywords - let mut captures = re.captures_iter(&self.template_contents).map(|capture| { + let mut captures = re.captures_iter(self.template_contents).map(|capture| { let mtch = capture.get(1).unwrap(); // we expand the range of the capture to include the {{{}}} (mtch.start() - 3, mtch.end() + 3, mtch.as_str().trim()) @@ -93,11 +93,11 @@ impl<'a, 'template> Template<'a, 'template> { local_items.push_str(&self.template_contents[begin..start]); if extract == "content" { - local_items.push_str(&self.exported_content); + local_items.push_str(self.exported_content); } else if let Some(command) = Command::check(extract) { match command { Command::If(cond) => { - if let Some(_) = self.p.keywords.get(&*cond) { + if self.p.keywords.contains_key(cond) { local_items.push_str(&self.process_captures( captures, self.end, @@ -194,8 +194,7 @@ impl<'a, 'template> Template<'a, 'template> { } } Command::Include(file) => { - let include_path = - relative_path_from(&self.template_path, Path::new(file))?; + let include_path = relative_path_from(self.template_path, Path::new(file))?; let included_template = read_to_string(&include_path).map_err(|e| { CliError::from(e) .with_path(&include_path) diff --git a/crates/org-cli/src/utils.rs b/crates/org-cli/src/utils.rs index 4e2b070..c32aa5b 100644 --- a/crates/org-cli/src/utils.rs +++ b/crates/org-cli/src/utils.rs @@ -43,10 +43,7 @@ pub fn mkdir_recursively(path: &Path) -> Result<(), CliError> { }) } -pub fn relative_path_from<'a, 'b>( - src: &'a Path, - added: &'b Path, -) -> Result, CliError> { +pub fn relative_path_from<'b>(src: &Path, added: &'b Path) -> Result, CliError> { if added.is_relative() { Ok(src .parent() diff --git a/crates/org-exporter/src/html.rs b/crates/org-exporter/src/html.rs index 2ace649..5adda83 100644 --- a/crates/org-exporter/src/html.rs +++ b/crates/org-exporter/src/html.rs @@ -4,7 +4,7 @@ use core::fmt; use std::borrow::Cow; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::fmt::Write; use latex2mathml::{DisplayStyle, latex_to_mathml}; @@ -72,7 +72,7 @@ pub(crate) struct HtmlEscape>(pub S); // TODO this is not appropriate for certain things (can break). i can't rememmber them atm // but you need to escape more for certain stuff, it would be easier to just not use two separate htmlescapes // REVIEW: jetscii -impl<'a, S: AsRef> fmt::Display for HtmlEscape { +impl> fmt::Display for HtmlEscape { // design based on: // https://lise-henry.github.io/articles/optimising_strings.html // we can iterate over bytes since it's not possible for @@ -136,13 +136,14 @@ impl<'buf> Exporter<'buf> for Html<'buf> { errors: Vec::new(), }; - if let Ok(opts) = Options::handle_opts(parsed) { - if let Ok(tocs) = process_toc(parsed, &opts) { - handle_toc(parsed, &mut obj, &tocs); - } + if let Ok(opts) = Options::handle_opts(parsed) + && let Ok(tocs) = process_toc(parsed, &opts) + { + handle_toc(parsed, &mut obj, &tocs); } - obj.export_rec(&parsed.pool.root_id(), &parsed); - obj.exp_footnotes(&parsed); + + obj.export_rec(&parsed.pool.root_id(), parsed); + obj.exp_footnotes(parsed); if obj.errors().is_empty() { Ok(()) @@ -166,7 +167,7 @@ fn handle_toc<'a, T: fmt::Write + ExporterInner<'a>>( ); w!(writer, "
    "); for toc in tocs { - toc_rec(&parsed, writer, toc, 1); + toc_rec(parsed, writer, toc, 1); } w!(writer, "
"); w!(writer, r#""#); @@ -181,7 +182,7 @@ fn toc_rec<'a, T: fmt::Write + ExporterInner<'a>>( w!(writer, "
  • "); if curr_level < parent.level { w!(writer, "
      "); - toc_rec(&parser, writer, parent, curr_level + 1); + toc_rec(parser, writer, parent, curr_level + 1); w!(writer, "
    "); } else { w!(writer, r#""#, parent.target); @@ -192,7 +193,7 @@ fn toc_rec<'a, T: fmt::Write + ExporterInner<'a>>( if !parent.children.is_empty() { w!(writer, "
      "); for child in &parent.children { - toc_rec(&parser, writer, child, curr_level + 1); + toc_rec(parser, writer, child, curr_level + 1); } w!(writer, "
    "); } @@ -416,12 +417,12 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { self.export_rec(id, parser); } } else { - let alt_text: Cow = if let Some(slashed) = path_link.split('/').last() - { - slashed.into() - } else { - path_link.into() - }; + let alt_text: Cow = + if let Some(slashed) = path_link.split('/').next_back() { + slashed.into() + } else { + path_link.into() + }; w!(self, "{}", HtmlEscape(alt_text)); } w!(self, r#"">"#) @@ -439,18 +440,17 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { } Expr::Paragraph(inner) => { - if inner.is_image(parser) { - if let Expr::RegularLink(link) = &parser.pool[inner.0[0]].obj { - if inner.is_image(&parser) { - w!(self, "
    \n"); - if let Some(affiliate) = link.caption { - self.export_rec(&affiliate, parser); - } - self.export_rec(&inner.0[0], parser); - w!(self, "\n
    \n"); - return; - } + if inner.is_image(parser) + && let Expr::RegularLink(link) = &parser.pool[inner.0[0]].obj + && inner.is_image(parser) + { + w!(self, "
    \n"); + if let Some(affiliate) = link.caption { + self.export_rec(&affiliate, parser); } + self.export_rec(&inner.0[0], parser); + w!(self, "\n
    \n"); + return; } w!(self, " ExporterInner<'buf> for Html<'buf> { // w!(self, "{{{}}}", inner.body)?; } Expr::Keyword(inner) => { - if inner.key.to_ascii_lowercase() == "include" { + if inner.key.eq_ignore_ascii_case("include") { w!(self, r#"
    "); @@ -561,7 +561,7 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { ", inner.name, inner.contents ); - let ret = latex_to_mathml(&formatted, DisplayStyle::Block); + let ret = latex_to_mathml(formatted, DisplayStyle::Block); // TODO/FIXME: this should be an error w!( self, @@ -876,13 +876,13 @@ impl<'buf> Html<'buf> { // get last heading, and check if its title is Footnotes, // if so, destroy it let heading_query = parser.pool.iter().rev().find(|node| { - if let Expr::Heading(head) = &node.obj { - if let Some(title) = &head.title { - if title.0 == "Footnotes\n" { - return true; - } - } + if let Expr::Heading(head) = &node.obj + && let Some(title) = &head.title + && title.0 == "Footnotes\n" + { + return true; } + false }); diff --git a/crates/org-exporter/src/include.rs b/crates/org-exporter/src/include.rs index 82dea92..5dfa67b 100644 --- a/crates/org-exporter/src/include.rs +++ b/crates/org-exporter/src/include.rs @@ -51,11 +51,11 @@ pub(crate) struct InclParams<'a> { /// parsed as org. block: Option>, // TODO - only_contents: bool, + _only_contents: bool, /// A range of lines from the file that will be included lines: Option>, // TODO - min_level: Option, + _min_level: Option, } impl<'a> InclParams<'a> { @@ -77,10 +77,9 @@ impl<'a> InclParams<'a> { provided_path = Path::new(file_chunk); } - let block: Option; let is_not_kwarg = |x: &&str| !x.starts_with(':'); - block = if let Some(potential_block) = params.next_if(is_not_kwarg) { + let block: Option = if let Some(potential_block) = params.next_if(is_not_kwarg) { Some(match potential_block { "example" => IncludeBlock::Example, "export" => { @@ -126,23 +125,20 @@ impl<'a> InclParams<'a> { } ":lines" => { if let Some(not_kwarg) = params.next_if(is_not_kwarg) { - let start: usize; - let end: usize; - let hyphen_ind = not_kwarg.find('-').ok_or(IncludeError::InvalidSyntax( "Lines pattern does not contain '-'".into(), ))?; - start = if hyphen_ind == 0 { + let start = if hyphen_ind == 0 { 0 } else { - usize::from_str_radix(¬_kwarg[..hyphen_ind], 10)? + not_kwarg[..hyphen_ind].parse()? }; - end = if hyphen_ind == (not_kwarg.len() - 1) { + let end = if hyphen_ind == (not_kwarg.len() - 1) { usize::MAX } else { - usize::from_str_radix(¬_kwarg[(hyphen_ind + 1)..], 10)? + not_kwarg[(hyphen_ind + 1)..].parse()? }; lines = Some(Range { start, end }); @@ -170,9 +166,9 @@ impl<'a> InclParams<'a> { Ok(Self { file: provided_path, block, - only_contents, + _only_contents: only_contents, lines, - min_level, + _min_level: min_level, }) } } @@ -219,7 +215,6 @@ pub(crate) fn include_handle<'a>( } let feed_str; - let parsed; // goal: create a string that can be parsed into our desired org object // HACK: for blocks, this involves wrapping the file in a #+begin_X to be interpreted literally @@ -274,7 +269,7 @@ pub(crate) fn include_handle<'a>( // TODO: minlevel // TODO: only-contents - parsed = parse_org(&feed_str); + let parsed = parse_org(&feed_str); // TODO/FIXME: expose these errors writer.export_rec(&parsed.pool.root_id(), &parsed); diff --git a/crates/org-exporter/src/org.rs b/crates/org-exporter/src/org.rs index d20b205..f487e3a 100644 --- a/crates/org-exporter/src/org.rs +++ b/crates/org-exporter/src/org.rs @@ -61,7 +61,7 @@ impl<'buf> Exporter<'buf> for Org<'buf> { errors: Vec::new(), }; - obj.export_rec(&parsed.pool.root_id(), &parsed); + obj.export_rec(&parsed.pool.root_id(), parsed); if obj.errors().is_empty() { Ok(()) @@ -75,7 +75,7 @@ impl<'buf> ExporterInner<'buf> for Org<'buf> { fn export_macro_buf<'inp, T: fmt::Write>( input: &'inp str, buf: &'buf mut T, - conf: ConfigOptions, + _conf: ConfigOptions, ) -> core::result::Result<(), Vec> { let parsed = org_parser::parse_macro_call(input); @@ -359,14 +359,13 @@ impl<'buf> ExporterInner<'buf> for Org<'buf> { w!(self, "{{{}}}", inner.body); } Expr::Keyword(inner) => { - if inner.key.to_ascii_lowercase() == "include" { - if let Err(e) = include_handle(inner.val, self) { - self.errors().push(ExportError::LogicError { - span: node.start..node.end, - source: LogicErrorKind::Include(e), - }); - return; - } + if inner.key.eq_ignore_ascii_case("include") + && let Err(e) = include_handle(inner.val, self) + { + self.errors().push(ExportError::LogicError { + span: node.start..node.end, + source: LogicErrorKind::Include(e), + }); } } Expr::LatexEnv(inner) => { @@ -601,7 +600,6 @@ impl<'buf> ExporterInner<'buf> for Org<'buf> { Org::export_macro_buf(&p, self, self.config_opts().clone()) { self.errors().append(&mut err_vec); - return; } } Cow::Borrowed(r) => { diff --git a/crates/org-exporter/src/utils.rs b/crates/org-exporter/src/utils.rs index 2be8bce..87b9c3e 100644 --- a/crates/org-exporter/src/utils.rs +++ b/crates/org-exporter/src/utils.rs @@ -23,18 +23,15 @@ impl Options { let ret = options.split_ascii_whitespace(); let mut toc = None; for optpair in ret { - if let Some((opt, val)) = optpair.split_once(':') { - match opt { - "toc" => { - toc = if val == "nil" { - None - } else if let Ok(num) = val.parse::() { - Some(num) - } else { - Some(6) - }; - } - _ => {} + if let Some(("toc", val)) = optpair.split_once(':') { + { + toc = if val == "nil" { + None + } else if let Ok(num) = val.parse::() { + Some(num) + } else { + Some(6) + }; } } } @@ -66,22 +63,21 @@ pub(crate) fn process_toc<'a>( for sub_id in parser.pool[parser.pool.root_id()].obj.children().unwrap() { let node = &parser.pool[*sub_id]; - if let org_parser::Expr::Heading(heading) = &node.obj { - if global_toc_level >= heading.heading_level.into() { - if let Some(properties) = &heading.properties { - if let Some(val) = properties.get("unnumbered") { - if val == "notoc" { - continue; - } - } - } - tocs.push(handle_babies( - parser, - heading, - node.id_target.clone(), - global_toc_level, - )); + if let org_parser::Expr::Heading(heading) = &node.obj + && global_toc_level >= heading.heading_level.into() + { + if let Some(properties) = &heading.properties + && let Some(val) = properties.get("unnumbered") + && val == "notoc" + { + continue; } + tocs.push(handle_babies( + parser, + heading, + node.id_target.clone(), + global_toc_level, + )); } } @@ -113,29 +109,28 @@ fn handle_babies<'a>( if let Some(childs) = &heading.children { for child in childs { let node = &p.pool[*child]; - if let org_parser::Expr::Heading(heading) = &node.obj { - if global_toc_level >= heading.heading_level.into() { - if let Some(properties) = &heading.properties { - if let Some(val) = properties.get("unnumbered") { - if val == "notoc" { - continue; - } - } - } - children_vec.push(handle_babies( - p, - &heading, - node.id_target.clone(), - global_toc_level, - )); + if let org_parser::Expr::Heading(heading) = &node.obj + && global_toc_level >= heading.heading_level.into() + { + if let Some(properties) = &heading.properties + && let Some(val) = properties.get("unnumbered") + && val == "notoc" + { + continue; } + children_vec.push(handle_babies( + p, + heading, + node.id_target.clone(), + global_toc_level, + )); } } } TocItem { name: if let Some((_, node_ids)) = &heading.title { - &node_ids + node_ids } else { &[] }, diff --git a/crates/org-parser/src/element/drawer.rs b/crates/org-parser/src/element/drawer.rs index 705b0d5..0855c77 100644 --- a/crates/org-parser/src/element/drawer.rs +++ b/crates/org-parser/src/element/drawer.rs @@ -91,7 +91,7 @@ pub(crate) fn parse_property(mut cursor: Cursor) -> Result let name_match = cursor.fn_until(|chr| chr == COLON || chr == NEWLINE)?; - if name_match.obj.to_ascii_lowercase() != "properties" { + if !name_match.obj.eq_ignore_ascii_case("properties") { return Err(MatchError::InvalidLogic); } cursor.index = name_match.end; diff --git a/crates/org-parser/src/element/keyword.rs b/crates/org-parser/src/element/keyword.rs index 972a50d..76d3ba4 100644 --- a/crates/org-parser/src/element/keyword.rs +++ b/crates/org-parser/src/element/keyword.rs @@ -106,7 +106,7 @@ impl<'a> Parseable<'a> for Keyword<'a> { let prev = cursor.index; cursor.adv_till_byte(NEWLINE); // not mentioned in the spec, but org-element trims - let val = bytes_to_str(&cursor.byte_arr[prev..cursor.index].trim_ascii()); + let val = bytes_to_str(cursor.byte_arr[prev..cursor.index].trim_ascii()); cursor.next(); let end_index = cursor.index; @@ -166,7 +166,7 @@ impl<'a> Parseable<'a> for Keyword<'a> { // inspection phase let operation = match &parser.pool[c_id].obj { - Expr::Paragraph(par) if par.is_image(&parser) => { + Expr::Paragraph(par) if par.is_image(parser) => { Operation::CaptionImage(par.0[0]) } Expr::Table(_) => Operation::Table, diff --git a/crates/org-parser/src/element/table.rs b/crates/org-parser/src/element/table.rs index a661394..031d9fa 100644 --- a/crates/org-parser/src/element/table.rs +++ b/crates/org-parser/src/element/table.rs @@ -103,15 +103,15 @@ impl<'a> Parseable<'a> for TableRow { // implies horizontal rule // |- - if let Ok(val) = cursor.try_curr() { - if val == HYPHEN { - // adv_till_byte handles eof - cursor.adv_till_byte(b'\n'); - // cursor.index + 1 to start at the next | on the next line - return Ok(parser - .pool - .alloc(Self::Rule, start, cursor.index + 1, parent)); - } + if let Ok(val) = cursor.try_curr() + && val == HYPHEN + { + // adv_till_byte handles eof + cursor.adv_till_byte(b'\n'); + // cursor.index + 1 to start at the next | on the next line + return Ok(parser + .pool + .alloc(Self::Rule, start, cursor.index + 1, parent)); } let mut children: Vec = Vec::new(); diff --git a/crates/org-parser/src/node_pool.rs b/crates/org-parser/src/node_pool.rs index 1f97562..d5b7b9a 100644 --- a/crates/org-parser/src/node_pool.rs +++ b/crates/org-parser/src/node_pool.rs @@ -121,7 +121,7 @@ impl<'a> NodePool<'a> { NodeID(old_counter) } - pub fn iter(&self) -> impl Iterator> + DoubleEndedIterator> { + pub fn iter(&self) -> impl DoubleEndedIterator> { self.inner_vec.iter() } diff --git a/crates/org-parser/src/object/link.rs b/crates/org-parser/src/object/link.rs index c624df9..3973bc2 100644 --- a/crates/org-parser/src/object/link.rs +++ b/crates/org-parser/src/object/link.rs @@ -137,7 +137,7 @@ impl<'a> PathReg<'a> { cursor.next(); } - return Ok(cursor.clamp_backwards(begin_id)); + Ok(cursor.clamp_backwards(begin_id)) } fn parse_file(mut cursor: Cursor<'a>) -> Result<&'a str> { @@ -148,7 +148,7 @@ impl<'a> PathReg<'a> { cursor.next(); } - return Ok(cursor.clamp_backwards(begin_id)); + Ok(cursor.clamp_backwards(begin_id)) } } @@ -296,11 +296,12 @@ impl RegularLink<'_> { // Word-constituent characters are letters, digits, and the underscore. // source: https://www.gnu.org/software/grep/manual/grep.html pub(crate) fn parse_plain_link(mut cursor: Cursor<'_>) -> Result>> { - if let Ok(pre_byte) = cursor.peek_rev(1) { - if pre_byte.is_ascii_alphanumeric() { - return Err(MatchError::InvalidLogic); - } + if let Ok(pre_byte) = cursor.peek_rev(1) + && pre_byte.is_ascii_alphanumeric() + { + return Err(MatchError::InvalidLogic); } + let start = cursor.index; for (i, &protocol) in ORG_LINK_PARAMETERS.iter().enumerate() { diff --git a/crates/org-parser/src/parse.rs b/crates/org-parser/src/parse.rs index d3cf4d1..4f6e500 100644 --- a/crates/org-parser/src/parse.rs +++ b/crates/org-parser/src/parse.rs @@ -121,7 +121,7 @@ pub(crate) fn parse_element<'a>( } } if NEWLINE == cursor.try_curr()? && cursor.index - start >= 5 { - return Ok(parser.alloc(Expr::HorizontalRule, start, cursor.index + 1, parent)); + Ok(parser.alloc(Expr::HorizontalRule, start, cursor.index + 1, parent)) } else { Err(MatchError::InvalidLogic) } @@ -163,10 +163,10 @@ pub(crate) fn parse_element<'a>( } } LBRACK => { - if indentation_level == 0 { - if let ret @ Ok(_) = FootnoteDef::parse(parser, cursor, parent, no_para_opts) { - return ret; - } + if indentation_level == 0 + && let ret @ Ok(_) = FootnoteDef::parse(parser, cursor, parent, no_para_opts) + { + return ret; } } _ => {} @@ -241,12 +241,11 @@ pub(crate) fn parse_object<'a>( // ripped off handle_markup // TODO: abstract this // if we're in a link description, and we hit ]] , return the ending - if parse_opts.markup.contains(MarkupKind::Link) { - if let Ok(byte) = cursor.peek(1) { - if byte == RBRACK { - return Err(MatchError::MarkupEnd(MarkupKind::Link)); - } - } + if parse_opts.markup.contains(MarkupKind::Link) + && let Ok(byte) = cursor.peek(1) + && byte == RBRACK + { + return Err(MatchError::MarkupEnd(MarkupKind::Link)); } else if parse_opts.markup.contains(MarkupKind::FootnoteRef) { return Err(MatchError::MarkupEnd(MarkupKind::FootnoteRef)); } From 1ec5f3613fedd6e5293cb7cd23b027327dd740db Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 09:57:55 -0500 Subject: [PATCH 5/8] implement keyword elision suggestions --- crates/org-parser/src/element/heading.rs | 2 +- crates/org-parser/src/element/item.rs | 4 ++-- crates/org-parser/src/node_pool.rs | 4 ++-- crates/org-parser/src/object/emoji.rs | 2 +- crates/org-parser/src/object/entity.rs | 2 +- crates/org-parser/src/object/inline_src.rs | 6 +++--- crates/org-parser/src/types.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/org-parser/src/element/heading.rs b/crates/org-parser/src/element/heading.rs index 4d7a892..29e05ca 100644 --- a/crates/org-parser/src/element/heading.rs +++ b/crates/org-parser/src/element/heading.rs @@ -213,7 +213,7 @@ impl<'a> Heading<'a> { } } - fn parse_keyword(mut cursor: Cursor) -> Result> { + fn parse_keyword(mut cursor: Cursor<'_>) -> Result> { let start = cursor.index; cursor.skip_ws(); diff --git a/crates/org-parser/src/element/item.rs b/crates/org-parser/src/element/item.rs index 90e3557..03e4fd4 100644 --- a/crates/org-parser/src/element/item.rs +++ b/crates/org-parser/src/element/item.rs @@ -191,7 +191,7 @@ impl BulletKind { } // - [@4] -fn parse_counter_set(mut cursor: Cursor) -> Result> { +fn parse_counter_set(mut cursor: Cursor<'_>) -> Result> { let start = cursor.index; cursor.skip_ws(); cursor.word("[@")?; @@ -233,7 +233,7 @@ fn parse_counter_set(mut cursor: Cursor) -> Result> { }) } -fn parse_tag(mut cursor: Cursor) -> Result> { +fn parse_tag<'a>(mut cursor: Cursor<'a>) -> Result> { // - [@A] [X] | our tag is here :: remainder let start = cursor.index; cursor.curr_valid()?; diff --git a/crates/org-parser/src/node_pool.rs b/crates/org-parser/src/node_pool.rs index d5b7b9a..0c6f6b6 100644 --- a/crates/org-parser/src/node_pool.rs +++ b/crates/org-parser/src/node_pool.rs @@ -102,11 +102,11 @@ impl<'a> NodePool<'a> { target_id } - pub fn get(&self, id: NodeID) -> Option<&'a Node> { + pub fn get(&self, id: NodeID) -> Option<&'a Node<'_>> { self.inner_vec.get(id.0 as usize) } - pub fn get_mut(&mut self, id: NodeID) -> Option<&'a mut Node> { + pub fn get_mut(&mut self, id: NodeID) -> Option<&'a mut Node<'_>> { self.inner_vec.get_mut(id.0 as usize) } diff --git a/crates/org-parser/src/object/emoji.rs b/crates/org-parser/src/object/emoji.rs index a040e63..34fac5b 100644 --- a/crates/org-parser/src/object/emoji.rs +++ b/crates/org-parser/src/object/emoji.rs @@ -1897,7 +1897,7 @@ impl<'a> Parseable<'a> for Emoji<'a> { } } -pub(crate) fn parse_emoji(name: &str) -> Result { +pub(crate) fn parse_emoji<'a>(name: &'a str) -> Result> { if let Some(mapped_item) = EMOJI_MAP.get(name) { Ok(Emoji { name, diff --git a/crates/org-parser/src/object/entity.rs b/crates/org-parser/src/object/entity.rs index 4461c4b..71f532f 100644 --- a/crates/org-parser/src/object/entity.rs +++ b/crates/org-parser/src/object/entity.rs @@ -400,7 +400,7 @@ pub struct Entity<'a> { pub mapped_item: &'a str, } -pub(crate) fn parse_entity(name: &str) -> Result { +pub(crate) fn parse_entity<'a>(name: &'a str) -> Result> { if let Some(mapped_item) = ENTITY_MAP.get(name) { Ok(Entity { name, mapped_item }) } else { diff --git a/crates/org-parser/src/object/inline_src.rs b/crates/org-parser/src/object/inline_src.rs index 7e344f8..961f387 100644 --- a/crates/org-parser/src/object/inline_src.rs +++ b/crates/org-parser/src/object/inline_src.rs @@ -67,14 +67,14 @@ impl<'a> Parseable<'a> for InlineSrc<'a> { impl<'a> InlineSrc<'a> { // the logic is exactly the same, except for the perimeters - fn parse_header(cursor: Cursor) -> Result> { + fn parse_header(cursor: Cursor<'_>) -> Result> { InlineSrc::parse_src(cursor, LBRACK, RBRACK) } - fn parse_body(cursor: Cursor) -> Result> { + fn parse_body(cursor: Cursor<'_>) -> Result> { InlineSrc::parse_src(cursor, LBRACE, RBRACE) } #[inline(always)] - fn parse_src(mut cursor: Cursor, lperim: u8, rperim: u8) -> Result> { + fn parse_src(mut cursor: Cursor<'_>, lperim: u8, rperim: u8) -> Result> { // Brackets have to be balanced // -1 for left bracket // +1 for right bracket diff --git a/crates/org-parser/src/types.rs b/crates/org-parser/src/types.rs index 34b4fc8..39f3792 100644 --- a/crates/org-parser/src/types.rs +++ b/crates/org-parser/src/types.rs @@ -45,7 +45,7 @@ pub type NodeCache = HashMap; pub(crate) fn process_attrs<'a>( mut cursor: Cursor<'a>, -) -> Result<(Cursor, HashMap<&'a str, &'a str>)> { +) -> Result<(Cursor<'a>, HashMap<&'a str, &'a str>)> { let mut new_attrs: HashMap<&'a str, &'a str> = HashMap::new(); loop { match cursor.try_curr()? { From c4b41338a9c7335cdd8278e8168537ce138aff0e Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 11:11:26 -0500 Subject: [PATCH 6/8] add caption tests and make table work --- crates/org-exporter/src/html.rs | 43 +++++++++++++++++++++++--- crates/org-parser/src/element/table.rs | 23 +++++++++++++- crates/org-parser/src/object/link.rs | 25 ++++++++++++++- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/crates/org-exporter/src/html.rs b/crates/org-exporter/src/html.rs index 5adda83..12617ca 100644 --- a/crates/org-exporter/src/html.rs +++ b/crates/org-exporter/src/html.rs @@ -446,7 +446,9 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { { w!(self, "
    \n"); if let Some(affiliate) = link.caption { + w!(self, "
    \n"); self.export_rec(&affiliate, parser); + w!(self, "
    \n"); } self.export_rec(&inner.0[0], parser); w!(self, "\n
    \n"); @@ -671,6 +673,11 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { self.prop(node); w!(self, ">\n"); + if let Some(affiliate) = inner.caption { + w!(self, "\n"); + self.export_rec(&affiliate, parser); + w!(self, "\n"); + } for id in &inner.children { self.export_rec(id, parser); } @@ -778,9 +785,10 @@ impl<'buf> ExporterInner<'buf> for Html<'buf> { Expr::Affiliated(inner) => match inner { Affiliated::Name(_id) => {} Affiliated::Caption(contents) => { - w!(self, "
    \n"); + // NOTE: table uses . images use
    . + // don't want to add complexity to the type to handle these, + // so let the parents handle it self.export_rec(contents, parser); - w!(self, "
    \n"); } Affiliated::Attr { .. } => {} }, @@ -1327,7 +1335,8 @@ mysterious
    a, r#"
    bmc.jpg -
    "# + +"# ); } @@ -1343,7 +1352,8 @@ mysterious a, r#"
    Org-mode-unicorn.svg -
    "# + +"# ); } @@ -1413,7 +1423,7 @@ here } #[test] - fn caption_with_child() { + fn link_caption() { let a = r#" #+caption: yes [[suki.jpg]] @@ -1427,6 +1437,29 @@ here suki.jpg +"# + ) + } + + #[test] + fn tabale_caption() { + let a = r#" +#+caption: i am a table +|a|b|c +"#; + + assert_eq!( + html_export(a), + r#" + + + + + + +
    +

    i am a table

    +
    abc
    "# ) } diff --git a/crates/org-parser/src/element/table.rs b/crates/org-parser/src/element/table.rs index 031d9fa..337985b 100644 --- a/crates/org-parser/src/element/table.rs +++ b/crates/org-parser/src/element/table.rs @@ -138,7 +138,7 @@ impl<'a> Parseable<'a> for TableRow { #[cfg(test)] mod tests { - use crate::{Expr, expr_in_pool, parse_org}; + use crate::{Expr, element::Affiliated, expr_in_pool, parse_org}; #[test] fn basic_table() { @@ -283,4 +283,25 @@ word let tab = expr_in_pool!(pool, Table).unwrap(); assert_eq!(tab.rows, 1); } + + #[test] + fn table_caption() { + let input = r" +#+caption: i am a table +|a|b|c + +"; + + let parser = parse_org(input); + let image_link = expr_in_pool!(parser, Table).unwrap(); + if let Some(cap_id) = image_link.caption + && let Expr::Affiliated(Affiliated::Caption(aff)) = &parser.pool[cap_id].obj + && let Expr::Paragraph(par) = &parser.pool[*aff].obj + && let Expr::Plain(text) = parser.pool[par.0[0]].obj + { + assert_eq!(text, " i am a table"); + } else { + panic!() + }; + } } diff --git a/crates/org-parser/src/object/link.rs b/crates/org-parser/src/object/link.rs index 3973bc2..06d8662 100644 --- a/crates/org-parser/src/object/link.rs +++ b/crates/org-parser/src/object/link.rs @@ -420,8 +420,9 @@ pub(crate) fn parse_angle_link<'a>( mod tests { use pretty_assertions::assert_eq; + use crate::element::Affiliated; use crate::expr_in_pool; - use crate::object::PlainLink; + use crate::object::{PlainLink, RegularLink}; use crate::parse_org; use crate::types::Expr; @@ -582,4 +583,26 @@ I'll be skipping over the instrumentals unless there's reason to. let pool = parse_org(input); pool.print_tree(); } + + #[test] + fn caption_link() { + let input = r" +#+caption: sing song +[[heathers.jpg]] + +"; + + let parser = parse_org(input); + let image_link = expr_in_pool!(parser, RegularLink).unwrap(); + if let Some(cap_id) = image_link.caption + && let Expr::Affiliated(Affiliated::Caption(aff)) = &parser.pool[cap_id].obj + && let Expr::Paragraph(par) = &parser.pool[*aff].obj + && let Expr::Plain(text) = parser.pool[par.0[0]].obj + { + // REVIEW: does the cap need to be trimmed + assert_eq!(text, " sing song"); + } else { + panic!() + }; + } } From c442996182085ceb2685e6db6e500a2bec9c0f46 Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 11:14:22 -0500 Subject: [PATCH 7/8] update versions --- crates/org-cli/Cargo.toml | 6 +++--- crates/org-exporter/Cargo.toml | 4 ++-- crates/org-parser/Cargo.toml | 2 +- pkg/aur/PKGBUILD | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/org-cli/Cargo.toml b/crates/org-cli/Cargo.toml index fa75b80..d133945 100644 --- a/crates/org-cli/Cargo.toml +++ b/crates/org-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "org-rust" -version = "0.1.17" +version = "0.1.18" description = "CLI tool for converting Org-Mode documents to other formats" keywords = ["org-mode", "parser"] categories = ["command-line-utilities"] @@ -30,8 +30,8 @@ clap = { version = "4.3.11", features=["derive"]} clap_complete = "4.3.2" clap_mangen = "0.2.14" serde = { version = "1.0.196", features=["derive"]} -org-exporter = { version = "0.1.8", path = "../org-exporter", package = "org-rust-exporter" } -org-parser = { version = "0.1.5", path = "../org-parser", package = "org-rust-parser" } +org-exporter = { version = "0.1.9", path = "../org-exporter", package = "org-rust-exporter" } +org-parser = { version = "0.1.6", path = "../org-parser", package = "org-rust-parser" } # [[bin]] diff --git a/crates/org-exporter/Cargo.toml b/crates/org-exporter/Cargo.toml index d51a246..3739620 100644 --- a/crates/org-exporter/Cargo.toml +++ b/crates/org-exporter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "org-rust-exporter" -version = "0.1.8" +version = "0.1.9" description = "exporter for org mode documents parsed with `org-rust-parser`" homepage.workspace = true @@ -14,7 +14,7 @@ rust-version.workspace = true [dependencies] latex2mathml = "0.2.3" memchr = "2.5.0" -org-parser = { version = "0.1.5", path = "../org-parser", package = "org-rust-parser" } +org-parser = { version = "0.1.6", path = "../org-parser", package = "org-rust-parser" } phf = {version = "0.11.1", features = ["macros"]} thiserror = "1.0.63" diff --git a/crates/org-parser/Cargo.toml b/crates/org-parser/Cargo.toml index eb4688b..235af1a 100644 --- a/crates/org-parser/Cargo.toml +++ b/crates/org-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "org-rust-parser" -version = "0.1.5" +version = "0.1.6" description = "parser for org mode documents" homepage.workspace = true diff --git a/pkg/aur/PKGBUILD b/pkg/aur/PKGBUILD index 22d7ef4..2bebe6c 100644 --- a/pkg/aur/PKGBUILD +++ b/pkg/aur/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: aquabeam pkgname=org-rust -pkgver=0.1.17 +pkgver=0.1.18 pkgrel=1 url=https://github.com/hydrobeam/org-rust pkgdesc='CLI tool for converting Org-Mode documents to other formats' From 33d6e1a0b2a6b2eb219d23837560599fd38e7683 Mon Sep 17 00:00:00 2001 From: Laith Date: Mon, 17 Nov 2025 11:35:43 -0500 Subject: [PATCH 8/8] feat(org-wasm): update webpack deps --- crates/org-wasm/Cargo.toml | 2 +- crates/org-wasm/editor.ts | 2 +- crates/org-wasm/package-lock.json | 623 +++++++++++++----------------- crates/org-wasm/package.json | 2 +- crates/org-wasm/webpack.config.js | 3 - 5 files changed, 271 insertions(+), 361 deletions(-) diff --git a/crates/org-wasm/Cargo.toml b/crates/org-wasm/Cargo.toml index 1a7d63c..384e7e7 100644 --- a/crates/org-wasm/Cargo.toml +++ b/crates/org-wasm/Cargo.toml @@ -2,7 +2,7 @@ name = "org-wasm" version = "0.1.0" authors = ["Laith Bahodi "] -edition = "2018" +edition = "2024" [lib] crate-type = ["cdylib", "rlib"] diff --git a/crates/org-wasm/editor.ts b/crates/org-wasm/editor.ts index 997a531..94ab199 100644 --- a/crates/org-wasm/editor.ts +++ b/crates/org-wasm/editor.ts @@ -1,7 +1,7 @@ import { Parser, Tree, Input, PartialParse, TreeFragment, NodeSet, NodeType } from "@lezer/common"; import { defineLanguageFacet, Language, languageDataProp } from "@codemirror/language"; -import { syntaxable_entites } from "./pkg" +import { syntaxable_entites } from "./pkg/org_wasm" import { styleTags, tags } from "@lezer/highlight"; export class ParserAdapter extends Parser { diff --git a/crates/org-wasm/package-lock.json b/crates/org-wasm/package-lock.json index ea3780e..edee767 100644 --- a/crates/org-wasm/package-lock.json +++ b/crates/org-wasm/package-lock.json @@ -30,7 +30,7 @@ "terser-webpack-plugin": "^5.3.9", "ts-loader": "^9.4.3", "typescript": "^5.1.3", - "webpack": "^5.87.0", + "webpack": "^5.102.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1" } @@ -38,6 +38,7 @@ "node_modules/@codemirror/commands": { "version": "6.2.4", "license": "MIT", + "peer": true, "dependencies": { "@codemirror/language": "^6.0.0", "@codemirror/state": "^6.2.0", @@ -49,6 +50,7 @@ "version": "6.8.0", "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.8.0.tgz", "integrity": "sha512-r1paAyWOZkfY0RaYEZj3Kul+MiQTEbDvYqf8gPGaRvNneHXCmfSaAVFjwRUPlgxS8yflMxw2CTu6uCMp8R8A2g==", + "peer": true, "dependencies": { "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.0.0", @@ -61,6 +63,7 @@ "node_modules/@codemirror/search": { "version": "6.5.0", "license": "MIT", + "peer": true, "dependencies": { "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.0.0", @@ -69,11 +72,13 @@ }, "node_modules/@codemirror/state": { "version": "6.2.1", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@codemirror/view": { "version": "6.13.2", "license": "MIT", + "peer": true, "dependencies": { "@codemirror/state": "^6.1.4", "style-mod": "^4.0.0", @@ -159,19 +164,16 @@ "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.18", + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "dev": true, - "license": "MIT" - }, "node_modules/@leichtgewicht/ip-codec": { "version": "2.0.4", "dev": true, @@ -271,7 +273,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.40.2", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", + "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", "dev": true, "license": "MIT", "dependencies": { @@ -280,7 +284,9 @@ } }, "node_modules/@types/eslint-scope": { - "version": "3.7.4", + "version": "3.7.7", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", + "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", "dev": true, "license": "MIT", "dependencies": { @@ -289,7 +295,9 @@ } }, "node_modules/@types/estree": { - "version": "1.0.1", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, "license": "MIT" }, @@ -350,7 +358,9 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.12", + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true, "license": "MIT" }, @@ -435,57 +445,73 @@ "license": "MIT" }, "node_modules/@webassemblyjs/ast": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", + "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/helper-numbers": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6" + "@webassemblyjs/helper-numbers": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2" } }, "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz", + "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==", "dev": true, "license": "MIT" }, "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz", + "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==", "dev": true, "license": "MIT" }, "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.14.1.tgz", + "integrity": "sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==", "dev": true, "license": "MIT" }, "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz", + "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.11.6", - "@webassemblyjs/helper-api-error": "1.11.6", + "@webassemblyjs/floating-point-hex-parser": "1.13.2", + "@webassemblyjs/helper-api-error": "1.13.2", "@xtuc/long": "4.2.2" } }, "node_modules/@webassemblyjs/helper-wasm-bytecode": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz", + "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==", "dev": true, "license": "MIT" }, "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.14.1.tgz", + "integrity": "sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6" + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/wasm-gen": "1.14.1" } }, "node_modules/@webassemblyjs/ieee754": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.13.2.tgz", + "integrity": "sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==", "dev": true, "license": "MIT", "dependencies": { @@ -493,7 +519,9 @@ } }, "node_modules/@webassemblyjs/leb128": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.13.2.tgz", + "integrity": "sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -501,67 +529,79 @@ } }, "node_modules/@webassemblyjs/utf8": { - "version": "1.11.6", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.13.2.tgz", + "integrity": "sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==", "dev": true, "license": "MIT" }, "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.14.1.tgz", + "integrity": "sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/helper-wasm-section": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-opt": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6", - "@webassemblyjs/wast-printer": "1.11.6" + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/helper-wasm-section": "1.14.1", + "@webassemblyjs/wasm-gen": "1.14.1", + "@webassemblyjs/wasm-opt": "1.14.1", + "@webassemblyjs/wasm-parser": "1.14.1", + "@webassemblyjs/wast-printer": "1.14.1" } }, "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.14.1.tgz", + "integrity": "sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/ieee754": "1.11.6", - "@webassemblyjs/leb128": "1.11.6", - "@webassemblyjs/utf8": "1.11.6" + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/ieee754": "1.13.2", + "@webassemblyjs/leb128": "1.13.2", + "@webassemblyjs/utf8": "1.13.2" } }, "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.14.1.tgz", + "integrity": "sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6" + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/wasm-gen": "1.14.1", + "@webassemblyjs/wasm-parser": "1.14.1" } }, "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.14.1.tgz", + "integrity": "sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-api-error": "1.11.6", - "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/ieee754": "1.11.6", - "@webassemblyjs/leb128": "1.11.6", - "@webassemblyjs/utf8": "1.11.6" + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-api-error": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/ieee754": "1.13.2", + "@webassemblyjs/leb128": "1.13.2", + "@webassemblyjs/utf8": "1.13.2" } }, "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.6", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz", + "integrity": "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==", "dev": true, "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.14.1", "@xtuc/long": "4.2.2" } }, @@ -608,11 +648,15 @@ }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", "dev": true, "license": "BSD-3-Clause" }, "node_modules/@xtuc/long": { "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", "dev": true, "license": "Apache-2.0" }, @@ -629,9 +673,12 @@ } }, "node_modules/acorn": { - "version": "8.9.0", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -639,23 +686,31 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-assertions": { - "version": "1.9.0", + "node_modules/acorn-import-phases": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz", + "integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==", "dev": true, "license": "MIT", + "engines": { + "node": ">=10.13.0" + }, "peerDependencies": { - "acorn": "^8" + "acorn": "^8.14.0" } }, "node_modules/ajv": { - "version": "6.12.6", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -678,32 +733,17 @@ } } }, - "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.12.0", + "node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", "dev": true, "license": "MIT", "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "fast-deep-equal": "^3.1.3" }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats/node_modules/json-schema-traverse": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/ajv-keywords": { - "version": "3.5.2", - "dev": true, - "license": "MIT", "peerDependencies": { - "ajv": "^6.9.1" + "ajv": "^8.8.2" } }, "node_modules/ansi-html-community": { @@ -774,6 +814,16 @@ "dev": true, "license": "MIT" }, + "node_modules/baseline-browser-mapping": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.29.tgz", + "integrity": "sha512-sXdt2elaVnhpDNRDz+1BDx1JQoJRuNk7oVlAlbGiFkLikHCAQiccexF/9e91zVi6RCgqspl04aP+6Cnl9zRLrA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.js" + } + }, "node_modules/batch": { "version": "0.6.1", "dev": true, @@ -868,7 +918,9 @@ } }, "node_modules/browserslist": { - "version": "4.21.9", + "version": "4.28.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.0.tgz", + "integrity": "sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ==", "dev": true, "funding": [ { @@ -885,11 +937,13 @@ } ], "license": "MIT", + "peer": true, "dependencies": { - "caniuse-lite": "^1.0.30001503", - "electron-to-chromium": "^1.4.431", - "node-releases": "^2.0.12", - "update-browserslist-db": "^1.0.11" + "baseline-browser-mapping": "^2.8.25", + "caniuse-lite": "^1.0.30001754", + "electron-to-chromium": "^1.5.249", + "node-releases": "^2.0.27", + "update-browserslist-db": "^1.1.4" }, "bin": { "browserslist": "cli.js" @@ -944,7 +998,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001504", + "version": "1.0.30001755", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001755.tgz", + "integrity": "sha512-44V+Jm6ctPj7R52Na4TLi3Zri4dWUljJd+RDm+j8LtNCc/ihLCT+X1TzoOAkRETEWqjuLnh9581Tl80FvK7jVA==", "dev": true, "funding": [ { @@ -1335,32 +1391,6 @@ } } }, - "node_modules/css-minimizer-webpack-plugin/node_modules/ajv": { - "version": "8.12.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/ajv-keywords": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, "node_modules/css-minimizer-webpack-plugin/node_modules/jest-worker": { "version": "29.5.0", "dev": true, @@ -1375,29 +1405,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/css-minimizer-webpack-plugin/node_modules/json-schema-traverse": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/css-minimizer-webpack-plugin/node_modules/schema-utils": { - "version": "4.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/css-minimizer-webpack-plugin/node_modules/supports-color": { "version": "8.1.1", "dev": true, @@ -1718,7 +1725,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.433", + "version": "1.5.254", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.254.tgz", + "integrity": "sha512-DcUsWpVhv9svsKRxnSCZ86SjD+sp32SGidNB37KpqXJncp1mfUgKbHvBomE89WJDbfVKw1mdv5+ikrvd43r+Bg==", "dev": true, "license": "ISC" }, @@ -1731,7 +1740,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.15.0", + "version": "5.18.3", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz", + "integrity": "sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==", "dev": true, "license": "MIT", "dependencies": { @@ -1770,7 +1781,9 @@ "license": "MIT" }, "node_modules/escalade": { - "version": "3.1.1", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "license": "MIT", "engines": { @@ -1919,10 +1932,22 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", + "node_modules/fast-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", + "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", "dev": true, - "license": "MIT" + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" }, "node_modules/fastest-levenshtein": { "version": "1.0.16", @@ -2029,6 +2054,21 @@ "dev": true, "license": "ISC" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.1", "dev": true, @@ -2080,6 +2120,8 @@ }, "node_modules/glob-to-regexp": { "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", "dev": true, "license": "BSD-2-Clause" }, @@ -2292,32 +2334,6 @@ "dev": true, "license": "MIT" }, - "node_modules/html-minimizer-webpack-plugin/node_modules/ajv": { - "version": "8.12.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/html-minimizer-webpack-plugin/node_modules/ajv-keywords": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, "node_modules/html-minimizer-webpack-plugin/node_modules/jest-worker": { "version": "29.5.0", "dev": true, @@ -2332,29 +2348,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/html-minimizer-webpack-plugin/node_modules/json-schema-traverse": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/html-minimizer-webpack-plugin/node_modules/schema-utils": { - "version": "4.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/html-minimizer-webpack-plugin/node_modules/supports-color": { "version": "8.1.1", "dev": true, @@ -2758,7 +2751,9 @@ "license": "MIT" }, "node_modules/json-schema-traverse": { - "version": "0.4.1", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true, "license": "MIT" }, @@ -3014,7 +3009,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.12", + "version": "2.0.27", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", "dev": true, "license": "MIT" }, @@ -3203,7 +3200,9 @@ "license": "MIT" }, "node_modules/picocolors": { - "version": "1.0.0", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true, "license": "ISC" }, @@ -3295,6 +3294,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", @@ -3790,14 +3790,6 @@ "node": ">= 0.10" } }, - "node_modules/punycode": { - "version": "2.3.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/qs": { "version": "6.11.0", "dev": true, @@ -4000,13 +3992,16 @@ "license": "MIT" }, "node_modules/schema-utils": { - "version": "3.3.0", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.3.tgz", + "integrity": "sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA==", "dev": true, "license": "MIT", "dependencies": { - "@types/json-schema": "^7.0.8", - "ajv": "^6.12.5", - "ajv-keywords": "^3.5.2" + "@types/json-schema": "^7.0.9", + "ajv": "^8.9.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.1.0" }, "engines": { "node": ">= 10.13.0" @@ -4089,7 +4084,9 @@ "license": "MIT" }, "node_modules/serialize-javascript": { - "version": "6.0.1", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -4483,20 +4480,28 @@ } }, "node_modules/tapable": { - "version": "2.2.1", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", + "integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==", "dev": true, "license": "MIT", "engines": { "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" } }, "node_modules/terser": { - "version": "5.18.0", + "version": "5.44.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz", + "integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", + "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, @@ -4508,15 +4513,17 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.9", + "version": "5.3.14", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz", + "integrity": "sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/trace-mapping": "^0.3.17", + "@jridgewell/trace-mapping": "^0.3.25", "jest-worker": "^27.4.5", - "schema-utils": "^3.1.1", - "serialize-javascript": "^6.0.1", - "terser": "^5.16.8" + "schema-utils": "^4.3.0", + "serialize-javascript": "^6.0.2", + "terser": "^5.31.1" }, "engines": { "node": ">= 10.13.0" @@ -4610,6 +4617,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -4627,7 +4635,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.11", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.4.tgz", + "integrity": "sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==", "dev": true, "funding": [ { @@ -4645,8 +4655,8 @@ ], "license": "MIT", "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.2.0", + "picocolors": "^1.1.1" }, "bin": { "update-browserslist-db": "cli.js" @@ -4655,14 +4665,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/uri-js": { - "version": "4.4.1", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "dev": true, @@ -4702,7 +4704,9 @@ "license": "MIT" }, "node_modules/watchpack": { - "version": "2.4.0", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz", + "integrity": "sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==", "dev": true, "license": "MIT", "dependencies": { @@ -4722,34 +4726,38 @@ } }, "node_modules/webpack": { - "version": "5.87.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/eslint-scope": "^3.7.3", - "@types/estree": "^1.0.0", - "@webassemblyjs/ast": "^1.11.5", - "@webassemblyjs/wasm-edit": "^1.11.5", - "@webassemblyjs/wasm-parser": "^1.11.5", - "acorn": "^8.7.1", - "acorn-import-assertions": "^1.9.0", - "browserslist": "^4.14.5", + "version": "5.102.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.102.1.tgz", + "integrity": "sha512-7h/weGm9d/ywQ6qzJ+Xy+r9n/3qgp/thalBbpOi5i223dPXKi04IBtqPN9nTd+jBc7QKfvDbaBnFipYp4sJAUQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@types/eslint-scope": "^3.7.7", + "@types/estree": "^1.0.8", + "@types/json-schema": "^7.0.15", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wasm-edit": "^1.14.1", + "@webassemblyjs/wasm-parser": "^1.14.1", + "acorn": "^8.15.0", + "acorn-import-phases": "^1.0.3", + "browserslist": "^4.26.3", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.15.0", + "enhanced-resolve": "^5.17.3", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.9", + "graceful-fs": "^4.2.11", "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", - "schema-utils": "^3.2.0", - "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.7", - "watchpack": "^2.4.0", - "webpack-sources": "^3.2.3" + "schema-utils": "^4.3.3", + "tapable": "^2.3.0", + "terser-webpack-plugin": "^5.3.11", + "watchpack": "^2.4.4", + "webpack-sources": "^3.3.3" }, "bin": { "webpack": "bin/webpack.js" @@ -4771,6 +4779,7 @@ "version": "5.1.4", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", @@ -4833,55 +4842,6 @@ "webpack": "^4.0.0 || ^5.0.0" } }, - "node_modules/webpack-dev-middleware/node_modules/ajv": { - "version": "8.12.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/webpack-dev-middleware/node_modules/ajv-keywords": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/webpack-dev-middleware/node_modules/json-schema-traverse": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/webpack-dev-middleware/node_modules/schema-utils": { - "version": "4.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/webpack-dev-server": { "version": "4.15.1", "dev": true, @@ -4940,55 +4900,6 @@ } } }, - "node_modules/webpack-dev-server/node_modules/ajv": { - "version": "8.12.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/webpack-dev-server/node_modules/ajv-keywords": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/webpack-dev-server/node_modules/json-schema-traverse": { - "version": "1.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/webpack-dev-server/node_modules/schema-utils": { - "version": "4.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 12.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/webpack-merge": { "version": "5.9.0", "dev": true, @@ -5002,7 +4913,9 @@ } }, "node_modules/webpack-sources": { - "version": "3.2.3", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.3.3.tgz", + "integrity": "sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==", "dev": true, "license": "MIT", "engines": { diff --git a/crates/org-wasm/package.json b/crates/org-wasm/package.json index 2220b64..3844011 100644 --- a/crates/org-wasm/package.json +++ b/crates/org-wasm/package.json @@ -32,7 +32,7 @@ "terser-webpack-plugin": "^5.3.9", "ts-loader": "^9.4.3", "typescript": "^5.1.3", - "webpack": "^5.87.0", + "webpack": "^5.102.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1" } diff --git a/crates/org-wasm/webpack.config.js b/crates/org-wasm/webpack.config.js index 6303b77..c099d21 100644 --- a/crates/org-wasm/webpack.config.js +++ b/crates/org-wasm/webpack.config.js @@ -1,6 +1,3 @@ -// const path = require('path'); -// const HtmlWebpackPlugin = require('html-webpack-plugin'); -// import HtmlWebpackPlugin from 'html-webpack-plugin'; import path from 'path'; import * as url from 'url'; const __dirname = url.fileURLToPath(new URL('.', import.meta.url));