diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-09-20 17:12:29 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-10-05 17:03:25 +0200 |
commit | 387858893a1a858e8205aae28a3609006c0c717d (patch) | |
tree | 1a52586a133e864097c6b3aa4c4e66aea2c14bdd /libstorycode/storycode.c | |
parent | 03ca4360631d5b0438912470c483989d294d7a1e (diff) |
Parse emphasis blocks in Bison
Diffstat (limited to 'libstorycode/storycode.c')
-rw-r--r-- | libstorycode/storycode.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c index e17d5dd..c35afcb 100644 --- a/libstorycode/storycode.c +++ b/libstorycode/storycode.c @@ -107,6 +107,25 @@ static const char *maybe_alignment(enum alignment ali) } +static void write_run_border(GOutputStream *fh, enum text_run_type t) +{ + if ( t == TEXT_RUN_BOLD ) write_string(fh, "*"); + if ( t == TEXT_RUN_ITALIC ) write_string(fh, "/"); + if ( t == TEXT_RUN_UNDERLINE ) write_string(fh, "_"); +} + + +static void write_para(GOutputStream *fh, struct text_run *runs, int n_runs) +{ + int i; + for ( i=0; i<n_runs; i++ ) { + write_run_border(fh, runs[i].type); + write_string(fh, runs[i].text); + write_run_border(fh, runs[i].type); + } +} + + static void write_text(GOutputStream *fh, SlideItem *item, int geom, const char *t) { @@ -129,13 +148,13 @@ static void write_text(GOutputStream *fh, SlideItem *item, int geom, indent = strlen(tmp); write_string(fh, tmp); write_string(fh, ": "); - write_string(fh, item->paras[0].text); + write_para(fh, &item->paras[0], item->paras[0].n_runs); write_string(fh, "\n"); for ( i=0; i<indent; i++ ) tmp[i] = ' '; for ( i=1; i<item->n_paras; i++ ) { write_string(fh, tmp); write_string(fh, ": "); - write_string(fh, item->paras[i].text); + write_para(fh, &item->paras[i], item->paras[i].n_runs); write_string(fh, "\n"); } } |