emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Reuleaux <rx@a-rx.info>
To: emacs-orgmode@gnu.org
Subject: aligning images, html attributes ignored when exporting to html (longish, sorry)
Date: Sat, 21 Apr 2018 16:14:50 +0100	[thread overview]
Message-ID: <87muxwvbf9.fsf@a-rx.info> (raw)

Hi,

following this tutorial

  https://orgmode.org/worg/org-tutorials/images-and-xhtml-export.html

I am trying to export some sample.org file to html, and have the images
floated to the right, with no success however.

to that end ATTR_HTML is used in the tutorial and in my sample.org:
-----
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. 
#+ATTR_HTML: style="float:right;"
[[./img/org-mode-unicorn.png]]
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
#+ATTR_HTML: style="float:right;"
[[./img/org-mode-unicorn.png]]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum
eu facilisis sed odio morbi quis. 
-----

but no matter how I export this sample.org snippet, the html attributes (ATTR_HTML)
are ignored. - below is an emacs bash script that I use for the export
(making my results reproducible hopefully).

all I get is the plain html image tags, no style attributes:


---
....
<p>
<img src="./img/org-mode-unicorn.png" alt="org-mode-unicorn.png">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
<p>
<img src="./img/org-mode-unicorn.png" alt="org-mode-unicorn.png">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum
eu facilisis sed odio morbi quis. 
</p>
...
---

I have no idea why these attributes are ignored, or how to make them appear:

- attr_html seems a fairly standard mechanism, and works for
  everybody but me ?, cf eg.

    https://linevi.ch/en/org-link-extra-attrs.html

- I have tried with different export options, but of course there
  are endless possibilies / combinations, and I have no
  clue here.

  I have tried to keep my export script below simple, but
  have kept a few lines as comments (or not) to more easily experiment
  with different export setting, like
	
      (setq org-html-head-include-default-style nil)
      (setq org-html-head-include-scripts nil)
      (setq org-html-doctype "html5")
      (setq org-html-html-fancy t)
      ;; (setq org-html-htmlize-output-type 'css)

  with no impact for the export of my html attributes however.

- maybe the org mode syntax / behaviour has changed ? - however
  I have tried both:

  - org version 9.1.9 - as comes with my debian elpa-org package

  - and org version 8.2.10 - as comes with my emacs 25.2.2 on debian
    buster.

  I can can choose either one be commenting / uncommenting the first
  few lines in my export script below

  ----
    (let ((package-dir (car (file-expand-wildcards (concat
                           "/usr/share/"
                           ;; emacs25
                           (symbol-name debian-emacs-flavor)
                           "/site-lisp/elpa/org-*")))
                       ))

      (when (file-directory-p package-dir)
        (add-to-list 'load-path package-dir)
        (add-to-list 'auto-mode-alist '("\\.org\\(-mode\\)?\\'" . org-mode))
        )
      )
  ----
  ie. I try to load from "/usr/share/emacs25/site-lisp/elpa/org-*" if not
  commented out.

  the script will respond by printing either org mode version:

    org version 8.2.10
    org version 9.1.9


- I *can* have extra style config added at the beginning of my export with

  ----
  #+html_head: <style type="text/css">
  #+html_head:<!--/*--><![CDATA[/*><!--*/
  #+html_head: img { float:right; }
  #+html_head: /*]]>*/-->
  #+html_head: </style>
  ----

  but in general don't want *all* my images floated to the right:
  I want to be able to assign attributes to individual images:
  one image floated to the right, say, another one to the left.
  and of course I may want to assign other attributes (besides float) 
  as well.


OK, thanks in advance. Find my export script below, and call with
  
  $ ./exporthtml.el sample.org sample.html

or 

  $ ./exporthtml.el sample.org

that way either org-html-export-as-html or org-html-export-to-html
gets used.

-Andreas


exporthtml.el
-----
:;exec /usr/bin/env emacs -batch -Q -l "$0" -f main "$@"



(let ((package-dir (car (file-expand-wildcards (concat
                       "/usr/share/"
                       ;; emacs25
                       (symbol-name debian-emacs-flavor)
                       "/site-lisp/elpa/org-*")))
                   ))

  (when (file-directory-p package-dir)
    (add-to-list 'load-path package-dir)
    (add-to-list 'auto-mode-alist '("\\.org\\(-mode\\)?\\'" . org-mode))
    )
  )



(require 'cl)
(toggle-debug-on-error)



;; (require 'cask "~/cfg/emacs/cask/cask.el")
;; (cask-initialize)




(defun main ()
  (interactive)
  
  (destructuring-bind (org-file &optional outfile) command-line-args-left
    
    (progn
      
      (setq make-backup-files nil)


      (require 'org)
      (require 'ox-html)      

      
      (message "org version %s" (org-version))

      
      (when (file-exists-p  org-file)
	
	(process-org-file org-file outfile)
	
	)
      )

    )
  )



(defun process-org-file (orgfile &optional outfile)
  (interactive)
  
  (progn


    ;; (defvar my-extra-head "<link rel='stylesheet' type='text/css' href='mytheme.css'/>")
    ;; (setq org-html-head-extra my-extra-head)



    (setq org-html-head-include-default-style nil)
    (setq org-html-head-include-scripts nil)

    (setq org-html-doctype "html5")
    (setq org-html-html-fancy t)


    ;; (setq org-html-htmlize-output-type 'css)
    ;; (setq org-html-htmlize-font-prefix "org-")
    
    




    (if (eq nil outfile)

	(progn
	  (message "no outfile given")
	  (find-file org-file)
	  
	  (org-html-export-to-html)
	  
	  )
      

      (progn
	(message "outfile is %s" outfile)
	(find-file org-file)


	(org-html-export-as-html)

	(write-file outfile)

	)
      )

    
    )
  )

             reply	other threads:[~2018-04-21 19:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-21 15:14 Andreas Reuleaux [this message]
2018-04-21 21:13 ` aligning images, html attributes ignored when exporting to html (longish, sorry) Andreas Reuleaux
2018-04-23 18:27   ` Richard Lawrence
2018-04-23 19:04     ` Andreas Reuleaux
2018-04-22  8:25 ` Nicolas Goaziou
2018-04-22 12:03   ` Andreas Reuleaux
2018-04-26 23:34   ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87muxwvbf9.fsf@a-rx.info \
    --to=rx@a-rx.info \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).