Dave Jarvis' Repositories

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

Passes straight quotes without substitution

AuthorDaveJarvis <email>
Date2024-10-09 23:57:37 GMT-0700
Commitf061c875c7a6113497540bf9d08e0f86ecf92d97
Parent37580aa
src/main/java/com/whitemagicsoftware/keenquotes/parser/Apostrophe.java
* No conversion is performed.
*/
- CONVERT_REGULAR( "'", "regular" ),
+ CONVERT_REGULAR( "", "regular" ),
/**
* Apostrophes become MODIFIER LETTER APOSTROPHE ({@code &#x2bc;}).
src/main/java/com/whitemagicsoftware/keenquotes/parser/Token.java
*/
public String toString( final Apostrophe apostrophe ) {
- final var glyph = mLexeme.getType().glyph();
final var tokenType = getType();
+ final var glyph = mLexeme.getType().glyph();
+ final var straight = tokenType.isStraight();
// Retrieves the base glyph, unless curling was requested. When curling
// apostrophes, this will determine the user-selected type of apostrophe
// entity to use.
- return apostrophe == CONVERT_REGULAR
+ return straight
+ ? CHARS.get( tokenType )
+ : apostrophe == CONVERT_REGULAR
? CHARS.getOrDefault( tokenType, glyph.text() )
: I18N_ENTITIES.getOrDefault( glyph, convert( tokenType, apostrophe ) );
src/main/java/com/whitemagicsoftware/keenquotes/parser/TokenType.java
}
+ /**
+ * Answers whether the quotation mark must be rendered straight.
+ *
+ * @return {@code true} means the quotation mark was escaped.
+ */
+ public boolean isStraight() {
+ return this == QUOTE_STRAIGHT_SINGLE || this == QUOTE_STRAIGHT_DOUBLE;
+ }
+
@Override
public String toString() {
src/test/java/com/whitemagicsoftware/keenquotes/parser/AmbiguityResolverTest.java
input,
CONTRACTIONS,
- replace( output, offset, CONVERT_APOS_ENTITY ),
+ replace( output, offset, CONVERT_APOS ),
_ -> false
);
src/test/java/com/whitemagicsoftware/keenquotes/parser/CurlerTest.java
public void test_Parse_UncurledQuotes1_CurlyQuotes() throws IOException {
testCurler(
- createCurler( FILTER_PLAIN, CONVERT_APOS_ENTITY ),
+ createCurler( FILTER_PLAIN, CONVERT_APOS ),
"unambiguous-1-pass.txt"
);
}
@Test
public void test_Parse_UncurledQuotes2_CurlyQuotes() throws IOException {
testCurler(
- createCurler( FILTER_PLAIN, CONVERT_APOS_ENTITY ),
+ createCurler( FILTER_PLAIN, CONVERT_APOS ),
"unambiguous-2-pass.txt"
);
public void test_Parse_UncurledQuotesXml_CurlyQuotes() throws IOException {
testCurler(
- createCurler( FILTER_XML, CONVERT_APOS_ENTITY ), "xml.txt"
+ createCurler( FILTER_XML, CONVERT_APOS ), "xml.txt"
);
}
@Test
public void test_Parse_UncurledQuotesI11l_CurlyQuotes() throws IOException {
testCurler(
- createCurler( FILTER_PLAIN, CONVERT_APOS_ENTITY ), "i18n.txt"
+ createCurler( FILTER_PLAIN, CONVERT_APOS ), "i18n.txt"
);
}
}
- final var curler = createCurler( FILTER_XML, CONVERT_APOS_ENTITY );
+ final var curler = createCurler( FILTER_XML, CONVERT_APOS );
System.out.println( curler.apply( sb.toString() ) );
}
src/test/java/com/whitemagicsoftware/keenquotes/parser/QuoteEmitterTest.java
import java.util.concurrent.atomic.AtomicInteger;
-import static com.whitemagicsoftware.keenquotes.parser.Apostrophe.CONVERT_APOS_ENTITY;
+import static com.whitemagicsoftware.keenquotes.parser.Apostrophe.CONVERT_APOS;
import static com.whitemagicsoftware.keenquotes.parser.Curler.replace;
import static com.whitemagicsoftware.keenquotes.texts.TestResource.readPairs;
input,
CONTRACTIONS,
- replace( output, offset, CONVERT_APOS_ENTITY ),
+ replace( output, offset, CONVERT_APOS ),
_ -> false
);
Delta23 lines added, 11 lines removed, 12-line increase