From: Aditya Mahajan <adityam@umich.edu>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: feature request
Date: Mon, 14 Nov 2011 22:35:13 -0500 (EST) [thread overview]
Message-ID: <alpine.LNX.2.00.1111142234190.16555@ybpnyubfg.ybpnyqbznva> (raw)
In-Reply-To: <4EC11FA7.6070402@wxs.nl>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 680 bytes --]
On Mon, 14 Nov 2011, Hans Hagen wrote:
> On 14-11-2011 09:47, Aditya Mahajan wrote:
>> On Fri, 11 Nov 2011, Steffen Wolfrum wrote:
>>
>> > quite often I wish we could have a kind of in line comment:
>> > Something like ¿this is my comment¡ this.
>> >
>> > I assume it is not trivial due to catcode issues, to say the least.
>> > But nevertheless, as it is getting close to christmas, I just wanted
>> > to mention this idea here.
>>
>> As long as there is no line break in the comment, the following lua
>> based solution works (inspired by m-translate)
>>
> or ...
>
Why not go all the way with full multiline comments then? See attached.
Aditya
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-tex; name=comment.tex, Size: 3106 bytes --]
\startluacode
thirddata = thirddata or { }
local comments = { filters = { } }
thirddata.comments = comments
local textlineactions = resolvers.openers.helpers.textlineactions
local sequencers = utilities.sequencers
local constants = interfaces.constants
local gsub, find, format = string.gsub, string.find, string.format
function comments.install(name,settings)
local settings = utilities.parsers.settings_to_hash(settings)
local start = string.escapedpattern(settings[constants.start] or "")
local stop = string.escapedpattern(settings[constants.stop] or "")
local any = ".-"
if start ~= "" and stop ~= "" then
local strip_inline = function(s) return gsub(s, start .. any .. stop, "", 1) end
local strip_start = function(s) return gsub(s, start .. any, "", 1) end
local strip_stop = function(s) return gsub(s, "^" .. any .. stop, "", 1) end
local insideComment = false
comments.filters[name] = function(s)
local filter = comments.filters[name]
if s == "" then
return s
elseif insideComment then
if find(s,stop) then
insideComment = false
return filter(strip_stop(s))
else
return ""
end
elseif find(s,start) then
if find(s, stop) then
return filter(strip_inline(s))
else
insideComment = true
return strip_start(s)
end
else
return s
end
end
sequencers.appendaction(textlineactions,"after",format("thirddata.comments.filters.%s",name))
comments.disable(name)
end
end
function comments.enable(name)
sequencers.enableaction(textlineactions,format("thirddata.comments.filters.%s",name))
end
function comments.disable(name)
sequencers.disableaction(textlineactions,format("thirddata.comments.filters.%s",name))
end
\stopluacode
\unprotect
\unexpanded\def\installcomments{\dodoubleargument\doinstallcomments}
\def\doinstallcomments[#1][#2]%
{\ctxlua{thirddata.comments.install(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}}
\unexpanded\def\enablecomments[#1]%
{\ctxlua{thirddata.comments.enable (\!!bs#1\!!es)}}
\unexpanded\def\disablecomments[#1]%
{\ctxlua{thirddata.comments.disable(\!!bs#1\!!es)}}
\protect
\installcomments[test] [start=/*,stop=*/]
\starttext
\enablecomments[test]
\section{Test of /*inline*/ comments}
/* Test for multiline comments
* to see if they work
*/
Another test for /* inline comments */ with multiple /* commented lines
that span /* false nested comments as well */ to see if it works
\stoptext
[-- Attachment #3: Type: text/plain, Size: 485 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2011-11-15 3:35 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 15:34 Steffen Wolfrum
2011-11-11 15:53 ` Andreas Harder
2011-11-11 15:57 ` Wolfgang Schuster
2011-11-11 16:01 ` Wolfgang Schuster
2011-11-11 18:47 ` Idris Samawi Hamid ادريس سماوي حامد
2011-11-13 10:55 ` Steffen Wolfrum
2011-11-13 21:33 ` Andreas Schneider
2011-11-14 7:57 ` Steffen Wolfrum
2011-11-14 8:07 ` Hans Hagen
2011-11-14 9:22 ` Steffen Wolfrum
2011-11-14 18:38 ` Idris Samawi Hamid ادريس سماوي حامد
2011-11-15 22:03 ` Idris Samawi Hamid ادريس سماوي حامد
2011-11-15 22:11 ` Wolfgang Schuster
2011-11-15 22:28 ` Aditya Mahajan
2011-11-15 22:47 ` Idris Samawi Hamid ادريس سماوي حامد
2011-11-14 8:47 ` Aditya Mahajan
2011-11-14 14:03 ` Hans Hagen
2011-11-15 3:35 ` Aditya Mahajan [this message]
2011-11-15 5:43 ` Aditya Mahajan
2011-11-15 8:56 ` Hans Hagen
-- strict thread matches above, loose matches on Subject: below --
2019-07-03 6:00 Atsuhito Kohda
2019-07-03 6:35 ` Henri Menke
2019-07-03 6:42 ` Henri Menke
2019-07-04 5:18 ` Atsuhito Kohda
2019-07-04 5:48 ` Henri Menke
2019-07-05 23:31 ` Atsuhito Kohda
2019-07-04 15:16 ` Aditya Mahajan
2019-07-04 15:54 ` Alan Braslau
2019-07-05 23:44 ` Atsuhito Kohda
2019-07-05 23:35 ` Atsuhito Kohda
2007-07-05 17:41 Feature request John R. Culleton
2007-07-05 21:37 ` Patrick Gundlach
2007-07-05 22:27 ` John R. Culleton
2007-07-06 8:09 ` Patrick Gundlach
2005-07-27 9:58 Steffen Wolfrum
2005-07-27 22:16 ` Hans Hagen
[not found] <a06210200bf0958f2bc0f@87.193.3.198>
2005-07-26 16:20 ` Mojca Miklavec
2005-07-26 22:56 ` Hans Hagen
2005-07-27 5:15 ` luigi.scarso
2005-07-26 15:33 Steffen Wolfrum
2005-07-26 22:38 ` Hans Hagen
2005-07-26 15:00 Steffen Wolfrum
2005-07-26 13:32 Steffen Wolfrum
2005-07-26 14:21 ` Hans Hagen
2005-07-26 14:32 ` Hans Hagen
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=alpine.LNX.2.00.1111142234190.16555@ybpnyubfg.ybpnyqbznva \
--to=adityam@umich.edu \
--cc=ntg-context@ntg.nl \
--cc=pragma@wxs.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).