-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Raw vs parsed metadata fields #2139
Comments
(Note that this doesn't happen when using |
Here's a clue:
The basic problem is that pandoc has no way of knowing that the command |
When you use |
Makes sense. As I see it, there are two ways to handle this: either modify 2015-05-07 19:16 GMT+03:00 John MacFarlane notifications@github.com:
|
+++ Nikolay Yakimov [May 07 15 09:25 ]:
I think |
Wow, I hadn’t realized that the metadata block, including header-includes, was parsed as Markdown. From where I stand, I agree that header-includes only makes sense as verbatim; but I don't know if there'd be other bizarre use cases out there. All in all, I'd appreciate if I could use this, whichever way, without having to resort to an external header file. Many thanks in advance! [edited: s/include-in-header/header-includes/] |
I hacked together a proof-of-concept code for inclusion of "raw strings" in metadata. Current work can be found on lierdakil/pandoc:rawstring-metadata branch (diff) This hacks on YAML object syntax. Example:
I'd like some comments on the viability of this idea. Another option is to add new flag to |
+++ Nikolay Yakimov [May 14 15 20:44 ]:
I think that ultimately we'll want this to be customizable Your proposal does have the advantage of not needing I suppose we could implement something now that could be naturally
(
This seems less useful to me. |
The more I think about your idea, the more I like it. And parenthesis syntax looks reasonable enough, I definitely prefer it to initially-proposed leading-underscore syntax. Now as for implementation, I think it's entirely possible to do without changes to It should be possible (and not that horrible) to hack templating engine, so that if a variable resolves to It's not entirely clear if we should do something similar when passing metadata to filters, or just pass these "format-dependent raw string" objects in their entirety. Thoughts? |
Following proposal in jgm#2139
So, I've played around with this idea for a little bit. See ec17fff for proof-of-concept implementation of above proposal. Code does need some polish, nevermind docs and tests, but general concept should be possible to grasp. I struggle a bit with HTML-based output though, since only HTML writer actually uses template engine, so we'll have to pass writer type to Also, I'm not sure about my implementation of |
This can be worked around with a simple filter which overloads flagged code/codeblock elements. |
I have been bitten by this issue a couple of times. Today I tried to set ---
mainfont: Alegreya
mainfontoptions: "UprightFeatures={SmallCapsFont=AlegreyaSC-Regular}"
--- It didn't work because Pandoc escaped the curly braces: \setmainfont[UprightFeatures=\{SmallCapsFont=AlegreyaSC-Regular\}]{Alegreya} I know this has been reported in #2565 -- just one more vote, hoping raw YAML fields could be possible some day. |
Why not make use of YAML tags? By now these tags are are ignored, so ---
foo: !!whatever "*bar*"
... is parsed equivalent to ---
foo: *bar*
... as
Metadata values passed on command line are not parsed in Markdown but end up as MetaString (or MetaBool). The former should also settable in YAML like this: ---
foo: !!MetaString "*bar*"
... as
This does not solve the full issue but at least gives a workaround. Last but not least disabling of Markdown parsing for selected YAML fields makes sense in other use cases too. P.S: It would be consistent to also support MetaBool but actually not needed much. ---
foo: !!MetaBool "true"
... should be parsed like ---
foo: true
... |
That's a really nice idea. +++ Jakob Voß [Sep 23 16 00:26 ]:
|
Just two observations:
Den 23 sep 2016 10:13 skrev "John MacFarlane" notifications@github.com:
|
A couple observations of my own:
So, at the moment, there seems to be no concise way of getting at yaml tags 2016-09-23 22:43 GMT+03:00 Benct Philip Jonsson notifications@github.com:
|
OK, I've lost enthusiasm for the Yaml tags idea.
or
This would require the following changes, I think:
This could be done without touching pandoc-types, I believe. More ambitiously we could change MetaString to a map from formats to raw strings. |
|
Another option would be to modify the Markdown reader so it parses
as |
To put yet another option on the table (again involving on the Markdown reader):
This would just require checking the key; if it ends with This would do the right thing in most cases, e.g. the raw latex would be omitted automatically in HTML output. And it would be easy to implement and easy to remember. |
I prefer the latter format with no addition nesting but I can't say why ;-)
I'd guess that it's
In any way the AST only contains a single metadata field |
No, the parser doesn't know what the output format is going
There are obviously some complexities here to consider... |
@jgm wrote:
Are you aware that the asterisk is a metacharacter in YAML? All keys containing it would have to be quoted. The underscore doesn't have that issue. |
I think that with 2b34337 we now have a decent solution to this problem.
|
Please comment here if you think that we should still support a syntax like
now that similar things can be achieved with the |
I think at least my problem will be solved by the new raw attribute. Thanks! |
I'm going to close this unless anyone really wants to bring it back. |
How to use this? My short run goal is to make this work in the YAML header
With pandoc 1.19, I get "_" in the tex file. My long run goal is to replace the explicit path with the result of an R chunk which retrieves a file path. This does work to retrieve the path, I can use it in export to HTML, but not PDF because "_" is inserted:
That works if package is installed in /usr/local/share, for example. However, if the R package is in user directory, where there is "_", its a total fail. |
But this only works with the dev version of pandoc, not with 1.19. |
I ran into this problem recently. I solved it by simply adding my metadata.yml file as the first of the array of input files.
|
%change color fot the institute
\setbeamercolor{institute in head/foot}{fg=black}
\makeatletter
%change the footline template to include frame numbers
\defbeamertemplate*{footline}{myminiframes theme}
{%
\begin{beamercolorbox}[colsep=1.5pt]{upper separation line foot}
\end{beamercolorbox}
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}%
\leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}%
\hfill%
{\usebeamerfont{institute in head/foot}\usebeamercolor[fg]{institute in head/foot}\insertshortinstitute}%
\end{beamercolorbox}%
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
{\usebeamerfont{title in head/foot}\insertshorttitle\hfill \insertframenumber/\inserttotalframenumber}%<-here
\end{beamercolorbox}%
\begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot}
\end{beamercolorbox}
}
\makeatother
%change look of sections in ToC
\defbeamertemplate*{section in toc}{mysections in toc}
{\leavevmode ---\,\inserttocsection\par}
%change look of subsections in ToC
\defbeamertemplate*{subsection in toc}{mysections in toc}
{\leavevmode\leftskip=2.5em --\,\inserttocsubsection\par} I want to customize Ilmenau beamer theme ( add the slide number into the footer ). I tried to add Raw latex with -header-includes but it said that they cannot parse YAML metadata. |
I do not use llmenau beamer theme, but I can show you a preamble code section that you can adjust to suit your needs. In the YAML header, include a code block like so:
This means that in your current directory, a file "beamerthemekucrmda.sty" must be found, and we also In the "beamerthemekucrmda.sty" file, here is example. Look down to the last line.
Do you see in the very last provision, we have inserted the "frame number, total frame number" piece at the end. I suspect that if you just put in that part, which goes with "short title", you will have good result. Only difficult part is reading your theme to figure out what name they use to refer to the part where you want to insert the number. I predict you will succeed! |
Thank you so much @pauljohn32, it worked like a charm. theme:
- CambridgeUS
colortheme:
- default
innertheme:
- rounded
outertheme:
- miniframes So with the outertheme: miniframes, you will get the miniframe and also the default footer of cambrideUS and you dont have to use an sty file because the CambrideUS is a theme Without Navigation Bar. |
Just for the record, there is no magic in this. Look at the file "beamerthemeCambridgeUS.sty", you see the outertheme is "infolines". Then look at "beamerouterthemeinfolines.sty" where you find the design for the top and bottom banners.
The Beamer themes are surprisingly simply, easy to adjust to your purpose. If you liked the other theme you were using, adjust it... |
Although not reflected in the discussion above, apparently some form of this was later implemented. See #5673. |
It is worth nothing that @jgm's code above no longer works:
produces the error
To fix this, the value needs to be wrapped in single quotes:
When using double quotes, pandoc will complain about an |
@rnwst you need to enclose strings containing backticks and '`\some{\LaTeX}{here}`{=latex}' |
Hello!
I have the following use-case of header-include:
When generating a PDF, the string
[a4paper]
gets converted to the invalid LaTeX sequence{[}a4paper{]}
:Am I doing something wrong?
I also tried the following variations, to no avail:
And:
May thanks in advance! My pandoc version is 1.13.2.
The text was updated successfully, but these errors were encountered: