Parser error with toml engine and CRLF. #92

Closed
opened 2019-03-08 04:06:39 +00:00 by fimars · 5 comments
fimars commented 2019-03-08 04:06:39 +00:00 (Migrated from github.com)
  1. gray-matter with CRLF, work well.
  2. node-toml with CRLF, work well too.

BUT:

If you run the toml example of README with CRLF file, will get a parse error.

image

Minimal example repo here

1. `gray-matter` with CRLF, work well. 2. `node-toml` with CRLF, work well too. **BUT:** If you run the `toml` example of README with **CRLF file**, will get a parse error. ![image](https://user-images.githubusercontent.com/16299018/54006871-2a2ef400-419a-11e9-9145-aa83283a65bf.png) [Minimal example repo here](https://github.com/fimars/gray-matter-with-toml-and-CRLF/tree/master)
fimars commented 2019-03-08 06:22:22 +00:00 (Migrated from github.com)

I see the point, here of gray-matter output code like:

\r\n RawOfMatter \r

And node-toml doesn't trim the input thing for now. Maybe add trim here for engines or else, Any suggestions with this?

@robertmassaioli

I see the point, [here](https://github.com/jonschlinkert/gray-matter/blob/8a22958e0afd4b2e09c705becec1c35e76c4f0ee/index.js#L99) of `gray-matter` output code like: ``` \r\n RawOfMatter \r ``` And `node-toml` doesn't trim the input thing for now. Maybe add trim here for engines or else, Any suggestions with this? @robertmassaioli
robertmassaioli commented 2019-03-26 23:25:14 +00:00 (Migrated from github.com)

I can verify this just by modifying line 15 of examples/toml.js to be:

].join('\r\n');

The error message suggests that the problem is not in the gray-matter library though. It suggests that the error is in the toml package.

In fact, this error message:

throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);

Looks like it comes from the PEG.js library, which I assume the toml library is using internally.

Please go raise an issue here to get this problem fixed: https://github.com/BinaryMuse/toml-node

I can verify this just by modifying line 15 of `examples/toml.js` to be: ].join('\r\n'); The error message suggests that the problem is not in the `gray-matter` library though. It suggests that the error is in the `toml` package. In fact, this error message: > throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); Looks like it comes from the PEG.js library, which I assume the `toml` library is using internally. Please go raise an issue here to get this problem fixed: https://github.com/BinaryMuse/toml-node
fimars commented 2019-03-27 01:36:29 +00:00 (Migrated from github.com)

@robertmassaioli thanks for your reply, But don't you think it's a little strange to output \r as EOF

@robertmassaioli thanks for your reply, But don't you think it's a little strange to output `\r` as EOF
zachleat commented 2019-06-25 13:09:39 +00:00 (Migrated from github.com)

I think this should be reopened. It causes errors on TOML parsing on Windows machines.

Input file: https://github.com/11ty/eleventy/blob/master/test/stubs/custom-frontmatter/template-toml.njk#L1 JavaScript test case: https://github.com/11ty/eleventy/blob/master/test/TemplateTest.js#L1732

Build failure on Windows machines from this: https://travis-ci.org/11ty/eleventy/jobs/550051432 (Works on Linux and Mac https://travis-ci.org/11ty/eleventy/builds/550051427)

I think this should be reopened. It causes errors on TOML parsing on Windows machines. Input file: https://github.com/11ty/eleventy/blob/master/test/stubs/custom-frontmatter/template-toml.njk#L1 JavaScript test case: https://github.com/11ty/eleventy/blob/master/test/TemplateTest.js#L1732 Build failure on Windows machines from this: https://travis-ci.org/11ty/eleventy/jobs/550051432 (Works on Linux and Mac https://travis-ci.org/11ty/eleventy/builds/550051427)
redblue9771 commented 2019-12-03 14:03:36 +00:00 (Migrated from github.com)

I also think that this issue should be reopened to solve the bug that appears on windows

I also think that this issue should be reopened to solve the bug that appears on windows
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rtlabs-llm-agents/gms-gray-matter#92
No description provided.