]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Improve apostrophe detection after punctuation mark
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 17 Jun 2017 21:50:34 +0000 (17:50 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 17 Jun 2017 21:50:34 +0000 (17:50 -0400)
Sources/libMultiMarkdown/mmd.c
tests/MMD6Tests/Smart Quotes.fodt
tests/MMD6Tests/Smart Quotes.html
tests/MMD6Tests/Smart Quotes.htmlc
tests/MMD6Tests/Smart Quotes.tex
tests/MMD6Tests/Smart Quotes.text

index 4ca0c94a21d243c52be666370a003ba0206e492e..9e2c7947f3faaf27ba090c787749424cbe6d3905 100644 (file)
@@ -1270,7 +1270,8 @@ void mmd_assign_ambidextrous_tokens_in_block(mmd_engine * e, token * block, size
                                // Some of these are actually APOSTROPHE's and should not be paired
                                offset = t->start;
 
-                               if (!((offset == 0) || (char_is_whitespace_or_line_ending_or_punctuation(str[offset - 1])) ||
+                               if (!((offset == 0) ||
+                                       (char_is_whitespace_or_line_ending_or_punctuation(str[offset - 1])) ||
                                        (char_is_whitespace_or_line_ending_or_punctuation(str[offset + 1])))) {
                                        t->type = APOSTROPHE;
                                        break;
@@ -1278,8 +1279,13 @@ void mmd_assign_ambidextrous_tokens_in_block(mmd_engine * e, token * block, size
 
                                if (offset && (char_is_punctuation(str[offset - 1])) &&
                                        (char_is_alphanumeric(str[offset + 1]))) {
-                                       t->type = APOSTROPHE;
-                                       break;
+                                       // If possessive apostrophe, e.g. `x`'s 
+                                       if (str[offset + 1] == 's' || str[offset + 1] == 'S') {
+                                               if (char_is_whitespace_or_line_ending_or_punctuation(str[offset + 2])) {
+                                                       t->type = APOSTROPHE;
+                                                       break;
+                                               }
+                                       }
                                }
                        case QUOTE_DOUBLE:
                                offset = t->start;
index 8a6b7268d736f403adc51e80060d7ed5b7f6be87..3d59ff8f25c1d572c6e99ecb8f1d9d53f985fbdb 100644 (file)
 <text:p text:style-name="Standard">foo&#8217;s and bar&#8217;s</text:p>
 
 <text:p text:style-name="Standard"><text:span text:style-name="Source_20_Text">foo</text:span>&#8217;s and <text:span text:style-name="Source_20_Text">bar</text:span>&#8217;s</text:p>
+
+<text:p text:style-name="Standard">30</text:p>
+
+<text:p text:style-name="Standard">foo(&#8216;bar&#8217;)</text:p>
+
+<text:p text:style-name="Standard">foo(&#8220;bar&#8221;)</text:p>
 </office:text>
 </office:body>
 </office:document>
index cf49903579a2a6ca19b5f19ed2a4e36f2ecba921..db157d9c684b815c7b88ec16bff946cfeb15b6c3 100644 (file)
 
 <p><code>foo</code>&#8217;s and <code>bar</code>&#8217;s</p>
 
+<p>30</p>
+
+<p>foo(&#8216;bar&#8217;)</p>
+
+<p>foo(&#8220;bar&#8221;)</p>
+
 </body>
 </html>
 
index 413ee558605c7bf51e7e27cf4d1e3e5472533684..104dafbddf1421268589a5fe3d28b3004f212fc5 100644 (file)
@@ -70,3 +70,9 @@ latex config: article</p>
 <p>foo's and bar's</p>
 
 <p><code>foo</code>'s and <code>bar</code>'s</p>
+
+<p>30</p>
+
+<p>foo('bar')</p>
+
+<p>foo(&quot;bar&quot;)</p>
index 16be996dc28ef8081396001a5b40c5f154b330d2..47d380007d963bbe77322efc7c18746b78ccce33 100644 (file)
@@ -72,5 +72,11 @@ foo's and bar's
 
 \texttt{foo}'s and \texttt{bar}'s
 
+30
+
+foo(`bar')
+
+foo(``bar'')
+
 \input{mmd6-article-footer}
 \end{document}
index a1e92e4928e0fb7f5dd20ab72d3ed9312dc67edb..c94227d1001bc345162ff5b42f16382a7050a973 100644 (file)
@@ -70,3 +70,9 @@ l'année l'été
 foo's and bar's
 
 `foo`'s and `bar`'s
+
+30
+
+foo('bar')
+
+foo("bar")