Top Description Fields Constructors Methods
de.undercouch.citeproc.helper

public Class SmartQuotes

extends Object
Class Inheritance
Imports
java.util.Locale, java.util.regex.Pattern

Replaces straight quotation marks and apostrophes by their typographically correct counterparts.

The code is based on smartquotes.js (https://smartquotes.js.org/) written by Kelly Martin released under the MIT license. It has been translated to Java and extended to support multiple languages.

Author
Michel Kraemer

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private final Pattern[]
private static final String
private final String[]
private static final String
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
SmartQuotes()

Creates the smart-quotes parser

public
SmartQuotes(String
custom left single quotation mark
leftSingleQuote
,
String
custom right singe quotation mark
rightSingleQuote
,
String
custom left double quotation mark
leftDoubleQuote
,
String
custom right double quotation mark
rightDoubleQuote
,
Locale
a locale object used to apply special rules and corner cases
locale
)

Creates the smart-quotes parser with custom symbols

public
SmartQuotes(String
custom left single quotation mark
leftSingleQuote
,
String
custom right singe quotation mark
rightSingleQuote
,
String
custom left double quotation mark
leftDoubleQuote
,
String
custom right double quotation mark
rightDoubleQuote
,
String
custom apostrophe
apostrophe
,
String
custom prime
prime
,
String
custom double prime
doublePrime
,
String
custom triple prime
triplePrime
,
Locale
a locale object used to apply special rules and corner cases
locale
)

Creates the smart-quotes parser with custom symbols

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the processed string
apply
(String
the input string
str
)

Replace straight quotation marks and apostrophes in the given string by their typographically correct counterparts.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DOUBLE_PRIMEback to summary
private static final String DOUBLE_PRIME
LEFT_DOUBLE_QUOTEback to summary
private static final String LEFT_DOUBLE_QUOTE
LEFT_SINGLE_QUOTEback to summary
private static final String LEFT_SINGLE_QUOTE
LETTERback to summary
private static final String LETTER
NO_NUMBERback to summary
private static final String NO_NUMBER
NO_WORDback to summary
private static final String NO_WORD
NUMBERback to summary
private static final String NUMBER
patternsback to summary
private final Pattern[] patterns
PRIMEback to summary
private static final String PRIME
replacementsback to summary
private final String[] replacements
RIGHT_DOUBLE_QUOTEback to summary
private static final String RIGHT_DOUBLE_QUOTE
RIGHT_SINGLE_QUOTEback to summary
private static final String RIGHT_SINGLE_QUOTE
TRIPLE_PRIMEback to summary
private static final String TRIPLE_PRIME
WORDback to summary
private static final String WORD

Constructor Detail

SmartQuotesback to summary
public SmartQuotes()

Creates the smart-quotes parser

SmartQuotesback to summary
public SmartQuotes(String leftSingleQuote, String rightSingleQuote, String leftDoubleQuote, String rightDoubleQuote, Locale locale)

Creates the smart-quotes parser with custom symbols

Parameters
leftSingleQuote:String

custom left single quotation mark

rightSingleQuote:String

custom right singe quotation mark

leftDoubleQuote:String

custom left double quotation mark

rightDoubleQuote:String

custom right double quotation mark

locale:Locale

a locale object used to apply special rules and corner cases

SmartQuotesback to summary
public SmartQuotes(String leftSingleQuote, String rightSingleQuote, String leftDoubleQuote, String rightDoubleQuote, String apostrophe, String prime, String doublePrime, String triplePrime, Locale locale)

Creates the smart-quotes parser with custom symbols

Parameters
leftSingleQuote:String

custom left single quotation mark

rightSingleQuote:String

custom right singe quotation mark

leftDoubleQuote:String

custom left double quotation mark

rightDoubleQuote:String

custom right double quotation mark

apostrophe:String

custom apostrophe

prime:String

custom prime

doublePrime:String

custom double prime

triplePrime:String

custom triple prime

locale:Locale

a locale object used to apply special rules and corner cases

Annotations
@SuppressWarnings:RegExpUnexpectedAnchor

Method Detail

applyback to summary
public String apply(String str)

Replace straight quotation marks and apostrophes in the given string by their typographically correct counterparts.

Parameters
str:String

the input string

Returns:String

the processed string