summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Ollila <tomi.ollila@iki.fi>2020-10-09 10:32:02 +0300
committerDavid Bremner <david@tethera.net>2020-10-21 06:55:39 -0300
commitbdb6956afdd2fca610c3bac0834636835793a831 (patch)
tree2c0c22d2f0406b52ef7ff56aaa90301ff9ec3d23
parent45193bab16c728ba892a5d45fc62ef59e2a6ef85 (diff)
emacs docs: rstdoc.el: consistent single quote conversions
With text-quoting-style 'grave keeps "'" and "`" quotes unaltered for further processing done by this code (regardless of locale...). The tools that read the reStructuredText markup generated can do their styling instead. Added temporary conversions of ' and ` to \001 and \002 so that 's and `s outside of `...' and `...` are converted separately ('s restored back to ' and `s converted to \`). Both `...' and `...` are finally "converted" to `...` (not ``...``). https://docutils.sourceforge.io/docs/user/rst/quickref.html documents that as `interpreted text`: "The rendering and meaning of interpreted text is domain- or application-dependent. It can be used for things like index entries or explicit descriptive markup (like program identifiers)." Which looks pretty much right.
-rw-r--r--emacs/rstdoc.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 63fa2794..4221f142 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -40,6 +40,7 @@
"Write docstrings from IN-FILE to OUT-FILE."
(load-file in-file)
(let* ((definitions (cdr (assoc (expand-file-name in-file) load-history)))
+ (text-quoting-style 'grave)
(doc-hash (make-hash-table :test 'eq)))
(mapc
(lambda (elt)
@@ -65,11 +66,14 @@
(insert "\n"))
(defvar rst--escape-alist
- '(("\\\\='" . "\\\\'")
- ("\\([^\\]\\)'" . "\\1`")
- ("^[[:space:]\t]*$" . "|br|")
- ("^[[:space:]\t]" . "|indent| "))
- "List of (regex . replacement) pairs.")
+ '( ("\\\\='" . "\001")
+ ("`\\([^\n`']*\\)[`']" . "\002\\1\002") ;; good enough for now...
+ ("`" . "\\\\`")
+ ("\001" . "'")
+ ("\002" . "`")
+ ("^[[:space:]]*$" . "|br|")
+ ("^[[:space:]]" . "|indent| "))
+ "list of (regex . replacement) pairs")
(defun rstdoc--rst-quote-string (str)
(with-temp-buffer