emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [bug, ox-ascii][PATCH] description list and long links


From: Rasmus
Subject: [O] [bug, ox-ascii][PATCH] description list and long links
Date: Wed, 28 Jan 2015 01:30:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi,

Consider the following example:

--8<---------------cut here---------------start------------->8---
(with-temp-buffer 
  (require 'ox-ascii)
  (insert
   "- 
[[http://www.npr.org/blogs/monkeysee/2009/03/a_very_long_url_makes_a_very_s.html][A
 label with a long link]] :: Lorem ipsum dolor sit amet, consectetur adipiscing 
elit\n")
  (org-ascii-export-as-ascii nil nil nil t))  
--8<---------------cut here---------------end--------------->8---

With output:

--8<---------------cut here---------------start------------->8---
[A label with a long link]: Lorem
                            ipsum
                            dolor
                            sit
                            amet,
                            consectetur
                            adipiscing
                            elit


[A label with a long link]
http://www.npr.org/blogs/monkeysee/2009/03/a_very_long_url_makes_a_very_s.html
--8<---------------cut here---------------end--------------->8---

The reason for the wrong formatting is that org-ascii--current-text-width
takes that there's is like -28 characters left for lorem ipsum...  It does
that because it counts link and label.

The patch fixes this by only counting the length of the label.

I'm not really familiar with the ascii backend, so let me know if there's
any obvious deficits that I have overlooked.

Otherwise I push it.

—Rasmus


-- 
Evidence suggests Snowden used a powerful tool called monospaced fonts
>From 7b6a8730de6f5ec57f5d45af57c3c9f90f389fef Mon Sep 17 00:00:00 2001
From: Rasmus <address@hidden>
Date: Wed, 28 Jan 2015 01:10:56 +0100
Subject: [PATCH] ox-ascii.el: Bug in description-list formatting

* ox-ascii.el (org-ascii--current-text-width): Consider length of
  label for links.
---
 lisp/ox-ascii.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e294fab..cd239f9 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -624,8 +624,11 @@ INFO is a plist used as a communication channel."
                      (string-width (or (org-ascii--checkbox parent-item info)
                                        ""))
                      (string-width
-                      (or (org-list-get-tag beg-item struct)
-                          (org-list-get-bullet beg-item struct)))))))))))))
+                      (let ((tag (or (org-list-get-tag beg-item struct)
+                                     (org-list-get-bullet beg-item struct))))
+                        (if (string-match org-bracket-link-analytic-regexp tag)
+                            (match-string 4 tag)
+                          tag)))))))))))))
 
 (defun org-ascii--current-justification (element)
   "Return expected justification for ELEMENT's contents.
-- 
2.2.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]