Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces. \def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works \def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces? Cheers, Mike
Santy, Michael wrote:
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
maybe "name" works ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
If I understand your suggestion correctly, specifying name doesn't work. \externalfigure[][name=flower[1].jpg] \externalfigure[name=flower[1].jpg] Cheers, Mike -----Original Message----- From: ntg-context-bounces@ntg.nl on behalf of Hans Hagen Sent: Thu 12/27/2007 8:55 AM To: mailing list for ConTeXt users Subject: Re: [NTG-context] escaping filenames with externalfigure Santy, Michael wrote:
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
maybe "name" works ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | 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://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Santy, Michael wrote:
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
\externalfigure[{flower[1].jpg}] may also work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
Cheers, Mike
------------------------------------------------------------------------
___________________________________________________________________________________ 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 ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
\externalfigure[{flower[1].jpg}] demonstrates the same behavior as \externalfigure[flower[1].jpg] Cheers, Mike -----Original Message----- From: ntg-context-bounces@ntg.nl on behalf of Hans Hagen Sent: Thu 12/27/2007 8:56 AM To: mailing list for ConTeXt users Subject: Re: [NTG-context] escaping filenames with externalfigure Santy, Michael wrote:
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
\externalfigure[{flower[1].jpg}] may also work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
Cheers, Mike
------------------------------------------------------------------------
___________________________________________________________________________________ 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 ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | 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://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Thu, 27 Dec 2007 15:56:14 +0100
Hans Hagen
Santy, Michael wrote:
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
\externalfigure[{flower[1].jpg}] may also work
This did not work, the bracket after 1 is interpreted as the end for externalfigure and ConTeXt looks for a figure with the name "flower[1" but brackets in figure names could be used with \useexternalfigure.
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
Cheers, Mike
Wolfgang
On Thu, 27 Dec 2007 08:09:55 -0600
"Santy, Michael"
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
Yould could define symbolic names for the figures and access the figures with this name, this allows you also to use bracketrs in the file names. \useexternalfigure[brace flower][flower{1}] \useexternalfigure[bracket flower][{flower[1]}] \starttext \externalfigure[brace flower] \externalfigure[bracket flower] \stoptext Wolfgang
Wolfgang,
Thanks for the suggestion. However, I'm using ConTeXt to typeset arbitrary XML input from users (and therefore arbitrary image filenames). While your idea works for the two examples that I gave, it doesn't work if the curly braces aren't balanced in the filename (e.g., "flower{1.jpg"). Is there any general character escaping mechanism for macro arguments?
Cheers,
Mike
-----Original Message-----
From: ntg-context-bounces@ntg.nl on behalf of Wolfgang Schuster
Sent: Thu 12/27/2007 9:00 AM
To: ntg-context@ntg.nl
Subject: Re: [NTG-context] escaping filenames with externalfigure
On Thu, 27 Dec 2007 08:09:55 -0600
"Santy, Michael"
Is there a way to escape special characters in filenames passed to externalfigure. I'm encountering the situation where users are choosing images that may contain brackets or curly braces (e.g., flower[1].jpg or flower{1}.jpg). If I pass filename containing these characters directly to externalfigure, the closing bracket is mistaken for the end of the filename. \externalfigure[flower{1}.jpg] % works \externalfigure[flower[1].jpg] % doesn't work
I then tried to define a variable that holds the filename and pass that variable to externalfigure, but it ran into problems with curly braces.
\def\myimagefilename{flower[1].jpg} \externalfigure[\myimagefilename] % works
\def\myimagefilename{flower{1}.jpg} \externalfigure[\myimagefilename] % doesn't work
Does anyone have any idea how I could handle arbitrary filename inputs that contain brackets and curly braces?
Yould could define symbolic names for the figures and access the figures with this name, this allows you also to use bracketrs in the file names. \useexternalfigure[brace flower][flower{1}] \useexternalfigure[bracket flower][{flower[1]}] \starttext \externalfigure[brace flower] \externalfigure[bracket flower] \stoptext Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________
Wolfgang,
Thanks for the suggestion. However, I'm using ConTeXt to typeset arbitrary XML input from users (and therefore arbitrary image filenames). While your idea works for the two examples that I gave, it doesn't work if the curly braces aren't balanced in the filename (e.g., "flower{1.jpg"). Is there any general character escaping mechanism for macro arguments?
Cheers, Mike
If you use xml as input format you could save the file name in a temporary macro and use this macro now in the \externalfigure command. You already gave a example for this. Wolfgang
The problem that I've found with that approach is that the braces have to be balanced. \def\myimagefilename{flower{1.jpg} % doesn't work \def\myimagefilename{flower{1}.jpg} % works -----Original Message----- From: ntg-context-bounces@ntg.nl on behalf of Wolfgang Schuster Sent: Thu 12/27/2007 9:27 AM To: mailing list for ConTeXt users Subject: Re: [NTG-context] escaping filenames with externalfigure
Wolfgang,
Thanks for the suggestion. However, I'm using ConTeXt to typeset arbitrary XML input from users (and therefore arbitrary image filenames). While your idea works for the two examples that I gave, it doesn't work if the curly braces aren't balanced in the filename (e.g., "flower{1.jpg"). Is there any general character escaping mechanism for macro arguments?
Cheers, Mike
If you use xml as input format you could save the file name in a temporary macro and use this macro now in the \externalfigure command. You already gave a example for this. Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________
Santy, Michael wrote:
The problem that I've found with that approach is that the braces have to be balanced.
\def\myimagefilename{flower{1.jpg} % doesn't work \def\myimagefilename{flower{1}.jpg} % works
no time for a detailed answer now, but in xml mode you can make { } letters which solves the problem Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans,
no time for a detailed answer now, but in xml mode you can make { } letters which solves the problem
Could you please elaborate a bit? I'm not familiar with ConTeXt's XML mode (other than for processing MathML). One thing that I suspect is that XML mode would have an issue with '<' and '>' in the filenames. Another thought: The image filenames are encoded in my original xml documents according to RFC 1738 (http://www.blooberry.com/indexdot/html/topics/urlencoding.htm). In my XML -> ConTeXt XSL stylesheets I'm decoding those filenames. Would it be useful for others if the externalfigure could understand url encoded filenames similar to something like this: % % includes the file "flower{1.jpg" % \externalfigure[flower%7B1.jpg][encoding=rfc1738] This would give ConTeXt a general-purpose filename escaping mechanism. Cheers, Mike
participants (3)
-
Hans Hagen
-
Santy, Michael
-
Wolfgang Schuster