diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-04-26 22:26:05 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-04-26 22:26:05 +0200 |
commit | 18a7cd2f8adb5fd03750e10cb397805f29ed9417 (patch) | |
tree | bf53ad0d4d31077640ba07cf4ec609757dd40ec4 /libstorycode | |
parent | 823d0b3160d95b02b5f2d886dd576f0f5e0293d5 (diff) |
Add API for getting style tree
Diffstat (limited to 'libstorycode')
-rw-r--r-- | libstorycode/stylesheet.c | 17 | ||||
-rw-r--r-- | libstorycode/stylesheet.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c index f3fd7e6..f625b19 100644 --- a/libstorycode/stylesheet.c +++ b/libstorycode/stylesheet.c @@ -543,3 +543,20 @@ char *stylesheet_serialise(Stylesheet *s) return text; } + + +int stylesheet_get_num_substyles(Stylesheet *s, const char *stn) +{ + struct style *sty = lookup_style(&s->top, stn); + if ( sty == NULL ) return 0; + return sty->n_substyles; +} + + +const char *stylesheet_get_substyle_name(Stylesheet *s, const char *stn, int i) +{ + struct style *sty = lookup_style(&s->top, stn); + if ( sty == NULL ) return NULL; + if ( i >= sty->n_substyles ) return NULL; + return sty->substyles[i].name; +} diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h index cd23c66..f814e01 100644 --- a/libstorycode/stylesheet.h +++ b/libstorycode/stylesheet.h @@ -104,6 +104,9 @@ extern int stylesheet_get_padding(Stylesheet *s, const char *stn, extern int stylesheet_get_paraspace(Stylesheet *s, const char *stn, struct length paraspace[4]); +extern int stylesheet_get_num_substyles(Stylesheet *s, const char *stn); +extern const char *stylesheet_get_substyle_name(Stylesheet *s, const char *stn, int i); + extern char *stylesheet_serialise(Stylesheet *s); #endif /* STYLESHEET_H */ |