45 struct box *
box,
const char *whitespace_text,
79 "failed to convert to local encoding, return %d", ret);
83 out = fopen(
path,
"w");
85 int res = fputs(
result, out);
88 NSLOG(netsurf, INFO,
"Warning: write failed");
91 res = fputs(
"\n", out);
94 "Warning: failed writing trailing newline");
127 size_t *whitespace_length)
152 CSS_WHITE_SPACE_PRE ||
154 CSS_WHITE_SPACE_PRE_WRAP) &&
170 *whitespace_text =
"";
171 *whitespace_length = 0;
176 *whitespace_text =
"\n\n";
177 *whitespace_length = 2;
180 *whitespace_text =
"\n";
181 *whitespace_length = 1;
184 *whitespace_text =
"\t";
185 *whitespace_length = 1;
188 *whitespace_text =
"";
189 *whitespace_length = 0;
192 *whitespace_text =
"";
193 *whitespace_length = 0;
218 const char *whitespace_text =
"";
219 size_t whitespace_length = 0;
241 whitespace_text, whitespace_length, save);
271 const char *whitespace_text,
size_t whitespace_length,
283 length += whitespace_length;
286 if (new_length >= save->
alloc) {
287 size_t new_alloc = save->
alloc + (save->
alloc / 4);
290 if (new_alloc < new_length) new_alloc = new_length;
292 new_block = realloc(save->
block, new_alloc);
293 if (!new_block)
return false;
295 save->
block = new_block;
296 save->
alloc = new_alloc;
298 if (whitespace_text) {
299 memcpy(save->
block + save->
length, whitespace_text,
@ CONTENT_HTML
content is HTML
nserror
Enumeration of error codes.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
struct box * html_get_box_tree(hlcache_handle *h)
Retrieve box tree.
Interface to HTML content handler to save documents.
Public content interface.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Interface to platform-specific utf8 operations.
#define NSLOG(catname, level, logmsg, args...)
void save_as_text(struct hlcache_handle *c, char *path)
Extract the text from an HTML content and save it as a text file.
void save_text_solve_whitespace(struct box *box, bool *first, save_text_whitespace *before, const char **whitespace_text, size_t *whitespace_length)
Decide what whitespace to place before the next bit of content-related text that is saved.
static bool save_text_add_to_buffer(const char *text, size_t length, struct box *box, const char *whitespace_text, size_t whitespace_length, struct save_text_state *save)
Add text to save text buffer.
static void extract_text(struct box *box, bool *first, save_text_whitespace *before, struct save_text_state *save)
Traverse though the box tree and add all text to a save buffer.
Text export of HTML (interface).
@ WHITESPACE_TWO_NEW_LINES
@ WHITESPACE_ONE_NEW_LINE
Interface to utility string handling.
struct box * parent
Parent box, or NULL.
struct box * children
First child box, or NULL.
struct box * list_marker
List marker box if this is a list-item, or NULL.
struct box * next
Next sibling box, or NULL.
box_type type
Type of box.
css_computed_style * style
Style for this box.
size_t length
Length of text.
char * text
Text, or NULL if none.
int space
Width of space after current text (depends on font and size).
nserror(* utf8_to_local)(const char *string, size_t len, char **result)
Convert a UTF-8 encoded string into the system local encoding.
struct gui_utf8_table * utf8
UTF8 table.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.