| Author | DaveJarvis <email> |
|---|---|
| Date | 2024-10-09 23:57:37 GMT-0700 |
| Commit | f061c875c7a6113497540bf9d08e0f86ecf92d97 |
| Parent | 37580aa |
| * No conversion is performed. | ||
| */ | ||
| - CONVERT_REGULAR( "'", "regular" ), | ||
| + CONVERT_REGULAR( "", "regular" ), | ||
| /** | ||
| * Apostrophes become MODIFIER LETTER APOSTROPHE ({@code ʼ}). |
| */ | ||
| 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 ) ); |
| } | ||
| + /** | ||
| + * 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() { |
| input, | ||
| CONTRACTIONS, | ||
| - replace( output, offset, CONVERT_APOS_ENTITY ), | ||
| + replace( output, offset, CONVERT_APOS ), | ||
| _ -> false | ||
| ); |
| 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() ) ); | ||
| } | ||
| 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 | ||
| ); | ||
| Delta | 23 lines added, 11 lines removed, 12-line increase |
|---|