emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] HTML export - Do not add spaces to the data in <pre> sections
@ 2008-08-10 14:30 Bernt Hansen
  2008-09-03  9:36 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2008-08-10 14:30 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode mailing list

<pre> sections for HTML export should be clean.  We can use styles
to indent the text if that is desired.

This allows copying and pasting the text from the HTML document
so that you get the original data in the
#+BEGIN_EXAMPLE
 ..
#+END_EXAMPLE
block.
---

I use <pre>..</pre> sections to save commands I use regularly in my
system documentation.  I copy and paste data directly from these
sections and noticed the extra 2 blanks preceeding the data.

This change removes the blanks only for HTML export.  The latex and
Ascii exports are unchanged.

 lisp/org-exp.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 32fa819..98fb4fe 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2953,7 +2953,7 @@ lang=\"%s\" xml:lang=\"%s\">
 
 	  ;; Fixed-width, verbatim lines (examples)
 	  (when (and org-export-with-fixed-width
-		     (string-match "^[ \t]*:\\(.*\\)" line))
+		     (string-match "^[ \t]*:  \\(.*\\)" line))
 	    (when (not infixed)
 	      (setq infixed t)
 	      (insert "<pre class=\"example\">\n"))
-- 
1.6.0.rc2

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

* Re: [PATCH] HTML export - Do not add spaces to the data in <pre> sections
  2008-08-10 14:30 [PATCH] HTML export - Do not add spaces to the data in <pre> sections Bernt Hansen
@ 2008-09-03  9:36 ` Carsten Dominik
  2008-09-03 12:00   ` Bernt Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2008-09-03  9:36 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: org-mode mailing list


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

Hi Bernt,  I am not sure if I understand your patch correctly:

On Aug 10, 2008, at 4:30 PM, Bernt Hansen wrote:

> <pre> sections for HTML export should be clean.  We can use styles
> to indent the text if that is desired.
>
> This allows copying and pasting the text from the HTML document
> so that you get the original data in the
> #+BEGIN_EXAMPLE
> ..
> #+END_EXAMPLE
> block.
> ---
>
> I use <pre>..</pre> sections to save commands I use regularly in my
> system documentation.  I copy and paste data directly from these
> sections and noticed the extra 2 blanks preceeding the data.
>
> This change removes the blanks only for HTML export.  The latex and
> Ascii exports are unchanged.
>
> lisp/org-exp.el |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> index 32fa819..98fb4fe 100644
> --- a/lisp/org-exp.el
> +++ b/lisp/org-exp.el
> @@ -2953,7 +2953,7 @@ lang=\"%s\" xml:lang=\"%s\">
>
> 	  ;; Fixed-width, verbatim lines (examples)
> 	  (when (and org-export-with-fixed-width
> -		     (string-match "^[ \t]*:\\(.*\\)" line))
> +		     (string-match "^[ \t]*:  \\(.*\\)" line))

Why are you matching exactly two spaces here?  Ah, I guess I am  
inserting
these when processing the examples....
Maybe it would be better to not insert the spaces, or insert them for  
ascii
export only.  I will do that.  Thanks.

- Carsten

>
> 	    (when (not infixed)
> 	      (setq infixed t)
> 	      (insert "<pre class=\"example\">\n"))
> -- 
> 1.6.0.rc2
>


[-- Attachment #1.2: Type: text/html, Size: 2664 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [PATCH] HTML export - Do not add spaces to the data in <pre> sections
  2008-09-03  9:36 ` Carsten Dominik
@ 2008-09-03 12:00   ` Bernt Hansen
  2008-09-03 12:41     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2008-09-03 12:00 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode mailing list

Carsten Dominik <dominik@science.uva.nl> writes:

> Hi Bernt,  I am not sure if I understand your patch correctly:

Hi Carsten!  Welcome back :)

> 
>
> On Aug 10, 2008, at 4:30 PM, Bernt Hansen wrote:
>
>     <pre> sections for HTML export should be clean.  We can use styles
>     to indent the text if that is desired.
>    
>     This allows copying and pasting the text from the HTML document
>     so that you get the original data in the
>     #+BEGIN_EXAMPLE
>     ..
>     #+END_EXAMPLE
>     block.
>     ---
>    
>     I use <pre>..</pre> sections to save commands I use regularly in my
>     system documentation.  I copy and paste data directly from these
>     sections and noticed the extra 2 blanks preceeding the data.
>    
>     This change removes the blanks only for HTML export.  The latex and
>     Ascii exports are unchanged.
>    
>     lisp/org-exp.el |    2 +-
>     1 files changed, 1 insertions(+), 1 deletions(-)
>    
>     diff --git a/lisp/org-exp.el b/lisp/org-exp.el
>     index 32fa819..98fb4fe 100644
>     --- a/lisp/org-exp.el
>     +++ b/lisp/org-exp.el
>     @@ -2953,7 +2953,7 @@ lang=\"%s\" xml:lang=\"%s\">
>    
>      ;; Fixed-width, verbatim lines (examples)
>      (when (and org-export-with-fixed-width
>     -     (string-match "^[ \t]*:\\(.*\\)" line))
>     +     (string-match "^[ \t]*:  \\(.*\\)" line))
>
> Why are you matching exactly two spaces here?  Ah, I guess I am inserting
> these when processing the examples....
> Maybe it would be better to not insert the spaces, or insert them for ascii
> export only.  I will do that.  Thanks.

Basically I don't want blanks put into the <pre> section as part of the
data.

I originally took out the 2 spaces instead of inserting them but that
affected both latex and ASCII exports and didn't look 'better' IMO.  My
goal here is just to keep the HTML output identical to what is in the
#+BEGIN_EXAMPLE..#+END_EXAMPLE block.  If we want preceeding blanks on
the data we can just put it in the original source text.

------------------------------------------------------------------------

If I do this

,----
| #+BEGIN_EXAMPLE
| $ somecommand
| data for the
| command goes here
| #+END_EXAMPLE
`----

the exported HTML output has 2 spaces in front of the data like this:

,----
| <pre class="example">
|   $ somecommand
|   data for the
|   command goes here
| </pre>
`----

The 2 preceeding blanks are put in during preprocessing of the example
section.

I don't want the preceeding 2 blanks.  They are mostly a formatting
issue and with CSS we can format the <pre> </pre> data anyway we want so
adding the blanks isn't really helpful.  It's easy to indent the
<pre>..</pre> section with CSS to get the same result as the embedded
blanks without resorting to adding preceeding blanks to the lines.

When cutting and pasting data from the resulting HTML I don't want the
extra blanks in the data since that's not really part of the original
data.  For some programs the data lines (following the $ somecommand)
needs to be verbatim and I have to cut and paste each line separately
instead of the entire block from the example.

The patch makes the output look like this instead:

,----
| <pre class="example">
| $ somecommand
| data for the
| command goes here
| </pre>
`----

and if you select it, copy it from the HTML page and paste it to a
buffer you get the original text.

Thanks!

-Bernt

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

* Re: [PATCH] HTML export - Do not add spaces to the data in <pre> sections
  2008-09-03 12:00   ` Bernt Hansen
@ 2008-09-03 12:41     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2008-09-03 12:41 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: org-mode mailing list

Fixed, thanks.

- Carsten

On Sep 3, 2008, at 2:00 PM, Bernt Hansen wrote:

> Carsten Dominik <dominik@science.uva.nl> writes:
>
>> Hi Bernt,  I am not sure if I understand your patch correctly:
>
> Hi Carsten!  Welcome back :)
>
>>
>>
>> On Aug 10, 2008, at 4:30 PM, Bernt Hansen wrote:
>>
>>    <pre> sections for HTML export should be clean.  We can use styles
>>    to indent the text if that is desired.
>>
>>    This allows copying and pasting the text from the HTML document
>>    so that you get the original data in the
>>    #+BEGIN_EXAMPLE
>>    ..
>>    #+END_EXAMPLE
>>    block.
>>    ---
>>
>>    I use <pre>..</pre> sections to save commands I use regularly in  
>> my
>>    system documentation.  I copy and paste data directly from these
>>    sections and noticed the extra 2 blanks preceeding the data.
>>
>>    This change removes the blanks only for HTML export.  The latex  
>> and
>>    Ascii exports are unchanged.
>>
>>    lisp/org-exp.el |    2 +-
>>    1 files changed, 1 insertions(+), 1 deletions(-)
>>
>>    diff --git a/lisp/org-exp.el b/lisp/org-exp.el
>>    index 32fa819..98fb4fe 100644
>>    --- a/lisp/org-exp.el
>>    +++ b/lisp/org-exp.el
>>    @@ -2953,7 +2953,7 @@ lang=\"%s\" xml:lang=\"%s\">
>>
>>     ;; Fixed-width, verbatim lines (examples)
>>     (when (and org-export-with-fixed-width
>>    -     (string-match "^[ \t]*:\\(.*\\)" line))
>>    +     (string-match "^[ \t]*:  \\(.*\\)" line))
>>
>> Why are you matching exactly two spaces here?  Ah, I guess I am  
>> inserting
>> these when processing the examples....
>> Maybe it would be better to not insert the spaces, or insert them  
>> for ascii
>> export only.  I will do that.  Thanks.
>
> Basically I don't want blanks put into the <pre> section as part of  
> the
> data.
>
> I originally took out the 2 spaces instead of inserting them but that
> affected both latex and ASCII exports and didn't look 'better' IMO.   
> My
> goal here is just to keep the HTML output identical to what is in the
> #+BEGIN_EXAMPLE..#+END_EXAMPLE block.  If we want preceeding blanks on
> the data we can just put it in the original source text.
>
> ------------------------------------------------------------------------
>
> If I do this
>
> ,----
> | #+BEGIN_EXAMPLE
> | $ somecommand
> | data for the
> | command goes here
> | #+END_EXAMPLE
> `----
>
> the exported HTML output has 2 spaces in front of the data like this:
>
> ,----
> | <pre class="example">
> |   $ somecommand
> |   data for the
> |   command goes here
> | </pre>
> `----
>
> The 2 preceeding blanks are put in during preprocessing of the example
> section.
>
> I don't want the preceeding 2 blanks.  They are mostly a formatting
> issue and with CSS we can format the <pre> </pre> data anyway we  
> want so
> adding the blanks isn't really helpful.  It's easy to indent the
> <pre>..</pre> section with CSS to get the same result as the embedded
> blanks without resorting to adding preceeding blanks to the lines.
>
> When cutting and pasting data from the resulting HTML I don't want the
> extra blanks in the data since that's not really part of the original
> data.  For some programs the data lines (following the $ somecommand)
> needs to be verbatim and I have to cut and paste each line separately
> instead of the entire block from the example.
>
> The patch makes the output look like this instead:
>
> ,----
> | <pre class="example">
> | $ somecommand
> | data for the
> | command goes here
> | </pre>
> `----
>
> and if you select it, copy it from the HTML page and paste it to a
> buffer you get the original text.
>
> Thanks!
>
> -Bernt
>

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

end of thread, other threads:[~2008-09-03 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-10 14:30 [PATCH] HTML export - Do not add spaces to the data in <pre> sections Bernt Hansen
2008-09-03  9:36 ` Carsten Dominik
2008-09-03 12:00   ` Bernt Hansen
2008-09-03 12:41     ` Carsten Dominik

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).