emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org publish inserting HTML tags into sitemap-format-entry
@ 2019-07-10 21:44 Thomas Ingram
  2019-07-10 23:47 ` Thibault Marin
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Ingram @ 2019-07-10 21:44 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hello,

I am using  ox-publish to build my website. I have a custom 
sitemap-formt-entry function that adds post dates and I'm trying to add 
a div around those dates. Problem is the tags are getting escaped in the 
resulting HTML. How can I add tags without them being escaped?

Below is my :sitemap-format-entry function.

(defun org-sitemap-custom-entry-format (entry style project)
   (let ((filename (org-publish-find-title entry project)))
     (if (= (length filename) 0)
         (format "*%s*" entry)
       (format "<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]"
               (format-time-string "%Y-%m-%d"
                   (org-publish-find-date entry project))
               entry
               filename))))

Thanks for the help!

Thomas Ingram

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

* Re: Org publish inserting HTML tags into sitemap-format-entry
  2019-07-10 21:44 Org publish inserting HTML tags into sitemap-format-entry Thomas Ingram
@ 2019-07-10 23:47 ` Thibault Marin
  2019-07-11  0:30   ` Thomas Ingram
  0 siblings, 1 reply; 5+ messages in thread
From: Thibault Marin @ 2019-07-10 23:47 UTC (permalink / raw)
  To: Thomas Ingram; +Cc: emacs-orgmode@gnu.org


You may need to wrap the html part in a `#+begin_export html' block or
similar.  I believe the custom sitemap function should generate org
content, not directly HTML.

Hope it helps.

On 2019-07-10T17:44:01-0400, Thomas Ingram wrote:

  Hello,

  I am using ox-publish to build my website. I have a custom
  sitemap-formt-entry function that adds post dates and I'm trying to
  add a div around those dates. Problem is the tags are getting escaped
  in the resulting HTML. How can I add tags without them being escaped?

  Below is my :sitemap-format-entry function.

  (defun org-sitemap-custom-entry-format (entry style project)
   (let ((filename (org-publish-find-title entry project)))
   (if (= (length filename) 0)
   (format "*%s*" entry)
   (format "<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]"
   (format-time-string "%Y-%m-%d"
       (org-publish-find-date entry project))
   entry
   filename))))

  Thanks for the help!

  Thomas Ingram

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

* Re: Org publish inserting HTML tags into sitemap-format-entry
  2019-07-10 23:47 ` Thibault Marin
@ 2019-07-11  0:30   ` Thomas Ingram
  2019-07-11  1:30     ` Thibault Marin
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Ingram @ 2019-07-11  0:30 UTC (permalink / raw)
  To: thibault.marin; +Cc: emacs-orgmode@gnu.org

Thanks, but adding `#+begin_export html' simply outputs that as well 
without changing the output

"#+begin_export html
<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]
#+end_export"

Produces

<li>#+begin<sub>export</sub>html &lt;div 
class="timestamp"&gt;2019-07-10&lt;/div&gt; <a 
href="blog/test.html">Test</a>#+end<sub>export</sub></li>

On 7/10/19 7:47 PM, Thibault Marin wrote:
> You may need to wrap the html part in a `#+begin_export html' block or
> similar.  I believe the custom sitemap function should generate org
> content, not directly HTML.
>
> Hope it helps.
>
> On 2019-07-10T17:44:01-0400, Thomas Ingram wrote:
>
>    Hello,
>
>    I am using ox-publish to build my website. I have a custom
>    sitemap-formt-entry function that adds post dates and I'm trying to
>    add a div around those dates. Problem is the tags are getting escaped
>    in the resulting HTML. How can I add tags without them being escaped?
>
>    Below is my :sitemap-format-entry function.
>
>    (defun org-sitemap-custom-entry-format (entry style project)
>     (let ((filename (org-publish-find-title entry project)))
>     (if (= (length filename) 0)
>     (format "*%s*" entry)
>     (format "<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]"
>     (format-time-string "%Y-%m-%d"
>         (org-publish-find-date entry project))
>     entry
>     filename))))
>
>    Thanks for the help!
>
>    Thomas Ingram
>
>
>

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

* Re: Org publish inserting HTML tags into sitemap-format-entry
  2019-07-11  0:30   ` Thomas Ingram
@ 2019-07-11  1:30     ` Thibault Marin
  2019-07-12 15:08       ` Thomas Ingram
  0 siblings, 1 reply; 5+ messages in thread
From: Thibault Marin @ 2019-07-11  1:30 UTC (permalink / raw)
  To: Thomas Ingram; +Cc: emacs-orgmode@gnu.org


Right, sorry I thought that would be easier.

The closest I can get is with a global macro (called `div' in the following):

,----
| (defun org-sitemap-custom-entry-format (entry style project)
|   "Custom sitemap entry formatting: add date"
|   (cond ((not (directory-name-p entry))
|          (format "[[file:%s][(%s) %s]]{{{div(%s)}}}\n"
|                  entry
|                  (format-time-string "%Y-%m-%d"
|                                      (org-publish-find-date entry project))
|                  (org-publish-find-title entry project)
|                  (format-time-string "%Y-%m-%d"
|                                      (org-publish-find-date entry project))))
|         ((eq style 'tree)
|          ;; Return only last subdir.
|          (file-name-nondirectory (directory-file-name entry)))
|         (t entry)))
`----

The macro is global:
,----
| (setq org-export-global-macros
|       '(("div" . "@@html:<div style=\"color:blue;\">$1</div>@@")))
`----

The only(?) problem is that I get a line return between the title and
the date in the sitemap.  I wonder if this can be fixed, maybe by
passing extra options to `org-list-to-generic'.

This may be a starting point.


On 2019-07-10T20:30:42-0400, Thomas Ingram wrote:

  Thanks, but adding `#+begin_export html' simply outputs that as well
  without changing the output

  "#+begin_export html
  <div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]
  #+end_export"

  Produces

  <li>#+begin<sub>export</sub>html &lt;div
  class="timestamp"&gt;2019-07-10&lt;/div&gt; <a
href="blog/test.html">Test</a>#+end<sub>export</sub></li>

  On 7/10/19 7:47 PM, Thibault Marin wrote:
  > You may need to wrap the html part in a `#+begin_export html' block or
  > similar.  I believe the custom sitemap function should generate org
  > content, not directly HTML.
  >
  > Hope it helps.
  >
  > On 2019-07-10T17:44:01-0400, Thomas Ingram wrote:
  >
  >    Hello,
  >
  >    I am using ox-publish to build my website. I have a custom
  >    sitemap-formt-entry function that adds post dates and I'm trying to
  >    add a div around those dates. Problem is the tags are getting escaped
  >    in the resulting HTML. How can I add tags without them being escaped?
  >
  >    Below is my :sitemap-format-entry function.
  >
  >    (defun org-sitemap-custom-entry-format (entry style project)
  >     (let ((filename (org-publish-find-title entry project)))
  >     (if (= (length filename) 0)
  >     (format "*%s*" entry)
  >     (format "<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]"
  >     (format-time-string "%Y-%m-%d"
  >         (org-publish-find-date entry project))
  >     entry
  >     filename))))
  >
  >    Thanks for the help!
  >
  >    Thomas Ingram
  >
  >
  >

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

* Re: Org publish inserting HTML tags into sitemap-format-entry
  2019-07-11  1:30     ` Thibault Marin
@ 2019-07-12 15:08       ` Thomas Ingram
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Ingram @ 2019-07-12 15:08 UTC (permalink / raw)
  To: thibault.marin; +Cc: emacs-orgmode@gnu.org

Thanks, I wouldn't have considered using a macro.

I ended up embracing the line break between the date and title, although 
this
could be removed by adding `display: inline;' CSS rule to the div.

(setq org-export-global-macros
        '(("div" . "@@html:<div class=\"timestamp\">[$1]</div>@@")))

(defun org-sitemap-custom-entry-format (entry style project)
   "Sitemap entry format that includes date."
   (let ((filename (org-publish-find-title entry project)))
     (if (= (length filename) 0)
         (format "*%s*" entry)
       (format "{{{div(%s)}}} [[file:blog/%s][%s]]"
               (format-time-string "%Y-%m-%d"
                   (org-publish-find-date entry project))
               entry
               filename))))

On 7/10/19 9:30 PM, Thibault Marin wrote:
> Right, sorry I thought that would be easier.
>
> The closest I can get is with a global macro (called `div' in the following):
>
> ,----
> | (defun org-sitemap-custom-entry-format (entry style project)
> |   "Custom sitemap entry formatting: add date"
> |   (cond ((not (directory-name-p entry))
> |          (format "[[file:%s][(%s) %s]]{{{div(%s)}}}\n"
> |                  entry
> |                  (format-time-string "%Y-%m-%d"
> |                                      (org-publish-find-date entry project))
> |                  (org-publish-find-title entry project)
> |                  (format-time-string "%Y-%m-%d"
> |                                      (org-publish-find-date entry project))))
> |         ((eq style 'tree)
> |          ;; Return only last subdir.
> |          (file-name-nondirectory (directory-file-name entry)))
> |         (t entry)))
> `----
>
> The macro is global:
> ,----
> | (setq org-export-global-macros
> |       '(("div" . "@@html:<div style=\"color:blue;\">$1</div>@@")))
> `----
>
> The only(?) problem is that I get a line return between the title and
> the date in the sitemap.  I wonder if this can be fixed, maybe by
> passing extra options to `org-list-to-generic'.
>
> This may be a starting point.
>
>
> On 2019-07-10T20:30:42-0400, Thomas Ingram wrote:
>
>    Thanks, but adding `#+begin_export html' simply outputs that as well
>    without changing the output
>
>    "#+begin_export html
>    <div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]
>    #+end_export"
>
>    Produces
>
>    <li>#+begin<sub>export</sub>html &lt;div
>    class="timestamp"&gt;2019-07-10&lt;/div&gt; <a
> href="blog/test.html">Test</a>#+end<sub>export</sub></li>
>
>    On 7/10/19 7:47 PM, Thibault Marin wrote:
>    > You may need to wrap the html part in a `#+begin_export html' block or
>    > similar.  I believe the custom sitemap function should generate org
>    > content, not directly HTML.
>    >
>    > Hope it helps.
>    >
>    > On 2019-07-10T17:44:01-0400, Thomas Ingram wrote:
>    >
>    >    Hello,
>    >
>    >    I am using ox-publish to build my website. I have a custom
>    >    sitemap-formt-entry function that adds post dates and I'm trying to
>    >    add a div around those dates. Problem is the tags are getting escaped
>    >    in the resulting HTML. How can I add tags without them being escaped?
>    >
>    >    Below is my :sitemap-format-entry function.
>    >
>    >    (defun org-sitemap-custom-entry-format (entry style project)
>    >     (let ((filename (org-publish-find-title entry project)))
>    >     (if (= (length filename) 0)
>    >     (format "*%s*" entry)
>    >     (format "<div class=\"timestamp\">%s</div> [[file:blog/%s][%s]]"
>    >     (format-time-string "%Y-%m-%d"
>    >         (org-publish-find-date entry project))
>    >     entry
>    >     filename))))
>    >
>    >    Thanks for the help!
>    >
>    >    Thomas Ingram
>    >
>    >
>    >
>
>

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

end of thread, other threads:[~2019-07-12 15:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 21:44 Org publish inserting HTML tags into sitemap-format-entry Thomas Ingram
2019-07-10 23:47 ` Thibault Marin
2019-07-11  0:30   ` Thomas Ingram
2019-07-11  1:30     ` Thibault Marin
2019-07-12 15:08       ` Thomas Ingram

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