Skip to content

Commit

Permalink
feat(plugin-bibtex): add -subtitle, -titleaddon
Browse files Browse the repository at this point in the history
Fix #116
  • Loading branch information
larsgw committed Jan 24, 2021
1 parent 18208cf commit 58c3630
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/plugin-bibtex/src/mapping/biblatex.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,28 @@ export default new util.Translator([
// multi-volume book.
// journaltitle is only used for articles.
{
source: 'maintitle',
source: ['maintitle', 'mainsubtitle', 'maintitleaddon'],
target: 'container-title',
when: {
source: true,
target: { 'number-of-volumes': true }
}
},
convert: Converters.TITLE
},
{
source: 'booktitle',
source: ['booktitle', 'booksubtitle', 'booktitleaddon'],
target: 'container-title',
when: {
source: { maintitle: false },
target: {
'number-of-volumes': false,
type (type) { return !type.startsWith('article') }
}
}
},
convert: Converters.TITLE
},
{
source: 'journaltitle',
source: ['journaltitle', 'journalsubtitle', 'journaltitleaddon'],
target: 'container-title',
when: {
source: { [TYPE]: 'article' },
Expand All @@ -177,7 +179,8 @@ export default new util.Translator([
'article-magazine'
]
}
}
},
convert: Converters.TITLE
},
{
source: 'shortjournal',
Expand Down Expand Up @@ -509,8 +512,9 @@ export default new util.Translator([
target: 'title-short'
},
{
source: 'title',
target: 'title'
source: ['title', 'subtitle', 'titleaddon'],
target: 'title',
convert: Converters.TITLE
},
{
source: 'translator',
Expand Down Expand Up @@ -545,8 +549,8 @@ export default new util.Translator([
target: 'number-of-volumes'
}
// {
// source: 'issuetitle',
// source: ['issuetitle', 'issuesubtitle', 'issuetitleaddon'],
// target: 'volume-title',
// convert: Converters.RICH_TEXT
// convert: Converters.TITLE
// }
])
9 changes: 9 additions & 0 deletions packages/plugin-bibtex/src/mapping/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,14 @@ export const Converters = {
return state
}
}
},
TITLE: {
toTarget (title, subtitle, addon) {
if (subtitle) { title += ': ' + subtitle }
return title
},
toSource (title) {
return [title]
}
}
}

0 comments on commit 58c3630

Please sign in to comment.