3
6.0.0.4
false
2013-05-24T19:37:40+02:00
pm
2023-01-10T08:21:20
Wq120
InTextCitation
EducationAndPsychology, LanguageAndLiteratureSciences
de
Germanistische-Linguistik_Heidelberg
AddFirstNames, AddPersonsUntilCitationIsUnique, AddLetterAfterYear
Full
Full
All
LastNameFirstName
Year
false
None
1
2
3
JournalArticle
false
{0}
Always
Always
.
Reference
true
Abstract
false
false
({0})
Always
Always
Reference
true
NextElementHasData
(
NextElementHasData
konsultiert am
AccessDate
false
dd.MM.yyyy
Always
im Druck
false
true
PreviousElementHasData
)
false
{0}
Always
Always
.
Reference
true
Additions
false
false
{0}
Always
Always
.
Reference
true
Authors
false
-1
LastNameFirstName
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
{0} [last name]
Always
Always
.
Reference
true
AuthorsOrEditorsOrOrganizations
false
-1
LastNameOnly
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
true
3
1
Always
et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
{0}
Always
Always
.
Reference
true
Categories
false
false
{0}
Always
Always
.
Reference
true
CitationKey
false
false
false
{0}
Always
Always
.
Reference
true
Collaborators
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
Reference
true
CustomField1
false
false
{0}
Always
Always
.
Reference
true
CustomField2
false
false
{0}
Always
Always
.
Reference
true
CustomField3
false
false
{0}
Always
Always
.
Reference
true
CustomField4
false
false
{0}
Always
Always
.
Reference
true
CustomField5
false
false
{0}
Always
Always
.
Reference
true
CustomField6
false
false
{0}
Always
Always
.
Reference
true
CustomField7
false
false
{0}
Always
Always
.
Reference
true
CustomField8
false
false
{0}
Always
Always
.
Reference
true
CustomField9
false
false
, {0}
Always
Always
,
Reference
true
Date
false
dd.MM.yyyy
Always
im Druck
true
true
false
{0}
Always
Always
.
Reference
true
Date2
false
D
Always
im Druck
true
false
false
doi: {0}
Always
Always
.
Reference
true
NextElementHasData
doi:
Doi
false
false
{0}
Always
Always
.
Reference
true
Edition
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Version 1.1 Filter can handle both Edition and EditionNumberResolved, can be part of a multi-element component part
//Version 1.0 Filter handles Edition only (no EditionNumberResolved)
handled = false;
if (componentPart == null) return null;
if (componentPart.Elements == null) return null;
if (citation == null || citation.Reference == null) return null;
if (componentPart.Scope == ComponentPartScope.ParentReference && citation.Reference.ParentReference == null) return null;
var editionFieldElement = componentPart.GetFieldElements().FirstOrDefault(item => item.PropertyId == ReferencePropertyId.Edition || item.PropertyId == ReferencePropertyId.EditionNumberResolved);
if (editionFieldElement == null) return null;
string editionNumberResolved;
if (componentPart.Scope == ComponentPartScope.ParentReference)
{
editionNumberResolved = citation.Reference.ParentReference.EditionNumberResolved;
}
else
{
editionNumberResolved = citation.Reference.EditionNumberResolved;
}
//now suppress the output ONLY if edition number is 1
if (editionNumberResolved == "1")
{
componentPart.Elements.Remove(editionFieldElement);
}
return null;
}
//FYI
/*
public string EditionNumberResolved
{
get
{
if (string.IsNullOrEmpty(_valueData.Edition))
{
return string.Empty;
}
return new ReferenceEditionNumberRegex().Match(_valueData.Edition).Value;
//ReferenceEditionNumberRegex -> \d+
}
}
*/
}
}]]>
true
ed. > 1
. [{0}. Aufl.]
Always
Always
.
Reference
true
NextElementHasData
[
EditionNumberResolved
false
Always
th
Always
Always
. Aufl.
Always
Always
. Aufl.
Always
1|st|2|nd|3|rd
Always
Always
false
PreviousElementHasData
]
false
{0}
Always
Always
.
Reference
true
Evaluation
false
false
{0}
Always
Always
.
Reference
true
FirstFootnoteCitationNumber
false
false
false
false
{0}
Always
Always
Reference
true
IndexInBibliography
false
Always
Arabic
Always
Always
LetterLowerCase
Always
Always
false
{0}
Always
Always
.
Reference
true
Isbn
false
false
{0}
Always
Always
.
Reference
true
Keywords
false
false
{0}
Always
Always
.
Reference
true
Language
false
false
{0}
Always
Always
.
Reference
true
Locations
false
true
true
true
false
{0}
Always
Always
.
Reference
true
Notes
false
false
({0})
Always
Always
Reference
true
NextElementHasData
(
Number
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
PreviousElementHasData
)
false
{0}
Always
Always
.
Reference
true
NumberOfVolumes
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
. {0}
Always
Always
.
Reference
true
NextElementHasData
Online unter:
OnlineAddress
false
false
false
false
false
false
. {0}
Always
Always
.
Reference
true
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
{0}
Always
Always
.
Reference
true
OriginalCheckedBy
false
false
{0}
Always
Always
.
Reference
true
OriginalPublication
false
D
Always
im Druck
true
false
false
{0}
Always
Always
.
Reference
true
OthersInvolved
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
Reference
true
PageCount
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
, {0}
Always
Always
,
Reference
true
PageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
{0}
Always
Always
.
Reference
true
ParallelTitle
false
false
{0}
Always
Always
,
Reference
true
Periodical
false
true
Name
false
. {0}: {1}
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
/
PreviousAndNextElementsHaveData
:
Publishers
false
false
{0}
Always
Always
.
Reference
true
Price
false
false
{0}
Always
Always
:
Reference
true
Publishers
false
false
{0}
Always
Always
.
Reference
true
PubMedId
false
false
: {0}
Always
Always
:
Reference
true
QuotationPageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
{0}
Always
Always
.
Reference
true
TextLinks
false
false
{0}
Always
Always
.
Reference
true
SeriesTitle
false
true
Name
false
{0}
Always
Always
.
Reference
true
SeriesTitleEditors
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
Reference
true
ShortTitle
false
false
{0}
Always
Always
.
Reference
true
SpecificField1
false
false
{0}
Always
Always
.
Reference
true
SpecificField2
false
false
{0}
Always
Always
.
Reference
true
SpecificField3
false
false
{0}
Always
Always
.
Reference
true
SpecificField4
false
false
{0}
Always
Always
.
Reference
true
SpecificField5
false
false
{0}
Always
Always
.
Reference
true
SpecificField6
false
false
{0}
Always
Always
.
Reference
true
SpecificField7
false
false
{0}
Always
Always
.
Reference
true
StorageMedium
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalizing
. {0}
Always
Always
.
Reference
true
Subtitle
false
false
{0}
Always
Always
.
Reference
true
TableOfContents
false
false
{0}
Always
Always
.
Reference
true
Tasks
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalizing
: {0}
Always
Always
:
Reference
true
Title
false
false
{0}
Always
Always
.
Reference
true
TitleInOtherLanguages
false
false
{0}
Always
Always
:
Reference
true
TitleSupplement
false
false
[{0}]
Always
Always
Reference
true
NextElementHasData
[
TranslatedTitle
false
PreviousElementHasData
]
false
{0}
Always
Always
.
Reference
true
UniformTitle
false
false
_{0}
Always
Always
Reference
true
Volume
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
Reference
true
Year
false
D
Always
im Druck
true
false
false
({0})
Always
Always
Reference
true
NextElementHasData
(
YearResolved
false
yyyy
Always
im Druck
true
true
PreviousElementHasData
)
false
(
Always
Always
Reference
true
Always
(
false
)
Always
Always
Reference
true
Always
)
false
[
Always
Always
Reference
true
Always
[
false
]
Always
Always
Reference
true
Always
]
false
_{0}
Always
Always
Reference
true
YearResolved
false
yyyy
Always
im Druck
true
true
false
, {0}
Always
Always
,
Reference
true
YearResolved
false
D
Always
im Druck
true
false
false
; {0}
Always
Always
;
Reference
true
YearResolved
false
D
Always
im Druck
true
false
false
. {0}
Always
Always
.
Reference
true
YearResolved
false
D
Always
im Druck
true
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalize
: {0} [italic]
Always
Always
:
Reference
true
Title
false
false
false
false
true
false
false
false
false
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalize
. {0} [italic]
Always
Always
.
Reference
true
Subtitle
false
false
false
false
true
false
false
false
false
false
false
’{0}: {1}’
Always
Always
.
Reference
true
AnyElementInComponentHasData
‘
Title
false
PreviousAndNextElementsHaveData
:
Subtitle
false
AnyElementInComponentHasData
’
false
"{0}: {1}"
Always
Always
.
Reference
true
AnyElementInComponentHasData
"
Title
false
PreviousAndNextElementsHaveData
:
Subtitle
false
AnyElementInComponentHasData
"
false
pp. {0}
Always
Always
.
Reference
true
PageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
pp.
Always
–
Always
true
StartPageOnly
Always
p.
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
ebd.
Always
Always
.
Reference
true
Always
ebd.
false
{0} (Hrsg.)
Always
Always
.
Reference
true
Editors
true
-1
LastNameFirstName
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
Always
(Hrsg.)
Always
(Hrsg.)
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
S. {0}
Always
Always
.
Reference
true
PageRange
false
Arabic
true
FullRange
Always
Sp.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
S.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
§§
Always
–
Always
true
StartPageOnly
Always
§
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Rn.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
{0}
Always
Always
.
Reference
true
AuthorsOrEditorsOrOrganizations
false
-1
LastNameFirstName
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
{0} [abbr., italic]
Always
Always
,
Reference
true
Periodical
false
true
false
false
false
true
false
false
false
false
false
StandardAbbreviation
false
{0}({1})
Always
Always
,
Reference
true
Volume
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
NextElementHasData
(
Number
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
PreviousElementHasData
)
false
S. {0}
Always
Always
,
Reference
true
QuotationPageRange
false
Arabic
true
FullRange
Always
Sp.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
S.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
§§
Always
–
Always
true
StartPageOnly
Always
§
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Rn.
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
. In: {0} [italic]
Always
Always
.
Reference
true
NextElementHasData
In:
Periodical
false
false
false
false
false
true
false
false
false
false
false
Name
false
[{0}]
Always
Always
.
Reference
true
NextElementHasData
[
OriginalPublication
false
D
Always
im Druck
true
false
PreviousElementHasData
]
false
„{0}: {1}“
Always
Always
.
Reference
true
AnyElementInComponentHasData
„
Title
false
PreviousAndNextElementsHaveData
:
Subtitle
false
AnyElementInComponentHasData
“
false
{0} [last name, et al., abbreviation only]
Always
Always
Reference
true
AuthorsOrEditorsOrOrganizations
false
-1
LastNameOnly
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
true
3
1
Always
et al.
false
false
false
false
Always
,
AbbreviationOnly
NextElementHasData
PreviousElementHasData
NextElementHasData
PreviousElementHasData
false
false
. https://doi.org/{0}
Always
Always
.
Reference
true
NextElementHasData
https://doi.org/
Doi
false
false
_({0} #{1})
Always
Always
Reference
true
AnyElementInComponentHasData
(
SeriesTitle
false
true
Name
NextElementHasData
#
Number
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
AnyElementInComponentHasData
)
false
: {0}
Always
Always
.
Reference
true
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
. {0}
Always
Always
.
Reference
true
TitleSupplement
false
false
, {0}
Always
Always
,
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
false
(Manuskript)
Always
Always
Reference
true
Always
(Manuskript)
false
_Nr. {0}
Always
Always
Reference
true
Number
false
Always
th
Always
Nr.
Always
Always
Nr.
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
Reference
true
Translators
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
Always
Always
Always
(
Always
)
false
false
{0}
Always
Always
.
Reference
true
EditionNumberResolved
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
Reference
true
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
: {0}
Always
Always
:
Reference
true
PageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
. {0}
Always
Always
.
Reference
true
TitleSupplement
false
false
, {0}
Always
Always
,
Reference
true
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
. {0}: {1} [Kopie]
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
PreviousAndNextElementsHaveData
:
Publishers
false
false
. {0}: {1} [Kopie]
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
PreviousAndNextElementsHaveData
:
Publishers
false
false
. {0}: {1}
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
PreviousAndNextElementsHaveData
:
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
. {0}: {1} [Kopie]
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
PreviousAndNextElementsHaveData
:
Publishers
false
false
. {0}
Always
Always
.
Reference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
,
false
{0} (no Hrsg.)
Always
Always
.
Reference
true
Editors
true
-1
LastNameFirstName
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
_(in Vorbereitung)
Always
Always
Reference
true
Always
(in Vorbereitung)
false
{0}
Always
Always
Reference
true
QuotationPageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
. {0}
Always
Always
.
Reference
true
Volume
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
ParentReference
true
Abstract
false
false
{0}
Always
Always
.
ParentReference
true
AccessDate
false
D
Always
im Druck
true
false
false
{0}
Always
Always
.
ParentReference
true
Additions
false
false
{0}
Always
Always
.
ParentReference
true
Authors
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
AuthorsOrEditorsOrOrganizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
Categories
false
false
{0}
Always
Always
.
ParentReference
true
CitationKey
false
false
false
{0}
Always
Always
.
ParentReference
true
Collaborators
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
CustomField1
false
false
{0}
Always
Always
.
ParentReference
true
CustomField2
false
false
{0}
Always
Always
.
ParentReference
true
CustomField3
false
false
{0}
Always
Always
.
ParentReference
true
CustomField4
false
false
{0}
Always
Always
.
ParentReference
true
CustomField5
false
false
{0}
Always
Always
.
ParentReference
true
CustomField6
false
false
{0}
Always
Always
.
ParentReference
true
CustomField7
false
false
{0}
Always
Always
.
ParentReference
true
CustomField8
false
false
{0}
Always
Always
.
ParentReference
true
CustomField9
false
false
{0}
Always
Always
.
ParentReference
true
Date
false
D
Always
im Druck
true
false
false
{0}
Always
Always
.
ParentReference
true
Date2
false
D
Always
im Druck
true
false
false
{0}
Always
Always
.
ParentReference
true
Doi
false
false
{0}
Always
Always
.
ParentReference
true
Edition
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
. [{0}. Aufl.]
Always
Always
.
ParentReference
true
NextElementHasData
[
EditionNumberResolved
false
Always
th
Always
Always
. Aufl.
Always
Always
. Aufl.
Always
1|st|2|nd|3|rd
Always
Always
false
PreviousElementHasData
]
false
{0}
Always
Always
.
ParentReference
true
Editors
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
Evaluation
false
false
{0}
Always
Always
.
ParentReference
true
FirstFootnoteCitationNumber
false
false
false
false
{0}
Always
Always
ParentReference
true
IndexInBibliography
false
Always
Arabic
Always
Always
LetterLowerCase
Always
Always
false
{0}
Always
Always
.
ParentReference
true
Isbn
false
false
{0}
Always
Always
.
ParentReference
true
Keywords
false
false
{0}
Always
Always
.
ParentReference
true
Language
false
false
{0}
Always
Always
.
ParentReference
true
Locations
false
true
true
true
false
{0}
Always
Always
.
ParentReference
true
Notes
false
false
{0}
Always
Always
.
ParentReference
true
Number
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
ParentReference
true
NumberOfVolumes
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
ParentReference
true
OnlineAddress
false
false
false
false
false
false
{0}
Always
Always
.
ParentReference
true
Organizations
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
OriginalCheckedBy
false
false
{0}
Always
Always
.
ParentReference
true
OriginalPublication
false
D
Always
im Druck
true
false
false
{0}
Always
Always
.
ParentReference
true
OthersInvolved
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
PageCount
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
ParentReference
true
PageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
{0}
Always
Always
.
ParentReference
true
ParallelTitle
false
false
{0}
Always
Always
.
ParentReference
true
Periodical
false
true
Name
false
. {0}: {1}
Always
Always
.
ParentReference
true
PlaceOfPublication
false
false
5
4
Always
, et al.
Always
/
PreviousAndNextElementsHaveData
:
Publishers
false
false
{0}
Always
Always
.
ParentReference
true
Price
false
false
{0}
Always
Always
:
ParentReference
true
Publishers
false
false
{0}
Always
Always
.
ParentReference
true
PubMedId
false
false
{0}
Always
Always
.
ParentReference
true
QuotationPageRange
false
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
Arabic
true
FullRange
Always
Always
–
Always
false
StartPageOnly
Always
Always
–
Always
false
FullRange
Always
Always
–
Always
false
{0}
Always
Always
.
ParentReference
true
TextLinks
false
false
{0}
Always
Always
.
ParentReference
true
SeriesTitle
false
true
Name
false
{0}
Always
Always
.
ParentReference
true
SeriesTitleEditors
false
-1
LastNameFirstName
Full
Full
All
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
{0}
Always
Always
.
ParentReference
true
ShortTitle
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField1
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField2
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField3
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField4
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField5
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField6
false
false
{0}
Always
Always
.
ParentReference
true
SpecificField7
false
false
{0}
Always
Always
.
ParentReference
true
StorageMedium
false
false
{0}
Always
Always
.
ParentReference
true
Subtitle
false
false
{0}
Always
Always
.
ParentReference
true
TableOfContents
false
false
{0}
Always
Always
.
ParentReference
true
Tasks
false
false
{0}
Always
Always
.
ParentReference
true
Title
false
false
{0}
Always
Always
.
ParentReference
true
TitleInOtherLanguages
false
false
{0}
Always
Always
.
ParentReference
true
TitleSupplement
false
false
{0}
Always
Always
.
ParentReference
true
TranslatedTitle
false
false
{0}
Always
Always
.
ParentReference
true
UniformTitle
false
false
{0}
Always
Always
.
ParentReference
true
Volume
false
Always
th
Always
Always
Always
Always
Always
1|st|2|nd|3|rd
Always
Always
false
false
{0}
Always
Always
.
ParentReference
true
Year
false
D
Always
im Druck
true
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalizing
: {0} [italic]
Always
Always
:
ParentReference
true
Title
false
false
false
false
true
false
false
false
false
false
false
GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
{
//Name of filter: Convert output to title case (with exceptions, such as "and", "or" etc.)
//Version 1.9: Consider parent's Language field if this is a child reference and the child's Language field is empty
//Version 1.8: Parametrized conversion of full upper case words; functionality was impaired in version 1.7
//Version 1.7: Added checking for null on GetTextUnitsUnfiltered() to avoid NullReferenceExceptions at runtime (which may lead to auto-deactivation of filter)
//Version 1.6: ToUpperFirstLetter() method now handles words completely in UPPERCASE and takes culture into consideration
//Version 1.5: capitalize stopwords directly after quotation mark
//Version 1.4: improved word tokenization
//Version 1.3: ignore expressions which are written completely in upper case
//Version 1.2: new option to ensure that the reference language is "English"
var ensureEnglishIsReferenceLanguage = true; //if set to false, the component part filter will ALWAYS capitalize, regardless of the reference's language
var convertFullUpperCaseWords = ConvertFullUpperCaseWords.Never;
#region Info on ConvertFullUpperCaseWords parameter
/*
Example 1: UN and US government made agreement on payments of contribution
Example 2: UN AND US GOVERNMENT MADE AGREEMENT ON PAYMENTS OF CONTRIBUTION
ConvertFullUpperCaseWords.Never (default)
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: UN and US GOVERNMENT MADE AGREEMENT on PAYMENTS of CONTRIBUTION
ConvertFullUpperCaseWords.Always:
Result 1: Un and Us Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
ConvertFullUpperCaseWords.Auto:
Result 1: UN and US Government Made Agreement on Payments of Contribution
Result 2: Un and Us Government Made Agreement on Payments of Contribution
*/
#endregion
CultureInfo culture = CultureInfo.CurrentCulture;
handled = false;
if (citation == null) return null;
if (citation.Reference == null) return null;
if (componentPart == null) return null;
if (template == null) return null;
if (ensureEnglishIsReferenceLanguage)
{
string languageResolved = citation.Reference.Language;
if (componentPart.Scope == ComponentPartScope.Reference)
{
//if ComponentPartScope is Reference, language can come from Reference or ParentReference
if (string.IsNullOrEmpty(languageResolved) && citation.Reference.ParentReference != null)
{
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
}
else
{
//if ComponentPartScope is ParentReference, language MUST come from ParentReference
if (citation.Reference.ParentReference == null) return null;
languageResolved = citation.Reference.ParentReference.Language;
}
if (string.IsNullOrEmpty(languageResolved)) return null;
var termsList = new string[] {
"en",
"eng",
"engl",
"English",
"Englisch"
};
var regEx = new Regex(@"\b(" + string.Join("|", termsList) + @")\b", RegexOptions.IgnoreCase);
if (!regEx.IsMatch(languageResolved))
{
return null;
}
}
//Words that will not be capitalized; add words to this list as required
string[] exceptionsArray = { "a", "an", "and", "as", "at",
"but", "by", "down", "for", "from",
"in", "into", "nor",
"of", "on", "onto", "or", "over",
"so", "the", "till", "to",
"up", "via", "with", "yet" };
List exceptions = new List(exceptionsArray);
var textUnits = componentPart.GetTextUnitsUnfiltered(citation, template);
if (textUnits == null || !textUnits.Any()) return null;
string fullString = textUnits.ToString();
bool fullUpperCaseTreatment = false;
switch (convertFullUpperCaseWords)
{
case ConvertFullUpperCaseWords.Always:
fullUpperCaseTreatment = true;
break;
case ConvertFullUpperCaseWords.Never:
{
fullUpperCaseTreatment = false;
}
break;
default:
case ConvertFullUpperCaseWords.Auto:
{
if (HasLowerCase(fullString))
{
fullUpperCaseTreatment = false;
}
else
{
fullUpperCaseTreatment = true;
}
}
break;
}
string prevWord = string.Empty;
for (int i = 0; i < textUnits.Count; i++)
{
//textUnit.Text = textUnits[i].Text.ToLower(culture);
var text = textUnits[i].Text;
//Break the input text into a list of words at whitespaces,
//hyphens, opening parens, and ASCII quotation marks
string splitPattern = @"(\s)|(-)|(\()|(\"")";
List words = new List(Regex.Split(text, splitPattern));
var counter = 0;
text = string.Empty;
//Check each remaining word against the list, and append it to the new text.
//Leave words in upper case unchanged, unless they appear in the exception list.
foreach (string word in words)
{
counter++;
if (counter == 1) // first word in a textunit
{
if (i == 0) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // first word overall => capitalize
else if ((String.IsNullOrWhiteSpace(prevWord)) && !(exceptions.Contains(word.ToLower(culture)))) text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture); // new textunit after space and not stopword => capitalize
else text = text + word; // in all other cases: do nothing
}
else if (prevWord == @"""") // capitalize also stopwords directly after quotation marks
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
else if (exceptions.Contains(word.ToLower(culture))) // check list of exceptions
{
text = text + word.ToLower(culture);
}
else // in all other cases: capitalize
{
text = text + ToUpperFirstLetter(word, fullUpperCaseTreatment, culture);
}
prevWord = word; // save current word as previous word for next iteration
}
textUnits[i].Text = text;
}
handled = true;
return textUnits;
}
public string ToUpperFirstLetter(string input, bool ensureAllButFirstIsLower = false, CultureInfo culture = null)
{
if (string.IsNullOrEmpty(input)) return input;
char[] letters = input.ToCharArray();
for (var i = 0; i < letters.Length; i++)
{
if (i == 0)
{
letters[0] = char.ToUpper(letters[0], culture);
continue;
}
if (i > 0 && ensureAllButFirstIsLower == false) break;
letters[i] = char.ToLower(letters[i], culture);
}
return new string(letters);
}
public enum ConvertFullUpperCaseWords
{
Never,
Always,
Auto //converts full uppercase words to lower case only if the conmplete text is written in uppercase
};
public bool HasLowerCase (string input)
{
return !string.IsNullOrEmpty(input) && input.Any(c => char.IsLower(c));
}
}
}]]>
true
Capitalizing
. {0} [italic]
Always
Always
.
ParentReference
true
Subtitle
false
false
false
false
true
false
false
false
false
false
false
in: {0}
Always
Always
,
ParentReference
true
Always
in:
Editors
false
-1
FirstNameLastName
Full
Full
All
Always
,
Always
,
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
Always
(Hrsg.)
Always
(Hrsg.)
NameOnly
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
. In: {0} (Hrsg.)
Always
Always
.
ParentReference
true
Always
In:
Editors
false
-1
LastNameFirstName
Full
Full
All
Always
/
Always
/
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
Always
(Hrsg.)
Always
(Hrsg.)
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
false
In: {0} [last name]
Always
Always
.
ParentReference
true
Always
In:
Editors
false
-1
LastNameOnly
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
false
3
1
Always
, et al.
false
false
false
false
Always
,
Always
(Hrsg.)
Always
(Hrsg.)
NameOnly
NextElementHasData
PreviousElementHasData
NextElementHasData
(
PreviousElementHasData
)
false
false
. In: {0} (Hrsg.) [last name only, et al]
Always
Always
.
ParentReference
true
Always
In:
Editors
false
-1
LastNameOnly
Full
Full
All
Always
;
Always
&
false
false
false
false
Always
,
Always
Always
Always
.
LastNameFirstName
Full
Full
All
Always
;
Always
;
Always
;
false
false
false
false
Always
,
Always
Always
Always
.
false
LastNameFirstName
Full
Full
All
false
false
false
false
Always
,
Always
Always
Always
.
false
Always
;
true
2
1
Always
et al.
false
false
false
false
Always
,
Always
(Hrsg.)
Always
(Hrsg.)
NameAbbreviation
NextElementHasData
PreviousElementHasData
NextElementHasData
[
PreviousElementHasData
]
false
true
true
Literatur
.
0
true
None
Arabic
1
0
;
true
0
CustomSortMacro
Sort: Author | Title (if no author) > Year (Ascending) > Title
0 (positive): x should go after y, x is greater than y
< 0 (negative): x should go before y, x is less than
*/
//First we make sure we are comparing BibliographyCitations only
var xBibliographyCitation = x as BibliographyCitation;
var yBibliographyCitation = y as BibliographyCitation;
if (xBibliographyCitation == null || yBibliographyCitation == null) return 0;
var xReference = xBibliographyCitation.Reference;
var yReference = yBibliographyCitation.Reference;
if (xReference == null || yReference == null) return 0;
//(1) Some comparers are predefined as static members of the CitationComparer class, see IntelliSense
var defaultCitationComparer = CitationComparer.AuthorYearTitleOrNoAuthorThenTitleYearAscending;
return defaultCitationComparer.Compare(x, y);
}
}
}]]>
OrderOfAppearance
LetterLowerCase
false
)
false
•
Completed
Unknown
None
ArchiveMaterial
false
Completed
ContributionBookEdited
BookEdited
ArchiveMaterial
false
Completed
ContributionBookEdited
CollectedWorks
ArchiveMaterial
false
Completed
ContributionBookEdited
UnpublishedWork
ArchiveMaterial
false
Completed
Book
None
AudioBook
false
Completed
Book
None
AudioOrVideoDocument
false
Completed
Unknown
None
RadioPlay
false
Completed
None
BookEdited
true
EditorsMissing
AuthorsOrEditorsOrOrganizationsMissing
Completed
Book
None
CollectedWorks
false
Completed
Book
None
ComputerProgram
false
Completed
BookEdited
None
ConferenceProceedings
false
Completed
BookEdited
Contribution
true
AuthorsMissing
Completed
ContributionBookEdited
CollectedWorks
Contribution
false
Completed
ContributionBookEdited
ConferenceProceedings
Contribution
false
Completed
ContributionBookEdited
SpecialIssue
Contribution
false
Completed
ContributionBookEdited
UnpublishedWork
Contribution
false
Completed
ContributionBookEdited
LegalCommentary
ContributionInLegalCommentary
false
Completed
Unknown
None
CourtDecision
false
Completed
None
InternetDocument
true
DoiAvailable
AuthorsOrEditorsOrOrganizationsMissing
AuthorsOrEditorsOrOrganizationsMissing
DoiAvailable
Completed
Unknown
None
InterviewMaterial
false
Completed
None
JournalArticle
true
DoiAvailable
AuthorsMissing
AuthorsMissing
DoiAvailable
Completed
None
Lecture
false
Completed
BookEdited
None
LegalCommentary
false
Completed
None
Manuscript
true
AuthorsOrEditorsOrOrganizationsMissing
Completed
Book
None
Map
false
Completed
None
Book
true
AuthorsOrEditorsOrOrganizationsMissing
Completed
Book
None
Movie
false
Completed
Unknown
None
MusicTrack
false
Completed
ContributionBookEdited
MusicAlbum
MusicTrack
false
Completed
Book
None
NewsAgencyReport
false
Completed
None
NewspaperArticle
true
DoiAvailable
AuthorsMissing
AuthorsMissing
DoiAvailable
Completed
Unknown
None
Patent
false
Completed
Unknown
None
PersonalCommunication
false
Completed
Book
None
PressRelease
false
Completed
RadioPlay
None
Broadcast
false
Completed
Unknown
None
File
false
Completed
Unknown
None
MusicAlbum
false
Completed
BookEdited
None
SpecialIssue
false
Completed
Unknown
None
Standard
false
Completed
Book
None
StatuteOrRegulation
false
Completed
ContributionBookEdited
BookEdited
StatuteOrRegulation
false
Completed
None
Thesis
true
Completed
None
Unknown
true
AuthorsOrEditorsOrOrganizationsMissing
Completed
None
UnpublishedWork
true
AuthorsMissing
EditorsMissing
AuthorsMissing
AuthorsOrEditorsOrOrganizationsMissing
true
false
,
;
AuthorThenYearAscendingThenTitle
false
None
Unknown
None
ArchiveMaterial
false
None
ContributionBookEdited
BookEdited
ArchiveMaterial
false
None
ContributionBookEdited
CollectedWorks
ArchiveMaterial
false
None
ContributionBookEdited
UnpublishedWork
ArchiveMaterial
false
None
Book
None
AudioBook
false
None
Book
None
AudioOrVideoDocument
false
None
Unknown
None
RadioPlay
false
None
Unknown
None
BookEdited
false
None
Book
None
CollectedWorks
false
None
Book
None
ComputerProgram
false
None
BookEdited
None
ConferenceProceedings
false
None
Unknown
BookEdited
Contribution
false
None
ContributionBookEdited
CollectedWorks
Contribution
false
None
ContributionBookEdited
ConferenceProceedings
Contribution
false
None
ContributionBookEdited
SpecialIssue
Contribution
false
None
ContributionBookEdited
UnpublishedWork
Contribution
false
None
ContributionBookEdited
LegalCommentary
ContributionInLegalCommentary
false
None
Unknown
None
CourtDecision
false
None
Unknown
None
InternetDocument
false
None
Unknown
None
InterviewMaterial
false
None
Unknown
None
JournalArticle
false
None
Book
None
Lecture
false
None
BookEdited
None
LegalCommentary
false
None
Unknown
None
Manuscript
false
None
Book
None
Map
false
None
Unknown
None
Book
false
None
Book
None
Movie
false
None
Unknown
None
MusicTrack
false
None
ContributionBookEdited
MusicAlbum
MusicTrack
false
None
Book
None
NewsAgencyReport
false
None
Unknown
None
NewspaperArticle
false
None
Unknown
None
Patent
false
None
Unknown
None
PersonalCommunication
false
None
Book
None
PressRelease
false
None
RadioPlay
None
Broadcast
false
None
Unknown
None
File
false
None
Unknown
None
MusicAlbum
false
None
BookEdited
None
SpecialIssue
false
None
Unknown
None
Standard
false
None
Book
None
StatuteOrRegulation
false
None
ContributionBookEdited
BookEdited
StatuteOrRegulation
false
None
Unknown
None
Thesis
false
None
None
Unknown
false
RepeatingFootnote
AuthorsMissing
EditorsMissing
OrganizationsMissing
None
Unknown
None
UnpublishedWork
false
false
false
false
,
;
;
;
true
3
–
true
3
–
AlwaysButOncePerRange
true
AuthorThenYearAscendingThenTitle
false
None
Unknown
None
ArchiveMaterial
false
None
ContributionBookEdited
BookEdited
ArchiveMaterial
false
None
ContributionBookEdited
CollectedWorks
ArchiveMaterial
false
None
ContributionBookEdited
UnpublishedWork
ArchiveMaterial
false
None
Book
None
AudioBook
false
None
Book
None
AudioOrVideoDocument
false
None
Unknown
None
RadioPlay
false
None
Unknown
None
BookEdited
false
None
Book
None
CollectedWorks
false
None
Book
None
ComputerProgram
false
None
BookEdited
None
ConferenceProceedings
false
None
Unknown
BookEdited
Contribution
false
None
ContributionBookEdited
CollectedWorks
Contribution
false
None
ContributionBookEdited
ConferenceProceedings
Contribution
false
None
ContributionBookEdited
SpecialIssue
Contribution
false
None
ContributionBookEdited
UnpublishedWork
Contribution
false
None
ContributionBookEdited
LegalCommentary
ContributionInLegalCommentary
false
None
Unknown
None
CourtDecision
false
None
Unknown
None
InternetDocument
false
None
Unknown
None
InterviewMaterial
false
None
Unknown
None
JournalArticle
false
None
Book
None
Lecture
false
None
BookEdited
None
LegalCommentary
false
None
Unknown
None
Manuscript
false
None
Book
None
Map
false
None
None
Book
false
RepeatingInTextCitation
OrganizationsMissing
EditorsMissing
AuthorsMissing
None
Book
None
Movie
false
None
Unknown
None
MusicTrack
false
None
ContributionBookEdited
MusicAlbum
MusicTrack
false
None
Book
None
NewsAgencyReport
false
None
Unknown
None
NewspaperArticle
false
None
Unknown
None
Patent
false
None
Unknown
None
PersonalCommunication
false
None
Book
None
PressRelease
false
None
RadioPlay
None
Broadcast
false
None
Unknown
None
File
false
None
Unknown
None
MusicAlbum
false
None
BookEdited
None
SpecialIssue
false
None
Unknown
None
Standard
false
None
Book
None
StatuteOrRegulation
false
None
ContributionBookEdited
BookEdited
StatuteOrRegulation
false
None
Unknown
None
Thesis
false
None
None
Unknown
false
RepeatingInTextCitation
AuthorsMissing
EditorsMissing
OrganizationsMissing
None
Unknown
None
UnpublishedWork
false