libmdcode.o : libmdcode.c mdcode.h
$(CC) $(CFLAGS) -c libmdcode.c
-
### File: md2c.c
#include <unistd.h>
Finally we need to know if the `code_node` was recognised by being
indented or not. If it was, the client of this data will want to
-strip of the leading tab or 4 spaces. Hence a `needs_strip` flag is
-needed.
+strip off the leading tab or 4 spaces. Hence a `needs_strip` flag is
+needed. This will be set to 8 if a tab is found and 4 if four spaces are found.
+This means the relative indent of text in the node
+is `node->indent - node->needs_strip`.
+The relative indent is needed for detecting indents in the overall file.
##### exported types
n->code = txt;
n->indent = 0;
n->line_no = line_no;
- n->needs_strip = needs_strip;
+ if (needs_strip) {
+ if (txt.txt[0] == '\t')
+ n->needs_strip = 8;
+ else
+ n->needs_strip = 4;
+ } else
+ n->needs_strip = 0;
n->next = NULL;
n->child = NULL;
if (where->last)
return c;
}
-
static char *take_code(char *pos, char *end, char *marker,
struct psection **table, struct text section,
int *line_nop)
struct section *code_extract(char *pos, char *end, code_err_fn error);
-
## Using the library
Now that we can extract code from a document and link it all together
no error we write out a file for each appropriate code section. And
we are done.
-
##### client includes
#include <fcntl.h>