* libtextstyle/gnulib-local/lib/styled-ostream.oo.h (struct styled_ostream): Add
methods get_hyperlink_ref, get_hyperlink_id, set_hyperlink.
* libtextstyle/gnulib-local/lib/term-styled-ostream.oo.c
(term_styled_ostream::get_hyperlink_ref, term_styled_ostream::get_hyperlink_id,
term_styled_ostream::set_hyperlink): New functions.
* libtextstyle/gnulib-local/lib/html-styled-ostream.oo.c
(struct html_styled_ostream): Add field hyperlink_id.
(html_styled_ostream::free): Free the hyperlink_id field.
(html_styled_ostream::get_hyperlink_ref, html_styled_ostream::get_hyperlink_id,
html_styled_ostream::set_hyperlink): New functions.
(html_styled_ostream_create): Initialize the hyperlink_id field.
* libtextstyle/gnulib-local/lib/noop-styled-ostream.oo.c
(struct noop_styled_ostream): Add fields hyperlink_ref, hyperlink_id.
(noop_styled_ostream::free): Free the hyperlink_ref and hyperlink_id fields.
(noop_styled_ostream::get_hyperlink_ref, noop_styled_ostream::get_hyperlink_id,
noop_styled_ostream::set_hyperlink): New functions.
(noop_styled_ostream_create): Initialize the hyperlink_ref and hyperlink_id
fields.
* libtextstyle/lib/textstyle.h (styled_ostream_get_hyperlink_ref,
styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink,
term_styled_ostream_get_hyperlink_ref, term_styled_ostream_get_hyperlink_id,
term_styled_ostream_set_hyperlink, html_styled_ostream_get_hyperlink_ref,
html_styled_ostream_get_hyperlink_id, html_styled_ostream_set_hyperlink,
noop_styled_ostream_get_hyperlink_ref, noop_styled_ostream_get_hyperlink_id,
noop_styled_ostream_set_hyperlink): New declarations.
* libtextstyle/adhoc-tests/hello.c (main): Invoke styled_ostream_set_hyperlink.
ostream_write_str (stream, "Dr. ");
styled_ostream_begin_use_class (stream, "boy-name");
+ /* Start a hyperlink. */
+ styled_ostream_set_hyperlink (stream, "https://en.wikipedia.org/wiki/Linus_Pauling", NULL);
ostream_write_str (stream, "Linus");
styled_ostream_end_use_class (stream, "boy-name");
ostream_write_str (stream, " Pauling");
+ /* End the current hyperlink. */
+ styled_ostream_set_hyperlink (stream, NULL, NULL);
/* Terminate the name. */
styled_ostream_end_use_class (stream, "name");
ostream_t destination;
/* A HTML aware wrapper around the destination stream. */
html_ostream_t html_destination;
+ /* The current hyperlink id. */
+ char *hyperlink_id;
};
/* Implementation of ostream_t methods. */
html_ostream_free (stream->html_destination);
ostream_write_str (stream->destination, "</body>\n");
ostream_write_str (stream->destination, "</html>\n");
+ free (stream->hyperlink_id);
free (stream);
}
html_ostream_end_span (stream->html_destination, classname);
}
+static const char *
+html_styled_ostream::get_hyperlink_ref (html_styled_ostream_t stream)
+{
+ return html_ostream_get_hyperlink_ref (stream->html_destination);
+}
+
+static const char *
+html_styled_ostream::get_hyperlink_id (html_styled_ostream_t stream)
+{
+ return stream->hyperlink_id;
+}
+
+static void
+html_styled_ostream::set_hyperlink (html_styled_ostream_t stream,
+ const char *ref, const char *id)
+{
+ char *id_copy = (id != NULL ? xstrdup (id) : NULL);
+
+ html_ostream_set_hyperlink_ref (stream->html_destination, ref);
+ free (stream->hyperlink_id);
+ stream->hyperlink_id = id_copy;
+}
+
static void
html_styled_ostream::flush_to_current_style (html_styled_ostream_t stream)
{
stream->base.base.vtable = &html_styled_ostream_vtable;
stream->destination = destination;
stream->html_destination = html_ostream_create (destination);
+ stream->hyperlink_id = NULL;
ostream_write_str (stream->destination, "<?xml version=\"1.0\"?>\n");
/* HTML 4.01 or XHTML 1.0?
/* The destination stream. */
ostream_t destination;
bool own_destination;
+ /* The current hyperlink ref and id. */
+ char *hyperlink_ref;
+ char *hyperlink_id;
};
/* Implementation of ostream_t methods. */
{
if (stream->own_destination)
ostream_free (stream->destination);
+ free (stream->hyperlink_ref);
+ free (stream->hyperlink_id);
free (stream);
}
{
}
+static const char *
+noop_styled_ostream::get_hyperlink_ref (noop_styled_ostream_t stream)
+{
+ return stream->hyperlink_ref;
+}
+
+static const char *
+noop_styled_ostream::get_hyperlink_id (noop_styled_ostream_t stream)
+{
+ return stream->hyperlink_id;
+}
+
+static void
+noop_styled_ostream::set_hyperlink (noop_styled_ostream_t stream,
+ const char *ref, const char *id)
+{
+ char *ref_copy = (ref != NULL ? xstrdup (ref) : NULL);
+ char *id_copy = (id != NULL ? xstrdup (id) : NULL);
+
+ free (stream->hyperlink_ref);
+ stream->hyperlink_ref = ref_copy;
+ free (stream->hyperlink_id);
+ stream->hyperlink_id = id_copy;
+}
+
static void
noop_styled_ostream::flush_to_current_style (noop_styled_ostream_t stream)
{
stream->base.base.vtable = &noop_styled_ostream_vtable;
stream->destination = destination;
stream->own_destination = pass_ownership;
+ stream->hyperlink_ref = NULL;
+ stream->hyperlink_id = NULL;
return stream;
}
/* Abstract output stream for CSS styled text.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
The begin_use_class / end_use_class calls must match properly. */
void end_use_class (styled_ostream_t stream, const char *classname);
+ /* Get/set the hyperlink attribute and its id. */
+ const char * get_hyperlink_ref (styled_ostream_t stream);
+ const char * get_hyperlink_id (styled_ostream_t stream);
+ void set_hyperlink (styled_ostream_t stream,
+ const char *ref, const char *id);
+
/* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
leaves the destination with the current text style enabled, instead
of with the default text style.
stream->curr_attr = (attributes_t *) found;
}
+static const char *
+term_styled_ostream::get_hyperlink_ref (term_styled_ostream_t stream)
+{
+ return term_ostream_get_hyperlink_ref (stream->destination);
+}
+
+static const char *
+term_styled_ostream::get_hyperlink_id (term_styled_ostream_t stream)
+{
+ return term_ostream_get_hyperlink_id (stream->destination);
+}
+
+static void
+term_styled_ostream::set_hyperlink (term_styled_ostream_t stream,
+ const char *ref, const char *id)
+{
+ term_ostream_set_hyperlink (stream->destination, ref, id);
+}
+
static void
term_styled_ostream::flush_to_current_style (term_styled_ostream_t stream)
{
extern void styled_ostream_free (styled_ostream_t first_arg);
extern void styled_ostream_begin_use_class (styled_ostream_t first_arg, const char *classname);
extern void styled_ostream_end_use_class (styled_ostream_t first_arg, const char *classname);
+extern const char *styled_ostream_get_hyperlink_ref (styled_ostream_t first_arg);
+extern const char *styled_ostream_get_hyperlink_id (styled_ostream_t first_arg);
+extern void styled_ostream_set_hyperlink (styled_ostream_t first_arg, const char *ref, const char *id);
/* Like styled_ostream_flush (first_arg, FLUSH_THIS_STREAM), except that it
leaves the destination with the current text style enabled, instead
of with the default text style.
extern void term_styled_ostream_free (term_styled_ostream_t first_arg);
extern void term_styled_ostream_begin_use_class (term_styled_ostream_t first_arg, const char *classname);
extern void term_styled_ostream_end_use_class (term_styled_ostream_t first_arg, const char *classname);
+extern const char *term_styled_ostream_get_hyperlink_ref (term_styled_ostream_t first_arg);
+extern const char *term_styled_ostream_get_hyperlink_id (term_styled_ostream_t first_arg);
+extern void term_styled_ostream_set_hyperlink (term_styled_ostream_t first_arg, const char *ref, const char *id);
extern void term_styled_ostream_flush_to_current_style (term_styled_ostream_t first_arg);
#ifdef __cplusplus
}
extern void html_styled_ostream_free (html_styled_ostream_t first_arg);
extern void html_styled_ostream_begin_use_class (html_styled_ostream_t first_arg, const char *classname);
extern void html_styled_ostream_end_use_class (html_styled_ostream_t first_arg, const char *classname);
+extern const char *html_styled_ostream_get_hyperlink_ref (html_styled_ostream_t first_arg);
+extern const char *html_styled_ostream_get_hyperlink_id (html_styled_ostream_t first_arg);
+extern void html_styled_ostream_set_hyperlink (html_styled_ostream_t first_arg, const char *ref, const char *id);
extern void html_styled_ostream_flush_to_current_style (html_styled_ostream_t first_arg);
#ifdef __cplusplus
}
extern void noop_styled_ostream_free (noop_styled_ostream_t first_arg);
extern void noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname);
extern void noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname);
+extern const char *noop_styled_ostream_get_hyperlink_ref (noop_styled_ostream_t first_arg);
+extern const char *noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg);
+extern void noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg, const char *ref, const char *id);
extern void noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg);
#ifdef __cplusplus
}