Skip to content

Deal with <figure> and <figcapture> tags #10

Closed

Description

@peterjc

Subset of #2, pandoc has output some rather verbose snippets for images.

e.g. from BOSC_2014.mediawiki as on https://open-bio.org/wiki/BOSC_2014 we had:

[[Image:Eagle_logo_2013.jpg|120px|left|Eagle Genomics logo|link=http://www.eaglegenomics.com/]]

This showed the image without a caption below it, clickable, with tool tip "Eagle Genomics logo".

After pandoc in https://github.com/OBF/wiki/edit/main/BOSC_2014.md we currently have:

<figure>
<img src="Eagle_logo_2013.jpg"
title="Eagle Genomics logo|link=http://www.eaglegenomics.com/"
width="120" />
<figcaption>Eagle Genomics logo|link=<a
href="http://www.eaglegenomics.com/">http://www.eaglegenomics.com/</a></figcaption>
</figure>

Sometimes the caption is appropriate, but generally I'd want just something like this:

<a href="http://www.eaglegenomics.com/">
<img src="Eagle_logo_2013.jpg" title="Eagle Genomics logo" alt="[Logo]" width="120" />
</a>

Can we tweak pandoc's settings? Can we adjust the MediaWiki before calling pandoc? Or must we post-process the Markdown?

Activity

  1. peterjc commented on Feb 8, 2024

    @peterjc
    MemberAuthor

    See https://www.mediawiki.org/wiki/Help:Images which suggests the caption should be last, not the link option.

  2. peterjc commented on Feb 8, 2024

    @peterjc
    MemberAuthor

    Confirmed - our MediaWiki version is not following the documented order, if we change it then pandoc does more like what I want:

    $ echo " [[Image:Eagle_logo_2013.jpg|120px|left|link=http://www.eaglegenomics.com/|Eagle Genomics logo]]" \
      | pandoc -f mediawiki -t gfm
    <img src="Eagle_logo_2013.jpg" title="Eagle Genomics logo" width="120"
    alt="Eagle Genomics logo" />
    

    Currently:

    i$ echo " [[Image:Eagle_logo_2013.jpg|120px|left|Eagle Genomics logo|link=http://www.eaglegenomics.com/]]"  \
      | pandoc -f mediawiki -t gfm
    <img src="Eagle_logo_2013.jpg"
    title="Eagle Genomics logo|link=http://www.eaglegenomics.com/" width="120"
    alt="Eagle Genomics logo|link=http://www.eaglegenomics.com/" />
    

    It would appear the the MediaWiki software is more tolerant that their documentation.

  3. added a commit that references this issue on Feb 8, 2024
    1f820ae
  4. peterjc commented on Feb 8, 2024

    @peterjc
    MemberAuthor

    Largely Partly fixed via 1f820ae and preceeding commit, i.e. tweaked the mediawiki before calling pandoc.

    Now https://obf.github.io/wiki/BOSC_2014 looks much better, but still has:

    <img src="Eagle_logo_2013.jpg" title="Eagle Genomics logo" width="120" />
    <figcaption>Eagle Genomics logo</figcaption>

    In this page (and probably the other sponsor logos) we can drop the <figcaption>Eagle Genomics logo</figcaption> line?

  5. peterjc commented on Feb 8, 2024

    @peterjc
    MemberAuthor

    Logged jgm/pandoc#9432 about Pandoc not capturing the image URL.

  6. added a commit that references this issue on Feb 9, 2024
  7. peterjc commented on Feb 9, 2024

    @peterjc
    MemberAuthor

    I've tried tweaking the MediaWiki, e.g. we have examples like this:

    $ echo "[[File:Cherry blossoms in Seattle.jpg|link=http://wikipedia.org|thumb|alt=Photo|Cherry blossoms in Seattle, USA]]" | pandoc -f mediawiki 
    <figure>
    <img src="Cherry_blossoms_in_Seattle.jpg"
    title="Cherry blossoms in Seattle, USA" />
    <figcaption>Cherry blossoms in Seattle, USA</figcaption>
    </figure>
    

    If we change it for external links to this:

    $ echo "[http://wikipedia.org [[File:Cherry blossoms in Seattle.jpg|thumb|alt=Photo|Cherry blossoms in Seattle, USA]]]" | pandoc -f mediawiki 
    <p><a href="http://wikipedia.org"><img
    src="Cherry_blossoms_in_Seattle.jpg"
    title="Cherry blossoms in Seattle, USA"
    alt="Cherry blossoms in Seattle, USA" /></a></p>
    

    So that ought to work, but it seems a side effect was pandoc stopped using HTML for the logo placement tables, and the new tables didn't work.

    Post-processing the markdown is probably our best bet - unless an unpaded pandoc works better.

  8. peterjc commented on Feb 9, 2024

    @peterjc
    MemberAuthor

    OK, now we just need to recover and insert the image links - not actually that many as many are repeat sponsor logos.

  9. added a commit that references this issue on Feb 9, 2024
    5e3b598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions