]> git.neil.brown.name Git - edlib.git/commitdiff
markup: implement "hide" attribute
authorNeilBrown <neil@brown.name>
Sat, 6 May 2023 23:15:45 +0000 (09:15 +1000)
committerNeilBrown <neil@brown.name>
Sat, 6 May 2023 23:15:45 +0000 (09:15 +1000)
text with attribute "hide" is not rendered at all.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/Developer/06-rendering.md
lib-markup.c

index cc5c490162d7a617cb71a91c8836a3283ad3af07..b306cb992063d62f66f0b545503282b220db4775 100644 (file)
@@ -357,6 +357,9 @@ display to affect drawing of the text.  Attributes understood by
   the width and half the height, but to be as large as possible.  With
   noupscale this calculation never makes the image larger than the
   native size of the image, only the same size or smaller.
+- "hide" - the text affected by this attribute is not rendered at all.
+   If any other attribute is active with the same or higher priority,
+   "hide" becomes ineffective.
 
 ### lib-markup
 
@@ -395,6 +398,9 @@ identically, as are priorities less than 1.
 
 Importantly and attribute which affects spacing, like 'tab' or 'centre'
 and which cannot be closed and re-opened must have priority of 0.
+Conversely the attribute "hide" is implicitly disabled when any other
+attribute has a higher priority, and so it should typically have the
+largest of the priorities in use.
 
 I would like 'str2' to be inserted with the given attributes, but that
 isn't implemented yet.
index 6338899781c8d3a0b3b28f7b6997314bd8f9d2a9..f6f94efa0e6b314dc9b8b1ab6cbaca36b886e140 100644 (file)
@@ -389,6 +389,9 @@ DEF_CMD(render_line)
                        break;
                if (doc_boundary && mark_ordered_or_same(doc_boundary, m))
                        break;
+               chars++;
+               if (ar.ast && strcmp(ar.ast->attr, "hide") == 0)
+                       continue;
                if (ch == '<') {
                        if (o >= 0 && b.len+1 >= o) {
                                doc_prev(focus, m);
@@ -411,7 +414,6 @@ DEF_CMD(render_line)
                        buf_concat(&b, "</>");
                } else
                        buf_append(&b, ch);
-               chars++;
        }
        if (add_newline && want_vis_newline(ar.ast))
                buf_concat(&b, "↩");