5 Commits

Author SHA1 Message Date
Tom Alexander
320b5f8568 Publish version 0.1.15.
All checks were successful
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded
clippy Build clippy has succeeded
rustfmt Build rustfmt has succeeded
rust-foreign-document-test Build rust-foreign-document-test has succeeded
2024-01-28 17:12:45 -05:00
Tom Alexander
99b2af6c99 Fix clippy. 2024-01-28 17:11:18 -05:00
Tom Alexander
6e71acdb7d Update README.
Some checks failed
clippy Build clippy has failed
rustfmt Build rustfmt has succeeded
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded
2024-01-28 14:25:57 -05:00
Tom Alexander
8406d37991 Switch to using JSON for wasm.
Some checks failed
rust-build Build rust-build has failed
clippy Build clippy has failed
rustfmt Build rustfmt has succeeded
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-test Build rust-test has succeeded
serde_wasm_bindgen was silently dropping many attributes (I suspect it is triggered by serde flatten) so this switches to serializing to JSON for passing values from wasm to js.
2024-01-27 16:13:17 -05:00
Tom Alexander
64bb597908 Build bundler wasm target by default. 2024-01-26 21:17:40 -05:00
5 changed files with 14 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
[package] [package]
name = "organic" name = "organic"
version = "0.1.14" version = "0.1.15"
authors = ["Tom Alexander <tom@fizz.buzz>"] authors = ["Tom Alexander <tom@fizz.buzz>"]
description = "An org-mode parser." description = "An org-mode parser."
edition = "2021" edition = "2021"
@@ -52,6 +52,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
futures = { version = "0.3.28", optional = true } futures = { version = "0.3.28", optional = true }
gloo-utils = "0.2.0"
nom = "7.1.1" nom = "7.1.1"
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] } opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
opentelemetry-otlp = { version = "0.13.0", optional = true } opentelemetry-otlp = { version = "0.13.0", optional = true }

View File

@@ -7,6 +7,7 @@ MAKEFLAGS += --no-builtin-rules
TESTJOBS := 4 TESTJOBS := 4
OS:=$(shell uname -s) OS:=$(shell uname -s)
RELEASEFLAGS := RELEASEFLAGS :=
WASMTARGET := bundler # or web
ifeq ($(OS),Linux) ifeq ($(OS),Linux)
TESTJOBS:=$(shell nproc) TESTJOBS:=$(shell nproc)
@@ -32,7 +33,7 @@ release:
.PHONY: wasm .PHONY: wasm
wasm: wasm:
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm > cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
> wasm-bindgen --target web --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm > wasm-bindgen --target $(WASMTARGET) --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
.PHONY: clean .PHONY: clean
clean: clean:

View File

@@ -10,17 +10,16 @@ Currently, Organic parses most documents the same as the official org-mode parse
### Project Goals ### Project Goals
- We aim to provide perfect parity with the emacs org-mode parser. In that regard, any document that parses differently between Emacs and Organic is considered a bug. - We aim to provide perfect parity with the emacs org-mode parser. In that regard, any document that parses differently between Emacs and Organic is considered a bug.
- The parser should have minimal dependencies. This should reduce effort w.r.t.: security audits, legal compliance, portability. - The parser should have minimal dependencies.
- The parser should be usable everywhere. In the interest of getting org-mode used in as many places as possible, this parser should be usable by everyone everywhere. This means: - The parser should be usable everywhere. In the interest of getting org used in as many places as possible, this parser should be usable by everyone everywhere. This means:
- It must have a permissive license. - It must have a permissive license.
- We will investigate compiling to WASM. This is an important goal of the project and will definitely happen, but only after the parser has a more stable API. - It compiles to both natively and to wasm.
- We will investigate compiling to a C library for native linking to other code. This is more of a maybe-goal for the project. - We will investigate compiling to a C library for native linking to other code. This is more of a maybe-goal for the project.
### Project Non-Goals ### Project Non-Goals
- This project will not include an elisp engine since that would drastically increase the complexity of the code. Any features requiring an elisp engine will not be implemented (for example, Emacs supports embedded eval expressions in documents but this parser will never support that). - This project will not include an elisp engine since that would drastically increase the complexity of the code. Any features requiring an elisp engine will not be implemented (for example, Emacs supports embedded eval expressions in documents but this parser will never support that).
- This project is exclusively an org-mode **parser**. This limits its scope to roughly the output of `(org-element-parse-buffer)`. It will not render org-mode documents in other formats like HTML or LaTeX. - This project is exclusively an org-mode **parser**. This limits its scope to roughly the output of `(org-element-parse-buffer)`. It will not render org-mode documents in other formats like HTML or LaTeX.
### Project Maybe-Goals ### Project Maybe-Goals
- table.el support. Currently we support org-mode tables but org-mode also allows table.el tables. So far, their use in org-mode documents seems rather uncommon so this is a low-priority feature. - table.el support. Currently we support org-mode tables but org-mode also allows table.el tables. So far, their use in org-mode documents seems rather uncommon so this is a low-priority feature.
- Document editing support. I do not anticipate any advanced editing features to make editing ergonomic, but it should be relatively easy to be able to parse an org-mode document and serialize it back into org-mode. This would enable cool features to be built on top of the library like auto-formatters. To accomplish this feature, We'd have to capture all of the various separators and whitespace that we are currently simply throwing away. This would add many additional fields to the parsed structs and it would add more noise to the parsers themselves, so I do not want to approach this feature until the parser is more complete since it would make modifications and refactoring more difficult.
### Supported Versions ### Supported Versions
This project targets the version of Emacs and Org-mode that are built into the [organic-test docker image](docker/organic_test/Dockerfile). This is newer than the version of Org-mode that shipped with Emacs 29.1. The parser itself does not depend on Emacs or Org-mode though, so this only matters for development purposes when running the automated tests that compare against upstream Org-mode. This project targets the version of Emacs and Org-mode that are built into the [organic-test docker image](docker/organic_test/Dockerfile). This is newer than the version of Org-mode that shipped with Emacs 29.1. The parser itself does not depend on Emacs or Org-mode though, so this only matters for development purposes when running the automated tests that compare against upstream Org-mode.

View File

@@ -11,6 +11,7 @@ macro_rules! to_wasm {
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>, $wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> { ) -> Result<Self::Output, crate::error::CustomError> {
let $original = self; let $original = self;
#[allow(unused_braces)]
$fnbody $fnbody
} }
} }

View File

@@ -1,3 +1,6 @@
use gloo_utils::format::JsValueSerdeExt;
use wasm_bindgen::JsValue;
use crate::parser::parse_with_settings; use crate::parser::parse_with_settings;
use crate::settings::GlobalSettings; use crate::settings::GlobalSettings;
use crate::wasm::ParseResult; use crate::wasm::ParseResult;
@@ -8,17 +11,15 @@ pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) { let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) {
Ok(document) => document, Ok(document) => document,
Err(err) => { Err(err) => {
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err))) return JsValue::from_serde(&ParseResult::Error(format!("{:?}", err))).unwrap();
.unwrap();
} }
}; };
let to_wasm_context = ToWasmContext::new(org_contents); let to_wasm_context = ToWasmContext::new(org_contents);
let wasm_document = match rust_parsed.to_wasm(to_wasm_context) { let wasm_document = match rust_parsed.to_wasm(to_wasm_context) {
Ok(document) => document, Ok(document) => document,
Err(err) => { Err(err) => {
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err))) return JsValue::from_serde(&ParseResult::Error(format!("{:?}", err))).unwrap();
.unwrap();
} }
}; };
serde_wasm_bindgen::to_value(&ParseResult::Success(wasm_document)).unwrap() JsValue::from_serde(&ParseResult::Success(wasm_document)).unwrap()
} }