Re: [Orgmode] text color + highlight
On 08/11/2010 01:14 AM, Samuel Wales wrote: i suggest begin-end pairs, not putting text in the syntax itself. though you could, if you want, using quotes. $[class begin :title animals]Some text about animals$[class end :title animals] Why not allow both? If I want to highlight one or two words, maybe I could use: $[class :title animals African swallow] Compare this to: $[class begin :title animals]African swallow$[class end :title animals] For a few sentences and to get support for nested formatting, I would definitely want begin-end pairs, too, but if you want to highlight a few words, being able to put text into the syntax itself makes things a lot shorter. As far as I understand it, once a framework for this extensible syntax is in place, it would not be too hard to support both variants. BTW, I really like the idea of having extensible syntax in general; this could also make inline todos a lot less painful. I do not know enough about elisp and Org to help with the implementation, but if someone wants to implement this and needs help with testing, I'd be glad to help. (I wrote my last exam today, so I will have a lot more time to spare until October.) Jan ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi, - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new /markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric I'd like an extensible inline markup construct (not primarily for coloring). Would it make sense to hijack custom links for this purpose, and use existing bracketed link syntax rather than add a new syntax? For semantic tagging (my chief interest), one might e.g. define a `class' link type and an HTML export handler to wrap the contents in span class=kewyord tags. : [[class:animals][some text about animals]] As for color: If one is satisfied with getting colors on export, defining a `color' link type and appropriate export handlers will do. : [[color:red][some colored text]] If one also wants the text to appear in the right color within Org-mode, and does not want the pseudo-link markup to be underlined and look like links, it would require additional Org functionality (I think): User-defined custom faces for different link types. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten Those examples are not very readable IMO -- without a separator it's hard to see where the property values end and the marked up text begins. Yours, Christian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi, Can we please first read Samuels post about extensible syntax? Before we invent 20 other new syntaxes? http://thread.gmane.org/gmane.emacs.orgmode/10204/focus=10204 Thanks! On Aug 10, 2010, at 8:14 AM, Christian Moe wrote: Hi, - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new / markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric I'd like an extensible inline markup construct (not primarily for coloring). Would it make sense to hijack custom links for this purpose, and use existing bracketed link syntax rather than add a new syntax? For semantic tagging (my chief interest), one might e.g. define a `class' link type and an HTML export handler to wrap the contents in span class=kewyord tags. : [[class:animals][some text about animals]] As for color: If one is satisfied with getting colors on export, defining a `color' link type and appropriate export handlers will do. : [[color:red][some colored text]] If one also wants the text to appear in the right color within Org- mode, and does not want the pseudo-link markup to be underlined and look like links, it would require additional Org functionality (I think): User-defined custom faces for different link types. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten Those examples are not very readable IMO -- without a separator it's hard to see where the property values end and the marked up text begins. Yours, Christian - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi Christian, Christian Moe m...@christianmoe.com writes: Hi, I'm sorry my point was buried in quoted text. I did read Samuel's post. But my question was whether we couldn't *avoid inventing new syntaxes*, by using the already existing link syntax with custom links and export handlers (plus possibly some some new functionality to user-customize the faces of different link types in Org-mode). e.g. : [[color:red][some text in red]] : [[class:highlight][some highlighted text]] It's already trivial to write one's own `color' and `class' custom link types with export handlers to turn this into HTML such as: : span style=color: red;some text in red/span : span class=highlightsome highlighted text/span Thanks for making this suggestion. This is a much better solution than creating a new syntax out of whole cloth, I should have known that Org would already have a working solution in place. Just for completeness I'm adding an example of a color handler which can be added to a users config to enable colorization of exported text to html and latex. --8---cut here---start-8--- (org-add-link-type color nil (lambda (path desc format) (cond ((eq format 'html) (format span style=\color:%s;\%s/span path desc)) ((eq format 'latex) (format {\\color{%s}%s} path desc) --8---cut here---end---8--- it should be fairly straightforward to extend the above for background or class link types (where the latter example would be styled by CSS). Doing this in exported text requires *no changes* to Org-mode. It also does not require finding one solution that fits everybody. If one wants Org text styled in these colors, highlights etc., I suppose it would require changes in Org-mode: not just user-customizable faces for different link types, as I wrote in the previous message, but a function to define link faces on the fly from the PATH part of the link. I think in-buffer colorization is much less important than the export behavior. Cheers -- Eric Christian Carsten Dominik wrote: Hi, Can we please first read Samuels post about extensible syntax? Before we invent 20 other new syntaxes? http://thread.gmane.org/gmane.emacs.orgmode/10204/focus=10204 Thanks! On Aug 10, 2010, at 8:14 AM, Christian Moe wrote: Hi, - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new /markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric I'd like an extensible inline markup construct (not primarily for coloring). Would it make sense to hijack custom links for this purpose, and use existing bracketed link syntax rather than add a new syntax? For semantic tagging (my chief interest), one might e.g. define a class' link type and an HTML export handler to wrap the contents in span class=kewyord tags. : [[class:animals][some text about animals]] As for color: If one is satisfied with getting colors on export, defining a `color' link type and appropriate export handlers will do. : [[color:red][some colored text]] If one also wants the text to appear in the right color within Org-mode, and does not want the pseudo-link markup to be underlined and look like links, it would require additional Org functionality (I think): User-defined custom faces for different link types. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten Those examples are not very readable IMO -- without a separator it's hard to see where the property values end and the marked up text begins. Yours, Christian - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi, Eric, Thanks for trying this out -- I should have taken the trouble to write out sample code myself. Just for completeness I'm adding an example of a color handler which can be added to a users config to enable colorization of exported text to html and latex. --8---cut here---start-8--- (org-add-link-type color nil (lambda (path desc format) (cond ((eq format 'html) (format span style=\color:%s;\%s/span path desc)) ((eq format 'latex) (format {\\color{%s}%s} path desc) --8---cut here---end---8--- A drawback with using links for markup is that the user sees things that look like links, but do nothing when clicked, except give error messages. So instead of setting the third argument -- the follow function -- to nil, I'd flash the user an informative message, e.g. --8---cut here---start-8--- (org-add-link-type color (lambda (path) (message (format This link adds %s color but goes nowhere path))) (lambda (path desc format) (cond ((eq format 'html) (format span style=\color:%s;\%s/span path desc)) ((eq format 'latex) (format {\\color{%s}%s} path desc) --8---cut here---end---8--- Yours, Christian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Christian Moe wrote: Hi, Eric, Thanks for trying this out -- I should have taken the trouble to write out sample code myself. Just for completeness I'm adding an example of a color handler which can be added to a users config to enable colorization of exported text to html and latex. --8---cut here---start-8--- (org-add-link-type color nil (lambda (path desc format) (cond ((eq format 'html) (format span style=\color:%s;\%s/span path desc)) ((eq format 'latex) (format {\\color{%s}%s} path desc) --8---cut here---end---8--- A drawback with using links for markup is that the user sees things that look like links, but do nothing when clicked, except give error messages. It's not just a drawback but a more fundamental problem: This solution abolishes the semantics of a fundamental entity, the link. color:red /means/ something completely different than info:elisp. I'll need some time to read the proposal about this topic but my out-of-the-guts impression is, that the distinction between semantics and markup (or visualization) is not drawn as sharp as it is. For Org it's all about semantics: If we know what a special sequence of characters means, we can provide appropriate actions. One possible action is to provide special colors etc. as a visual aid. So maybe don't focus on how to /implement/ visualization but on the general purpose or meaning of what is /visualized/ (!) by distinct colors. Best, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de pgpHre2SLG92r.pgp Description: PGP signature ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
I wrote (against my own suggestion): A drawback with using links for markup is that the user sees things that look like links, but do nothing when clicked, except give error messages. David Maus wrote: It's not just a drawback but a more fundamental problem: This solution abolishes the semantics of a fundamental entity, the link. color:red /means/ something completely different than info:elisp. I certainly see that objection. I don't have a strong opinion, I just hit on the idea of using custom links as a quick hack to do some inline semantic tagging I wanted, then thought it might be worth considering in the present discussion, as an alternative to complex new syntaxes. Quibble: Note that =info:elisp= also means something rather different from =shell: ls *org=, =elisp: org-agenda=, or =elisp:(find-file-other-frame Elisp.org)=. Okay, so Org-babel might put these link types out of business (and anyway they unfailingly crash my Emacs 23 for the Mac). But currently they /are/ defined as Org links, even though execute this code does not mean follow this link. So the double-bracket syntax seems to have a broader meaning. Admittedly, though, all the currently defined link types mean do something when clicked, which a =color:red= link does not. Christian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
i suggest begin-end pairs, not putting text in the syntax itself. though you could, if you want, using quotes. $[class begin :title animals]Some text about animals$[class end :title animals] i wrote the following long ago, but never sent it to the list. it is not polished at all -- needs more work that i cannot do on it now -- and not even capitalized. this is just one example of many for extensible syntax. note that the code i provide is for the /user/ to use if he wants. the following pretends that color is not a feature of org and demonstrates that even a /user/, without modifying any code in org, can actually implement a new feature with its own syntax (actually extensible syntax, which will never conflict with other features) -- if extensible syntax becomes a feature of org. i wrote it in response to somebody requesting color. it needs work. for example, s/color/face/g . === as far as i know, this is not a feature in org. however, if extensible syntax were implemented, you could add this feature to org yourself without touching org source code or writing any regexps. here is what it would look like (not what you normally see, but what you would see if everything were visible). here is text in your normal face. $[color begin :face myface :label nil]here is text in myface. the extensible syntax at the beginning has :label nil, which means that both ends are invisible except when you are editing them or have specified that :label should be ignored. to make them visible, remove or change :label. you can also change the label of the end syntax separately if you want. $[color end]here is text in your normal face. to implement this as a user, you would put something like this into your .emacs. (define-org-syntax color ;;these are the quasiarguments to your feature. they ;;use common lisp's keyword argument feature. face ;;defaults to default-face and label defaults to nil, ;;which means to (begin-or-end key (face default-face) label) Implement my color feature in org. (cond ((equal begin-or-end begin) ;;fixme here you put the emacs code to start a color block ) ((equal begin-or-end end) ;;fixme here you put the emacs code to end a color block ) (otherwise (error needs to be begin or end (define-key org-mode-map \C-cc 'my-insert-color-block) (defun my-insert-color-block () Insert a color block. (interactive) ;;fixme place point between them (insert $[color begin :face myface :label nil]$[color end])) On 2010-08-09, Christian Moe m...@christianmoe.com wrote: Hi, - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new /markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric I'd like an extensible inline markup construct (not primarily for coloring). Would it make sense to hijack custom links for this purpose, and use existing bracketed link syntax rather than add a new syntax? For semantic tagging (my chief interest), one might e.g. define a `class' link type and an HTML export handler to wrap the contents in span class=kewyord tags. : [[class:animals][some text about animals]] As for color: If one is satisfied with getting colors on export, defining a `color' link type and appropriate export handlers will do. : [[color:red][some colored text]] If one also wants the text to appear in the right color within Org-mode, and does not want the pseudo-link markup to be underlined and look like links, it would require additional Org functionality (I think): User-defined custom faces for different link types. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten Those examples are not very readable IMO -- without a separator it's hard to see where the property values end and the marked up text begins. Yours, Christian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode -- Q: How many CDC scientists
Re: [Orgmode] text color + highlight
Christian Moe m...@christianmoe.com writes: [...] Admittedly, though, all the currently defined link types mean do something when clicked, which a =color:red= link does not. well this may be trivial, but at least it's an action --8---cut here---start-8--- (org-add-link-type color (lambda (path) (message (concat color (progn (add-text-properties 0 (length path) (list 'face `((t (:foreground ,path path) path (lambda (path desc format) (cond ((eq format 'html) (format span style=\color:%s;\%s/span path desc)) ((eq format 'latex) (format {\\color{%s}%s} path desc) --8---cut here---end---8--- Best -- Eric Christian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi, The attached patch implements in-buffer coloring and html export using the syntax proposed below. While I think this is an improvement over my previous patch, this idea still has some shortcoming including the fact that - nested color specifications aren't working for export (and could be tricky to implement) - when using a dark-background Emacs theme colors that look good in the buffer generally don't look good in the html export and vise versa The following Org-mode buffer demonstrates this patch --8---cut here---start-8--- #+Title: A Buffer with Color * top Some colors [color[green]are] green, and [color[red]also] red, and even html colors like [color[#610B5E]these others] sometimes subtler colors. These can also be [background[yellow]highlighted]. --8---cut here---end---8--- Cheers -- Eric From db9d463ce7d015de16fe768804d83132bc1780d2 Mon Sep 17 00:00:00 2001 From: Eric Schulte schulte.e...@gmail.com Date: Fri, 6 Aug 2010 11:29:33 -0400 Subject: [PATCH] introduction of colorization for html output * lisp/org-exp.el (org-export-with-color): new customization parameter controlling the code colorization on export * lisp/org-html.el (org-html-do-expand): conditional application of string colorization in html (org-export-html-colorize): apply html colorization to org-mode text * lisp/org.el (org-fontify-colorized-text): add option to control in-buffer colorization of the text (org-do-colorize-faces): function which applies color to a buffer (org-set-font-lock-defaults): add coloring to the org-mode fontification loop --- lisp/org-exp.el |5 + lisp/org-html.el | 22 ++ lisp/org.el | 36 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index cd0a105..7c3d0dd 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -449,6 +449,11 @@ This option can also be set with the +OPTIONS line, e.g. \*:nil\. :group 'org-export-translation :type 'boolean) +(defcustom org-export-with-color t + Non-nil means apply colors to exported text. + :group 'org-export-translation + :type 'boolean) + (defcustom org-export-with-footnotes t If nil, export [1] as a footnote marker. Lines starting with [1] will be formatted as footnotes. diff --git a/lisp/org-html.el b/lisp/org-html.el index a12141f..1b5665b 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -2060,6 +2060,8 @@ If there are links in the string, don't modify these. (setq s (replace-match \\1 t nil s (if org-export-with-emphasize (setq s (org-export-html-convert-emphasize s))) + (if org-export-with-color + (setq s (org-export-html-colorize s))) (if org-export-with-special-strings (setq s (org-export-html-convert-special-strings s))) (if org-export-with-sub-superscripts @@ -2131,6 +2133,26 @@ If there are links in the string, don't modify these. (setq s (1+ s string)) +(defun org-export-html-colorize (string) + Apply colors. + (let ((s1 0) (length (length string)) s2 s3 parens) +(while (string-match \\[\\([^\r\n]+?\\)\\[\\(.+?\\)\\] string s1) + (setq s2 s1 s3 (match-beginning 0) s1 (match-end 0) parens 1) + (while (and ( parens 0) (= s1 length)) + ((lambda (h) + (cond ((string= h [) (setq parens (+ parens 1))) + ((string= h ]) (setq parens (- parens 1) + (substring string s1 (setq s1 (+ 1 s1) + (when (= s1 length) + (setq string + (concat (substring string 0 s3) + span style=\ (match-string 1 string) + : (match-string 2 string) ;\ + (substring string (match-end 0) (- s1 1)) /span + (substring string s1 + (setq length (+ length 20))) +string)) + (defun org-open-par () Insert p, but first close previous paragraph if any. (org-close-par-maybe) diff --git a/lisp/org.el b/lisp/org.el index af4f793..772b31f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3294,6 +3294,12 @@ Changing this variable requires a restart of Emacs to take effect. :group 'org-appearance :type 'boolean) +(defcustom org-fontify-colorized-text t + Non-nil means colorize colored text. +Changing this variable requires a restart of Emacs to take effect. + :group 'org-appearance + :type 'boolean) + (defcustom org-fontify-whole-heading-line nil Non-nil means fontify the whole line for headings. This is useful when setting a background color for the @@ -4932,6 +4938,30 @@ The time stamps may be either active or inactive.) (backward-char 1)) rtn)) +(defun org-do-colorize-faces (limit) + Run through the buffer and add overlays to colored text. + (let ((s1 0) parens rtn) +(while (and (re-search-forward \\[\\([^\r\n]+?\\)\\[\\(.+?\\)\\] limit t)) + (setq s1 (match-end 0) parens 1) + (while ( parens 0) + ((lambda (h) + (cond ((string= h [) (setq parens (+ parens 1))) + ((string= h ])
Re: [Orgmode] text color + highlight
Hi Eric, Did you read my proposals in detail? Samuel On 2010-08-08, Eric Schulte schulte.e...@gmail.com wrote: Hi, The attached patch implements in-buffer coloring and html export using the syntax proposed below. While I think this is an improvement over my previous patch, this idea still has some shortcoming including the fact that - nested color specifications aren't working for export (and could be tricky to implement) - when using a dark-background Emacs theme colors that look good in the buffer generally don't look good in the html export and vise versa The following Org-mode buffer demonstrates this patch --8---cut here---start-8--- #+Title: A Buffer with Color * top Some colors [color[green]are] green, and [color[red]also] red, and even html colors like [color[#610B5E]these others] sometimes subtler colors. These can also be [background[yellow]highlighted]. --8---cut here---end---8--- Cheers -- Eric -- Q: How many CDC scientists does it take to change a lightbulb? A: You only think it's dark. [CDC has denied a deadly disease for 25 years] == Retrovirus: http://www.wpinstitute.org/xmrv/index.html -- PLEASE DONATE === PNAS must publish the original Lo and Alter NIH/FDA XMRV paper verbatim along with the new paper. ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
On Aug 8, 2010, at 11:00 PM, Eric Schulte wrote: Vinh Nguyen vinhdi...@gmail.com writes: On Fri, Aug 6, 2010 at 8:15 PM, Eric Schulte schulte.e...@gmail.com wrote: In playing with the patched code I sent out, I noticed that it may be doing weird things to my headings (#+Title: etc...) in some Org-mode files, so probably it could use some more tweaking before any merge, also I'd not want to rush what could be a reasonably large change into Org-mode without more discussion, but I agree I'd ultimately like to see some form of this functionality appear in Org-mode. Best -- Eric Eric, so are you tweaking the code to give it a more org-like syntax? If not, I'll have to get dirty with your patch to figure out the lisp code. You're right the regular parentheses will probably be mixed up with lisp code. Sebastian also brought up that curly braces are hard to type on a German keyboard. Just googled up the layout -- don't even seen them. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new /markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Am 09.08.2010, 08:28 Uhr, schrieb Carsten Dominik carsten.domi...@gmail.com: Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. I'd prefer this kind of syntax, too. Btw, shouldn't the syntax be: $[face :color red :italic t the red italic text] ?? (i.e. the red following the :color keyword, not the ':italic t') I didn't find a canonical way to make a paragraph or a longer text passage italic However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Am 09.08.2010, 09:37 Uhr, schrieb Robert Klein rokl...@roklein.de: Sorry dropped something on the keyboard and sent the message early :( Am 09.08.2010, 08:28 Uhr, schrieb Carsten Dominik carsten.domi...@gmail.com: Nope, I am against this syntax. If we introduce a more general syntax, then it should be done in the way Samuel proposed. WHich means we firs get a keyword indtroducing the piece, and then properties. Like $[style :color red the red text] or $[face :color :italic t red the red text] Something like the $ before [ also would seem critical to disambiguate from other uses of [. I'd prefer this kind of syntax, too. Btw, shouldn't the syntax be: $[face :color red :italic t the red italic text] ?? (i.e. the red following the :color keyword, not the ':italic t') I didn't find a canonical way to make a paragraph or a longer text passage italic, so I'd love an easy way to get it. BTW, if simply '$[' is free, why not use this for style, e.g.: $[:italic t :bold nil :color teal My italic and teal text] (sorry for the double mail) Best regards Robert However, I am not too excited about extra syntax to get this kind of thing. Would not oppose it, but probably never use it. - Carsten ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
On Fri, Aug 6, 2010 at 8:15 PM, Eric Schulte schulte.e...@gmail.com wrote: In playing with the patched code I sent out, I noticed that it may be doing weird things to my headings (#+Title: etc...) in some Org-mode files, so probably it could use some more tweaking before any merge, also I'd not want to rush what could be a reasonably large change into Org-mode without more discussion, but I agree I'd ultimately like to see some form of this functionality appear in Org-mode. Best -- Eric Eric, so are you tweaking the code to give it a more org-like syntax? If not, I'll have to get dirty with your patch to figure out the lisp code. You're right the regular parentheses will probably be mixed up with lisp code. Sebastian also brought up that curly braces are hard to type on a German keyboard. Just googled up the layout -- don't even seen them. What syntax to use... ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Eric Schulte schulte.e...@gmail.com writes: Hi, I've recently seen similar requests on this list. The attached patch provides a first pass at this support implementing both in-buffer coloring given the following syntax, and html export (I don't know the correct LaTeX syntax, but it shouldn't be hard to extend this to LaTeX as well). This uses something like the LaTeX Beamer \color{}{} directive, for example... My name is \color{red}{eric} schulte. Would result in the word eric appearing in red. Even though I implemented the syntax above, I'm *not* recommending this syntax, it feels decidedly more like latex than org, it was simply the only obvious option for this initial implementation. Well, why not keep that syntax, but add another one: --8---cut here---start-8-- #+color: red * This entired entry is in red color The contents too. * Back to normal Some text. #+color: green This next something (a pragraph in this case) is in green color. back to normal --8---cut here---end---8-- Maybe it's easier to make the comment color the next line only? How about #+style: color=red weight=bold Or #+red #+bold I'm red and bold. Something like this. It's easier to just add a comment, than to wrap a region. Curly braces are hard to type on a german keyboard. Just jump to the beginning of a line and type `#+red RET' seems easier to me. To remove `#+red', `C-k C-k' is enough. No need to learn another Shortcut. Sebastian ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi all, I do, very strongly, propose extensible syntax. Thanks for bringing it up, Dan. I have much more on this but cannot type now. Samuel -- Q: How many CDC scientists does it take to change a lightbulb? A: You only think it's dark. [CDC has denied a deadly disease for 25 years] == Retrovirus: http://www.wpinstitute.org/xmrv/index.html -- PLEASE DONATE === PNAS must publish the original Lo and Alter NIH/FDA XMRV paper verbatim along with the new paper. ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Vinh Nguyen vinhdi...@gmail.com writes: On Fri, Aug 6, 2010 at 8:15 PM, Eric Schulte schulte.e...@gmail.com wrote: In playing with the patched code I sent out, I noticed that it may be doing weird things to my headings (#+Title: etc...) in some Org-mode files, so probably it could use some more tweaking before any merge, also I'd not want to rush what could be a reasonably large change into Org-mode without more discussion, but I agree I'd ultimately like to see some form of this functionality appear in Org-mode. Best -- Eric Eric, so are you tweaking the code to give it a more org-like syntax? If not, I'll have to get dirty with your patch to figure out the lisp code. You're right the regular parentheses will probably be mixed up with lisp code. Sebastian also brought up that curly braces are hard to type on a German keyboard. Just googled up the layout -- don't even seen them. What syntax to use... I've thought briefly about the following syntax [color[red] text to be colored red] - this would be extensible, e.g. [background[yellow] highlighted text] could export to the following html span style=background:yellow;highlighted text/span - this would avoid {}s - this would look more org-like than the pure latex solution the only issue with the above is that it may conflate a new /markup/ syntax with org-mode's existing /link/ syntax. Thoughts? -- Eric ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi Vinh, Vinh Nguyen vinhdi...@gmail.com writes: I was wondering if there is an easy way to markup the color of the text for html output (and highlight as well). When I prepare meeting minutes I'd like to color some things and highlight certain things. Right now, I am using emphasizing a major portion of the text. It would be great to have colors and highlights to draw attention to certain items. I don't understand your request: what portion of org-mode buffer do you want to highlight? based on what criteria? -- Bastien ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
On Fri, Aug 6, 2010 at 2:18 AM, Bastien bastien.gue...@wikimedia.fr wrote: Hi Vinh, Vinh Nguyen vinhdi...@gmail.com writes: I was wondering if there is an easy way to markup the color of the text for html output (and highlight as well). When I prepare meeting minutes I'd like to color some things and highlight certain things. Right now, I am using emphasizing a major portion of the text. It would be great to have colors and highlights to draw attention to certain items. I don't understand your request: what portion of org-mode buffer do you want to highlight? based on what criteria? Apologies for the ambiguity. In the org, we can use *text* and the word text would be bold in the html output. I was wondering if there is a markup that would change the color, eg, \{red}[text], or something of that sort. I don't think it exists. If I wanted to implement this myself, what should I start with. Ditto with highlights (say, highlight text yellow). Something more on org-mode's line would be like setting a variable #+ color=red and with some new symbols, say ^text^, the color of text would be red in the html output. Hope this clears things up. -- Bastien ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi, I've recently seen similar requests on this list. The attached patch provides a first pass at this support implementing both in-buffer coloring given the following syntax, and html export (I don't know the correct LaTeX syntax, but it shouldn't be hard to extend this to LaTeX as well). This uses something like the LaTeX Beamer \color{}{} directive, for example... My name is \color{red}{eric} schulte. Would result in the word eric appearing in red. Even though I implemented the syntax above, I'm *not* recommending this syntax, it feels decidedly more like latex than org, it was simply the only obvious option for this initial implementation. -- Eric From a488b43b66971b16f63141d29cb61f44b959abfa Mon Sep 17 00:00:00 2001 From: Eric Schulte schulte.e...@gmail.com Date: Fri, 6 Aug 2010 11:29:33 -0400 Subject: [PATCH] introduction of colorization for html output * lisp/org-exp.el (org-export-with-color): new customization parameter controlling the code colorization on export * lisp/org-html.el (org-html-do-expand): conditional application of string colorization in html (org-export-html-colorize): apply html colorization to org-mode text * lisp/org.el (org-fontify-colorized-text): add option to control in-buffer colorization of the text (org-do-colorize-faces): function which applies color to a buffer (org-set-font-lock-defaults): add coloring to the org-mode fontification loop --- lisp/org-exp.el |5 + lisp/org-html.el | 18 ++ lisp/org.el | 27 +++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 6fc5109..991a555 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -445,6 +445,11 @@ This option can also be set with the +OPTIONS line, e.g. \*:nil\. :group 'org-export-translation :type 'boolean) +(defcustom org-export-with-color t + Non-nil means apply colors to exported text. + :group 'org-export-translation + :type 'boolean) + (defcustom org-export-with-footnotes t If nil, export [1] as a footnote marker. Lines starting with [1] will be formatted as footnotes. diff --git a/lisp/org-html.el b/lisp/org-html.el index a12141f..3d3bdcb 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -2060,6 +2060,8 @@ If there are links in the string, don't modify these. (setq s (replace-match \\1 t nil s (if org-export-with-emphasize (setq s (org-export-html-convert-emphasize s))) + (if org-export-with-color + (setq s (org-export-html-colorize s))) (if org-export-with-special-strings (setq s (org-export-html-convert-special-strings s))) (if org-export-with-sub-superscripts @@ -2131,6 +2133,22 @@ If there are links in the string, don't modify these. (setq s (1+ s string)) +(defun org-export-html-colorize (string) + Apply colors. + (replace-regexp-in-string + color{\\(.+?\\)}{\\(.+?\\)} + (lambda (text) + (let ((ind 7) (length (length text))) + (while (and ( ind length) + (not (string= (substring text ind (+ 2 ind)) }{))) + (setq ind (+ 1 ind))) + (if (get-text-property (match-beginning 0) 'org-protected string) + text + (concat span style=\color: (substring text 7 ind) + ;\ (substring text (+ 2 ind) (- length 1)) + /span + string)) + (defun org-open-par () Insert p, but first close previous paragraph if any. (org-close-par-maybe) diff --git a/lisp/org.el b/lisp/org.el index d2c1fdf..fe98fb0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3282,6 +3282,12 @@ Changing this variable requires a restart of Emacs to take effect. :group 'org-appearance :type 'boolean) +(defcustom org-fontify-colorized-text t + Non-nil means colorize colored text. +Changing this variable requires a restart of Emacs to take effect. + :group 'org-appearance + :type 'boolean) + (defcustom org-fontify-whole-heading-line nil Non-nil means fontify the whole line for headings. This is useful when setting a background color for the @@ -4920,6 +4926,21 @@ The time stamps may be either active or inactive.) (backward-char 1)) rtn)) +(defun org-do-colorize-faces (limit) + Run through the buffer and add overlays to colored text. + (let ((org-color-re color{\\(.+?\\)}{\\(.+?\\)})) +(while (re-search-forward org-color-re limit t) + ;; hide wrapper + (add-text-properties (match-beginning 0) (+ 2 (match-end 1)) + '(invisible org-link)) + (add-text-properties (- (match-end 0) 1) (match-end 0) + '(invisible org-link)) + ;; color text + (font-lock-prepend-text-property (match-beginning 2) (match-end 2) + 'face + `((t (:foreground ,(match-string 1)) +rtn)) + (defun org-emphasize (optional char) Insert or change an emphasis, i.e. a font like bold or italic. If there is an active region, change that region to a new emphasis. @@ -5367,6 +5388,7 @@ For plain list items, if they are matched by
Re: [Orgmode] text color + highlight
Thanks Eric, this works. I do agree that the implemented syntax is not org-like but more latex-like. To be more org-like, could we use parentheses or curly braces like how links are implemented? They aren't taken, are they? For example, ((red)(this text is red)) {{yellow}{this text is highlighted yellow}} ## see http://answers.yahoo.com/question/index?qid=20080316135432AANXSJc What do you think? How hard would it be to change your code to this? Can this be merged into the development branch? Thanks, Vinh On Fri, Aug 6, 2010 at 2:51 PM, Eric Schulte schulte.e...@gmail.com wrote: Hi, I've recently seen similar requests on this list. The attached patch provides a first pass at this support implementing both in-buffer coloring given the following syntax, and html export (I don't know the correct LaTeX syntax, but it shouldn't be hard to extend this to LaTeX as well). This uses something like the LaTeX Beamer \color{}{} directive, for example... My name is \color{red}{eric} schulte. Would result in the word eric appearing in red. Even though I implemented the syntax above, I'm *not* recommending this syntax, it feels decidedly more like latex than org, it was simply the only obvious option for this initial implementation. -- Eric ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] text color + highlight
Hi Vinh, Vinh Nguyen vinhdi...@gmail.com writes: Thanks Eric, this works. Great, I do agree that the implemented syntax is not org-like but more latex-like. To be more org-like, could we use parentheses or curly braces like how links are implemented? They aren't taken, are they? For example, ((red)(this text is red)) {{yellow}{this text is highlighted yellow}} ## see http://answers.yahoo.com/question/index?qid=20080316135432AANXSJc yes, these would be equally easy to implement, and simpler than with the \color prefix, but as someone who often leaves lisp snippets laying around org-mode files, these options may be too dangerous. We'd have to ensure that the syntax doesn't accidentally grab text which is not intended for formatting. also, color gives the option of other keyword attributes which we may want to associate with text, e.g. background for background coloring (highlighting), font-type for possibly different fonts, etc... but again, I'm reticent to commit to any particular format, as Org-mode does a good job of feeling consistent, and I'd not want to hurt that consistency. What do you think? How hard would it be to change your code to this? Can this be merged into the development branch? In playing with the patched code I sent out, I noticed that it may be doing weird things to my headings (#+Title: etc...) in some Org-mode files, so probably it could use some more tweaking before any merge, also I'd not want to rush what could be a reasonably large change into Org-mode without more discussion, but I agree I'd ultimately like to see some form of this functionality appear in Org-mode. Best -- Eric Thanks, Vinh On Fri, Aug 6, 2010 at 2:51 PM, Eric Schulte schulte.e...@gmail.com wrote: Hi, I've recently seen similar requests on this list. The attached patch provides a first pass at this support implementing both in-buffer coloring given the following syntax, and html export (I don't know the correct LaTeX syntax, but it shouldn't be hard to extend this to LaTeX as well). This uses something like the LaTeX Beamer \color{}{} directive, for example... My name is \color{red}{eric} schulte. Would result in the word eric appearing in red. Even though I implemented the syntax above, I'm *not* recommending this syntax, it feels decidedly more like latex than org, it was simply the only obvious option for this initial implementation. -- Eric ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode