Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch between location and raw string for triple-quoted string #25

Open
mgeisler opened this issue May 4, 2022 · 0 comments
Open

Comments

@mgeisler
Copy link

mgeisler commented May 4, 2022

This is from thomaseizinger/set-crate-version#2 where @thomaseizinger asked me to try and reproduce the problem. I'm trying to use toml-patch to update the version number of a Rust crate. The crate description is a triple-quoted string and the full TOML file looks like this:

[package]
name = "lipsum"
version = "0.8.0"
authors = ["Martin Geisler <[email protected]>"]
description = """
Lipsum is a lorem ipsum text generation library. Use this if you need
filler or dummy text for your application.

The text is generated using a simple Markov chain, which you can also
instantiate to generate your own pieces of pseudo-random text.
"""
documentation = "https://docs.rs/lipsum/"
repository = "https://github.com/mgeisler/lipsum/"
readme = "README.md"

I can reproduce the problem with toml-patch alone:

% node
Welcome to Node.js v14.19.1.
Type ".help" for more information.
> const TOML = require('toml-patch');
> const existing = `
... [package]
... name = "lipsum"
... version = "0.8.0"
... authors = ["Martin Geisler <[email protected]>"]
... description = """
... Lipsum is a lorem ipsum text generation library. Use this if you need
... filler or dummy text for your application.
... 
... The text is generated using a simple Markov chain, which you can also
... instantiate to generate your own pieces of pseudo-random text.
... """
... documentation = "https://docs.rs/lipsum/"
... repository = "https://github.com/mgeisler/lipsum/"
... readme = "README.md"
... `
> TOML.parse(existing)
[Object: null prototype] {
  package: [Object: null prototype] {
    name: 'lipsum',
    version: '0.8.0',
    authors: [ 'Martin Geisler <[email protected]>' ],
    description: 'Lipsum is a lorem ipsum text generation library. Use this if you need\n' +
      'filler or dummy text for your application.\n' +
      '\n' +
      'The text is generated using a simple Markov chain, which you can also\n' +
      'instantiate to generate your own pieces of pseudo-random text.\n',
    documentation: 'https://docs.rs/lipsum/',
    repository: 'https://github.com/mgeisler/lipsum/',
    readme: 'README.md'
  }
}
> TOML.patch(existing, TOML.parse(existing))
Uncaught Error: Mismatch between location and raw string, expected 7 lines for """"
Lipsum is a lorem ipsum text generation library. Use this if you need
filler or dummy text for your application.

The text is generated using a simple Markov chain, which you can also
instantiate to generate your own pieces of pseudo-random text.
""""
    at write (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:27835)
    at String (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:27000)
    at r (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:15532)
    at r (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:15840)
    at n (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:15459)
    at r (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:15645)
    at n (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:15459)
    at traverse (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:16245)
    at toTOML (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:26453)
    at Object.patch (/home/mg/tmp/node_modules/toml-patch/dist/toml-patch.cjs.min.js:1:33281)
> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant