Skip to content

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

@mgeisler

Description

@mgeisler

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 <martin@geisler.net>"]
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 <martin@geisler.net>"]
... 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 <martin@geisler.net>' ],
    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)
> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions