git.y1.nz

digest-html

Converts HTML to plaintext-with-links.
download: http://git.y1.nz/archives/digest-html.tar.gz
README | Files | Log | Refs

translate.h

      1 #include "gumbo.h"
      2 #include "okra.h"
      3 
      4 /**
      5  * Stores any state data, which pertains to the whole document in a
      6  * location-independent way. Calculated by the collection pass.
      7  */
      8 typedef struct {
      9 	FILE *out;
     10 	OkraUri *base_uri;
     11 	int debug;
     12 	// TODO DigestInput *inputs; int input_count;
     13 } GlobalState;
     14 
     15 /**
     16  * Stores location-dependent state data, for use during the translation pass.
     17  */
     18 typedef struct {
     19 	const GlobalState *global;
     20 
     21 	int indents;
     22 
     23 	int list_ordered; /* is the most recent list ordered? */
     24 	int list_index; /* what item are we on? */
     25 
     26 	/**
     27 	 * The type of spacing currently queued. The whitespace is only
     28 	 * "rendered" when a non-whitespace character is printed.
     29 	 * 
     30 	 * It is important that whitespace is redundant, so that 100 nested
     31 	 * divs, for example, only result in 1 newline being printed. The exact
     32 	 * rendering of spacing is effected by the non-space characters on
     33 	 * either side of it:
     34 	 * spacing==SPACING_SPACE, then a comma, results in no whitespace.
     35 	 *
     36 	 * TODO how does this interact with wrapping and such?
     37 	 */ 
     38 	int spacing;
     39 
     40 	/**
     41 	 * Whether the current element is inside of a verbatim environment.
     42 	 * Inside of a verbatim section, whitespace is not handled differently
     43 	 * than any other kind of text.
     44 	 */
     45 	int verbatim;
     46 } EphemeralState;
     47 
     48 void process_node(EphemeralState *s, GumboNode *node);
     49 void process_element(EphemeralState *s, GumboElement *element);

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.