emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* angle brackets around timestamps in html export
@ 2013-08-30 15:59 Matt Price
  2013-09-03 13:01 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Price @ 2013-08-30 15:59 UTC (permalink / raw)
  To: Org Mode

Hello again,

I'm trying to get rid of angle brackets in HTML export.  I've set
org-export-date-timestamp-format to "%a, %b %d".  I also have
timestamp overlays turned on, and the displayed custom format set to
"<%a, %b %d>" (that seems unlikely to be relevant, but I've changed it
just in case).

Sorry I can't find the answer in the docs, I'm sure it's there
somewhere but I'm missing it somehow!

Matt

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

* Re: angle brackets around timestamps in html export
  2013-08-30 15:59 angle brackets around timestamps in html export Matt Price
@ 2013-09-03 13:01 ` Nicolas Goaziou
  2013-09-03 13:40   ` Matt Price
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2013-09-03 13:01 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Hello,

Matt Price <moptop99@gmail.com> writes:

> I'm trying to get rid of angle brackets in HTML export.  I've set
> org-export-date-timestamp-format to "%a, %b %d".

This variable only applies to a timestamp specified in DATE keyword.

> I also have timestamp overlays turned on, and the displayed custom
> format set to "<%a, %b %d>" (that seems unlikely to be relevant, but
> I've changed it just in case).

This should work with:

  - `org-display-custom-times' set to t
  - `org-time-stamp-custom-formats' set to a cons cell with values
    without angle brackets.

These variables can be buffer-local.

> Sorry I can't find the answer in the docs, I'm sure it's there
> somewhere but I'm missing it somehow!

You can also use a filter on every timestamp exported and make sure any
angle bracket is removed.


Regards,

-- 
Nicolas Goaziou

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

* Re: angle brackets around timestamps in html export
  2013-09-03 13:01 ` Nicolas Goaziou
@ 2013-09-03 13:40   ` Matt Price
  2013-09-03 13:50     ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Price @ 2013-09-03 13:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

On Tue, Sep 3, 2013 at 9:01 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> Matt Price <moptop99@gmail.com> writes:
>
>> I'm trying to get rid of angle brackets in HTML export.  I've set
>> org-export-date-timestamp-format to "%a, %b %d".
>
> This variable only applies to a timestamp specified in DATE keyword.
>
>> I also have timestamp overlays turned on, and the displayed custom
>> format set to "<%a, %b %d>" (that seems unlikely to be relevant, but
>> I've changed it just in case).
>
> This should work with:
>
>   - `org-display-custom-times' set to t
>   - `org-time-stamp-custom-formats' set to a cons cell with values
>     without angle brackets.
>
> These variables can be buffer-local.
>

Hmm.  I have org-diplay-custom-times set to t.
org-time-stamp-custom-formats is customized:
----------
org-time-stamp-custom-formats is a variable defined in `org.el'.
Its value is (" %a, %b. %d " . "<%m/%d/%y %a %H:%M>")
Original value was
("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>")
-----------

On html export, the following is generated:
-----
<span class="timestamp-wrapper"><span class="timestamp">&lt;Tue, Sep.
10&gt;</span></span>
-----

so it looks like it's difficult to remove the brackets with those two
variables.

>> Sorry I can't find the answer in the docs, I'm sure it's there
>> somewhere but I'm missing it somehow!
>
> You can also use a filter on every timestamp exported and make sure any
> angle bracket is removed.

I was able to add this bit of javascript to my wordpress site to
remove the brackets:
-----------
     var elements = document.getElementsByClassName("timestamp");
for (var i = 0; i < elements.length; ++i) {
    console.log("removing timestamp");
  elements[i].innerHTML =
elements[i].innerHTML.replace(/(&lt;|&gt;|\[|\])/g,'');
}
---------
Is that what you mean by a filter, or should I be doing something in emacs.

thank you Nicolas!
Matt
>
>
> Regards,
>
> --
> Nicolas Goaziou

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

* Re: angle brackets around timestamps in html export
  2013-09-03 13:40   ` Matt Price
@ 2013-09-03 13:50     ` Nicolas Goaziou
  2013-09-03 14:22       ` Matt Price
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2013-09-03 13:50 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Matt Price <moptop99@gmail.com> writes:

> so it looks like it's difficult to remove the brackets with those two
> variables.

Indeed. It looks like `org-translate-time' always add brackets in the
end.
>
>>> Sorry I can't find the answer in the docs, I'm sure it's there
>>> somewhere but I'm missing it somehow!
>>
>> You can also use a filter on every timestamp exported and make sure any
>> angle bracket is removed.
>
> I was able to add this bit of javascript to my wordpress site to
> remove the brackets:
> -----------
>      var elements = document.getElementsByClassName("timestamp");
> for (var i = 0; i < elements.length; ++i) {
>     console.log("removing timestamp");
>   elements[i].innerHTML =
> elements[i].innerHTML.replace(/(&lt;|&gt;|\[|\])/g,'');
> }
> ---------
> Is that what you mean by a filter, or should I be doing something in
> emacs.

I basically meant the Elisp counterpart of this.  See
`org-export-filter-timestamp-functions' and "12.13 Advanced
configuration" in Org manual.


Regards,

-- 
Nicolas Goaziou

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

* Re: angle brackets around timestamps in html export
  2013-09-03 13:50     ` Nicolas Goaziou
@ 2013-09-03 14:22       ` Matt Price
  2013-09-03 14:34         ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Price @ 2013-09-03 14:22 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

On Tue, Sep 3, 2013 at 9:50 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Matt Price <moptop99@gmail.com> writes:
>
>>> You can also use a filter on every timestamp exported and make sure any
>>> angle bracket is removed.
>>
>> I was able to add this bit of javascript to my wordpress site to
>> remove the brackets:
>> -----------
>>      var elements = document.getElementsByClassName("timestamp");
>> for (var i = 0; i < elements.length; ++i) {
>>     console.log("removing timestamp");
>>   elements[i].innerHTML =
>> elements[i].innerHTML.replace(/(&lt;|&gt;|\[|\])/g,'');
>> }
>> ---------
>> Is that what you mean by a filter, or should I be doing something in
>> emacs.
>
> I basically meant the Elisp counterpart of this.  See
> `org-export-filter-timestamp-functions' and "12.13 Advanced
> configuration" in Org manual.

thanks nicolas.  If you happen to have a moment, I'm having trouble
reproducing this regexp in elisp.  I would think that, even if I can't
figure out how to construct a single regex that matches all the
characters I want to remove, omething like this ought to work:
-------
(defun matt-org-export-filter-timestamp-function (timestamp backend info)
  "removes relevant brackets from a timestamp"
  (when (org-export-derived-backend-p backend 'html)
    ;; unfortunatley I can't make emacs regexps work yet.  sigh.
    (replace-regexp-in-string "[][]" "" timestamp)
    ;; (replace-regexp-in-string "&lt;" "" timestamp)
))
--------------
but the second (commented-out) regexp seems to break my export.

Again, many thanks.
matt


>
>
> Regards,
>
> --
> Nicolas Goaziou

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

* Re: angle brackets around timestamps in html export
  2013-09-03 14:22       ` Matt Price
@ 2013-09-03 14:34         ` Nicolas Goaziou
  2013-09-03 16:24           ` Matt Price
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2013-09-03 14:34 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Matt Price <moptop99@gmail.com> writes:

> thanks nicolas.  If you happen to have a moment, I'm having trouble
> reproducing this regexp in elisp.  I would think that, even if I can't
> figure out how to construct a single regex that matches all the
> characters I want to remove, omething like this ought to work:
> -------
> (defun matt-org-export-filter-timestamp-function (timestamp backend info)
>   "removes relevant brackets from a timestamp"
>   (when (org-export-derived-backend-p backend 'html)
>     ;; unfortunatley I can't make emacs regexps work yet.  sigh.
>     (replace-regexp-in-string "[][]" "" timestamp)
>     ;; (replace-regexp-in-string "&lt;" "" timestamp)
> ))
> --------------
> but the second (commented-out) regexp seems to break my export.

The following should work:

  (defun matt-org-export-filter-timestamp-function (timestamp backend info)
    "removes relevant brackets from a timestamp"
    (when (org-export-derived-backend-p backend 'html)
      (replace-regexp-in-string "&[lg]t;\\|[][]" "" timestamp)))

  (add-to-list 'org-export-filter-timestamp-functions
               'matt-org-export-filter-timestamp-function)

Regards,

-- 
Nicolas Goaziou

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

* Re: angle brackets around timestamps in html export
  2013-09-03 14:34         ` Nicolas Goaziou
@ 2013-09-03 16:24           ` Matt Price
  0 siblings, 0 replies; 7+ messages in thread
From: Matt Price @ 2013-09-03 16:24 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

On Tue, Sep 3, 2013 at 10:34 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Matt Price <moptop99@gmail.com> writes:

> The following should work:
>
>   (defun matt-org-export-filter-timestamp-function (timestamp backend info)
>     "removes relevant brackets from a timestamp"
>     (when (org-export-derived-backend-p backend 'html)
>       (replace-regexp-in-string "&[lg]t;\\|[][]" "" timestamp)))
>
>   (add-to-list 'org-export-filter-timestamp-functions
>                'matt-org-export-filter-timestamp-function)
>
that did it!  Thanks Nicolas.

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

end of thread, other threads:[~2013-09-03 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-30 15:59 angle brackets around timestamps in html export Matt Price
2013-09-03 13:01 ` Nicolas Goaziou
2013-09-03 13:40   ` Matt Price
2013-09-03 13:50     ` Nicolas Goaziou
2013-09-03 14:22       ` Matt Price
2013-09-03 14:34         ` Nicolas Goaziou
2013-09-03 16:24           ` Matt Price

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