mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Add document.description
field
This commit is contained in:
parent
d00a5d6c9b
commit
497446944c
@ -37,6 +37,10 @@ pub struct DocumentElem {
|
|||||||
#[ghost]
|
#[ghost]
|
||||||
pub author: Author,
|
pub author: Author,
|
||||||
|
|
||||||
|
/// The document's description.
|
||||||
|
#[ghost]
|
||||||
|
pub description: Option<Content>,
|
||||||
|
|
||||||
/// The document's keywords.
|
/// The document's keywords.
|
||||||
#[ghost]
|
#[ghost]
|
||||||
pub keywords: Keywords,
|
pub keywords: Keywords,
|
||||||
@ -91,6 +95,8 @@ pub struct DocumentInfo {
|
|||||||
pub title: Option<EcoString>,
|
pub title: Option<EcoString>,
|
||||||
/// The document's author.
|
/// The document's author.
|
||||||
pub author: Vec<EcoString>,
|
pub author: Vec<EcoString>,
|
||||||
|
/// The document's description.
|
||||||
|
pub description: Option<EcoString>,
|
||||||
/// The document's keywords.
|
/// The document's keywords.
|
||||||
pub keywords: Vec<EcoString>,
|
pub keywords: Vec<EcoString>,
|
||||||
/// The document's creation date.
|
/// The document's creation date.
|
||||||
@ -111,6 +117,10 @@ impl DocumentInfo {
|
|||||||
if has(<DocumentElem as Fields>::Enum::Author) {
|
if has(<DocumentElem as Fields>::Enum::Author) {
|
||||||
self.author = DocumentElem::author_in(chain).0;
|
self.author = DocumentElem::author_in(chain).0;
|
||||||
}
|
}
|
||||||
|
if has(<DocumentElem as Fields>::Enum::Description) {
|
||||||
|
self.description =
|
||||||
|
DocumentElem::description_in(chain).map(|content| content.plain_text());
|
||||||
|
}
|
||||||
if has(<DocumentElem as Fields>::Enum::Keywords) {
|
if has(<DocumentElem as Fields>::Enum::Keywords) {
|
||||||
self.keywords = DocumentElem::keywords_in(chain).0;
|
self.keywords = DocumentElem::keywords_in(chain).0;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,11 @@ pub fn write_catalog(
|
|||||||
xmp.title([(None, title.as_str())]);
|
xmp.title([(None, title.as_str())]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(description) = &ctx.document.info.description {
|
||||||
|
info.subject(TextStr::trimmed(description));
|
||||||
|
xmp.description([(None, description.as_str())]);
|
||||||
|
}
|
||||||
|
|
||||||
let authors = &ctx.document.info.author;
|
let authors = &ctx.document.info.author;
|
||||||
if !authors.is_empty() {
|
if !authors.is_empty() {
|
||||||
// Turns out that if the authors are given in both the document
|
// Turns out that if the authors are given in both the document
|
||||||
|
Loading…
x
Reference in New Issue
Block a user