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

spec: Attributes on headings and other elements #9

Open
MurakamiShinyu opened this issue Jan 27, 2020 · 10 comments
Open

spec: Attributes on headings and other elements #9

MurakamiShinyu opened this issue Jan 27, 2020 · 10 comments
Assignees
Labels
spec Spec related thing
Milestone

Comments

@MurakamiShinyu
Copy link
Member

Goals

For effective CSS styling, we need to add attributes on headings and other elements.

Prior Art

PHP Markdown Extra defines Special Attributes:

Special Attributes

With Markdown Extra, you can set the id and class attribute on certain elements using an attribute block. For instance, put the desired id prefixed by a hash inside curly brackets after the header at the end of the line, like this:

Header 1            {#header1}
========

## Header 2 ##      {#header2}

Then you can create links to different parts of the same document like this:

[Link back to header 1](#header1)

To add a class name, which can be used as a hook for a style sheet, use a dot like this:

## The Site ##    {.main}

You can also add custom attributes having simple values by specifying the attribute name, followed by an equal sign, followed by the value (which cannot contain spaces at this time):

## Le Site ##    {lang=fr}

The id, multiple class names, and other custom attributes can be combined by putting them all into the same special attribute block:

## Le Site ##    {.main .shine #the-site lang=fr}

At this time, special attribute blocks can be used with

  • headers,
  • fenced code blocks,
  • links, and
  • images.

Pandoc’s Markdown defines extensions for attributes, compatible with PHP Markdown Extra's Special Attributes and further extended:

Discussion

Related issues:

@MurakamiShinyu MurakamiShinyu added the spec Spec related thing label Jan 27, 2020
@tk0miya
Copy link

tk0miya commented Jan 28, 2020

It seems bracketed_spans conflicts with Ruby annotation (#10). Is it better to change syntax for Ruby?

@uetchy
Copy link
Member

uetchy commented Feb 3, 2020

Yes we need to change the ruby ​​notation to fix the conflict.

The most likely notation is {Text|Ruby}
#10

@tk0miya
Copy link

tk0miya commented Feb 3, 2020

Curly brackets are used in special attributes notation. So we need to make examples for it to avoid the conflicts with denden-markdown styled ruby notation.

How this text are parsed? An image and ruby-text? Or An image having special attributes? (Sorry for malicious example!)

![caption](uri){.Text|ドットテキスト}

@uetchy
Copy link
Member

uetchy commented Feb 3, 2020

@tk0miya That's interesting. Can you provide some possible outcomes? so we can discuss more concisely. I think a properly implemented parser will fail to consume this as an image with attributed value because it has invalid character "|" for CSS class name.

@uetchy
Copy link
Member

uetchy commented Feb 3, 2020

After reading this spec, I realized that "|" can be used for a part of CSS class name by adding "\" before "|" hence "\|" (seriously?)
It means that we will have to put some limitations on this naming rule if we continue to adapt denden ruby syntax.

@tk0miya
Copy link

tk0miya commented Feb 3, 2020

Actually, almost of users would not use to pipes to class name. So it is enough to define range of characters to special attribute block.

  • A special attribute block can contain one or more attributes separated by spaces.
  • An attribute should be element ID, class or attribute definition.
  • An element ID should be starts with # and following one or more ASCII printable characters
    • In regexp, /^#[\x21-\x7e]+$/
  • A class should be starts with . and following one or more ASCII printable characters
    • In regexp, /^\.[\x21-\x7e]+$/
  • An attribute definition should be consist with attribute name, = and value
    • An attribute name and value should be one or more ASCII printable characters
    • In regexp, /^[\x21-\x7e]+=[\x21-\x7e]+$/
    • Quoted strings might be allowed as value (if needed)

@MurakamiShinyu
Copy link
Member Author

MurakamiShinyu commented Jan 14, 2021

現状の vfm での実装状況と課題

見出しその他の要素に属性を指定する記法は、現状の vfm (1.0.0-alpha.15) で一部は利用可能になってますが、Pandoc's Markdownで使える次のものがまだ使えません:

また次のものは、現状の vfm で利用可能ですが、課題があります。

課題:

課題: spec: <figure> for image container #15 に関して

  • 属性が <img> タグに出力されるが、それを囲む <figure> タグには出力されない
    • <img> タグのみに意味がある属性以外は <figure> タグにも属性がコピーされるのがよいのでないか
    • id 属性は <figure> に移動したほうがよいのでないか

@akabekobeko akabekobeko self-assigned this Jan 16, 2021
@akabekobeko
Copy link
Member

@MurakamiShinyu

現状の vfm での実装状況と課題

について v1.0 対応とするか v2.0 へ見送るかの意見をお願いします。

@akabekobeko akabekobeko added this to the v1.0.0 milestone Apr 3, 2021
@MurakamiShinyu
Copy link
Member Author

について v1.0 対応とするか v2.0 へ見送るかの意見をお願いします。

v1.0は現状でリリースして、v2.0の検討・開発に進むのでよいだろうと思います。

@akabekobeko akabekobeko modified the milestones: v1.0.0, v2.0.0 Apr 3, 2021
@akabekobeko
Copy link
Member

コメントありがとうございます。v2.0 へ送ります。

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

No branches or pull requests

4 participants