oli-obk / pandoc-ast

35 stars 11 forks source link

Wrong api version? #15

Closed VoreckLukas closed 1 year ago

VoreckLukas commented 1 year ago

Im constructing a command to run pandoc, getting its json ast and then am trying to parse it:

    match pandoc_command.wait_with_output() {
        Ok(output) => {
            println!("{}", String::from_utf8_lossy(&output.stdout));
            pandoc_ast::Pandoc::from_json(&String::from_utf8_lossy(&output.stdout))
                .pandoc_api_version
        }
        Err(error) => {
            eprintln!("Couldn't run pandoc: {error}");
            exit(-1);
        }
    }

But it crashes (ill include the print statements output)

{"pandoc-api-version":[1,23,0,1],"meta":{},"blocks":[{"t":"Para","c":[{"t":"Str","c":"t"}]}]}

thread 'main' panicked at 'Unable to parse pandoc version from JSON. Please update your pandoc to at least version 1.18 or use an older version of `pandoc-ast`', /home/lukas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pandoc_ast-0.8.4/src/lib.rs:49:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It tells me to use at least version 1.18. but im on 3.1.6:

 ❯ pandoc --version
pandoc 3.1.6
oli-obk commented 1 year ago

Yea, I only expected version numbers with two components. Should be easy enough to add more components in https://github.com/oli-obk/pandoc-ast/blob/276c46d7206504f26cf558aa87e8e67c5d8ce5e2/src/lib.rs#L35

If you want to try it locally, just add a , .. to the slice pattern.

VoreckLukas commented 1 year ago

If you want to try it locally, just add a , .. to the slice pattern.

That completely fixed the issue! should i open a pr to upstream it? i feel bad for a pr that only has 4 new characters lol

oli-obk commented 1 year ago

Please do. Anything that takes steps away from me makes it easier for me to (motivate myself) publish a new version.

VoreckLukas commented 1 year ago

done

oli-obk commented 1 year ago

published as 0.8.5