emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* adding "wrap=off" option to textarea for HTML export
@ 2016-09-08 15:49 Eric S Fraga
  2016-09-08 17:54 ` Nick Dokos
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Eric S Fraga @ 2016-09-08 15:49 UTC (permalink / raw)
  To: Emacs Org mode mailing list

Hi,

I'm preparing some documentation, exported to HTML, that includes the
output of a src block.  Because this output is rather long, I have

#+attr_html: :textarea t :height 20

before the results of the src block.  This generates the correct
<textarea> form in the HTML output.  The text area form's width is
automatically set to the text width using CSS.  The problem is that some
of the output lines in the src block results are quite long and they
wrap; this looks ugly.

To turn wrapping off, I would need to add 'wrap="off"' to the textarea
form as this option cannot be controlled using CSS unfortunately.  I
don't see any way to do this from org.

Any suggestions on how to accomplish this, assuming it is possible?  

Many thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.94.1, Org release_8.3.5-1070-g190476

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
  2016-09-08 15:49 adding "wrap=off" option to textarea for HTML export Eric S Fraga
@ 2016-09-08 17:54 ` Nick Dokos
       [not found] ` <69324c9e4bfc4fd3bd7df7882e857fd2@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Nick Dokos @ 2016-09-08 17:54 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> I'm preparing some documentation, exported to HTML, that includes the
> output of a src block.  Because this output is rather long, I have
>
> #+attr_html: :textarea t :height 20
>
> before the results of the src block.  This generates the correct
> <textarea> form in the HTML output.  The text area form's width is
> automatically set to the text width using CSS.  The problem is that some
> of the output lines in the src block results are quite long and they
> wrap; this looks ugly.
>
> To turn wrapping off, I would need to add 'wrap="off"' to the textarea
> form as this option cannot be controlled using CSS unfortunately.  I
> don't see any way to do this from org.
>
> Any suggestions on how to accomplish this, assuming it is possible?  
>
Can you add a post-processing hook? A simple text replacement might be enough.

Or modify the textarea function to understand :wrap - not sure whether Nicolas
would accept a patch though:

--8<---------------cut here---------------start------------->8---
(defun org-html--textarea-block (element)
  "Transcode ELEMENT into a textarea block.
ELEMENT is either a src block or an example block."
  (let* ((code (car (org-export-unravel-code element)))
	 (attr (org-export-read-attribute :attr_html element)))
    (format "<p>\n<textarea cols=\"%s\" rows=\"%s\" wrap=\"%s\">\n%s</textarea>\n</p>"
	    (or (plist-get attr :width) 80)
	    (or (plist-get attr :height) (org-count-lines code))
            (or (plist-get attr :wrap) "on")
	    code)))
--8<---------------cut here---------------end--------------->8---

Untested.

-- 
Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
       [not found] ` <69324c9e4bfc4fd3bd7df7882e857fd2@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-09-08 18:27   ` Eric S Fraga
  2016-09-08 20:51     ` Nicolas Goaziou
       [not found]     ` <36a89fa2bafb4a0b84ff8ad6523d61a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  2016-09-09  8:08   ` Eric S Fraga
  1 sibling, 2 replies; 8+ messages in thread
From: Eric S Fraga @ 2016-09-08 18:27 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode@gnu.org

On Thursday,  8 Sep 2016 at 17:54, Nick Dokos wrote:
> Can you add a post-processing hook? A simple text replacement might be enough.

Very good suggestion.  The HTML produced is quite straightforward so
this should be easy.  I'll play around.  Thanks.

> Or modify the textarea function to understand :wrap - not sure whether
> Nicolas would accept a patch though:

Would be nice...  Nicolas?

Thanks again,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.94.1, Org release_8.3.5-1070-g190476

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
  2016-09-08 18:27   ` Eric S Fraga
@ 2016-09-08 20:51     ` Nicolas Goaziou
       [not found]     ` <36a89fa2bafb4a0b84ff8ad6523d61a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2016-09-08 20:51 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode@gnu.org

Hello,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Thursday,  8 Sep 2016 at 17:54, Nick Dokos wrote:
>> Can you add a post-processing hook? A simple text replacement might be enough.
>
> Very good suggestion.  The HTML produced is quite straightforward so
> this should be easy.  I'll play around.  Thanks.
>
>> Or modify the textarea function to understand :wrap - not sure whether
>> Nicolas would accept a patch though:
>
> Would be nice...  Nicolas?

It sounds like a good idea. However, it would also require some
documentation, even minimal.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
       [not found] ` <69324c9e4bfc4fd3bd7df7882e857fd2@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  2016-09-08 18:27   ` Eric S Fraga
@ 2016-09-09  8:08   ` Eric S Fraga
  1 sibling, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2016-09-09  8:08 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode@gnu.org

On Thursday,  8 Sep 2016 at 17:54, Nick Dokos wrote:
> Can you add a post-processing hook? A simple text replacement might be enough.

This worked very well:

#+begin_src emacs-lisp :exports results :results none
  (defun add-wrap-to-textarea (text backend info)
    (when (org-export-derived-backend-p backend 'html)
      (replace-regexp-in-string "<textarea " "<textarea wrap=\"off\" " text)))
  (add-to-list 'org-export-filter-final-output-functions 'add-wrap-to-textarea)
#+end_src

Thanks again,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.94.1, Org release_8.3.4-655-g9fb077

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
  2016-09-08 15:49 adding "wrap=off" option to textarea for HTML export Eric S Fraga
  2016-09-08 17:54 ` Nick Dokos
       [not found] ` <69324c9e4bfc4fd3bd7df7882e857fd2@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-09-09 15:32 ` Clément Pit--Claudel
       [not found] ` <0960a5432ed143b18552148fd5b67941@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  3 siblings, 0 replies; 8+ messages in thread
From: Clément Pit--Claudel @ 2016-09-09 15:32 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 305 bytes --]

On 2016-09-08 11:49, Eric S Fraga wrote:
> To turn wrapping off, I would need to add 'wrap="off"' to the textarea
> form as this option cannot be controlled using CSS unfortunately.  I
> don't see any way to do this from org.

Hm. Doesn't the following work?

textarea {
  white-space: pre;
}


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
       [not found] ` <0960a5432ed143b18552148fd5b67941@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-09-09 16:06   ` Eric S Fraga
  0 siblings, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2016-09-09 16:06 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-orgmode@gnu.org

On Friday,  9 Sep 2016 at 15:32, Clément Pit--Claudel wrote:
> On 2016-09-08 11:49, Eric S Fraga wrote:
>> To turn wrapping off, I would need to add 'wrap="off"' to the textarea
>> form as this option cannot be controlled using CSS unfortunately.  I
>> don't see any way to do this from org.
>
> Hm. Doesn't the following work?
>
> textarea {
>   white-space: pre;
> }

Ah, it does!  That'll teach me to believe what I read on the
Interweb... which told me that CSS could not achieve this.  I've just
tested it and it works just fine, at least on Firefox.

Thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-535-g7213aa

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding "wrap=off" option to textarea for HTML export
       [not found]     ` <36a89fa2bafb4a0b84ff8ad6523d61a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-09-10  9:20       ` Eric S Fraga
  0 siblings, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2016-09-10  9:20 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode@gnu.org

On Thursday,  8 Sep 2016 at 20:51, Nicolas Goaziou wrote:
> Hello,
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> On Thursday,  8 Sep 2016 at 17:54, Nick Dokos wrote:
>>> Or modify the textarea function to understand :wrap - not sure whether
>>> Nicolas would accept a patch though:
>>
>> Would be nice...  Nicolas?
>
> It sounds like a good idea. However, it would also require some
> documentation, even minimal.

Nicolas, given that it is actually possible to control this aspect using
CSS (white-space style), there is no need for a special attribute after
all.

thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.94.1, Org release_8.3.5-1070-g190476

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-09-10 14:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-08 15:49 adding "wrap=off" option to textarea for HTML export Eric S Fraga
2016-09-08 17:54 ` Nick Dokos
     [not found] ` <69324c9e4bfc4fd3bd7df7882e857fd2@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-09-08 18:27   ` Eric S Fraga
2016-09-08 20:51     ` Nicolas Goaziou
     [not found]     ` <36a89fa2bafb4a0b84ff8ad6523d61a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-09-10  9:20       ` Eric S Fraga
2016-09-09  8:08   ` Eric S Fraga
2016-09-09 15:32 ` Clément Pit--Claudel
     [not found] ` <0960a5432ed143b18552148fd5b67941@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-09-09 16:06   ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).