emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]
@ 2021-01-20 10:46 TEC
  2021-01-20 11:00 ` [PATCH] tweaks to ox-html style TEC
                   ` (3 more replies)
  0 siblings, 4 replies; 33+ messages in thread
From: TEC @ 2021-01-20 10:46 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

Hi All,

This is just some tweaks to the styling in ox-html that I think may
appeal (and prevent ridiculously long lines on non-small displays, which
are an issue for legibility).

I also took the opportunity to remove the (obsolete) CDATA strings and
make the CSS more consistently formatted. If you don't want this to
get its own commit, please just squash it.

Style changes:
- Restrict max content width, and centre
- tweak styling of source code blocks

I took some screenshots (1440p monitor, 120% zoom, Firefox).
Current: https://0x0.st/-iW9.png
This patch: https://0x0.st/-iWp.png

All the best,

Timothy.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html.el-remove-CDATA-strings.patch --]
[-- Type: text/x-patch, Size: 2679 bytes --]

From 635bd77cd7a2dc55cc0705c5bbf2e11091bfbaf3 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 20 Jan 2021 16:37:29 +0800
Subject: [PATCH 1/5] ox-html.el: remove CDATA strings

* lisp/ox-html.el (org-html-scripts, org-html-style-default,
org-html-infojs-template): remove CDATA strings, as they are now
considered obsolete --- see
https://developer.mozilla.org/en-US/docs/Web/API/CDATASection#specifications
---
 lisp/ox-html.el | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 03145e35c..0cf3425df 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -234,7 +234,6 @@ property on the headline itself.")
 (defconst org-html-scripts
   "<script type=\"text/javascript\">
 // @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
-<!--/*--><![CDATA[/*><!--*/
      function CodeHighlightOn(elem, id)
      {
        var target = document.getElementById(id);
@@ -251,14 +250,12 @@ property on the headline itself.")
          target.classList.remove(\"code-highlighted\");
        }
      }
-    /*]]>*///-->
 // @license-end
 </script>"
   "Basic JavaScript that is needed by HTML files produced by Org mode.")
 
 (defconst org-html-style-default
   "<style type=\"text/css\">
- <!--/*--><![CDATA[/*><!--*/
   .title  { text-align: center;
              margin-bottom: .2em; }
   .subtitle { text-align: center;
@@ -439,7 +436,6 @@ property on the headline itself.")
   .org-info-js_search-highlight
     { background-color: #ffff00; color: #000000; font-weight: bold; }
   .org-svg { width: 90%; }
-  /*]]>*/-->
 </style>"
   "The default style specification for exported HTML files.
 You can use `org-html-head' and `org-html-head-extra' to add to
@@ -515,10 +511,8 @@ means to use the maximum value consistent with other options."
 
 <script type=\"text/javascript\">
 // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&amp;dn=gpl-3.0.txt GPL-v3-or-Later
-<!--/*--><![CDATA[/*><!--*/
 %MANAGER_OPTIONS
 org_html_manager.setup();  // activate after the parameters are set
-/*]]>*///-->
 // @license-end
 </script>"
   "The template for the export style additions when org-info.js is used.
@@ -1448,13 +1442,11 @@ done, timestamp, timestamp-kwd, tag, target.
 For example, a valid value would be:
 
    <style type=\"text/css\">
-    /*<![CDATA[*/
       p { font-weight: normal; color: gray; }
       h1 { color: black; }
       .title { text-align: center; }
       .todo, .timestamp-kwd { color: red; }
       .done { color: green; }
-    /*]]>*/
    </style>
 
 If you want to refer to an external style, use something like
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ox-html.el-limit-maximum-content-width-and-center.patch --]
[-- Type: text/x-patch, Size: 895 bytes --]

From 5bef340093102936efe831f85fabdb589070ce43 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 20 Jan 2021 16:45:20 +0800
Subject: [PATCH 2/5] ox-html.el: limit maximum content width and center

* lisp/ox-html.el (org-html-style-default): To improve the appearance
and legibility on larger screens:
 1. Limit the content width to the upper end of advised line width, ~140
 characters.
 2. Centre the content.
---
 lisp/ox-html.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 0cf3425df..9bbfad678 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -256,6 +256,7 @@ property on the headline itself.")
 
 (defconst org-html-style-default
   "<style type=\"text/css\">
+  #content { max-width: 60em; margin: auto; }
   .title  { text-align: center;
              margin-bottom: .2em; }
   .subtitle { text-align: center;
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-ox-html.el-format-CSS-more-consistently.patch --]
[-- Type: text/x-patch, Size: 2278 bytes --]

From 2c0f648ae87e789f21c24b645b2049f05d084799 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 20 Jan 2021 17:58:38 +0800
Subject: [PATCH 3/5] ox-html.el: format CSS more consistently

* lisp/ox-html.el (org-html-style-default): Format CSS declarations more
consistently.
---
 lisp/ox-html.el | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 9bbfad678..14f023e87 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -257,8 +257,8 @@ property on the headline itself.")
 (defconst org-html-style-default
   "<style type=\"text/css\">
   #content { max-width: 60em; margin: auto; }
-  .title  { text-align: center;
-             margin-bottom: .2em; }
+  .title { text-align: center;
+           margin-bottom: .2em; }
   .subtitle { text-align: center;
               font-size: medium;
               font-weight: bold;
@@ -282,13 +282,11 @@ property on the headline itself.")
     padding: 8pt;
     font-family: monospace;
     overflow: auto;
-    margin: 1.2em;
-  }
+    margin: 1.2em; }
   pre.src {
     position: relative;
     overflow: auto;
-    padding-top: 1.2em;
-  }
+    padding-top: 1.2em; }
   pre.src:before {
     display: none;
     position: absolute;
@@ -296,8 +294,7 @@ property on the headline itself.")
     top: -10px;
     right: 10px;
     padding: 3px;
-    border: 1px solid black;
-  }
+    border: 1px solid black; }
   pre.src:hover:before { display: inline; margin-top: 14px;}
   /* Languages per Org manual */
   pre.src-asymptote:before { content: 'Asymptote'; }
@@ -410,22 +407,17 @@ property on the headline itself.")
   .equation-container {
     display: table;
     text-align: center;
-    width: 100%;
-  }
-  .equation {
-    vertical-align: middle;
-  }
+    width: 100%; }
+  .equation { vertical-align: middle; }
   .equation-label {
     display: table-cell;
     text-align: right;
-    vertical-align: middle;
-  }
+    vertical-align: middle; }
   .inlinetask {
     padding: 10px;
     border: 2px solid gray;
     margin: 10px;
-    background: #ffffcc;
-  }
+    background: #ffffcc; }
   #org-div-home-and-up
    { text-align: right; font-size: 70%; white-space: nowrap; }
   textarea { overflow-x: auto; }
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-ox-html.el-tweak-styling-of-src-blocks.patch --]
[-- Type: text/x-patch, Size: 1617 bytes --]

From c341a278291be3c6a4fcca77fede476a04417a69 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 20 Jan 2021 18:17:06 +0800
Subject: [PATCH 4/5] ox-html.el: tweak styling of src blocks

* lisp/ox-html.el (org-html-style-default): Apply the following changes
to the styling of src blocks:
- Remove box shadow.
- Lighten border.
- Add very light grey background colour.
- Make lang label (visible on hover) less obtrusive by removing border.
---
 lisp/ox-html.el | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 14f023e87..e83648726 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -277,24 +277,24 @@ property on the headline itself.")
   #postamble p, #preamble p { font-size: 90%; margin: .2em; }
   p.verse { margin-left: 3%; }
   pre {
-    border: 1px solid #ccc;
-    box-shadow: 3px 3px 3px #eee;
+    border: 1px solid #e6e6e6;
+    border-radius: 3px;
+    background-color: #f2f2f2;
     padding: 8pt;
     font-family: monospace;
     overflow: auto;
     margin: 1.2em; }
   pre.src {
     position: relative;
-    overflow: auto;
-    padding-top: 1.2em; }
+    overflow: auto; }
   pre.src:before {
     display: none;
     position: absolute;
-    background-color: white;
-    top: -10px;
-    right: 10px;
+    top: -8px;
+    right: 12px;
     padding: 3px;
-    border: 1px solid black; }
+    color: #555;
+    background-color: #f2f2f299; }
   pre.src:hover:before { display: inline; margin-top: 14px;}
   /* Languages per Org manual */
   pre.src-asymptote:before { content: 'Asymptote'; }
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-ox-html.el-add-lang-label-to-authinfo-src-blocks.patch --]
[-- Type: text/x-patch, Size: 931 bytes --]

From b8eb175c709ad9cff259b4326d8c9a344a4381ba Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 20 Jan 2021 18:22:58 +0800
Subject: [PATCH 5/5] ox-html.el: add lang label to authinfo src blocks

* lisp/ox-html.el (org-html-style-default): `authinfo-mode' is defined
in Emacs 27. As such, in the CSS add an "Authinfo" lang label to
authinfo src blocks.
---
 lisp/ox-html.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index e83648726..e5e82a5d8 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -299,6 +299,7 @@ property on the headline itself.")
   /* Languages per Org manual */
   pre.src-asymptote:before { content: 'Asymptote'; }
   pre.src-awk:before { content: 'Awk'; }
+  pre.src-authinfo::before { content: 'Authinfo'; }
   pre.src-C:before { content: 'C'; }
   /* pre.src-C++ doesn't work in CSS */
   pre.src-clojure:before { content: 'Clojure'; }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH]
@ 2021-09-26 11:51 Timothy
  2021-09-26 12:01 ` [PATCH] Timothy
  2021-09-26 12:14 ` [PATCH] Timothy
  0 siblings, 2 replies; 33+ messages in thread
From: Timothy @ 2021-09-26 11:51 UTC (permalink / raw)
  To: Org Mode List


[-- Attachment #1.1: Type: text/plain, Size: 1370 bytes --]

Hi Everyone,

I’ve recently been wondering why it is that for sensibly sized images in a
LaTeX-export-oriented document I need to do both:
┌────
│ #+attr_org: :width 400
│ #+attr_latex: :width 0.4\linewidth
└────

When in HTML, just
┌────
│ #+attr_html: :width 400px
└────
is fine.

This has lead me to have a look at `org-display-inline-images', and I’ve realised
that the `#+attr_latex' width of `0.4\linewidth' is actually picked up, and
interpreted as a width of `0.4' pixels. I think it would make much more sense for
fractional values between zero and one to be interpreted as that portion of the
text width in the buffer. On second thoughts, given that the document width can
be slightly larger than the text width, perhaps an upper bound just a bit higher
— say 2, could be better.

I’ve prepared a patch which implements this logic, by converting extracted
widths that are:
⁃ floats, and
⁃ within the range [0,2]
and sizes them as that proportion of the text width in the buffer, which is
determined by checking
1. `visual-fill-column-width', when that package is installed and the mode active
2. `fill-column', when auto fill is active
3. `(window-text-width)', if neither of the above two cases hold

Please let me know what you think 🙂.

All the best,
Timothy

[-- Attachment #1.2: Type: text/html, Size: 6912 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-Display-proportional-image-widths.patch --]
[-- Type: text/x-patch, Size: 4258 bytes --]

From bc8aa862f513946599efe4a9bb420e54c504ab3b Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Fri, 24 Sep 2021 01:39:31 +0800
Subject: [PATCH] org: Display proportional image widths

* lisp/org.el (org-display-inline-images): When the image width is given
as a float less than 2, interpret the value as that portion of the text
area width.  This works well with cases such as "#+attr_latex: :width
0.6\linewidth" as this will now be interpreted as 60% of the text area
width.  The upper bound is set to 2 not 1, as more than 100% of the text
width can be realistic, e.g. "1.2\linewidth" in LaTeX, but more than
200% seems unrealistic.
---
 lisp/org.el | 47 +++++++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 66ca73d5e..ce2ac7404 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16622,22 +16622,37 @@ (defun org-display-inline-images (&optional include-linked refresh beg end)
 			   (cond
 			    ((eq org-image-actual-width t) nil)
 			    ((listp org-image-actual-width)
-			     (or
-			      ;; First try to find a width among
-			      ;; attributes associated to the paragraph
-			      ;; containing link.
-			      (pcase (org-element-lineage link '(paragraph))
-				(`nil nil)
-				(p
-				 (let* ((case-fold-search t)
-					(end (org-element-property :post-affiliated p))
-					(re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)"))
-				   (when (org-with-point-at
-					     (org-element-property :begin p)
-					   (re-search-forward re end t))
-				     (string-to-number (match-string 1))))))
-			      ;; Otherwise, fall-back to provided number.
-			      (car org-image-actual-width)))
+                             (let ((width
+                                    (or
+                                     ;; First try to find a width among
+                                     ;; attributes associated to the paragraph
+                                     ;; containing link.
+                                     (pcase (org-element-lineage link '(paragraph))
+                                       (`nil nil)
+                                       (par (let* ((case-fold-search t)
+                                                   (end (org-element-property :post-affiliated par))
+                                                   (re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)"))
+                                              (when (org-with-point-at
+                                                        (org-element-property :begin par)
+                                                      (re-search-forward re end t))
+                                                (string-to-number (match-string 1)))))))
+                                    ;; Otherwise, fall-back to provided number.
+                                    (car org-image-actual-width))))
+                               (when width
+                                 (if (and (floatp width) (<= 0 width 2.0))
+                                     ;; A float in [0,2] should be interpereted as this portion of
+                                     ;; the text width in the window.  This works well with cases like
+                                     ;; #+attr_latex: :width 0.X\{line,page,column,etc.}width,
+                                     ;; as the "0.X" is pulled out as a float.  We use 2 as the upper
+                                     ;; bound as cases such as 1.2\linewidth are feasible.
+                                     (round (* width
+                                               (window-pixel-width)
+                                               (/ (or (and (bound-and-true-p visual-fill-column-mode)
+                                                           (or visual-fill-column-width auto-fill-function))
+                                                      (when auto-fill-function fill-column)
+                                                      (window-text-width))
+                                                  (float (window-total-width)))))
+                                   width))))
 			    ((numberp org-image-actual-width)
 			     org-image-actual-width)
 			    (t nil)))
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH]
@ 2011-07-13 14:13 Evgeny Boykov
  2011-07-16 17:10 ` [PATCH] Bastien
  0 siblings, 1 reply; 33+ messages in thread
From: Evgeny Boykov @ 2011-07-13 14:13 UTC (permalink / raw)
  To: emacs-orgmode


===========================================================================

I want org-publish-current-file ~/git/org/filename.org in ~/pub/org/

Some setup:

(setq org-publish-project-alist
...
         :base-directory "~/git/org"
         :publishing-directory "~/pub/org"
         :publishing-function org-publish-org-to-pdf
...

or just

(org-export-as-pdf 3 nil nil "*Org LaTeX Export*" nil "~/pub/org")

Before patch, incorrectly: 

all pdf-creating files: filename.aux, filename.out, etc,
apart from filename.tex, are here:
../base-directory/

After patch, correctly:

all pdf-creating files are here:
../publishing-directory/

======================================================================

Solution:

All 'cmds' must be called in 'lbuf', but not in filename.org's buffer context.

======================================================================


diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 1d6e042..5270943 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1043,26 +1043,28 @@ when PUB-DIR is set, use this as the publishing directory."
     (with-current-buffer outbuf (erase-buffer))
     (message (concat "Processing LaTeX file " file "..."))
     (setq output-dir (file-name-directory file))
-    (if (and cmds (symbolp cmds))
-	(funcall cmds (shell-quote-argument file))
-      (while cmds
-	(setq cmd (pop cmds))
-	(while (string-match "%b" cmd)
-	  (setq cmd (replace-match
-		     (save-match-data
-		       (shell-quote-argument base))
-		     t t cmd)))
-	(while (string-match "%f" cmd)
-	  (setq cmd (replace-match
-		     (save-match-data
-		       (shell-quote-argument file))
-		     t t cmd)))
-	(while (string-match "%o" cmd)
-	  (setq cmd (replace-match
-		     (save-match-data
-		       (shell-quote-argument output-dir))
-		     t t cmd)))
-	(shell-command cmd outbuf)))
+    (with-current-buffer lbuf
+      (save-excursion
+	(if (and cmds (symbolp cmds))
+	    (funcall cmds (shell-quote-argument file))
+	  (while cmds
+	    (setq cmd (pop cmds))
+	    (while (string-match "%b" cmd)
+	      (setq cmd (replace-match
+			 (save-match-data
+			   (shell-quote-argument base))
+			 t t cmd)))
+	    (while (string-match "%f" cmd)
+	      (setq cmd (replace-match
+			 (save-match-data
+			   (shell-quote-argument file))
+			 t t cmd)))
+	    (while (string-match "%o" cmd)
+	      (setq cmd (replace-match
+			 (save-match-data
+			   (shell-quote-argument output-dir))
+			 t t cmd)))
+	    (shell-command cmd outbuf)))))
     (message (concat "Processing LaTeX file " file "...done"))
     (setq errors (org-export-latex-get-error outbuf))
     (if (not (file-exists-p pdffile))

__________________________

С уважением,
Бойков Евгений Алексеевич
сот. 8-924-202-25-65
e-mail: artscan@list.ru

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

end of thread, other threads:[~2021-09-28 15:51 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 10:46 [PATCH] TEC
2021-01-20 11:00 ` [PATCH] tweaks to ox-html style TEC
2021-02-12  6:16 ` Kyle Meyer
2021-02-12 16:57   ` Jens Lechtenboerger
2021-02-12 17:08     ` Jens Lechtenboerger
2021-02-12 18:22       ` Timothy
2021-02-13 14:43         ` Jens Lechtenboerger
2021-02-12 18:16     ` Timothy
2021-02-12 21:46     ` Tim Cross
2021-02-13  9:28       ` Eric S Fraga
2021-02-13 13:32       ` Christian Moe
2021-02-14  4:36         ` Timothy
2021-04-28  3:38 ` [PATCH] Bastien
2021-04-28  3:53   ` [PATCH] Timothy
2021-04-28  6:36     ` [PATCH] Bastien
2021-04-28  6:33 ` [PATCH] Bastien
  -- strict thread matches above, loose matches on Subject: below --
2021-09-26 11:51 [PATCH] Timothy
2021-09-26 12:01 ` [PATCH] Timothy
2021-09-26 12:14 ` [PATCH] Timothy
2021-09-27  8:19   ` [PATCH] Bastien
2021-09-27 10:35     ` [PATCH] Timothy
2021-09-27 11:45       ` [PATCH] Bastien
2021-09-27 12:20         ` [PATCH] Timothy
2021-09-27 12:31           ` [PATCH] Bastien
2021-09-27 15:26           ` [PATCH] Bastien
2021-09-27 15:36             ` [PATCH] Timothy
2021-09-27 17:44               ` [PATCH] Bastien
2021-09-27 17:52                 ` [PATCH] Timothy
2021-09-27 19:45                   ` [PATCH] Bastien
2021-09-28 15:31                     ` [PATCH] Bastien Guerry
2021-09-28 15:50                       ` [PATCH] Timothy
2011-07-13 14:13 [PATCH] Evgeny Boykov
2011-07-16 17:10 ` [PATCH] Bastien

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