Hi Hans, 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. Thanks, Steffen
Am 11.11.2011 um 16:53 schrieb Andreas Harder:
On 11.11.2011, at 16:34, Steffen Wolfrum wrote:
Hi Hans,
quite often I wish we could have a kind of in line comment: Something like ¿this is my comment¡ this.
Isn't there already \comment{…}?
\starttext test \comment{comment} test \stoptext
The \comment command can be used to add PDF comments to your document, IIRC it’s documented in the widgets manual. Wolfgang
Am 11.11.2011 um 16:34 schrieb Steffen Wolfrum:
Hi Hans,
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.
\usemodule[annotation] \defineannotation[hide][alternative=none] \starttext Something like \hide{This is my comment!} this. \stoptext A simple definition of the hide which doesn’t require the annotation module is: \define[1]\hide{\removeunwantedspaces} Wolfgang
On Fri, 11 Nov 2011 08:34:28 -0700, Steffen Wolfrum
quite often I wish we could have a kind of in line comment: Something like ¿this is my comment¡ this.
I think the mechanism for fancy in-line comments is already there, developed one-or-two years ago as we were working on some critical-edition-related stuff ... I saw the other answers: Could you elaborate more about exactly what you're looking for, just in case their suggestions don't quite hit the spot? Best wishes Idris -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shiʿi Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
Hi Idris, Am 11.11.2011 um 19:47 schrieb Idris Samawi Hamid ادريس سماوي حامد:
On Fri, 11 Nov 2011 08:34:28 -0700, Steffen Wolfrum
wrote: quite often I wish we could have a kind of in line comment: Something like ¿this is my comment¡ this.
I think the mechanism for fancy in-line comments is already there, developed one-or-two years ago as we were working on some critical-edition-related stuff ...
I saw the other answers: Could you elaborate more about exactly what you're looking for, just in case their suggestions don't quite hit the spot?
I am looking for the same functionality as the traditional TeX comment (starting with %), but used in-line not only after a paragraph. This means, it is only meant for writing/reading comments in the source. And its presence must not affect the typeset file, eg. the resulting PDF, in any respect, of course! Is the mechanism you mention best suited for that purpose? Steffen
On 13.11.2011 11:55, Steffen Wolfrum wrote:
I am looking for the same functionality as the traditional TeX comment (starting with %), but used in-line not only after a paragraph.
That sounds a bit strange, because a paragraph doesn't end with a line break. That's how I usually do my comments too; just add a comment and continue after the line break with the content/sentence/paragraph: -----8<---------------- This is %some comment an example. ----->8---------------- ... will end up as: "This is an example." -- Best Regards, Andreas Schneider
Am 13.11.2011 um 22:33 schrieb Andreas Schneider:
On 13.11.2011 11:55, Steffen Wolfrum wrote:
I am looking for the same functionality as the traditional TeX comment (starting with %), but used in-line not only after a paragraph.
That sounds a bit strange, because a paragraph doesn't end with a line break. That's how I usually do my comments too; just add a comment and continue after the line break with the content/sentence/paragraph:
-----8<---------------- This is %some comment an example. ----->8----------------
... will end up as: "This is an example."
maybe "paragraph" was the wrong word (even though in your example between "comment" and "an" there is a pilcrow too, which is commonly used to denote individual paragraphs). that's what I meant: a true in-line comment ... without a line-break, parapgraph-break, pilcrow for ending the comment: This is ¿some comment¡ an example. Steffen
On 14-11-2011 08:57, Steffen Wolfrum wrote:
Am 13.11.2011 um 22:33 schrieb Andreas Schneider:
On 13.11.2011 11:55, Steffen Wolfrum wrote:
I am looking for the same functionality as the traditional TeX comment (starting with %), but used in-line not only after a paragraph.
That sounds a bit strange, because a paragraph doesn't end with a line break. That's how I usually do my comments too; just add a comment and continue after the line break with the content/sentence/paragraph:
-----8<---------------- This is %some comment an example. ----->8----------------
... will end up as: "This is an example."
maybe "paragraph" was the wrong word (even though in your example between "comment" and "an" there is a pilcrow too, which is commonly used to denote individual paragraphs).
that's what I meant: a true in-line comment ... without a line-break, parapgraph-break, pilcrow for ending the comment:
This is ¿some comment¡ an example.
and next one would want: This is ¿some comment¡ an example. and \startchapter[title={This is ¿some comment¡ an example.}] and ... so it's asking for a mess. Just use a command as Wolfgang mentioned. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 14.11.2011 um 09:07 schrieb Hans Hagen:
On 14-11-2011 08:57, Steffen Wolfrum wrote:
Am 13.11.2011 um 22:33 schrieb Andreas Schneider:
On 13.11.2011 11:55, Steffen Wolfrum wrote:
I am looking for the same functionality as the traditional TeX comment (starting with %), but used in-line not only after a paragraph.
That sounds a bit strange, because a paragraph doesn't end with a line break. That's how I usually do my comments too; just add a comment and continue after the line break with the content/sentence/paragraph:
-----8<---------------- This is %some comment an example. ----->8----------------
... will end up as: "This is an example."
maybe "paragraph" was the wrong word (even though in your example between "comment" and "an" there is a pilcrow too, which is commonly used to denote individual paragraphs).
that's what I meant: a true in-line comment ... without a line-break, parapgraph-break, pilcrow for ending the comment:
This is ¿some comment¡ an example.
and next one would want:
This is ¿some comment¡ an example.
and
\startchapter[title={This is ¿some comment¡ an example.}]
of course! how did you know that :o)
and ... so it's asking for a mess.
Just use a command as Wolfgang mentioned.
yes, that what I thought right away too. for the sake of completeness, I just wanted to answer Idris question and wait what he thinks. Thanks to all, Steffen
On Mon, 14 Nov 2011 02:22:17 -0700, Steffen Wolfrum
I just wanted to answer Idris question and wait what he thinks.
Your request is a bit different from what I had in mind ... OTOH, why not just use bla bla \message{Here is a note to myself.} bla bla It'll show up in the log file, but who cares? :-) Best wishes Idris -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shiʿi Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
On Mon, 14 Nov 2011 11:38:42 -0700, Idris Samawi Hamid ادريس سماوي حامد
OTOH, why not just use bla bla \message{Here is a note to myself.} bla bla
Just curious: Is there anything that \message is missing for what u want? I tried both inline and multiline combos and they all work like a charm: ========== \starttext Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text. Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text. Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text. Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text. \stoptext ========== As a feature, I suppose all that's needed -- for the paranoid, maybe you're writing a letter to your boss with hidden curses ;-) -- is the option to suppress the showing of the text on the console/log. Although it's in the source anyway ... For ¿ and ¡ probably some simple catcode trickery will \let you define them as you like. So I'm curious: How can we define ¿ = \message{ ¡ = } % this one is of course trivial, but for completeness... Since you brought this up, I've actually started using \message more (and no, not for cursing my boss!) Best wishes Idris -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shīʿī Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
Am 15.11.2011 um 23:03 schrieb Idris Samawi Hamid ادريس سماوي حامد:
On Mon, 14 Nov 2011 11:38:42 -0700, Idris Samawi Hamid ادريس سماوي حامد
wrote: OTOH, why not just use bla bla \message{Here is a note to myself.} bla bla
Just curious: Is there anything that \message is missing for what u want? I tried both inline and multiline combos and they all work like a charm:
When you use \gobbleoneargument you can omit the output in the log.
========== \starttext Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text.
Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text.
Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text.
Here is some text. \message{Given an action, the recompense is always in proportion to the degree of participation in Consciousness involved.} Here is some text. \stoptext ==========
You see that there are now two spaces between your sentences, compare the following two sentences: \starttext text \message{hidden} text text\message{hidden} text \stoptext To avoid this I added \removeunwantedspaces to my \hide command. Wolfgang
On Tue, 15 Nov 2011, Idris Samawi Hamid ادريس سماوي حامد wrote:
On Mon, 14 Nov 2011 11:38:42 -0700, Idris Samawi Hamid ادريس سماوي حامد
wrote: OTOH, why not just use bla bla \message{Here is a note to myself.} bla bla
Just curious: Is there anything that \message is missing for what u want? I tried both inline and multiline combos and they all work like a charm:
Untested, but I am pretty sure \message{\iffalse} will fail. Basically, everything inside \message (or the \hide macro by Wolfgang) needs to be processed by TeX, so strictly speaking it is not equivalent to a comment. See the TeX FAQ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=conditional for more details. The most robust solution is to use buffers, but that will not work if the buffer is part of a macro argument. The luatex solution (which is again not perfect) that I posted removes everything inside the comment before it is seeen by TeX. Aditya
Dear Aditya, Wolfgang,
On Tue, 15 Nov 2011 15:11:55 -0700, Wolfgang Schuster
When you use \gobbleoneargument you can omit the output in the log. : To avoid this I added \removeunwantedspaces to my \hide command.
On Tue, 15 Nov 2011 15:28:24 -0700, Aditya Mahajan
Untested, but I am pretty sure
\message{\iffalse}
will fail. Basically, everything inside \message (or the \hide macro by Wolfgang) needs to be processed by TeX, so strictly speaking it is not equivalent to a comment.
See the TeX FAQ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=conditional for more details.
The most robust solution is to use buffers, but that will not work if the buffer is part of a macro argument.
The luatex solution (which is again not perfect) that I posted removes everything inside the comment before it is seeen by TeX.
Thank you both for your insightful answers. I appreciate it! Best wishes Idris -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shīʿī Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
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) \startluacode local comments = {} thirddata = thirddata or {} thirddata.comments = comments function comments.translate(s) return string.gsub(s, "¿.-¡","") end local textlineactions = resolvers.openers.helpers.textlineactions utilities.sequencers.appendaction(textlineactions,"after","thirddata.comments.translate") function comments.enable() utilities.sequencers.enableaction(textlineactions,"thirddata.comments.translate") end function comments.disable() utilities.sequencers.disableaction(textlineactions,"thirddata.comments.translate") end comments.disable() \stopluacode \def\enablecomments {\ctxlua{thirddata.comments.enable()}} \def\disablecomments{\ctxlua{thirddata.comments.disable()}} \appendtoks \enablecomments \to \everystarttext \starttext \section{An ¿in \iffalse comment¡ works} Multiple ¿in \iffalse comment¡ with something ¿in \iffalse comment¡ in betweeen \stoptext Aditya
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)
\startluacode local comments = {} thirddata = thirddata or {}
thirddata.comments = comments
function comments.translate(s) return string.gsub(s, "¿.-¡","") end
local textlineactions = resolvers.openers.helpers.textlineactions utilities.sequencers.appendaction(textlineactions,"after","thirddata.comments.translate")
function comments.enable() utilities.sequencers.enableaction(textlineactions,"thirddata.comments.translate")
end
function comments.disable() utilities.sequencers.disableaction(textlineactions,"thirddata.comments.translate")
end
comments.disable() \stopluacode
\def\enablecomments {\ctxlua{thirddata.comments.enable()}} \def\disablecomments{\ctxlua{thirddata.comments.disable()}}
\appendtoks \enablecomments \to \everystarttext
\starttext \section{An ¿in \iffalse comment¡ works} Multiple ¿in \iffalse comment¡ with something ¿in \iffalse comment¡ in betweeen \stoptext
or ... \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 "") if start ~= "" and stop ~= "" then local pattern = start .. ".-" .. stop comments.filters[name] = function(s) if s == "" then return "" elseif find(s,start) then return (gsub(s,pattern,"")) 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=¡] \installcomments[test2][start=¡,stop=¿] \enablecomments[test] \enablecomments[test2] \starttext \section{An ¿in \iffalse comment¡ works} Multiple ¿in \iffalse comment¡ with something ¿in \iffalse comment¡ in betweeen oeps ¿oeps¡ oeps ¡oeps¿ oeps \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
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
On Mon, 14 Nov 2011, Aditya Mahajan wrote:
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.
Here is a slightly cleanup version that handles multiline comments better https://github.com/adityam/context-comments/blob/master/t-comments.mkvi But this will only work if % has its usual catcode. I don't know how to get around that limitation. Aditya
On 15-11-2011 06:43, Aditya Mahajan wrote:
Here is a slightly cleanup version that handles multiline comments better
https://github.com/adityam/context-comments/blob/master/t-comments.mkvi
if find(s,stop) then insideComment = false return cleaned_line .. currentfilter(strip_to_stop(s)) else as find returns a position, you can do things like this: local stop = find(s,stop) if stop then ... return cleaned_line .. sub(s,stop+#stop,#s) (ok, you need to know the real unescaped length of stop)
But this will only work if % has its usual catcode. I don't know how to get around that limitation.
for multiline we can plug into the texthandler instead, but it's not worth the trouble and the line based one permits selective enable/disable Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (8)
-
Aditya Mahajan
-
Andreas Harder
-
Andreas Schneider
-
Hans Hagen
-
Idris Samawi Hamid ادريس سماوي ح امد
-
Idris Samawi Hamid ادريس سماوي حامد
-
Steffen Wolfrum
-
Wolfgang Schuster