Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenquotes.git

Add lexeme for curly single quotes, add corresponding test

AuthorDave Jarvis <email>
Date2021-06-17 08:00:14 GMT-0700
Commit35eee5b5918dd63d90eb686ddbb884b28acf9b78
Parenta2fe599
lib/src/main/java/com/keenwrite/quotes/LexemeType.java
public enum LexemeType {
QUOTE_SINGLE,
+ QUOTE_SINGLE_OPENING,
+ QUOTE_SINGLE_CLOSING,
QUOTE_DOUBLE,
ESC_SINGLE,
lib/src/main/java/com/keenwrite/quotes/Lexer.java
lexeme = createLexeme( QUOTE_DOUBLE, began, i.getIndex() );
}
+ else if( curr == '‘') {
+ lexeme = createLexeme( QUOTE_SINGLE_OPENING, began, i.getIndex() );
+ }
+ else if( curr == '’') {
+ lexeme = createLexeme( QUOTE_SINGLE_CLOSING, began, i.getIndex() );
+ }
else if( curr == '-' && peek( i ) == '-' || curr == '—' ) {
slurp( i, ( next, ci ) -> next == '-' || next == '—' );
lib/src/main/java/com/keenwrite/quotes/Parser.java
*/
private static final LexemeType[] LAGGING_QUOTE_OPENING_DOUBLE =
- new LexemeType[]{WORD, NUMBER, ELLIPSIS, QUOTE_SINGLE, QUOTE_DOUBLE};
+ new LexemeType[]{WORD, NUMBER, ELLIPSIS,
+ QUOTE_SINGLE, QUOTE_SINGLE_OPENING, QUOTE_SINGLE_CLOSING, QUOTE_DOUBLE};
/**
* Double quotes preceded by these {@link LexemeType}s may be closing quotes.
*/
private static final LexemeType[] LEADING_QUOTE_CLOSING_DOUBLE =
- new LexemeType[]{WORD, NUMBER, PERIOD, PUNCT, DASH, ELLIPSIS, QUOTE_SINGLE};
+ new LexemeType[]{WORD, NUMBER, PERIOD, PUNCT, DASH, ELLIPSIS,
+ QUOTE_SINGLE, QUOTE_SINGLE_CLOSING, QUOTE_SINGLE_OPENING};
/**
lib/src/test/resources/com/keenwrite/quotes/smartypants.txt
shouldn&apos;t drop letters, nor say &ldquo;ain&apos;t&rdquo; or &ldquo;hain&apos;t.&rdquo;
-#"’Kearney lives on the banks of Killarney—’
-#&ldquo;’Kearney lives on the banks of Killarney—’
+"’Kearney lives on the banks of Killarney—’
+&ldquo;’Kearney lives on the banks of Killarney—’
# ########################################################################
Delta14 lines added, 4 lines removed, 10-line increase