Allow multi-line titles and authors in meta block.

Based on a patch by Justin Bogner.

Titles may span multiple lines, provided continuation lines
begin with a space character.

Separate authors may be put on multiple lines, provided
each line after the first begins with a space character.
Each author must fit on one line. Multiple authors on
a single line may still be separated by a semicolon.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1854 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2010-02-28 11:21:19 +00:00
parent 36675bd206
commit 77ba3429e2
4 changed files with 62 additions and 24 deletions

64
README
View file

@ -905,32 +905,56 @@ Title blocks
If the file begins with a title block
% title
% author(s) (separated by semicolons)
% date
% title
% author(s) (separated by semicolons)
% date
it will be parsed as bibliographic information, not regular text. (It
will be used, for example, in the title of standalone LaTeX or HTML
output.) The block may contain just a title, a title and an author,
or all three lines. Each must begin with a % and fit on one line.
The title may contain standard inline formatting. If you want to
include an author but no title, or a title and a date but no author,
you need a blank line:
or all three elements. If you want to include an author but no
title, or a title and a date but no author, you need a blank line:
% My title
%
% June 15, 2006
%
% Author
Titles will be written only when the `--standalone` (`-s`) option is
chosen. In HTML output, titles will appear twice: once in the
document head -- this is the title that will appear at the top of the
window in a browser -- and once at the beginning of the document body.
The title in the document head can have an optional prefix attached
(`--title-prefix` or `-T` option). The title in the body appears as
an H1 element with class "title", so it can be suppressed or
reformatted with CSS. If a title prefix is specified with `-T` and no
title block appears in the document, the title prefix will be used by
itself as the HTML title.
% My title
%
% June 15, 2006
The title may occupy multiple lines, but continuation lines must
begin with leading space, thus:
% My title
on multiple lines
If a document has multiple authors, the authors may be put on
separate lines with leading space, or separated by semicolons, or
both. So, all of the following are equivalent:
% Author One
Author Two
% Author One; Author Two
% Author One;
Author Two
The date must fit on one line.
All three metadata fields may contain standard inline formatting
(italics, links, footnotes, etc.).
Title blocks will always be parsed, but they will affect the output only
when the `--standalone` (`-s`) option is chosen. In HTML output, titles
will appear twice: once in the document head -- this is the title that
will appear at the top of the window in a browser -- and once at the
beginning of the document body. The title in the document head can have
an optional prefix attached (`--title-prefix` or `-T` option). The title
in the body appears as an H1 element with class "title", so it can be
suppressed or reformatted with CSS. If a title prefix is specified with
`-T` and no title block appears in the document, the title prefix will
be used by itself as the HTML title.
The man page writer extracts a title, man page section number, and
other header and footer information from the title line. The title

View file

@ -133,15 +133,23 @@ inlinesInBalancedBrackets parser = try $ do
--
titleLine :: GenParser Char ParserState [Inline]
titleLine = try $ char '%' >> skipSpaces >> manyTill inline newline
titleLine = try $ do
char '%'
skipSpaces
res <- many $ (notFollowedBy newline >> inline)
<|> try (endline >> whitespace)
newline
return $ normalizeSpaces res
authorsLine :: GenParser Char ParserState [[Inline]]
authorsLine = try $ do
char '%'
skipSpaces
authors <- sepEndBy (many1 (notFollowedBy (oneOf ";\n") >> inline)) (oneOf ";")
authors <- sepEndBy (many (notFollowedBy (oneOf ";\n") >> inline))
(char ';' <|>
try (newline >> notFollowedBy blankline >> spaceChar))
newline
return $ map normalizeSpaces authors
return $ filter (not . null) $ map normalizeSpaces authors
dateLine :: GenParser Char ParserState [Inline]
dateLine = try $ do

View file

@ -1,4 +1,4 @@
Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
Pandoc (Meta {docTitle = [Str "Title",Space,Str "spanning",Space,Str "multiple",Space,Str "lines"], docAuthors = [[Str "Author",Space,Str "One"],[Str "Author",Space,Str "Two"],[Str "Author",Space,Str "Three"],[Str "Author",Space,Str "Four"]], docDate = []})
[ Header 1 [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]
, Header 2 [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]
, Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")]

View file

@ -1,3 +1,9 @@
% Title
spanning multiple lines
% Author One
Author Two; Author Three;
Author Four
# Additional markdown reader tests
## Blank line before URL in link reference