From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Ingram Subject: Re: Org publish inserting HTML tags into sitemap-format-entry Date: Fri, 12 Jul 2019 11:08:10 -0400 Message-ID: References: <877e8pwiyh.fsf@dell-desktop.WORKGROUP> <875zo9we5o.fsf@dell-desktop.WORKGROUP> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:55597) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlx9j-0006iE-5F for emacs-orgmode@gnu.org; Fri, 12 Jul 2019 11:08:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlx9h-0006Wv-W5 for emacs-orgmode@gnu.org; Fri, 12 Jul 2019 11:08:15 -0400 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]:39165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlx9h-0006Ur-FR for emacs-orgmode@gnu.org; Fri, 12 Jul 2019 11:08:13 -0400 Received: by mail-io1-xd2e.google.com with SMTP id f4so21012991ioh.6 for ; Fri, 12 Jul 2019 08:08:12 -0700 (PDT) In-Reply-To: <875zo9we5o.fsf@dell-desktop.WORKGROUP> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: thibault.marin@gmx.com 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:
[$1]
@@"))) (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:
$1
@@"))) > `---- > > 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 >
%s
[[file:blog/%s][%s]] > #+end_export" > > Produces > >
  • #+beginexporthtml <div > class="timestamp">2019-07-10</div> href="blog/test.html">Test#+endexport
  • > > 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 "
    %s
    [[file:blog/%s][%s]]" > > (format-time-string "%Y-%m-%d" > > (org-publish-find-date entry project)) > > entry > > filename)))) > > > > Thanks for the help! > > > > Thomas Ingram > > > > > > > >