vivliostyle / vfm

⬇️ Open and extendable Markdown syntax and toolchain.
https://vivliostyle.github.io/vfm/#/vfm
Other
70 stars 12 forks source link

spec: Attributes on headings and other elements #9

Open MurakamiShinyu opened 4 years ago

MurakamiShinyu commented 4 years ago

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:

tk0miya commented 4 years ago

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

uetchy commented 4 years ago

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

The most likely notation is {Text|Ruby} https://github.com/vivliostyle/vfm/issues/10

tk0miya commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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.

MurakamiShinyu commented 3 years ago

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

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

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

課題:

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

akabekobeko commented 3 years ago

@MurakamiShinyu

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

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

MurakamiShinyu commented 3 years ago

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

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

akabekobeko commented 3 years ago

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