Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.openoffice.oocsltext

public final Class CSLFormatUtils

extends Object
Class Inheritance
Imports
java.util.List, .Optional, java.util.regex.Matcher, .Pattern, org.jabref.logic.citationkeypattern.BracketedPattern, org.jabref.logic.citationstyle.CitationStyle, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.AuthorList, .BibEntry, org.jabref.model.entry.field.StandardField, org.apache.commons.text.StringEscapeUtils

Contains utility constants and methods for processing of CSL citations as generated by methods of citeproc-java (org.jabref.logic.citationstyle.CitationStyleGenerator). These methods are used in CSLCitationOOAdapter which inserts CSL citation text into an OO document.

Field Summary

Modifier and TypeField and Description
private static final Pattern
public static final List<String>
public static final List<String>
BIBLIOGRAPHY_TITLE_FORMATS

The formatting names specified to and understood by LibreOffice internally via code are often different from their displayed names in the LibreOffice application.

private static final Pattern
private static final String
private static final String
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern
private static final Pattern

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String
changeToInText(String
the citation cleaned up and formatted using transformHTML.
formattedCitation
)

Extracts year from a citation having single or multiple entries, for the purpose of using in in-text citations.

public static String

Returns:

the alphanumeric citation (for a single entry or a group of entries).
generateAlphanumericCitation
(List<BibEntry>
the list of entries for which the alphanumeric citation is to be generated.
entries
,
BibDatabaseContext bibDatabaseContext)

Alphanumeric citations are not natively supported by citeproc-java (see generateCitation).

public static String
public static String
generateAuthorPrefix(BibEntry currentEntry, BibDatabaseContext bibDatabaseContext)

Generates Author Prefix for an in-text citation

public static String
public static String

Returns:

The formatted html string.
transformHTML
(String
The HTML string to be transformed into OO-write ready HTML.
html
)

Transforms provided HTML into a format that can be fully parsed and inserted into an OO document.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

A_OPEN_TAGback to summary
private static final Pattern A_OPEN_TAG
BIBLIOGRAPHY_BODY_FORMATSback to summary
public static final List<String> BIBLIOGRAPHY_BODY_FORMATS
BIBLIOGRAPHY_TITLE_FORMATSback to summary
public static final List<String> BIBLIOGRAPHY_TITLE_FORMATS

The formatting names specified to and understood by LibreOffice internally via code are often different from their displayed names in the LibreOffice application. For example, "Hanging Indent" as visible in LO styles list should be specified as "Hanging indent" (note casing) internally. Similarly, "Body Text, Indented" is specified as "Text body indent". This is also why we don't let users manually input the name of any pre-set format. The following two lists below are taken from https://github.com/LibreOffice/core/blob/0891df6b21fd95ec7c9614509d92829c0f17c353/sw/qa/python/check_styles.py#L132

BOLD_SPANback to summary
private static final Pattern BOLD_SPAN
DEFAULT_BIBLIOGRAPHY_BODY_FORMATback to summary
private static final String DEFAULT_BIBLIOGRAPHY_BODY_FORMAT
DEFAULT_HANGING_INDENT_BIBLIOGRAPHY_BODY_FORMATback to summary
private static final String DEFAULT_HANGING_INDENT_BIBLIOGRAPHY_BODY_FORMAT
DIV_OPEN_TAGback to summary
private static final Pattern DIV_OPEN_TAG
ITALIC_SPANback to summary
private static final Pattern ITALIC_SPAN
LEADING_EMPTY_PARAGRAPH_MARKERback to summary
private static final Pattern LEADING_EMPTY_PARAGRAPH_MARKER
LINE_BREAKSback to summary
private static final Pattern LINE_BREAKS
MARGIN_PATTERNback to summary
private static final Pattern MARGIN_PATTERN
REMAINING_SPAN_TAGSback to summary
private static final Pattern REMAINING_SPAN_TAGS
SMALL_CAPS_SPANback to summary
private static final Pattern SMALL_CAPS_SPAN
TRAILING_EMPTY_PARAGRAPH_MARKERSback to summary
private static final Pattern TRAILING_EMPTY_PARAGRAPH_MARKERS
UNDERLINE_SPANback to summary
private static final Pattern UNDERLINE_SPAN
YEAR_IN_CITATION_PATTERNback to summary
private static final Pattern YEAR_IN_CITATION_PATTERN

Constructor Detail

CSLFormatUtilsback to summary
private CSLFormatUtils()

Method Detail

changeToInTextback to summary
public static String changeToInText(String formattedCitation)

Extracts year from a citation having single or multiple entries, for the purpose of using in in-text citations.

Parameters
formattedCitation:String

the citation cleaned up and formatted using transformHTML.

generateAlphanumericCitationback to summary
public static String generateAlphanumericCitation(List<BibEntry> entries, BibDatabaseContext bibDatabaseContext)

Alphanumeric citations are not natively supported by citeproc-java (see generateCitation). Thus, we manually format a citation to produce its alphanumeric form.

Parameters
entries:List<BibEntry>

the list of entries for which the alphanumeric citation is to be generated.

Returns:String

the alphanumeric citation (for a single entry or a group of entries).

generateAlphanumericInTextCitationback to summary
public static String generateAlphanumericInTextCitation(BibEntry entry, BibDatabaseContext bibDatabaseContext)
generateAuthorPrefixback to summary
public static String generateAuthorPrefix(BibEntry currentEntry, BibDatabaseContext bibDatabaseContext)

Generates Author Prefix for an in-text citation

getDefaultBodyFormatForStyleback to summary
public static String getDefaultBodyFormatForStyle(CitationStyle style)
transformHTMLback to summary
public static String transformHTML(String html)

Transforms provided HTML into a format that can be fully parsed and inserted into an OO document. Context: The HTML produced by generateBibliography or generateCitation is not directly (completely) parsable by write. For more details, read the documentation for the org.jabref.model.openoffice.ootext.OOTextIntoOO class. Additional Information.

Parameters
html:String

The HTML string to be transformed into OO-write ready HTML.

Returns:String

The formatted html string.