Org-mode mailing list
 help / color / mirror / Atom feed
From: Mingkai Dong <mk@dong.mk>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] lisp/ox-html.el: Move the space after exported section number
Date: Tue, 4 May 2021 00:35:21 +0800
Message-ID: <2F46C11A-B2CD-445C-A811-CB05A043FE46@dong.mk> (raw)
In-Reply-To: <87v97zn8az.fsf@gnu.org>

Hi Bastien,

At the end of the mail is the output of `diff old.html new.html`, most
differences are caused by time and randomly generated ids.

The only exception is the Table-of-Content entries, which now has two
spaces before each section title. I find that the org-html--format-toc-headline
function first appends “. “ after each section number, and then appends
the output of html-format-headline-default-function. Thus, after moving
the space to the head of html-format-headline-default-function, there are
two spaces.

Then the problem becomes more complicated, and it might be difficult to solve
it without changing the original behavior.

I can come up with three options:

1. Stay with the two spaces in ToC, since extra spaces seldom change the
   appearance of rendered html. But it would cause problems when users use
   custom org-html-format-headline-function.

2. Further modify the org-html--format-toc-headline function to remove
   the logic of appending “. “ as below. Then the section heading in both
   the text and the ToC will have the format of “1 Section-Text”, without
   “.”. However, this changes the original appearance of ToC.

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index f2ce71f68..a17445ca5 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2396,8 +2396,7 @@ INFO is a plist used as a communication channel."
            (concat
             (and (not (org-export-low-level-p headline info))
                  (org-export-numbered-headline-p headline info)
-                 (concat (mapconcat #'number-to-string headline-number ".")
-                         ". "))
+                 (mapconcat #'number-to-string headline-number "."))
             (apply (plist-get info :html-format-headline-function)
                    todo todo-type priority text tags :section-number nil)))))



3. Based on the second solution, further update the org-html-format-headline-default-function
   to append “. “ by default (rather than “ “) like below. This keeps the
   original ToC content unchanged, but changes the default in-text section
   heading format by appending one more “.” after the section number.


diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index f2ce71f68..84da95ddb 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2396,8 +2396,7 @@ INFO is a plist used as a communication channel."
            (concat
             (and (not (org-export-low-level-p headline info))
                  (org-export-numbered-headline-p headline info)
-                 (concat (mapconcat #'number-to-string headline-number ".")
-                         ". "))
+                 (mapconcat #'number-to-string headline-number "."))
             (apply (plist-get info :html-format-headline-function)
                    todo todo-type priority text tags :section-number nil)))))

@@ -2696,7 +2695,7 @@ See `org-html-format-headline-function' for details."
   (let ((todo (org-html--todo todo info))
        (priority (org-html--priority priority info))
        (tags (org-html--tags tags info)))
-    (concat " "
+    (concat ". "
            todo (and todo " ")
            priority (and priority " ")
            text


Both option 2 and 3 give users better control over of the section heading
format, but will alter the current behavior of html export.

What do you think?


- - - - Below is the diff of generated HTML - - - -


4c4
< <!-- 2021-05-03 Mon 23:53 -->
---
> <!-- 2021-05-03 Mon 23:56 -->
228,231c228,231
< <li><a href="#orgc72e91c">1. Terms</a></li>
< <li><a href="#org8c55297">2. TME</a></li>
< <li><a href="#orga4a3735">3. MKTME</a></li>
< <li><a href="#org822b2db">4. Configuration</a>
---
> <li><a href="#org329df72">1.  Terms</a></li>
> <li><a href="#org870abfd">2.  TME</a></li>
> <li><a href="#orgcb05acd">3.  MKTME</a></li>
> <li><a href="#org48f2f09">4.  Configuration</a>
233c233
< <li><a href="#org47ff03e">4.1. Exclusion Range MSRs</a></li>
---
> <li><a href="#orgcd598c6">4.1.  Exclusion Range MSRs</a></li>
236,237c236,237
< <li><a href="#org463c0b8">5. Runtime Behavior</a></li>
< <li><a href="#org665a598">6. 管理 KeyID</a>
---
> <li><a href="#org993a386">5.  Runtime Behavior</a></li>
> <li><a href="#org1b5b5c2">6.  管理 KeyID</a>
239c239
< <li><a href="#org48b1087">6.1. Guidance</a></li>
---
> <li><a href="#org8ebed26">6.1.  Guidance</a></li>
254,255c254,255
< <div id="outline-container-orgc72e91c" class="outline-2">
< <h2 id="orgc72e91c"><span class="section-number-2">1</span> Terms</h2>
---
> <div id="outline-container-org329df72" class="outline-2">
> <h2 id="org329df72"><span class="section-number-2">1</span> Terms</h2>
264,265c264,265
< <div id="outline-container-org8c55297" class="outline-2">
< <h2 id="org8c55297"><span class="section-number-2">2</span> TME</h2>
---
> <div id="outline-container-org870abfd" class="outline-2">
> <h2 id="org870abfd"><span class="section-number-2">2</span> TME</h2>
276c276
< <figure id="org79fe63c">
---
> <figure id="org111b265">
289,290c289,290
< <div id="outline-container-orga4a3735" class="outline-2">
< <h2 id="orga4a3735"><span class="section-number-2">3</span> MKTME</h2>
---
> <div id="outline-container-orgcb05acd" class="outline-2">
> <h2 id="orgcb05acd"><span class="section-number-2">3</span> MKTME</h2>
308c308
< <figure id="orga12c576">
---
> <figure id="orgd6d7e27">
326,327c326,327
< <div id="outline-container-org822b2db" class="outline-2">
< <h2 id="org822b2db"><span class="section-number-2">4</span> Configuration</h2>
---
> <div id="outline-container-org48f2f09" class="outline-2">
> <h2 id="org48f2f09"><span class="section-number-2">4</span> Configuration</h2>
334,335c334,335
< <div id="outline-container-org47ff03e" class="outline-3">
< <h3 id="org47ff03e"><span class="section-number-3">4.1</span> Exclusion Range MSRs</h3>
---
> <div id="outline-container-orgcd598c6" class="outline-3">
> <h3 id="orgcd598c6"><span class="section-number-3">4.1</span> Exclusion Range MSRs</h3>
356,357c356,357
< <div id="outline-container-org463c0b8" class="outline-2">
< <h2 id="org463c0b8"><span class="section-number-2">5</span> Runtime Behavior</h2>
---
> <div id="outline-container-org993a386" class="outline-2">
> <h2 id="org993a386"><span class="section-number-2">5</span> Runtime Behavior</h2>
364c364
< <figure id="orgccdf090">
---
> <figure id="org27b7774">
390,391c390,391
< <div id="outline-container-org665a598" class="outline-2">
< <h2 id="org665a598"><span class="section-number-2">6</span> 管理 KeyID</h2>
---
> <div id="outline-container-org1b5b5c2" class="outline-2">
> <h2 id="org1b5b5c2"><span class="section-number-2">6</span> 管理 KeyID</h2>
400,401c400,401
< <div id="outline-container-org48b1087" class="outline-3">
< <h3 id="org48b1087"><span class="section-number-3">6.1</span> Guidance</h3>
---
> <div id="outline-container-org8ebed26" class="outline-3">
> <h3 id="org8ebed26"><span class="section-number-3">6.1</span> Guidance</h3>
418c418
< <p class="date">Created: 2021-05-03 Mon 23:53</p>
---
> <p class="date">Created: 2021-05-03 Mon 23:56</p>


Best,
Mingkai


> On May 3, 2021, at 23:31, Bastien <bzg@gnu.org> wrote:
> 
> Hi Mingkai,
> 
> Mingkai Dong <mk@dong.mk> writes:
> 
>> * ox-html.el (org-html-headline, org-html-format-headline-default-function):
>> delete the space after the section number span format and add it back in
>> org-html-format-headline-default-function.
> 
> It looks good, thanks.
> 
> Can you show the exact difference by comparing the relevant HTML
> portion before and after this change?
> 
> -- 
> Bastien



  reply	other threads:[~2021-05-03 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 15:07 Mingkai Dong
2021-05-03 15:31 ` Bastien
2021-05-03 16:35   ` Mingkai Dong [this message]
2021-05-03 17:19     ` 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://orgmode.org

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

  git send-email \
    --in-reply-to=2F46C11A-B2CD-445C-A811-CB05A043FE46@dong.mk \
    --to=mk@dong.mk \
    --cc=bzg@gnu.org \
    --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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git