[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bidirectional text and URLs
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: Bidirectional text and URLs |
Date: |
Sun, 30 Nov 2014 20:10:29 +0100 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Bug fix! Leading neutralish characters would defeat it.
(defun ensure-left-to-right-string (string)
(let ((prev (get-char-code-property (aref string 0) 'bidi-class))
(start 0)
(pos 0)
(bits nil))
(while (< pos (length string))
(setq current (get-char-code-property (aref string pos) 'bidi-class))
(when (or (and (eq prev 'L)
(memq current '(R AL)))
(and (memq prev '(R AL))
(eq current 'L)))
(push (substring string start pos) bits)
(setq start pos))
(when (memq current '(L R AL))
(setq prev current))
(cl-incf pos))
(push (substring string start pos) bits)
(mapconcat
(lambda (bit)
(if (cl-notany (lambda (char)
(memq (get-char-code-property char 'bidi-class) '(R
AL)))
bit)
;; Wrap the string in LRO and PDF.
(concat (string ?\x202d) bit (string ?\x202C))
;; And RLO and PDF for the right-to-left bits.
(concat (string ?\x202e) bit (string ?\x202C))))
(nreverse bits)
"")))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: Bidirectional text and URLs, (continued)
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/29
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs, Yuri Khan, 2014/11/30
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs,
Lars Magne Ingebrigtsen <=
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Lars Magne Ingebrigtsen, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Richard Stallman, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30
- Re: Bidirectional text and URLs, Ted Zlatanov, 2014/11/29
- Re: Bidirectional text and URLs, Stephen J. Turnbull, 2014/11/30
- Re: Bidirectional text and URLs, Eli Zaretskii, 2014/11/30