typora-issues icon indicating copy to clipboard operation
typora-issues copied to clipboard

Image classes are not inherited in Pandoc export.

Open 273c opened this issue 1 year ago • 3 comments

With Typora 1.8.3dev,

export > Pandoc > -f native -s -o ${outputPath} -t html+east_asian_line_breaks+raw_html

In the HTML file created by this, the Class, Alt, and Width assigned to the image are not reflected. (They are not transferred.)

Therefore, the image tags set on Typora (e.g. width=200px) are not reflected, resulting in a very large image (lol)

I tried the following tags Neither of these are reflected.

(1) ! [myimage](. /assets/myimage.png){ .left width=200px }
(2) <img src=". /assets/myimage.png" alt="myimage" class="left" width="200px">

Of course, the Typora original HTML export reflects this.

273c avatar Jan 08 '24 23:01 273c

As per #2442

[style*="-typora: img-left"] {
    float: left;
    margin: 0 1em 1em 0;
    width:200px;
  }

Add the CSS for

<img src=". /assets/myimage.png" alt="myimage" style="-typora: img-left;" />

but this time only the style was removed. ......

273c avatar Jan 09 '24 08:01 273c

Currently Typora uses GFM, and { .left width=200px } is not parsed and supported, this should be covered in #249

<img src=". /assets/myimage.png" alt="myimage" class="left" width="200px"> should work if you set "Raw Type" as HTML in the export → Pandoc setting. In that case, we tell Pandoc it is raw HTML. Otherwise, we should parse the html and tell pandoc all its attributes, but it depends on Pandoc if those attributes are used or not.

abnerlee avatar Jan 19 '24 07:01 abnerlee

The RAW type is already set to HTML and still the class is not inherited.

The exported HTML looks like the following, which is stuck in a mysterious state where title="fig:" is automatically given.

<img src=". /assets/myimage.png" **title="fig:"** alt="myimage"> (fig: is added, alt is inherited, but class and width are gone)

Huh ...... If it works for others, I may be doing something wrong. Can abnerlee export HTML in pandoc correctly using abnerlee's method ......?

273c avatar Jan 21 '24 06:01 273c