Skip to content

Commit

Permalink
Fix forced multiline blockquotes in -tgemini.
Browse files Browse the repository at this point in the history
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 [email protected] for the report, thanks!
  • Loading branch information
kristapsdz committed Nov 7, 2023
1 parent 7953d7d commit 6958611
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
22 changes: 20 additions & 2 deletions gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions regress/blockquote-linebreaks.gemini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> this is a
> blockquote
> with
> two spaces at the end of
> ever line
7 changes: 7 additions & 0 deletions regress/blockquote-linebreaks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<blockquote>
<p>this is a<br/>
blockquote<br/>
with<br/>
two spaces at the end of<br/>
ever line</p>
</blockquote>
7 changes: 7 additions & 0 deletions regress/blockquote-linebreaks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

> this is a
> blockquote
> with
> two spaces at the end of
> ever line
5 changes: 5 additions & 0 deletions regress/blockquote-linebreaks.term
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
 | this is a
 | blockquote
 | with
 | two spaces at the end of
 | ever line
14 changes: 9 additions & 5 deletions regress/simple.gemini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6958611

Please sign in to comment.