This code allows you to evaluate HTML in org-mode code blocks.
(with-eval-after-load "org"
(require 'ob-html)
(org-babel-html-enable-open-src-block-result-temporary)) ;;Enable C-c C-o on html code block
Customize the variable org-babel-html-chrome-executable
or org-babel-html-screenshot-method
.
Generate html export block:
#+begin_src html :results replace html :exports both
<p><strong>STRONG</strong> <ins>INS</ins> <del>DEL</del></p>
#+end_src
#+RESULTS:
#+begin_export html
<p><strong>STRONG</strong> <ins>INS</ins> <del>DEL</del></p>
#+end_export
Generate external html file:
#+begin_src html :results replace file :file example.html :exports both
<!DOCTYPE html>
<html><head><title>example</title></head><body><p>Example</p></body></html>
#+end_src
#+RESULTS:
[[file:example.html]]
Generate screenshot image file:
#+begin_src html :results replace file graphics :file example.png :width 640 :height 100 :exports both
<!DOCTYPE html>
<html><head><title>example</title></head><body><p>Hello</p></body></html>
#+end_src
#+RESULTS:
[[file:example.png]]
Generate nothing but open HTML as temporary file:
#+begin_src html
<!DOCTYPE html>
<html><head><title>example</title></head><body><p>Hello</p></body></html>
#+end_src
- Add session support
- Add more screenshot methods
- PhantomJS
- puppeteer
- PlayWright
- Fix org-babel-html-chrome-executable