-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simpleFigure builder [GSoC 2021] #90
Conversation
The new Figure block represents a figure with attributes, caption, caption position, and arbitrary block content. Since the figure block represents captioned material, the Caption in Table is no longer necessary, and has been removed.
Some comments:
|
Right, doing the AST element would incluce the builder function (I'll clarify this in the top message)
Because, as I see it now, I was drawing too much inspiration from JATS's data Block
= ...
| Graphic Attr Caption Target
| Figure Attr Caption [Block]
... But now I believe that using the current data Block
=...
| Div Attr [Block]
... Could cover the JATS's |
We should probably move the discussion about the new constructor back to the fork. I'm wondering whether it would make sense to let the constructor also add the |
Is |
Ah, right. I guess Definition would be a better place for it. |
db51d6c
to
be85d6f
Compare
If I'm understanding correctly, this PR does two distinct things:
Can these two distinct changes be split into two separate PRs? Because merging this PR and jgm/pandoc#7364 would, if I'm not mistaken, leave the code unable to compile without warnings, since the writers would also need to be modified to handle the new Figure constructor... |
You are correct that this PR does two things and could be staged into:
I added 2 to 1 b.c. time constrains and I needed one version of I'll close this PR and make one new with 1. |
Introducing new constructor to handle figures. This is in the context of pandoc's issue #3177. Use of these on
Readers
andWriters
was submitted with the pandoc pull request.The
SimpleFigure
constructionTo address some of the issues with the previous handling of figures, we introduced, along with some helper functions, the
SimpleFigure
pattern synonymThis is very much like adding a new constructor to the
Block
type but with some differences.Some benefits of this approach are:
It is backward compatible with the previous construction.
It formalizes, without enforcing, the roles for the construction's elements.
It makes it easier to find where are figures handled in the code for both
Readers
andWriters
.Here is an example diff from the RST
Reader
in the pandoc pull request:Of course, there are also some limitations:
It doesn't enforce the construction on new code, as an actual constructor would do. For example, code with non-exhaustive patterns matches won't rise a warning if
SimpleFigure
is not handled.It lacks an explicit
alt-text
field. This can be included using attributes, but I would have liked to give it more importance.I believe this is a modest improvement of the previous code. It provides an explicit representation for figures. It could go a little further with an explicit constructor; but keeping the behavior backward compatible prevents breaking some workflows down the line, for example someone using a
lua-filter
.The
Figure
constructorThe
SimpleFigure
constructor only addressed one type of figures, the ones with only one image in them. To address the general case of the concept of a document within a document detailed in the section on figures, we introduced the followingBlock
constructor:This includes other helper functions and tests and is part of the pandoc-types pull request. It's based on the previous work by @despresc. Modifications include: the removal of the
CaptionPos
argument that can be specified as an attribute; and the code involving tables.Tests for this constructor are also included with the pull request.
This constructor allows pandoc to capture the semantics of figures from different formats into its internal representation. It also helps when writing output in formats that support figures.