I have a document containing many quotation marks. I need to replace all pairs of " with \quotation{ (beginning) and } (ending), for use in ConTeXt, e.g.:
"Do not be afraid," said the tiger, "I am a vegetarian."
This should become:
\quotation{Do not be afraid,} said the tiger, \quotation{I am a vegetarian.}
- There are no nested quotes in the document.
- The replacement should only appear when the quotation marks are found in pairs. If a line has an odd number of quotation marks, then changes should not made made to that line, as that is an indication that there is an error.
- If the character “/” appears between the start and ending quote, then the changes should mode be made to that line, as that is another indication of an error.
- Each paragraph appears on a single line, so the code should process the document one line at a time.
How can I replace these quotation marks with the format used by ConTeXt?
Not perfect, but you can try something like this –
Test: