textile / php-textile

Textile markup language parser for PHP
https://textile-lang.com
Other
216 stars 44 forks source link

Change where classes and other attributes are added in RedCloth definition lists #220

Open jools-r opened 2 years ago

jools-r commented 2 years ago

When adding a (class-name) to the first item of a definition list, the HTML output is not consistent depending on the notation you use. The semicolon/colon notation places the classname on the containing dl element. The dash-colon-equals notation places the class name on the first dt element.

Expected behaviour

Consistent behaviour regardless of definition list notation used: the class should in my view be applied to the containing dl tag so that one can style the entire definition list. Currently using -Term := Definition notation you can only style the first dt.

Actual behaviour

See above

Additional information

PHP-Textile version: 3.7.6 PHP version: 8.1

Steps to reproduce

Try inserting the following into the textarea at textile-lang.com:

;(class-name) HTML
: HyperText Markup Language, based on SGML.
; XHTML
: HTML 4.0 rewritten to be compliant with XML rules.
; HTML5
: The latest revision of the HTML standard.
: Still under development.

-(class-name) HTML := HyperText Markup Language, based on SGML.
- XHTML := HTML 4.0 rewritten to be compliant with XML rules.
- HTML5 := The latest revision of the HTML standard
Still under development =:

The first ;(class-name) HTML produces what I think is correct output:

<dl class="class-name">
    <dt><span class="caps">HTML</span></dt>
        ...

while the second -(class-name) HTML := … produces

<dl>
    <dt class="class-name"><span class="caps">HTML</span></dt>
        ...
gocom commented 2 years ago

Unfortunately, both are expected results covered by fixtures and not bugs:

https://github.com/textile/php-textile/blob/master/test/fixtures/basic.yaml#L2229 https://github.com/textile/php-textile/blob/master/test/fixtures/basic.yaml#L2243

The other one is simplified RedCloth syntax. The output of one could be changed, but because of b/c break, earliest it could be done is in 4.0.0.

jools-r commented 2 years ago

Oh, you are right. I didn't realise that is the current behaviour of the Redcloth syntax. Thanks for the clarification. And I think your suggestion of adding it to the next major version is good.