[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: images for Info
From: |
Jan Nieuwenhuizen |
Subject: |
Re: images for Info |
Date: |
Wed, 16 Apr 2003 18:40:10 +0200 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.3.50 (gnu/linux) |
address@hidden (Karl Berry) writes:
Hi Karl,
Find a new version at
http://lilypond.org/~jan/info-image
I've included a patch to texinfo (makinfo and info) below that makes
makeinfo write new style image tags, and makes the info reader skip
the address@hidden cookies. Maybe we want the info reader to cut everything
except for one of VALUE in text=VALUE or FILENAME in src=FILENAME, but
that's quite a bit of extra work, and I'm not quite comfortable with
my simple path to info yet. What about the character position
calculations?
> So I'd prefer to use address@hidden ... address@hidden
Ok, done.
> We'll have to warn users (in the manual) that they'll have to copy
> the image files along with the .info* files.
Not done yet; code first.
> It looks fine to me. My only comment is that the docstring
I've added docstrings,
> Also, the function name should probably be something less generic,
made names quite specific, and
> Oh, and is there something in there that replaces a quoted \" with an
> actual "?
do unquoting of strings.
Jan.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/texinfo/texinfo/ChangeLog,v
retrieving revision 1.123
diff -p -u -r1.123 ChangeLog
--- ChangeLog 9 Apr 2003 12:29:26 -0000 1.123
+++ ChangeLog 16 Apr 2003 16:23:47 -0000
@@ -1,3 +1,14 @@
+2003-04-14 Jan Nieuwenhuizen <address@hidden>
+
+ * info/display.c (display_update_one_window): Skip new style
+ image tag/cookie.
+
+2003-04-09 Jan Nieuwenhuizen <address@hidden>
+
+ * bootstrap.sh: New file.
+
+ * makeinfo/makeinfo.c (cm_image): Write address@hidden address@hidden
tag.
+
2003-04-08 <address@hidden>
* makeinfo/makeinfo.c (usage): avoid double blank line.
Index: NEWS
===================================================================
RCS file: /cvsroot/texinfo/texinfo/NEWS,v
retrieving revision 1.45
diff -p -u -r1.45 NEWS
--- NEWS 9 Apr 2003 12:29:26 -0000 1.45
+++ NEWS 16 Apr 2003 16:23:47 -0000
@@ -30,11 +30,16 @@ convenience, here's a url to one of the
. search for image files in the include file search path.
. --html output now uses <h3> at the smallest.
. under --html, @cartouche now outputs a <table> with a border.
+ . @image now writes full address@hidden address@hidden tag to .info file, so
+ that graphical info browsers may show the actual image. Also,
+ makeinfo will not require a .txt image file substitute if a real
+ image is found.
* texinfo.tex:
. new Polish translation txi-pl.tex.
* info:
. RET now goes to the nearest xref (rather like Emacs Info),
instead of the next xref starting on the current line.
+ . Skip address@hidden cookies.
* Distribution:
. Variables now declared const where appropriate.
. automake 1.7.3.
Index: info/display.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/display.c,v
retrieving revision 1.2
diff -p -u -r1.2 display.c
--- info/display.c 5 Feb 2003 17:53:31 -0000 1.2
+++ info/display.c 16 Apr 2003 16:23:47 -0000
@@ -152,6 +152,15 @@ display_update_one_window (win)
{
replen = win->width - pl_index + pl_ignore;
}
+ else if (*nodetext == '\0'
+ && (nodetext + 1) < last_node_char
+ && *(nodetext + 1) == '\b')
+ {
+ /* Found new style image tag/cookie \0\b[ or \0\b]
+ Just skip for now. */
+ nodetext++;
+ continue;
+ }
else
{
rep = printed_representation (*nodetext, pl_index);
Index: makeinfo/makeinfo.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.24
diff -p -u -r1.24 makeinfo.c
--- makeinfo/makeinfo.c 8 Apr 2003 14:13:54 -0000 1.24
+++ makeinfo/makeinfo.c 16 Apr 2003 16:23:49 -0000
@@ -3441,62 +3441,43 @@ cm_image (arg)
char *pathname = NULL;
char *fullname = xmalloc (strlen (name_arg)
+ (ext_arg && *ext_arg ? strlen (ext_arg) + 1 : 4) + 1);
-
- if (html)
- {
- if (ext_arg && *ext_arg)
- {
- sprintf (fullname, "%s.%s", name_arg, ext_arg);
- if (access (fullname, R_OK) != 0)
- {
- pathname = get_file_info_in_path (fullname,
include_files_path, &file_info);
- if (pathname != NULL && access (pathname, R_OK) != 0)
- {
- line_error(_("@image file `%s' (for HTML) not readable:
%s"),
- fullname, strerror (errno));
- return;
- }
- else if (pathname == NULL)
- {
- line_error (_("No such file `%s'"),
- fullname);
- return;
- }
- }
- }
- else
- {
- sprintf (fullname, "%s.png", name_arg);
- if (access (fullname, R_OK) != 0)
+
+ if (ext_arg && *ext_arg)
+ {
+ sprintf (fullname, "%s.%s", name_arg, ext_arg);
+ if (access (fullname, R_OK) != 0)
+ pathname = get_file_info_in_path (fullname, include_files_path,
&file_info);
+ }
+ else
+ {
+ sprintf (fullname, "%s.png", name_arg);
+ if (access (fullname, R_OK) != 0)
+ {
+ pathname = get_file_info_in_path (fullname, include_files_path,
&file_info);
+ if (pathname == NULL)
{
- pathname = get_file_info_in_path (fullname,
include_files_path, &file_info);
- if (pathname != NULL && access (pathname, R_OK) != 0)
- {
- line_error(_("@image file `%s' (for HTML) not readable:
%s"),
- fullname, strerror (errno));
- return;
- }
-
sprintf (fullname, "%s.jpg", name_arg);
if (access (fullname, R_OK) != 0)
- {
- pathname = get_file_info_in_path (fullname,
include_files_path, &file_info);
- if (pathname != NULL && access (pathname, R_OK) != 0)
- {
- line_error(_("@image file `%s' (for HTML) not
readable: %s"),
- fullname, strerror (errno));
- return;
- }
- else if (pathname == NULL)
- {
- line_error (_("No `%s.png' or `.jpg', and no
extension supplied"),
- name_arg);
- return;
- }
- }
+ pathname = get_file_info_in_path (fullname,
include_files_path, &file_info);
}
}
-
+ }
+
+ if (html)
+ {
+ if (pathname == NULL && access (fullname, R_OK) != 0)
+ {
+ line_error(_("@image file `%s' (for HTML) not readable: %s"),
+ fullname, strerror (errno));
+ return;
+ }
+ if (pathname != NULL && access (pathname, R_OK) != 0)
+ {
+ line_error (_("No such file `%s'"),
+ fullname);
+ return;
+ }
+
add_html_elt ("<img src=");
add_word_args ("\"%s\"", fullname);
add_html_elt (" alt=");
@@ -3513,16 +3494,22 @@ cm_image (arg)
else
{ /* Try to open foo.txt. */
FILE *image_file;
- strcpy (fullname, name_arg);
- strcat (fullname, ".txt");
- image_file = fopen (fullname, "r");
+ char *txtpath = NULL;
+ char *txtname = xmalloc (strlen (name_arg)
+ + (ext_arg && *ext_arg ? strlen (ext_arg) +
1 : 4) + 1);
+ strcpy (txtname, name_arg);
+ strcat (txtname, ".txt");
+ image_file = fopen (txtname, "r");
if (image_file == NULL)
{
- pathname = get_file_info_in_path (fullname, include_files_path,
&file_info);
- if (pathname != NULL)
- image_file = fopen (pathname, "r");
+ txtpath = get_file_info_in_path (txtname, include_files_path,
&file_info);
+ if (txtpath != NULL)
+ image_file = fopen (txtpath, "r");
}
- if (image_file)
+
+ if (image_file != NULL
+ || access (fullname, R_OK) == 0
+ || (pathname != NULL && access (pathname, R_OK) == 0))
{
int ch;
int save_inhibit_indentation = inhibit_paragraph_indentation;
@@ -3532,22 +3519,44 @@ cm_image (arg)
filling_enabled = 0;
last_char_was_newline = 0;
- /* Maybe we need to remove the final newline if the image
- file is only one line to allow in-line images. On the
- other hand, they could just make the file without a
- final newline. */
- while ((ch = getc (image_file)) != EOF)
- add_char (ch);
+ add_char ('\0');
+ add_word ("\010[image");
+
+ if (access (fullname, R_OK) == 0
+ || pathname != NULL && access (pathname, R_OK) == 0)
+ add_word_args (" src=%s", fullname);
+
+ if (*alt_arg)
+ add_word_args (" alt=\"%s\"", alt_arg);
+
+ if (image_file != NULL)
+ {
+ add_word (" text=\"");
+ /* Maybe we need to remove the final newline if the image
+ file is only one line to allow in-line images. On the
+ other hand, they could just make the file without a
+ final newline. */
+ while ((ch = getc (image_file)) != EOF)
+ {
+ if (ch == '"' || ch == '\\')
+ add_char ('\\');
+ add_char (ch);
+ }
+ add_char ('"');
+
+ if (fclose (image_file) != 0)
+ perror (txtname);
+ }
inhibit_paragraph_indentation = save_inhibit_indentation;
filling_enabled = save_filling_enabled;
- if (fclose (image_file) != 0)
- perror (fullname);
+ add_char ('\0');
+ add_word ("\010]");
}
else
line_error (_("@image file `%s' (for text) unreadable: %s"),
- fullname, strerror (errno));
+ txtname, strerror (errno));
}
free (fullname);
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
- Re: images for Info,
Jan Nieuwenhuizen <=