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

The subtitle is omitted when writing rST #4803

Closed
danse opened this issue Jul 31, 2018 · 5 comments
Closed

The subtitle is omitted when writing rST #4803

danse opened this issue Jul 31, 2018 · 5 comments

Comments

@danse
Copy link
Contributor

danse commented Jul 31, 2018

In the case of rST the subtitle is rendered within the $title variable rather than being handled as a separate template field. Besides this, the rendering of the subtitle is fragile due to a pattern match which causes subtitles to be discarded in the many cases when the structure of the metadata field does not match the pattern. For instance given the following template and native document, no subtitle is rendered:

 rotterdam (master)*$ cat templates/template.rst 
$if(title)$
$title$

$endif$
$if(subtitle)$
$subtitle$

$endif$
 rotterdam (master)*$ cat sottotitolo.native 
Pandoc (Meta {unMeta = fromList [("subtitle",MetaInlines [Str "Un",Space,Str "breve",Space,Str "sottotitolo",Space,Str "che",Space,Str "spiega",Space,Str "di",Space,Str "cosa",Space,Str "si",Space,Str "tratta"]),("title",MetaInlines [Str "Titolo",Space,Str "del",Space,Str "documento"])]})
[Para [Str "Questo",Space,Str "documento",Space,Str "di",Space,Str "test",Space,Str "serve",Space,Str "a",Space,Str "provare",Space,Str "il",Space,Str "sottotitolo."]
,Para [Str "Altro",Space,Str "paragrafo."]]
 rotterdam (master)*$ pandoc sottotitolo.native -t rst --template template --data-dir . -s
====================
Titolo del documento
====================

 rotterdam (master)*$ 

I found that title and subtitle are enclosed in MetaInlines at least when coming from a .docx like sottotitolo.docx, so i would at least add a pattern match for MetaInlines and drop the Plain container.

I also found confusing not to be able to use $subtitle$ in a template, and it's important for my team to render a subtitle within an highlight directive rather than as a bordered title like it's currently hardcoded in the rST writer, so i would change this logic in order to have $subtitle$ as a regular template variable.

I'd be happy to learn about reasons which might have caused the choices above and could affect the way we are planning to address this

danse added a commit to italia/pandoc that referenced this issue Jul 31, 2018
in case of input formats like ODT or DOCX this doesn't change the
existing interface. this change will cause the subtitle not to be
rendered within the `$title$` template variable in the case of input
formats which parse the subtitle as a plain block
@jgm
Copy link
Owner

jgm commented Jul 31, 2018 via email

@mb21
Copy link
Collaborator

mb21 commented Jul 31, 2018

The RST writer could populate the title variable with mytitle\n=======

@jgm
Copy link
Owner

jgm commented Jul 31, 2018 via email

@danse
Copy link
Contributor Author

danse commented Jul 31, 2018

aha! yes, now i get it. I would opt for a dedicated variable. I would call it $titlerst, or $title-rst, or $titleRST, you know the style of meta variables better than me. This convention would be easy to use also in other formats when we want a smarter rendering of some metadata. I'd still keep $title and $subtitle available for the templates. If this solution works for you i will update the pull request tomorrow

@jgm
Copy link
Owner

jgm commented Jul 31, 2018 via email

danse added a commit to italia/pandoc that referenced this issue Aug 1, 2018


after this commit use `$titleblock` in order to get what was contained
in `$title` before, that is a title and subtitle rendered according to
the official rST method
http://docutils.sourceforge.net/docs/user/rst/quickstart.html#document-title-subtitle. from
now on, the `$title` and `$subtitle` metadata are available and they
simply carry the metadata values
@jgm jgm closed this as completed in 2661658 Aug 1, 2018
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