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

Allow whitespace between attributes in directives #20

Open
4 tasks done
AlbertMarashi opened this issue May 16, 2023 · 9 comments
Open
4 tasks done

Allow whitespace between attributes in directives #20

AlbertMarashi opened this issue May 16, 2023 · 9 comments
Labels
🤞 phase/open Post is being triaged manually

Comments

@AlbertMarashi
Copy link

Initial checklist

Problem

suffers from long lines

::question{slug="are-you-excited" question="What are you excited to learn about in this course?" context="The course is about Programmatic thinking" }

Easier to write & read

::question{
    slug="are-you-excited"
    question="What are you excited to learn about in this course?"
    context="The course is about Programmatic thinking"
}

Solution

Easier to write & read

::question{
    slug="are-you-excited"
    question="What are you excited to learn about in this course?"
    context="The course is about Programmatic thinking"
}

Alternatives

Nope, enhancement

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 16, 2023
@AlbertMarashi
Copy link
Author

Also, this is more inline with how HTML attributes work since I'm fairly certain they allow newlines or spaces in between attributes of elements

@wooorm
Copy link
Member

wooorm commented May 16, 2023

Have you considered how this affects different directives? Texts? Containers?

Are there other markdown things that work like this?

Have you found this feature in the proposal or in other implementations?

@AlbertMarashi
Copy link
Author

AlbertMarashi commented Jun 6, 2023

@wooorm I don't think it would affect anything. The { should enter a parse mode where consecutive whitespaces are ignored, as is done in HTML, which allows whitespace in attributes.

For container directives, it also should not play a role

:::foo{
   bar="xyz"
}
Some text
:::

Should be functionally equivalent to:

:::foo{ bar="xyz" }
Some text
:::

@wooorm
Copy link
Member

wooorm commented Jun 6, 2023

HTML is a mostly whitespace-insensitive language. Markdown is a whitespace-sensitive language.

Markdown blocks are parsed per line: either a line is something, or it isn’t. It doesn’t backtrack past lines. What do you want to happen for:

:::foo{
   bar="xyz"
   qwe

Additionally, you mention whitespace, there are still many forms of whitespace that you don’t show. What about:

::question{
    slug="are-you-excited"
      

    098
}

To illustrate those two together, how far do you go?

::question{

# Is this a heading? Just some attributes?

> Block quote? Do we just go to the end is every word here an attribute?

@wooorm
Copy link
Member

wooorm commented Jun 6, 2023

Importantly, “whitespace” is generally [\r\n\t ]+, and maybe a couple more characters. But in your case you are talking about (\r?\n|\r), which is a line ending.
Some characters and a line ending are called a line.
In markdown, there is also blank lines, which typically break every construct: two line endings, with only spaces and/or tabs in between.

@AlbertMarashi
Copy link
Author

AlbertMarashi commented Jun 6, 2023

I don't know how the inner workings of the parser works, but I don't see why the parser can't enter a certain mode for parsing attributes

When it runs into :::foo{ It should enter the mode of parsing "attributes" (Key-value pairs)

When it runs into a } it should collect those attributes and store them inside of the object holding the information/attributes of the directive

Any cases where it runs into unexpected format of attributes should cause an error

@wooorm
Copy link
Member

wooorm commented Jun 6, 2023

Markdown doesn't have errors, just like html or css, unlike javascript, it never crashes.

I don't think crashing for directives is a good idea. They're supposed to be like markdown.

This seems like a very big departure from the proposal.

If you want errors and breaking away from markdown and line endings in attributes: we have that already with MDX!

@AlbertMarashi
Copy link
Author

Markdown doesn't have errors, just like html or css, unlike javascript, it never crashes.

I don't think crashing for directives is a good idea. They're supposed to be like markdown.

This seems like a very big departure from the proposal.

If you want errors and breaking away from markdown and line endings in attributes: we have that already with MDX!

In that case, it doesn't need to error, rather it will just not parse correctly and instead just return the directive content as text as is currently done (for example like when a comma is inserted in between directives)

@wooorm
Copy link
Member

wooorm commented Jun 7, 2023

This (backtracking across lines) is something that markdown doesn’t currently do.
It’s dangerous (it can be a source of “DDoSing”).

I understand that you want to do what you propose.
But there is no precedence currently for this feature, in markdown itself or in the proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually
Development

No branches or pull requests

2 participants