From 69586115f8b182be1e65169de7c2c867702a3d0a Mon Sep 17 00:00:00 2001 From: Kristaps Dz Date: Mon, 6 Nov 2023 21:16:31 -0800 Subject: [PATCH] Fix forced multiline blockquotes in -tgemini. If a blockquote in -tgemini had hard breaks in it (lines ending with two spaces), the leading ">" was not printed before this fix. Thanks to l@81c.org for the report, thanks! --- gemini.c | 22 ++++++++++++++++++++-- regress/blockquote-linebreaks.gemini | 5 +++++ regress/blockquote-linebreaks.html | 7 +++++++ regress/blockquote-linebreaks.md | 7 +++++++ regress/blockquote-linebreaks.term | 5 +++++ regress/simple.gemini | 14 +++++++++----- 6 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 regress/blockquote-linebreaks.gemini create mode 100644 regress/blockquote-linebreaks.html create mode 100644 regress/blockquote-linebreaks.md create mode 100644 regress/blockquote-linebreaks.term diff --git a/gemini.c b/gemini.c index 091b5505..c0b34610 100644 --- a/gemini.c +++ b/gemini.c @@ -607,7 +607,7 @@ static int rndr(struct lowdown_buf *ob, struct lowdown_metaq *mq, struct gemini *st, const struct lowdown_node *n) { - const struct lowdown_node *child, *prev; + const struct lowdown_node *child, *prev, *nn; struct link *l; void *pp; struct lowdown_buf *tmpbuf; @@ -677,13 +677,31 @@ rndr(struct lowdown_buf *ob, struct lowdown_metaq *mq, break; case LOWDOWN_DEFINITION_TITLE: case LOWDOWN_HRULE: - case LOWDOWN_LINEBREAK: case LOWDOWN_LISTITEM: case LOWDOWN_META: case LOWDOWN_TABLE_ROW: if (!rndr_buf_vspace(st, ob, 1)) return 0; break; + case LOWDOWN_LINEBREAK: + if (!rndr_buf_vspace(st, ob, 1)) + return 0; + + /* + * A linebreak is special if invoked within a + * blockquote, because it means we want to output a + * newline but also continue outputting the blockquote + * marker. + */ + + for (nn = n->parent; nn != NULL; nn = nn->parent) + if (nn->type == LOWDOWN_BLOCKQUOTE) { + if (!HBUF_PUTSL(ob, "> ")) + return 0; + st->last_blank = 0; + break; + } + break; case LOWDOWN_IMAGE: case LOWDOWN_LINK: case LOWDOWN_LINK_AUTO: diff --git a/regress/blockquote-linebreaks.gemini b/regress/blockquote-linebreaks.gemini new file mode 100644 index 00000000..e84a2376 --- /dev/null +++ b/regress/blockquote-linebreaks.gemini @@ -0,0 +1,5 @@ +> this is a +> blockquote +> with +> two spaces at the end of +> ever line diff --git a/regress/blockquote-linebreaks.html b/regress/blockquote-linebreaks.html new file mode 100644 index 00000000..9f7f4c19 --- /dev/null +++ b/regress/blockquote-linebreaks.html @@ -0,0 +1,7 @@ +
+

this is a
+blockquote
+with
+two spaces at the end of
+ever line

+
diff --git a/regress/blockquote-linebreaks.md b/regress/blockquote-linebreaks.md new file mode 100644 index 00000000..e73499b7 --- /dev/null +++ b/regress/blockquote-linebreaks.md @@ -0,0 +1,7 @@ + +> this is a +> blockquote +> with +> two spaces at the end of +> ever line + diff --git a/regress/blockquote-linebreaks.term b/regress/blockquote-linebreaks.term new file mode 100644 index 00000000..55e4a710 --- /dev/null +++ b/regress/blockquote-linebreaks.term @@ -0,0 +1,5 @@ +  | this is a +  | blockquote +  | with +  | two spaces at the end of +  | ever line diff --git a/regress/simple.gemini b/regress/simple.gemini index 40d051c9..837e1d99 100644 --- a/regress/simple.gemini +++ b/regress/simple.gemini @@ -26,20 +26,23 @@ Here’s a numbered list: Note again how the actual text starts at 4 columns in (4 characters from the left side). Here’s a code sample: -```# Let me re-iterate ... +``` +# Let me re-iterate ... for i in 1 .. 10 { do-something(i) } ``` As you probably guessed, indented 4 spaces. By the way, instead of indenting the block, you can use delimited blocks, if you like: -```define foobar() { +``` +define foobar() { print "Welcome to flavor country!"; } ``` (which makes copying & pasting easier). You can optionally mark the delimited block for Pandoc to syntax highlight it: -```import time +``` +import time # Quick, count to ten! for i in range(10): # (but not *too* quick) @@ -61,7 +64,8 @@ Now a nested list: 3. Dump everything in the pot and follow this algorithm: -```find wooden spoon +``` +find wooden spoon uncover pot stir cover pot @@ -82,7 +86,7 @@ Here’s a link to a website[a], to a local doc[b], and to a section heading in Tables can look like this: -``` +``` size | material | color -----|-------------|------------- 9 | leather | brown