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

Labels in container block directives #28

Open
mrwwalmsley opened this issue Oct 13, 2022 · 7 comments
Open

Labels in container block directives #28

mrwwalmsley opened this issue Oct 13, 2022 · 7 comments

Comments

@mrwwalmsley
Copy link

I'm a Nuxt user for my personal projects, but React for work.

For the past couple of years we have used a similar markdown directive syntax to Nuxt MDC.

After I started using Nuxt MDC in my personal projects, I then tried this plugin with my React work projects. It worked great except for ONE thing. We use labels in many of our container block directives.

::: name[label]{key=val}
contents, which are sometimes further block elements
:::

The Nuxt MDC syntax highlighter doesn't work with container directives as per this spec discussion:
https://talk.commonmark.org/t/generic-directives-plugins-syntax/444

Is that easy to implement?

Copy link
Member

Atinux commented Oct 19, 2022

Could you give an example of using [label]?

We use [] for the content of the component.

@mrwwalmsley
Copy link
Author

mrwwalmsley commented Nov 17, 2022

We have code like this in our educational platform:

:::text_select_activity[jungle_theme]{text_size=small find_all_locations layout=wide wrap=false}
A|M
ABCDEFGHIJKLMNOPQRSTUVWXYZ
:::

The Nuxt syntax highlighter works great... except when you add in the [jungle_theme].
Adding in the [] breaks the syntax highlighting:

image

Our examples are similar to the spec below:

image

Copy link
Member

Atinux commented Nov 18, 2022

What do you think @farnabaz ?

Copy link
Collaborator

I think supporting inline content for block components is a bit confusing, it is block so it should expect children inside it's scope.

Also for leaf usage we implemented a self-closing(leaf) block in MDC here
So instead of using ::name[content]{attrs}, it can simply written as. :name[content]{atttr} with single colon.

@mrwwalmsley
Copy link
Author

mrwwalmsley commented Nov 20, 2022

This spec document has been around for 8 years, and was implemented years ago by Remark.

It supports 3 kinds of directives:

  1. Inline start with one colon (analogous to spans)
  2. Leaf block, start with two colons (analogous to empty divs)
  3. Container block, start with at least three colons (analogous to divs containing further blocks)

1. Inline Directive Syntax

:name[content]{key=val}

2. Leaf Block Directives

:: name [content] {key=val}

3. Container Block Directives

::: name [inline-content] {key=val}
contents, which are sometimes further block elements
:::

I'm not too concerned if Nuxt MDC implementation supports both 1 & 2 above, since I am only using it on new projects.

However, it would be great if the Nuxt VSCode plugin syntax highlighter could support all 3 syntaxes, so that the plugin would work correctly for projects using the standard Remark MDC implementation.

https://talk.commonmark.org/t/generic-directives-plugins-syntax/444

While I agree that it is potentially redundant and confusing to allow the label in blocks, I have never-the-less found it useful. Here is an example. While the first syntax is less explicit, it gives an example of the utility of supporting both inline-content and block-content with the same directive.

:::spoiler[Click me to expand]
... content ...
:::

:::spoiler{label='Click me to expand'}
... content ...
:::

:::spoiler
---
label: Click me to expand
---
... content ...
:::

:::spoiler
# label
Click me to expand

# content
... content ...
:::

@mrwwalmsley
Copy link
Author

mrwwalmsley commented Apr 12, 2023

So @farnabaz & @Atinux would you suggest that I fork to add support for this feature of the common mark spec?

::: name [inline-content] {key=val}
contents, which are sometimes further block elements
:::

I'm taking it you don't want to support this syntax highlighting since Nuxt3 MCD doesn't support this part of the spec.

Note that I'm using the remark-directives plugin, which fully supports the spec:
https://github.com/remarkjs/remark-directive#readme

Copy link
Member

Atinux commented Apr 13, 2023

You can fork yes @mrwwalmsley

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