-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Markdown: recent pandoc --standalone writes not clear warnings about title #4048
Comments
+++ Roman Kuzmin [Nov 06 17 18:50 ]:
I recently moved from pandoc 1.x to 2.0.1.1 and noticed some new not
clear warnings.
Example, hello.md:
Hello
Command:
pandoc hello.md --standalone
Output:
> pandoc hello.md --standalone
[WARNING] This document format requires a nonempty <title> element.
Please specify either 'title' or 'pagetitle' in the metadata.
Falling back to 'hello'
<HTML output>
...
What does this warning mean?
What is wrong with the markdown file or the pandoc command?
It means what it says. HTML5 requires a nonempty title
element. You did not specify a title in the metadata (see
the manual under "metadata" for how to do this). So pandoc
is warning you that it's using the title "hello" (derived
from the filename) in order to have a valid title element.
This will show up in the title bar of browsers when they
look at this web page.
NB: This warning is written to stderr and this causes a lot of pain on
calling from
PowerShell (due to its own strange handling of stderr output of
external apps).
I wasn't aware of these issues. Can you elaborate?
By the way, if you don't want any warnings, just use
--quiet.
|
I see. Can this be done without a warning? If I get the default title which
There more than one, including subtle depending on environments and hosts. pandoc.exe hello.md --standalone --output hello.html 2>&1 As a result, I am getting something like this:
|
Is it this part?
Then it says it is related to the extension |
Here is the PowerShell known issue PowerShell/PowerShell#3813 and the coming (who knows when) fix PowerShell/PowerShell#5190 Currently PowerShell "wraps stderr as ErrorRecord". The result depends on the current settings and the host. It may fail, produce strange errors and output, etc. |
Well, that looks like a PowerShell problem, not a pandoc
problem. We don't really have an alternative to writing
the warnings to stderr, becaue pandoc can be used as a pipe,
writing its output to stdout, and if warnings went there
too, things would be messed up.
+++ Roman Kuzmin [Nov 06 17 20:38 ]:
… Here is the PowerShell known issue [1]PowerShell/PowerShell#5190
Currently PowerShell "wraps stderr as ErrorRecord". The result depends
on settings and the host. It may fail, produce strange errors and
output, etc.
—
You are receiving this because you commented.
Reply to this email directly, [2]view it on GitHub, or [3]mute the
thread.
References
1. PowerShell/PowerShell#5190
2. #4048 (comment)
3. https://github.com/notifications/unsubscribe-auth/AAAL5EyzyM7sdAwR3X7Q89JYEURQsj2iks5sz25CgaJpZM4QTs7W
|
+++ Roman Kuzmin [Nov 06 17 20:23 ]:
Then it says it is related to the extension pandoc_title_block.
But I am not using this extension in my command.
It's built into pandoc's markdown by default.
You can also use a YAML metadata block, or specify the
title on the command line `--metadata title="Blah"`.
|
Probably not: Example: % title
Hello Command:
Output:
|
Aha, this is what I am looking for. Thank you. No problem, if all is by design, please close. NB: IMHO it kind of violates the least surprise principle. I have to use not obvious tricks (documented, yes). I did not have to do this in the old version. Just my opinion. |
Hmm, no. The title is rendered in the document itself.... |
Example: % title
Hello Command:
Output html: <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Blah.</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.line-block{white-space: pre-line;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<h1 class="title">Blah.</h1>
</header>
<p>% title</p>
<p>Hello</p>
</body>
</html> In the browser it is rendered as
I did not mean |
You're specifying markdown_strict, which turns off pandoc
extensions.
+++ Roman Kuzmin [Nov 06 17 23:05 ]:
… It's built into pandoc's markdown by default.
Probably not:
Example:
% title
Hello
Command:
pandoc hello.md --standalone --from=markdown_strict --output hello.html
Output:
C:\tmp\_171106_195128_pandoc_stderr>pandoc hello.md --standalone --from=markdown
_strict --output hello.html
[WARNING] This document format requires a nonempty <title> element.
Please specify either 'title' or 'pagetitle' in the metadata.
Falling back to 'hello'
—
You are receiving this because you commented.
Reply to this email directly, [1]view it on GitHub, or [2]mute the
thread.
References
1. #4048 (comment)
2. https://github.com/notifications/unsubscribe-auth/AAAL5AHk3kJWMGJSr7A9CEFJ9ZztlVT5ks5sz5C9gaJpZM4QTs7W
|
|
+++ Roman Kuzmin [Nov 06 17 23:11 ]:
NB: IMHO it kind of violates the least surprise principle. I have to
use not obvious tricks (documented, yes). I did not have to do this in
the old version. Just my opinion.
The old version would just happily produce an invalid HTML5
document. If we don't want to do that, we need to put
something in the title element, and I think a warning
to the user that we're populating the title element with
text they didn't explicitly specify is appropriate in that case.
Better to be surprised by a warning than surprised by
something inserted without your knowledge into the document
itself.
|
+++ Roman Kuzmin [Nov 06 17 23:18 ]:
Aha, this is what I am looking for. Thank you.
Hmm, no. The title is rendered in the document itself....
If you don't want that, then set pagetitle instead of title
(as the warning suggests).
|
Well yes. These don't include pandoc-specific extensions either. |
Fixes #156 Idea to use --quiet came from here: jgm/pandoc#4048 Idea for previous solution (more targetted, more involved) came from here: rstudio/rmarkdown@6558c3c
Definitely wasn't a clear message - i didn't even notice I finally was getting beautiful CSS, it just sounds like it's totally failing. (now also will use --metadata title="Blah" since I want to not set it in the markdown till I understand more) |
So what's the resolution here? Is there some way to put title metadata in a document of type gfm or markdown_strict? I certainly can't get pandoc to output such a gfm file from its own markdown format--it seems to strip the title off always. |
No---these formats don't support metadata. However, for `markdown_strict` (but not `gfm`) you can add in support for pandoc-style yaml metadata: `-f markdown_strict+yaml_metadata_block`. (This is not currently possible in `gfm` because here we just wrap a C library.)
stanford-scs <notifications@github.com> writes:
… So what's the resolution here? Is there some way to put title metadata in a document of type gfm or markdown_strict? I certainly can't get pandoc to output such a gfm file from its own markdown format--it seems to strip the title off always.
--
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub:
#4048 (comment)
|
This continues to be really frustrating. Are you just saying don't use gfm format as input for pandoc? Otherwise, can you just break it down in really stupid terms and spoon feed me a solution here for turning a gfm file into an html file? Basically I would like to preview mardown files before pushing them to github by translating them to HTML. Surely I can't be the only person to want to do this. But this annoying problem is such that it is not clear whether or not pandoc could be used for the purpose. I would love a definitive answer of yes or no, and if no, suggestions for other tools would of course be welcome... |
@stanford-scs this is what I ended up using: https://gist.github.com/FlorianHeigl/773411d0b2d180d5974508d4b716256a I lack the css/html understanding to make anything more of it, but it is my "everyday toolchain" now. Pending inotify or other extensions that will probably take another year. |
@stanford-scs if you have YAML metadata, but use GitHub extensions, you can try
(or use
|
Just hit this myself. One nice-to-have would be potentially suppressing that warning if |
Let's add |
Is it possible to achieve this behavior – that the file name is used as the basis for the I like this behavior, but would like to get rid of the warning. I understand the reason for the warning – something happens that the user didn't ask for – so it would be good to be able to ask for it. |
@allefeld you can always set the pagetitle variable explicitly in a defaults file (variables section). |
I recently moved from pandoc 1.x to 2.0.1.1 and noticed some new not clear warnings.
Example, hello.md:
Command:
Output:
What does this warning mean?
What is wrong with the markdown file or the pandoc command?
NB: This warning is written to stderr and this causes a lot of pain on calling from
PowerShell (due to its own strange handling of stderr output of external apps).
Related issues:
The text was updated successfully, but these errors were encountered: