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

"Prelude.read: no parse" when giving -M with --template #5177

Closed
K4zuki opened this issue Dec 26, 2018 · 10 comments
Closed

"Prelude.read: no parse" when giving -M with --template #5177

K4zuki opened this issue Dec 26, 2018 · 10 comments

Comments

@K4zuki
Copy link
Sponsor

K4zuki commented Dec 26, 2018

condition

  • pandoc = 2.5
  • OS = Ubuntu 16.04
  • blank tex template = markdown/template.tex
  • simple markdown file = markdown/markdown.md
This is a pen

how to reproduce

  • input:
    pandoc -f markdown -t latex -M meta='1e' --template markdown/template.tex markdown/markdown.md

  • output:
    pandoc: Prelude.read: no parse

  • changing to meta='' stops error

  • meta='1e|3e|5e|7e|9e' causes error but 'e' does not

  • removing quote does not stop error

  • position of -M meta=1e does not stop error

  • similar with Error when html constains <ol start=''> #5162 ?

@jgm
Copy link
Owner

jgm commented Dec 26, 2018

Simple repro:

% echo "" | pandoc  -M foo=1e -s
pandoc: Prelude.read: no parse

@jgm
Copy link
Owner

jgm commented Dec 26, 2018

I confirm that this issue affects current HEAD (5101f43).

@mb21
Copy link
Collaborator

mb21 commented Dec 27, 2018

Interestingly even:

echo '' | pandoc -- -M foo=1e -s -f html -t native
pandoc: Prelude.read: no parse

The e looks suspiciously like something is trying to parse this as an exponential number, scientific notation. But what/where?

@mb21
Copy link
Collaborator

mb21 commented Dec 27, 2018

Reading to MetaInlines works:

cat foo.yaml
foo: "1e"

$ echo '' | stack exec pandoc -- --metadata-file foo.yaml -s -t native
Pandoc (Meta {unMeta = fromList [("foo",MetaInlines [Str "1e"])]})
[]

But -M would be reading to MetaString... possibly it's the Read instance on Many or something similar?

@mb21
Copy link
Collaborator

mb21 commented Dec 27, 2018

Stack trace:

$ echo '' | stack exec pandoc -- -M foo=1e -s -t native +RTS -xc
*** Exception (reporting due to +RTS -xc): (THUNK), stack trace: 
  Text.Pandoc.Class.liftIO,
  called from Text.Pandoc.Class.liftIOError,
  called from Text.Pandoc.Class.fileExists,
  called from Text.Pandoc.Class.readDataFile,
  called from Text.Pandoc.App.convertWithOpts,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK), stack trace: 
  Text.Pandoc.Class.liftIO,
  called from Text.Pandoc.Class.liftIOError,
  called from Text.Pandoc.Class.fileExists,
  called from Text.Pandoc.Class.readDataFile,
  called from Text.Pandoc.App.convertWithOpts,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: 
  Text.Pandoc.Class.liftIO,
  called from Text.Pandoc.Class.liftIOError,
  called from Text.Pandoc.Class.fileExists,
  called from Text.Pandoc.Class.readDataFile,
  called from Text.Pandoc.App.convertWithOpts,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace: 
  Data.YAML.Schema.CAF:lvl130_r1kBj
  --> evaluated by: Data.YAML.Schema.coreDecodeFloat.float,
  called from Data.YAML.Schema.coreDecodeFloat,
  called from Data.YAML.Schema.coreSchemaResolver.schemaResolverScalar.go,
  called from Data.YAML.Schema.scalarTag,
  called from Data.YAML.Schema.coreSchemaResolver.schemaResolverScalar,
  called from Data.YAML.Schema.coreSchemaResolver,
  called from Data.YAML.decodeNode'.failsafeLoader.\,
  called from Data.YAML.decodeNode'.failsafeLoader,
  called from Data.YAML.Loader.decodeLoader.goNode,
  called from Data.YAML.Loader.decodeLoader.goDoc,
  called from Data.YAML.Loader.>>=,
  called from Data.YAML.Loader.manyUnless,
  called from Data.YAML.Loader.decodeLoader.goStream,
  called from Data.YAML.Loader.runParserT,
  called from Data.YAML.Loader.decodeLoader,
  called from Data.YAML.decodeNode',
  called from Data.YAML.decodeNode,
  called from Data.YAML.decode,
  called from Data.YAML.decodeStrict,
  called from Text.Pandoc.App.readMetaValue,
  called from Text.Pandoc.App.addMeta.v',
  called from Text.Pandoc.App.addMeta,
  called from Text.Pandoc.App.addMetadata,
  called from Text.Pandoc.Class.runIO,
  called from Text.Pandoc.Class.runIOorExplode,
  called from Text.Pandoc.App.convertWithOpts.runIO',
  called from Text.Pandoc.App.convertWithOpts,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (base:GHC.Exception.SomeException), stack trace: 
  Data.YAML.Schema.CAF:lvl130_r1kBj
pandoc: Prelude.read: no parse
CallStack (from -prof):
  Data.YAML.Schema.CAF:lvl130_r1kBj (<no location info>)

@mb21
Copy link
Collaborator

mb21 commented Dec 27, 2018

Filed an upstream issue: haskell-hvr/HsYAML#7

@jgm
Copy link
Owner

jgm commented Dec 29, 2018 via email

@jgm
Copy link
Owner

jgm commented Jan 1, 2019

Interestingly we don't get the error if you include this metadata value in the YAML metadata in a markdown file. Only with -M.

@jgm
Copy link
Owner

jgm commented Jan 1, 2019

OK, we should be able to fix this in pandoc by using the failsafe schema instead of the json schema, which is used by default with decodeStrict, in Text.Pandoc.App's function readMetaValue.

@jgm
Copy link
Owner

jgm commented Jan 1, 2019

Note also this workaround:

echo '' | pandoc -M foo='!!text 1e' -s 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants