* Overriding / redefining / disabling standard commands @ 2018-06-25 20:49 Rik Kabel 2018-06-25 21:52 ` Wolfgang Schuster 0 siblings, 1 reply; 11+ messages in thread From: Rik Kabel @ 2018-06-25 20:49 UTC (permalink / raw) To: mailing list for ConTeXt users List, What is the preferred way to override a standard command? My use case is that I am trying to produce html (and epub, but that has a long long way to go) from the same source I use for pdf. Some features are not needed, and I have separate environment files for each output format to accommodate the differences. I would like to override the standard \index command in one of those environment files, eliminating the generation of index references. There may be other constructs as well that would benefit from this simplification while allowing a common content source file. On a related note, does anyone have a css file that handles block quotations, margin notes, and cross references? I would love to steal bits of it. -- Rik ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-25 20:49 Overriding / redefining / disabling standard commands Rik Kabel @ 2018-06-25 21:52 ` Wolfgang Schuster 2018-06-25 23:11 ` Rik 0 siblings, 1 reply; 11+ messages in thread From: Wolfgang Schuster @ 2018-06-25 21:52 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1000 bytes --] > Rik Kabel <mailto:context@rik.users.panix.com> > 25. Juni 2018 um 22:49 > List, > > What is the preferred way to override a standard command? > > My use case is that I am trying to produce html (and epub, but that > has a long long way to go) from the same source I use for pdf. Some > features are not needed, and I have separate environment files for > each output format to accommodate the differences. > > I would like to override the standard \index command in one of those > environment files, eliminating the generation of index references. > There may be other constructs as well that would benefit from this > simplification while allowing a common content source file. You can use the “*export” mode to disable commands when the export is enabled. \startmode[ebook] \setupbackend[export=yes] \stopmode \starttext \index{Knuth}\input knuth \index{Ward}\input ward \index{Zapf}\input zapf \startnotmode[*export] \completeregister[index] \stopnotmode \stoptext Wolfgang [-- Attachment #1.2: Type: text/html, Size: 2085 bytes --] [-- Attachment #2: Type: text/plain, Size: 492 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-25 21:52 ` Wolfgang Schuster @ 2018-06-25 23:11 ` Rik 2018-06-26 0:11 ` Alan Braslau 0 siblings, 1 reply; 11+ messages in thread From: Rik @ 2018-06-25 23:11 UTC (permalink / raw) To: ntg-context [-- Attachment #1.1: Type: text/plain, Size: 1007 bytes --] On 6/25/2018 17:52, Wolfgang Schuster wrote: > \startmode[ebook] > \setupbackend[export=yes] > \stopmode > > \starttext > > \index{Knuth}\input knuth > > \index{Ward}\input ward > > \index{Zapf}\input zapf > > \startnotmode[*export] > \completeregister[index] > \stopnotmode > > \stoptext Unfortunately, this does not suppress generation of index references in the exported output. Here is a snippet of the -div.html file generated by the example you provided: <div class="registerlocation index" href="#aut-1" onclick="location.href='#aut-1'"><!--empty--></div>Thus, I came to the conclusion that the designer of a new system must not only be the implementer and first large--scale user; the designer should also write the first user manual. and a snip of the output with the default css: Thus the request for a (simple) mechanism to redefine or disable standard commands. There are commands other than \index that might also benefit from similar treatment. -- Rik [-- Attachment #1.2.1: Type: text/html, Size: 1688 bytes --] [-- Attachment #1.2.2: pninnflokfdmchpk.png --] [-- Type: image/png, Size: 3996 bytes --] [-- Attachment #2: Type: text/plain, Size: 492 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-25 23:11 ` Rik @ 2018-06-26 0:11 ` Alan Braslau 2018-06-26 0:50 ` Rik Kabel 0 siblings, 1 reply; 11+ messages in thread From: Alan Braslau @ 2018-06-26 0:11 UTC (permalink / raw) To: Rik; +Cc: mailing list for ConTeXt users On Mon, 25 Jun 2018 19:11:30 -0400 Rik <rik@panix.com> wrote: > On 6/25/2018 17:52, Wolfgang Schuster wrote: > > \startmode[ebook] > > \setupbackend[export=yes] > > \stopmode > > > > \starttext > > > > \index{Knuth}\input knuth > > > > \index{Ward}\input ward > > > > \index{Zapf}\input zapf > > > > \startnotmode[*export] > > \completeregister[index] > > \stopnotmode > > > > \stoptext > > Unfortunately, this does not suppress generation of index references > in the exported output. Here is a snippet of the -div.html file > generated by the example you provided: > > <div class="registerlocation index" href="#aut-1" > onclick="location.href='#aut-1'"><!--empty--></div>Thus, > I came to the conclusion that the designer of a new system must not > only be the implementer and first large--scale user; the designer > should also write the first user manual. > > and a snip of the output with the default css: > > Thus the request for a (simple) mechanism to redefine or disable > standard commands. There are commands other than \index that might > also benefit from similar treatment. > \def\MyIndex#1{\index{#1}} is one route. Another might be \let\index\gobbleoneargument (use at your risk) Alan ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 0:11 ` Alan Braslau @ 2018-06-26 0:50 ` Rik Kabel 2018-06-26 2:00 ` Alan Braslau 0 siblings, 1 reply; 11+ messages in thread From: Rik Kabel @ 2018-06-26 0:50 UTC (permalink / raw) To: ntg-context On 6/25/2018 20:11, Alan Braslau wrote: > On Mon, 25 Jun 2018 19:11:30 -0400 > Rik <rik@panix.com> wrote: > >> On 6/25/2018 17:52, Wolfgang Schuster wrote: >>> \startmode[ebook] >>> \setupbackend[export=yes] >>> \stopmode >>> >>> \starttext >>> >>> \index{Knuth}\input knuth >>> >>> \index{Ward}\input ward >>> >>> \index{Zapf}\input zapf >>> >>> \startnotmode[*export] >>> \completeregister[index] >>> \stopnotmode >>> >>> \stoptext >> Unfortunately, this does not suppress generation of index references >> in the exported output. Here is a snippet of the -div.html file >> generated by the example you provided: >> >> <div class="registerlocation index" href="#aut-1" >> onclick="location.href='#aut-1'"><!--empty--></div>Thus, >> I came to the conclusion that the designer of a new system must not >> only be the implementer and first large--scale user; the designer >> should also write the first user manual. >> >> and a snip of the output with the default css: >> >> Thus the request for a (simple) mechanism to redefine or disable >> standard commands. There are commands other than \index that might >> also benefit from similar treatment. >> > \def\MyIndex#1{\index{#1}} > > is one route. > > Another might be > > \let\index\gobbleoneargument > > (use at your risk) > > Alan > This would work if \index took one argument, but it takes as well an optional argument preceding the required argument, and so these fail. The best solution would seem to be one which does not require knowledge of the number of required and optional arguments, but that might be a stretch. That is why I asked for help. -- Rik ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 0:50 ` Rik Kabel @ 2018-06-26 2:00 ` Alan Braslau 2018-06-26 2:44 ` Rik Kabel 2018-06-26 6:34 ` Wolfgang Schuster 0 siblings, 2 replies; 11+ messages in thread From: Alan Braslau @ 2018-06-26 2:00 UTC (permalink / raw) To: Rik Kabel; +Cc: mailing list for ConTeXt users On Mon, 25 Jun 2018 20:50:51 -0400 Rik Kabel <context@rik.users.panix.com> wrote: > On 6/25/2018 20:11, Alan Braslau wrote: > > On Mon, 25 Jun 2018 19:11:30 -0400 > > Rik <rik@panix.com> wrote: > > > >> On 6/25/2018 17:52, Wolfgang Schuster wrote: > >>> \startmode[ebook] > >>> \setupbackend[export=yes] > >>> \stopmode > >>> > >>> \starttext > >>> > >>> \index{Knuth}\input knuth > >>> > >>> \index{Ward}\input ward > >>> > >>> \index{Zapf}\input zapf > >>> > >>> \startnotmode[*export] > >>> \completeregister[index] > >>> \stopnotmode > >>> > >>> \stoptext > >> Unfortunately, this does not suppress generation of index > >> references in the exported output. Here is a snippet of the > >> -div.html file generated by the example you provided: > >> > >> <div class="registerlocation index" href="#aut-1" > >> onclick="location.href='#aut-1'"><!--empty--></div>Thus, > >> I came to the conclusion that the designer of a new system must not > >> only be the implementer and first large--scale user; the > >> designer should also write the first user manual. > >> > >> and a snip of the output with the default css: > >> > >> Thus the request for a (simple) mechanism to redefine or disable > >> standard commands. There are commands other than \index that might > >> also benefit from similar treatment. > >> > > \def\MyIndex#1{\index{#1}} > > > > is one route. > > > > Another might be > > > > \let\index\gobbleoneargument > > > > (use at your risk) > > > > Alan > > > This would work if \index took one argument, but it takes as well an > optional argument preceding the required argument, and so these fail. > > The best solution would seem to be one which does not require > knowledge of the number of required and optional arguments, but that > might be a stretch. > > That is why I asked for help. \setupregister[index][referencing=off] Besides, if you use \index, why object to index reference tags in the export? Alan ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 2:00 ` Alan Braslau @ 2018-06-26 2:44 ` Rik Kabel 2018-06-26 7:35 ` Hans Hagen 2018-06-26 6:34 ` Wolfgang Schuster 1 sibling, 1 reply; 11+ messages in thread From: Rik Kabel @ 2018-06-26 2:44 UTC (permalink / raw) To: Alan Braslau; +Cc: mailing list for ConTeXt users On 6/25/2018 22:00, Alan Braslau wrote: > On Mon, 25 Jun 2018 20:50:51 -0400 > Rik Kabel <context@rik.users.panix.com> wrote: > >> On 6/25/2018 20:11, Alan Braslau wrote: >>> On Mon, 25 Jun 2018 19:11:30 -0400 >>> Rik <rik@panix.com> wrote: >>> >>>> On 6/25/2018 17:52, Wolfgang Schuster wrote: >>>>> \startmode[ebook] >>>>> \setupbackend[export=yes] >>>>> \stopmode >>>>> >>>>> \starttext >>>>> >>>>> \index{Knuth}\input knuth >>>>> >>>>> \index{Ward}\input ward >>>>> >>>>> \index{Zapf}\input zapf >>>>> >>>>> \startnotmode[*export] >>>>> \completeregister[index] >>>>> \stopnotmode >>>>> >>>>> \stoptext >>>> Unfortunately, this does not suppress generation of index >>>> references in the exported output. Here is a snippet of the >>>> -div.html file generated by the example you provided: >>>> >>>> <div class="registerlocation index" href="#aut-1" >>>> onclick="location.href='#aut-1'"><!--empty--></div>Thus, >>>> I came to the conclusion that the designer of a new system must not >>>> only be the implementer and first large--scale user; the >>>> designer should also write the first user manual. >>>> >>>> and a snip of the output with the default css: >>>> >>>> Thus the request for a (simple) mechanism to redefine or disable >>>> standard commands. There are commands other than \index that might >>>> also benefit from similar treatment. >>>> >>> \def\MyIndex#1{\index{#1}} >>> >>> is one route. >>> >>> Another might be >>> >>> \let\index\gobbleoneargument >>> >>> (use at your risk) >>> >>> Alan >>> >> This would work if \index took one argument, but it takes as well an >> optional argument preceding the required argument, and so these fail. >> >> The best solution would seem to be one which does not require >> knowledge of the number of required and optional arguments, but that >> might be a stretch. >> >> That is why I asked for help. > \setupregister[index][referencing=off] > > Besides, if you use \index, why object to index reference tags in the > export? > > Alan Alan (and list), This option still leaves the registerlocation entries in the html file, and so accomplishes nothing that Wolfgang's suggestion did. Being implemented in the environment file, it does have the advantage of not requiring changes to the content source file. As to why I object to index reference tags in the export: There are a few constructs beyond indexes that I wish to exclude in export output -- indices are one and the problem is easily demonstrated. Referencetags themselves are not a significant problem -- a little css will hide them. I have not explored the other constructs yet (among them margin notes and cross-references) but was hoping for a generic solution, or at least an easily adapted per command solution. There are a few options I can see. In order of least to most preferred, I can maintain separate sources; I can invoke a filter in my makefile to preprocess the source, removing \index commands (or margin notes, or ...); I can redefine \index (or margin notes, or ...) to be no-ops. As much as possible I would like to use the same content source files for different output formats with some unique environment files. Filters are an added step and fragile, depending on correctly identifying the target constructs. So, I have been looking at redefinition. I thought that the ability to override a command like \index might be generally useful, and so brought it up to the list when I could not find a way to do it. -- Rik ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 2:44 ` Rik Kabel @ 2018-06-26 7:35 ` Hans Hagen 2018-06-26 12:56 ` Alan Braslau 2018-06-26 13:22 ` Hans Hagen 0 siblings, 2 replies; 11+ messages in thread From: Hans Hagen @ 2018-06-26 7:35 UTC (permalink / raw) To: Rik Kabel, ntg-context@ntg.nl >> mailing list for ConTeXt users On 6/26/2018 4:44 AM, Rik Kabel wrote: > I thought that the ability to override a command like \index might be > generally useful, and so brought it up to the list when I could not find > a way to do it. could be but only when it can be implemented efficiently (i don't want to add overhead related to export when export is off so it would mean permanently disabled and not locally in a run) ... what commands are we talking about Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 7:35 ` Hans Hagen @ 2018-06-26 12:56 ` Alan Braslau 2018-06-26 13:22 ` Hans Hagen 1 sibling, 0 replies; 11+ messages in thread From: Alan Braslau @ 2018-06-26 12:56 UTC (permalink / raw) To: Hans Hagen; +Cc: mailing list for ConTeXt users On Tue, 26 Jun 2018 09:35:06 +0200 Hans Hagen <j.hagen@xs4all.nl> wrote: > On 6/26/2018 4:44 AM, Rik Kabel wrote: > > > I thought that the ability to override a command like \index might > > be generally useful, and so brought it up to the list when I could > > not find a way to do it. > could be but only when it can be implemented efficiently (i don't > want to add overhead related to export when export is off so it would > mean permanently disabled and not locally in a run) ... what commands > are we talking about AND, I still don't get the point... (you can always define your own custom commands by mode) Alan ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 7:35 ` Hans Hagen 2018-06-26 12:56 ` Alan Braslau @ 2018-06-26 13:22 ` Hans Hagen 1 sibling, 0 replies; 11+ messages in thread From: Hans Hagen @ 2018-06-26 13:22 UTC (permalink / raw) To: mailing list for ConTeXt users On 6/26/2018 9:35 AM, Hans Hagen wrote: > On 6/26/2018 4:44 AM, Rik Kabel wrote: > >> I thought that the ability to override a command like \index might be >> generally useful, and so brought it up to the list when I could not >> find a way to do it. > could be but only when it can be implemented efficiently (i don't want > to add overhead related to export when export is off so it would mean > permanently disabled and not locally in a run) ... what commands are we > talking about i'll add \ignoretagsinexport as in: \setupbackend[export=yes] \ignoretagsinexport [registerlocation] \starttext test \index {test} test \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overriding / redefining / disabling standard commands 2018-06-26 2:00 ` Alan Braslau 2018-06-26 2:44 ` Rik Kabel @ 2018-06-26 6:34 ` Wolfgang Schuster 1 sibling, 0 replies; 11+ messages in thread From: Wolfgang Schuster @ 2018-06-26 6:34 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 251 bytes --] > Alan Braslau <mailto:braslau.list@comcast.net> > 26. Juni 2018 um 04:00 > On Mon, 25 Jun 2018 20:50:51 -0400 > > \setupregister[index][referencing=off] This option doesn’t exist in MkIV and there is no other option to disable \index. Wolfgang [-- Attachment #1.2: Type: text/html, Size: 1260 bytes --] [-- Attachment #2: Type: text/plain, Size: 492 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-06-26 13:22 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-06-25 20:49 Overriding / redefining / disabling standard commands Rik Kabel 2018-06-25 21:52 ` Wolfgang Schuster 2018-06-25 23:11 ` Rik 2018-06-26 0:11 ` Alan Braslau 2018-06-26 0:50 ` Rik Kabel 2018-06-26 2:00 ` Alan Braslau 2018-06-26 2:44 ` Rik Kabel 2018-06-26 7:35 ` Hans Hagen 2018-06-26 12:56 ` Alan Braslau 2018-06-26 13:22 ` Hans Hagen 2018-06-26 6:34 ` Wolfgang Schuster
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).