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

Indent is significant within HTML blocks #105

Open
allenap opened this issue Sep 4, 2021 · 2 comments
Open

Indent is significant within HTML blocks #105

allenap opened this issue Sep 4, 2021 · 2 comments

Comments

@allenap
Copy link

allenap commented Sep 4, 2021

Observed: Leading whitespace appears to cause the parser to see a code block within an HTML block.

Expected: Whitespace within an HTML block should be treated the same as whitespace in HTML, i.e. for the most part it is insignificant. The examples of HTML blocks in the GFM spec appear to show that nothing within an HTML block should be interpreted as Markdown.

See this example; screenshot below:

image

Related to #50, #70, and #102.

@dillonkearns
Copy link
Owner

Very good point @allenap, this has been on my mind, too. I think there are a few things to consider here. This is one of the things I want to clarify and make an explicit spec for as part of #93.

I think it's worth looking at a few different examples here and thinking through what would be intuitive. For example, if you have a line with only whitespace, should that be ignored for figuring out the initial indent level?

My initial ideas on this:

  • If something is not indented at all, that's fine (should work as expected, indentation should be optional)
  • The first line of content with indentation sets the reference point for everything else
  • What do we do if something starts with, say, 4 spaces of indentation, and then goes back to 0 spaces? My gut feeling is that the parser should require look-ahead to see the indentation level of future lines. That said, one option would be to look at everything in the HTML tag, and treat the least indented item as the calibration point for 0 indentation.
  • There should be a maximum beyond which it is not the calibration for 0, but becomes part of the markdown. For example, if you go beyond 4 spaces. So starting with 8 spaces could be used for a code block.

@tad-lispy
Copy link

What do we do if something starts with, say, 4 spaces of indentation, and then goes back to 0 spaces?

I think a parse error would be more useful here. First line indented and some lines below not is most likely an accident. And if the smallest indentation counts, this accident will result in incorrect output, e.g. some code blocks in the beginning.

I'm not sure if it's compatible with the design goals of Elm Markdown, but maybe we can be even more strict and require multi-line content inside HTML tag to always be indented? Just a thought.

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

No branches or pull requests

3 participants