Skip to content

Commit

Permalink
Implicit short title, disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Jul 21, 2019
1 parent 1f0d230 commit d3710f4
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
76 changes: 76 additions & 0 deletions fixtures/local/magic_ImplicitShortTitle.txt
@@ -0,0 +1,76 @@
>>===== MODE =====>>
citation
<<===== MODE =====<<

>>===== OPTIONS =====>>
{
"implicit_short_title": true
}
<<===== OPTIONS =====<<


>>===== RESULT =====>>
My title?
My title!
My title
<<===== RESULT =====<<


>>===== CITATION-ITEMS =====>>
[
[
{
"id": "ITEM-1"
}
],
[
{
"id": "ITEM-2"
}
],
[
{
"id": "ITEM-3"
}
]
]
<<===== CITATION-ITEMS =====<<

>>===== CSL =====>>
<style
xmlns="http://purl.org/net/xbiblio/csl"
class="note"
version="1.0"
default-locale="en-x-translit-ja">
<info>
<id />
<title />
<updated>2009-08-10T04:49:00+09:00</updated>
</info>
<citation>
<layout>
<text variable="title-short"/>
</layout>
</citation>
</style>
<<===== CSL =====<<

>>===== INPUT =====>>
[
{
"id": "ITEM-1",
"type": "article-journal",
"title": "My title? yes, with a subtitle"
},
{
"id": "ITEM-2",
"type": "article-journal",
"title": "My title! yes, with a subtitle"
},
{
"id": "ITEM-3",
"type": "article-journal",
"title": "My title: yes, with a subtitle"
}
]
<<===== INPUT =====<<
2 changes: 1 addition & 1 deletion src/build.js
Expand Up @@ -95,7 +95,7 @@ CSL.Engine = function (sys, style, lang, forceLang) {
}

}
if (this.opt.development_extensions.uppercase_subtitles) {
if (this.opt.development_extensions.uppercase_subtitles || this.opt.development_extensions.implicit_short_title) {
this.opt.development_extensions.main_title_from_short_title = true;
}
if (this.opt.development_extensions.csl_reverse_lookup_support) {
Expand Down
12 changes: 11 additions & 1 deletion src/load.js
Expand Up @@ -753,6 +753,15 @@ var CSL = {
vals[title.main] = splitTitle[0];
vals[title.subjoin] = splitTitle[1];
vals[title.sub] = splitTitle[2];
if (this.opt.development_extensions.implicit_short_title) {
if (!Item["title-short"]) {
var punct = vals[title.subjoin].trim();
if (["?", "!"].indexOf(punct) === -1) {
punct = "";
}
vals[title["short"]] = vals[title.main] + punct;
}
}
} else {
vals[title.main] = vals[title.title];
vals[title.subjoin] = "";
Expand Down Expand Up @@ -1183,7 +1192,8 @@ var CSL = {
"csl_reverse_lookup_support",
"main_title_from_short_title",
"uppercase_subtitles",
"force_short_title_casing_alignment"
"force_short_title_casing_alignment",
"implicit_short_title"
],

TITLE_SPLIT_REGEXP: (function() {
Expand Down
1 change: 1 addition & 0 deletions src/state.js
Expand Up @@ -165,6 +165,7 @@ CSL.Engine.Opt = function () {
this.development_extensions.strict_inputs = true;
this.development_extensions.prioritize_disambiguate_condition = false;
this.development_extensions.force_short_title_casing_alignment = true;
this.development_extensions.implicit_short_title = false;
};

CSL.Engine.Tmp = function () {
Expand Down

0 comments on commit d3710f4

Please sign in to comment.