Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
Hello, Jens Lechtenboerger writes: > Thanks! A patch is attached. Applied. Thank you. Regards, -- Nicolas Goaziou
Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
On 2019-10-13, at 09:30, Nicolas Goaziou wrote: > Jens Lechtenboerger writes: > >> Subject: [PATCH] ox-html: Control wrapping of source lines >> >> * lisp/ox-html.el (org-html-format-code, org-html-do-format-code): >> Use new export option :html-wrap-src-lines with variable >> org-html-wrap-src-lines to control whether source code lines should >> be wrapped in code elements or not. >> * doc/org-manual.org: Document the new option > > Applied. Would you mind adding an ORG-NEWS entry about it? Thanks! A patch is attached. Best wishes Jens >From f2f93c573fef6a079c2f7f434e6c65d51e2f0906 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Sun, 13 Oct 2019 14:06:09 +0200 Subject: [PATCH] Mention option html-wrap-src-lines in ORG-NEWS * etc/ORG-NEWS: Mention new option html-wrap-src-lines. --- etc/ORG-NEWS | 6 ++ 1 file changed, 6 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 9fff4ad16..0e07326cb 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -123,6 +123,12 @@ auto-commit attachments to git: one need to require the =org-attach-git= module in the startup. ** New features +*** New option to wrap source code lines in HTML export + +When new option ~html-wrap-src-lines~ (with variable +~org-html-wrap-src-lines~) is non-nil, HTML export wraps source code +lines in HTML ~code~ elements. + *** New option to handle schedules and deadlines in iCalendar export Export ignore done tasks with a deadline when -- 2.17.1
Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
Hello, Jens Lechtenboerger writes: > Subject: [PATCH] ox-html: Control wrapping of source lines > > * lisp/ox-html.el (org-html-format-code, org-html-do-format-code): > Use new export option :html-wrap-src-lines with variable > org-html-wrap-src-lines to control whether source code lines should > be wrapped in code elements or not. > * doc/org-manual.org: Document the new option Applied. Would you mind adding an ORG-NEWS entry about it? Thank you. Regards, -- Nicolas Goaziou
Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
On 2019-10-08, at 11:31, Nicolas Goaziou wrote: > Jens Lechtenboerger writes: > >> The attached patch adds a new variable org-html-wrap-src-lines to >> control whether code tags should be added or not. > > Thank you. > > However, the patch is not right. Exporters do not use defcustoms > directly. Instead, you register them within :options-alist in the the > back-end definition, e.g., under :html-wrap-src-lines and then call > (plist-get info :html-wrap-src-lines) in the function. This allows to > control these options during publishing. Indeed, sorry. Many thanks for the detailed feedback! I had to change the calling function org-html-format-code and add an argument to org-html-do-format-code as info is not available in the latter function. > Also, this would need an entry in the manual, if only in the "options > for the exporters" subsection. Done. >> I’m not sure whether :package-version 9.3 is correct. > > It is correct. You can also use :safe t. Added. >> Also, I set the value to t, which does not change the current >> functionality. However, for backwards compatibility (up to version >> 9.2.6), a value of nil would be preferable. Any thoughts? > > I agree with the nil default value. Done. >> +(defcustom org-html-wrap-src-lines t >> + "If t, wrap individual lines of source blocks in \"code\" elements. > > When non-nil, wrap... Done. Best wishes Jens >From 961c0b45ff3e5548df11fc3fe9274e913c467c65 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Tue, 8 Oct 2019 20:15:06 +0200 Subject: [PATCH] ox-html: Control wrapping of source lines * lisp/ox-html.el (org-html-format-code, org-html-do-format-code): Use new export option :html-wrap-src-lines with variable org-html-wrap-src-lines to control whether source code lines should be wrapped in code elements or not. * doc/org-manual.org: Document the new option --- doc/org-manual.org | 3 ++- lisp/ox-html.el| 39 +++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index f2f059e77..68543d67c 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -10789,7 +10789,7 @@ environments and math templates. Inside Org mode, you can make use of some of the features of CDLaTeX mode. You need to install =cdlatex.el= and =texmathp.el= (the latter comes also with AUCTeX) using [[https://melpa.org/][MELPA]] with the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Installation.html][Emacs packaging system]] or alternatively from -[[https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/]]. Do not use +[[https://staff.fnwi.uva.nl/c.dominik/Tools/cdlatex/]]. Do not use CDLaTeX mode itself under Org mode, but use the special version Org CDLaTeX minor mode that comes as part of Org. Turn it on for the current buffer with {{{kbd(M-x org-cdlatex-mode)}}}, or for all Org @@ -15753,6 +15753,7 @@ Settings]]), however, override everything. | ~:html-use-infojs~ | ~org-html-use-infojs~ | | ~:html-validation-link~| ~org-html-validation-link~| | ~:html-viewport~ | ~org-html-viewport~ | +| ~:html-wrap-src-lines~ | ~org-html-wrap-src-lines~ | | ~:html-xml-declaration~| ~org-html-xml-declaration~| LaTeX specific properties diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 882f82dcb..83d0fd2e9 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -172,6 +172,7 @@ (:html-table-row-open-tag nil nil org-html-table-row-open-tag) (:html-table-row-close-tag nil nil org-html-table-row-close-tag) (:html-xml-declaration nil nil org-html-xml-declaration) +(:html-wrap-src-lines nil nil org-html-wrap-src-lines) (:html-klipsify-src nil nil org-html-klipsify-src) (:html-klipse-css nil nil org-html-klipse-css) (:html-klipse-js nil nil org-html-klipse-js) @@ -932,6 +933,15 @@ in all modes you want. Then, use the command :group 'org-export-html :type 'string) +(defcustom org-html-wrap-src-lines nil + "If non-nil, wrap individual lines of source blocks in \"code\" elements. +In this case, add line number in attribute \"data-ox-html-linenr\" when line +numbers are enabled." + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'boolean + :safe t) + Table (defcustom org-html-table-default-attributes @@ -2231,14 +2241,15 @@ is the language used for CODE, as a string, or nil." (if (and beg end) (substring code beg end) code) (defun org-html-do-format-code - (code &optional lang refs retain-labels num-start) + (code &optional lang refs retain-labels num-start wrap-lines) "Format CODE string as source code. -Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are, -respectively, the language o
Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
Hello, Jens Lechtenboerger writes: > The attached patch adds a new variable org-html-wrap-src-lines to > control whether code tags should be added or not. Thank you. However, the patch is not right. Exporters do not use defcustoms directly. Instead, you register them within :options-alist in the the back-end definition, e.g., under :html-wrap-src-lines and then call (plist-get info :html-wrap-src-lines) in the function. This allows to control these options during publishing. Also, this would need an entry in the manual, if only in the "options for the exporters" subsection. > I’m not sure whether :package-version 9.3 is correct. It is correct. You can also use :safe t. > Also, I set the value to t, which does not change the current > functionality. However, for backwards compatibility (up to version > 9.2.6), a value of nil would be preferable. Any thoughts? I agree with the nil default value. > +(defcustom org-html-wrap-src-lines t > + "If t, wrap individual lines of source blocks in \"code\" elements. When non-nil, wrap... Regards, -- Nicolas Goaziou
Re: [O] [PATCH] ox-html: add option to restore old src block behaviour?
So I'm pretty interested in this: what to others thi k? On Sat., Sep. 21, 2019, 8:16 a.m. Jens Lechtenboerger, < jens.lechtenboer...@fsfe.org> wrote: > On 2019-09-19, Matt Price wrote: > > > Over the summer, commit ded3d27b1468b878197e5fe55a70c5e13350ea27 > > by Nik Clayton was merged to master. It's a one-line change that > > adds new ~~ tags around each lin of code in html export of > > source blocks. It's useful because it allows individual lines to > > be addressed directly by CSS. > > > > However, at least one very common syntax highlighter, > > https://highlinghtjs.org, expects just a single tag, as do > > other common CSS frameworks. > > [...] > > The attached patch adds a new variable org-html-wrap-src-lines to > control whether code tags should be added or not. > > I’m not sure whether :package-version 9.3 is correct. Also, I set > the value to t, which does not change the current functionality. > However, for backwards compatibility (up to version 9.2.6), a value > of nil would be preferable. Any thoughts? > > Best wishes > Jens > >
[O] [PATCH] ox-html: add option to restore old src block behaviour?
On 2019-09-19, Matt Price wrote: > Over the summer, commit ded3d27b1468b878197e5fe55a70c5e13350ea27 > by Nik Clayton was merged to master. It's a one-line change that > adds new ~~ tags around each lin of code in html export of > source blocks. It's useful because it allows individual lines to > be addressed directly by CSS. > > However, at least one very common syntax highlighter, > https://highlinghtjs.org, expects just a single tag, as do > other common CSS frameworks. > [...] The attached patch adds a new variable org-html-wrap-src-lines to control whether code tags should be added or not. I’m not sure whether :package-version 9.3 is correct. Also, I set the value to t, which does not change the current functionality. However, for backwards compatibility (up to version 9.2.6), a value of nil would be preferable. Any thoughts? Best wishes Jens >From ba3130deb9dbbab3c7d293f901ff08be839a8a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Lechtenb=C3=B6rger?= Date: Sat, 21 Sep 2019 12:01:59 +0200 Subject: [PATCH] ox-html: Control source line wrapping * list/ox-html.el (org-html-do-format-code): Use new variable org-html-wrap-src-lines to control whether source code lines should be wrapped in code elements or not. Allow to revert to behavior before commit ded3d27b1468b878197e5fe55a70c5e13350ea27. --- lisp/ox-html.el | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 757006321..969e649fc 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -932,6 +932,14 @@ in all modes you want. Then, use the command :group 'org-export-html :type 'string) +(defcustom org-html-wrap-src-lines t + "If t, wrap individual lines of source blocks in \"code\" elements. +In this case, add line number in attribute \"data-ox-html-linenr\" when line +numbers are enabled." + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'boolean) + Table (defcustom org-html-table-default-attributes @@ -2256,11 +2264,13 @@ line of code." (format "%s" (format num-fmt line-num))) ;; Transcoded src line. - (format "%s" - (if num-start - (format " data-ox-html-linenr=\"%s\"" line-num) -"") - loc) + (if org-html-wrap-src-lines + (format "%s" + (if num-start + (format " data-ox-html-linenr=\"%s\"" line-num) +"") + loc) + loc) ;; Add label, if needed. (when (and ref retain-labels) (format " (%s)" ref ;; Mark transcoded line as an anchor, if needed. -- 2.20.1