jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.54k stars 3.38k forks source link

feature: stylized elements in document titles #5341

Closed brainchild0 closed 5 years ago

brainchild0 commented 5 years ago

Though obviously very rare for academic publishing, use of formatting elements within titles is not wildly uncommon in popular printing, including some nonfiction.

Some lighthearted illustrations might be:

Pandoc already features a precedent for stylizing text read from a metadata source. Abstract blocks, it seems, are able to be typeset in the target format using MarkDown style elements.

Similar support might be adapted to title text. Support in subtitle and even author text ought also to be included for completeness. Obviously, text included in actual metadata fields of the output must be unformatted. As such, this feature might be best implemented by adding a display version of each of these fields (e.g. display_title, etc.), which would contain the stylized text, if formatting is desired in the metadata-derived text displayed in documents (e.g. title blocks, title pages). Then, convenience and backward compatibility are maintained by using the standard version of each field for the display text when the display version is not given.

mb21 commented 5 years ago

You didn't provide sample input, but have you actually tried it? It should be supported already.

mb21 commented 5 years ago

This input works well for LaTeX output:

---
title: '`<xml/>`: The E*x*tensible *M*arkup *L*anguage'
---

# `<xml/>`: The E*x*tensible *M*arkup *L*anguage 

For future questions, please use the pandoc-discuss mailing list instead of this issue tracker. Thanks!

brainchild0 commented 5 years ago

I'm sorry for the distraction. I tested beforehand with line breaks in the title, which did not appear to work at that time. It is possible that the editor, ever so helpfully, removed the trailing whitespace in the YAML input, that marks a line in MarkDown as the last in the paragraph.

One further remark, though, I do think it would be a slight improvement if the user could separately specify a display title, if desired. One can still consider cases where the unformatted metadata ought not to include exactly the same characters as the formatted representation of a field. For example, suppose in my first example, the author feels that the triangle braces <> are too distracting without the code-style formatting, and wishes the title metadata field of the target document to literally contain only xml: The Extensible Markup Language. Or suppose he wishes to capitalize XML, lacking the clear indication that it is to read as code. Or, in other cases, slashes or vertical bars might serve as substitutes for line breaks. The intention of a document author cannot be inferred with deterministic accuracy in the general case, pointing to the benefit of allowing overriding default behavior with a separate field.