X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Fmdcode.mdc;h=cf6887dea25c316bab6bc6679ce2f8e2d622a046;hb=69756809ef2d0324ec94b277f9750f92db4ae416;hp=2789671a6bf0ba9780dfeec773965d4b624fbabe;hpb=5107f51f1ba2b12dbffef31403ebfea30688b96b;p=ocean diff --git a/csrc/mdcode.mdc b/csrc/mdcode.mdc index 2789671..cf6887d 100644 --- a/csrc/mdcode.mdc +++ b/csrc/mdcode.mdc @@ -161,8 +161,11 @@ the root. 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 @@ -287,7 +290,13 @@ in a new node. 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)