TEIC / Stylesheets

TEI XSL Stylesheets
231 stars 124 forks source link

First pass at issue #511: graphics to markdown images. #528

Closed martindholmes closed 2 years ago

martindholmes commented 2 years ago

I've added handling for TEI graphic elements in tei-to-markdown.xsl per issue #511. You can test this by running this in the Stylesheets repo root:

bin/teitomarkdown Test2/inputFiles/generalP5.xml Test2/outputFiles/test.md

then looking at the file Test2/outputFiles/test.md

martindholmes commented 2 years ago

@sydb Feel free to simplify the XPath. I wasn't firing on all cylinders when I wrote the if-then-else stuff. Re the width/height: I was looking for a way to handle those attributes because the TEI has them, and most of us would use them; Common Markdown doesn't provide a way to do that, but the widely-used Kramdown editor implements what I've included. The alternative is to output an HTML img tag; we could branch on whether those atts are there, and fall back to an img tag if they are, and that would work for almost all Markdown implementations, but it's not Markdown, of course.

martindholmes commented 2 years ago

@sydb I've updated the XPath per your suggestion, and added a missing colon for compliance with the Kramdown syntax.

sydb commented 2 years ago

Excellent. I had never heard of Kramdown. Learned something new. (Can I go home now?)

I have run the test above, and it works for me.

Would you be opposed to changing lines 253–260 to the following?

    <xsl:sequence select="
        '!['
      ||$altText
      ||']('
      ||@url
      ||' &quot;'
      ||$titleText
      ||'&quot;)'
      ||string-join( $dim, '')
      "/>

Either way, I think PR is fine to be merged. Yes, there is still a lot to be done in this conversion, but it is 1 step better than what we have now.

martindholmes commented 2 years ago

@sydb Done and tested again.

sydb commented 2 years ago

Seems pretty simple, so just merged.