ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Johannes Graumann <johannes_graumann@web.de>
To: ntg-context@ntg.nl
Subject: Re: XML
Date: Sun, 26 Oct 2008 15:05:27 +0100	[thread overview]
Message-ID: <ge1tf8$6oi$1@ger.gmane.org> (raw)
In-Reply-To: <48FF9B5C.3070909@wxs.nl>

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

This is sending me down the right paths (at least showing me the sign post ;0) - I know I'm a pain in the neck, but the attached minimal (mirroring your proposal with the "colored" snippet fixed) compiles to to "black" "test"s ...  

What's wrong?

Thanks, Joh

Hans Hagen wrote:

> \starttext
> 
> \startluacode
> document.commands = document.commands or { }
> function document.commands.somehexcolor(str)
> local r, g, b = str:match("#(..)(..)(..)")
> r, g, b = tonumber(r,16) or 0, tonumber(g,16) or 0,
> tonumber(b,16) or 0
> 
> tex.sprint(string.format("\\colored[r=%s,g=%s,b=%s]",r/255,g/255,b/255))
> end
> \stopluacode
> 
> \setupcolors[state=start]
> 
> \def\WhatAMess#1{\ctxlua{document.commands.somehexcolor("#1")}}
> 
> {test \WhatAMess{\letterhash FF3344} test}
> 
> \stoptext
> 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: versuch.tex --]
[-- Type: text/x-tex; name="versuch.tex", Size: 524 bytes --]

\starttext

\startluacode
     document.commands = document.commands or { }
     function document.commands.somehexcolor(str)
         local r, g, b = str:match("#(..)(..)(..)")
         r, g, b = tonumber(r,16) or 0, tonumber(g,16) or 0, tonumber(b,16) or 0
 	 tex.sprint(string.format("\\color[r=%s,g=%s,b=%s]",r/255,g/255,b/255))
     end
\stopluacode

\setupcolors[state=start]

\def\WhatAMess#1{\ctxlua{document.commands.somehexcolor("#1")}}

{test \WhatAMess{\letterhash FF3344} test}

\stoptext



[-- Attachment #3: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2008-10-26 14:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-07 22:14 XML johannes_graumann
2008-10-08  6:34 ` XML luigi scarso
2008-10-08  8:02   ` XML Johannes Graumann
2008-10-08  8:11     ` XML luigi scarso
2008-10-09  7:50 ` XML Wolfgang Schuster
2008-10-09 18:13   ` XML Johannes Graumann
2008-10-14  7:24     ` XML Wolfgang Schuster
2008-10-16  8:24       ` XML Johannes Graumann
2008-10-18  7:28         ` XML olivier Turlier
2008-10-19 13:25           ` XML Johannes Graumann
2008-10-16  8:27       ` XML Johannes Graumann
2008-10-19 20:38       ` XML Johannes Graumann
2008-10-22  6:50         ` XML Wolfgang Schuster
2008-10-22 14:56           ` XML Johannes Graumann
2008-10-22 21:04           ` XML Johannes Graumann
2008-10-22 21:30             ` XML Hans Hagen
2008-10-26 14:05               ` Johannes Graumann [this message]
2008-10-27 10:42                 ` XML Wolfgang Schuster
2008-10-27 20:16                   ` XML Johannes Graumann
2008-10-29  7:09                     ` XML Wolfgang Schuster
  -- strict thread matches above, loose matches on Subject: below --
2005-09-22  6:29 XML Jessica Holle
2005-09-22  6:39 ` XML Henning Hraban Ramm

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

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

  git send-email \
    --in-reply-to='ge1tf8$6oi$1@ger.gmane.org' \
    --to=johannes_graumann@web.de \
    --cc=ntg-context@ntg.nl \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).