jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.69k stars 3.39k forks source link

Other Markdown FrontMatter parse problem when generating ePub (stringify issue?) #8095

Open hoijui opened 2 years ago

hoijui commented 2 years ago

Multi-line title with ![](image)\n\nText is not recognized with -t epub, but is successfully parsed and used when generating Latex/PDF.

(a continuation of issue #8091)

pandoc 2.18 on debian testing

testing script:

#!/bin/sh

pandoc --version

echo
echo "ePub out -This prints a warning:"
# [WARNING] This document format requires a nonempty <title> element.
echo '---
title: |
  [![sample logo](https://i.imgur.com/I86rTVl.jpg){width=4cm}](#attributions)

  bla
---
' | pandoc -t epub -o /dev/null

echo
echo "ePub out (no sep.) - This works fine (No warning):"
echo '---
title: |
  [![sample logo](https://i.imgur.com/I86rTVl.jpg){width=4cm}](#attributions)
  bla
---
' | pandoc -t epub -o /dev/null

echo
echo "PDF out - This works fine (No warning):"
echo '---
title: |
  [![sample logo](https://i.imgur.com/I86rTVl.jpg){width=4cm}](#attributions)

  bla
---
' | pandoc -t pdf -o /dev/null

output:

pandoc 2.18
Compiled with pandoc-types 1.22.2, texmath 0.12.5, skylighting 0.12.3,
citeproc 0.7, ipynb 0.2, hslua 2.2.0
Scripting engine: Lua 5.4
User data directory: /home/user/.pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

ePub out -This prints a warning:
[WARNING] This document format requires a nonempty <title> element.
  Defaulting to '-' as the title.
  To specify a title, use 'title' in metadata or --metadata title="...".

ePub out (no sep.) - This works fine (No warning):

PDF out - This works fine (No warning):
jgm commented 2 years ago

I'm curious what you think the title should look like when it contains multiple paragraphs. If we applied stringify as we do with PDF output, we wouldn't get a warning, but I don't think it would look as you intend, since the contents would be smushed together.

hoijui commented 2 years ago

Well in my case, there would be only a single line of text (if images are removed). Also this case - image plus one line of text (with a separating line, as Markdown requires that to create a new-line) - is a common one. I agree though, that it would not work in the general case, if people use multiple lines of text. Then it is a question whether it should use only the first line of text, or smush them all together, or create a warning/error. what do you think?

jgm commented 2 years ago

A blank line in Markdown creates a new paragraph. If you just want a hard line break in the same paragraph, use two spaces + newline or backslash + newline.