Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for most common nested elements in block quotes #49

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rmecham
Copy link

@rmecham rmecham commented Apr 28, 2020

I've had a go at updating Ink to support what I think are the HTML elements most commonly nested inside block quotes. I'm relatively new to Swift, so please let me know if you have any comments or suggestions.

@mflint
Copy link

mflint commented May 3, 2020

I was excited to see your contribution @rmecham. I've tried this with an example from Gruber's markdown syntax page:

> ## This is a header.
> 
> 1.   This is the first list item.
> 2.   This is the second list item.
>
> Here's some example code:
>
>    return shell_exec("echo $input | $markdown_script");

This renders as two separate blockquote elements, but I'd expect it to be just one.

@mflint
Copy link

mflint commented May 3, 2020

Thinking aloud: The PR also adds explicit code for other fragments inside the blockquote, checking for #, -*+ and > - but there's already support for that when parsing the document in MarkdownParser.swft:67.

Ideally that code would be reused - but it might need part of MarkdownParser to be extracted into a Document fragment, so BlockQuote can instead do:

let nestedDocument = try Document.read(using: &reader, ignorePrefix: ">")
blockquote.items.append(nestedDocument)

The ignorePrefix thing is smart. ❤️

@russellgordon
Copy link

I'll chime in and express my enthusiasm for this pull request. In particular, the idea of multiple > lines being rendered as a single block quote, such as:

> 1.   This is the first list item.
> 2.   This is the second list item.
>
> This renders as two separate blockquote elements, but I'd expect it to be just one.

In fact we can see that's just what the GitHub markdown parser does, if you inspect the following element, you'll see it is transformed to a single blockquote:

  1. This is the first list item.
  2. This is the second list item.

This renders as two separate blockquote elements, but I'd expect it to be just one.

I had to do some gymnastics with inserting <hr/> tags and CSS to get a block quote to render visually across multiple lines. That's not ideal and it'd be nice to see Ink more fully support block quotes in this manner.

@kevinrenskers
Copy link

This is definitely something that is needed in Ink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants