From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
Date: Fri, 9 Oct 2020 10:32:02 +0300 [thread overview]
Message-ID: <20201009073202.9450-1-tomi.ollila@iki.fi> (raw)
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.
---
Overhauled version of id:20200413104108.10837-1-tomi.ollila@iki.fi
When the default 'curve text quoting style was effective in UTF-8
locale, I experienced inconsistent conversions from `' to ‘’;
sometimes conversions weren't done (one more reason to use 'grave :)
---
emacs/rstdoc.el | 14 +++++++++-----
1 file 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 @@ (defun rstdoc-extract (in-file out-file)
"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 @@ (defun rstdoc--insert-docstring (symbol docstring)
(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
--
2.25.1\r
next reply other threads:[~2020-10-09 7:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 7:32 Tomi Ollila [this message]
2020-10-09 9:44 ` [PATCH] emacs docs: rstdoc.el: consistent single quote conversions David Bremner
2020-10-13 15:00 ` Tomi Ollila
2020-10-17 11:29 ` David Bremner
2020-10-21 9:59 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009073202.9450-1-tomi.ollila@iki.fi \
--to=tomi.ollila@iki.fi \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).