jespersandal / drupal-fixer

Fixing common errors with character encoding and markdown in articles.
0 stars 0 forks source link

Fast quote fix causes problems #3

Closed jespersandal closed 7 years ago

jespersandal commented 7 years ago

There are two issues that breaks the easy substitution of begin and end quotes:

1) Sometimes a document uses the same mark as both start and end for a quote. This causes a simple substitution to fail. E.g. ”Something something,” she said.

2) Sometimes the same marks are used for both the quote and a quote within the quote, causing the advanced and simple substitution to fail.

In fixpick.js: // First, a simple substitution of marks with different start and end: // This part creates issues with documents where end marks are used for // both beginning and end. XXX FIXME / if (settings.charAt(3) != "C") { unfixed = unfixed.replace(/“/g, markin); unfixed = unfixed.replace(/”/g, markout); } // Similarly, this part could cause issues if converting from French quotes: if (settings.charAt(3) != "B") { unfixed = unfixed.replace(/»/g, markin); unfixed = unfixed.replace(/«/g, markout); } / // As a temporary fix, we replace with straight quotes. unfixed = unfixed.replace(/”/g, '"'); unfixed = unfixed.replace(/“/g, '"'); // Another fix needed: if a quote contains another quote and both use // the same quotation marks, not all will be fixed. That will require // a tweak of the algorithm.

jespersandal commented 7 years ago

Changed the algorithm that looks for sentence quotes so it can better handle different scenarios where we start with all straight quotes. Not perfect, but works so far.