Skip to content
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

Block consistency #2286

Merged
merged 18 commits into from
Dec 22, 2023
Merged

Block consistency #2286

merged 18 commits into from
Dec 22, 2023

Conversation

brucemiller
Copy link
Owner

@brucemiller brucemiller commented Dec 20, 2023

This PR improves the LaTeXML Schema for vertical blocks of material at various levels (block, logical (aka para), sectional) and improves the flexibility of processing. The revised insertBlock captures the material to be inserted in a special _CaptureBlock_ (temporary) element, and then determines an appropriate container element based on the content, context, and attributes to be added. Several other simplifications and cleanup were then enabled.

To make this work, a more consistent set of blocks were needed: we now have

  • block which contains Block.model and can appear in Block.class
  • logical-block which contains Para.model and can appear in Para.class
  • sectional-block which contains sectional material and can appear in sections.
    Along with an inline- variant for each, which appears in Misc.class.
    NOTE the breaking change that ltx:inline-para has been renamed ltx:inline-logical-block.

Additional changes include cleaning up \normal@par and \lx@newline to behave more generally, and to no-longer need \inner@par.
Moreover, the content model of ltx:td was changed to Inline.model to be more consistent with HTML; when needed inline- block can be used.

Fixes #1705
Fixes #2038
Fixes #2005
Fixes #2037

which are typically (vertical) blocks of block, para orsectional material (according to the level)
for layout purposes.

* block can contain Block.model allowed in Block.class
* logical-block can contain Para.model allowed in Para.class
* sectional-block can contain sectional material, allowed in sections
Each has an inline- variant which is in Misc.class.

NOTE: that inline-para has been renamed inline-logical-block!
NOTE: that the content model of table cells (ltx:td) has been changed to Inline.model; if it needs to contain block level material, it needs to be contained in an appropriate inline-xxx element.
…porarily capturing block-like content at various levels to defer determining which level (block,logical,sectional) is needed
…with the new name allowing for automatic opening/closing of nodes
…ode avoiding unnecessary ltx:break; use these more consistently, obsoleting \inner@par, \lx@parboxnewline
@brucemiller brucemiller requested a review from dginev December 20, 2023 00:33
Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a first introductory read through the PR - I really like the changes! The new naming scheme is very helpful to describe the variations on the block-like theme.

_CaptureBlock_ is really fascinating. I'm going to explore a bit how the tests change for my subfigure refactor branch.

return; },
properties => { isBreak => 1 });

Let('\lx@parboxnewline[]', '\lx@newline'); # Obsolete, but in case still used
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably the [] arg should go away for the Let?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

@@ -4,8 +4,8 @@
<document xmlns="http://dlmf.nist.gov/LaTeXML">
<resource src="LaTeXML.css" type="text/css"/>
<resource src="ltx-article.css" type="text/css"/>
<para xml:id="p1">
<tabular vattach="bottom">
<para vattach="bottom" xml:id="p1">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... vattach on para, which is the top content element of a document? Seems a little fishy.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the test is fishy starting with a vbox.

@@ -116,7 +114,6 @@ and collectively as <ref labelref="LABEL:fig:D"/>.</p>
<toccaption><tag close=" ">(b)</tag>This is another figure</toccaption>
<caption><tag close=" "><text font="bold" fontsize="80%">(b)</text></tag><text font="italic" fontsize="80%">This is another figure</text></caption>
</figure>
<break class="ltx_centering"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to remember if the trailing break was helpful for the flexbox layout to have a clear end... Would need to look at tests, but dropping it is probably fine. The intermediate breaks are the important ones.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, I've generally been trying to avoid introducing the breaks if I can, particularly in a block situation where things should be vertically stacked anyway.

@@ -1970,7 +1970,7 @@ sub renameNode {
my $key = $attr->getName;
my $value = $node->getAttribute($key);
$id = $value if $key eq 'xml:id'; # Save to register after removal of old node.
$new->setAttribute($key, $value); }
$new->setAttribute($key, $value) if $model->canHaveAttribute($newname, $key); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we emit an Info message if an attribute gets dropped here? I wonder if it may aid some future debugging session.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, yeah maybe, but probably just a lot of noise?

@@ -111,7 +111,7 @@ grammar {
common.attrs.aria.implicit.link = empty
SVG.Core.extra.attrib &= parent svgForeign.attributes
include "svg11.rnc"
{ SVG.foreignObject.content = parent Flow.model
{ SVG.foreignObject.content = parent Inline.model
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud: Right, so the idea for switching to Inline.model is to leverage ltx:inline-block (or similar) auto-opening.

I think that would benefit from a schema comment - since the HTML+SVG spec and TeX would both permit pretty much any layout-oriented content in those nodes (e.g. a table, a citation, a math formula, but not a section or a bibliography). I think it would be helpful for the schema to document that, and mention the inline-block mechanism as the intended carrier for the effect.

I guess the alternative was to start as block-level and auto-open nodes that can hold Inline content?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certain TeX does, which is the issue; HTML sorta does, but when you start getting p in peculiar places, it has undesirable effects that can be papered over with CSS, but it gets complex & error-prone. So it's basically the same rationale for changing td content model to Inline.

In this recent set of changes, I'm finding Flow model kinda annoying for that reason. It probably contributes to the confusion dealing with figure & graphic layout since you're never quite sure what you're getting.

@brucemiller brucemiller changed the title [WiP] Block consistency Block consistency Dec 21, 2023
Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No further comments, excited to merge and rebase my subfigure work over.

@brucemiller brucemiller merged commit e3e4845 into master Dec 22, 2023
26 checks passed
@brucemiller brucemiller deleted the block-consistency branch December 22, 2023 00:13
@dginev
Copy link
Collaborator

dginev commented Dec 23, 2023

I just got a private email inquiring about some details of LaTeXML's schema and I realized I forgot to suggest a post-merge step:

@brucemiller Could you please regenerate the schema docs at the online manual? The current schema page mentions it was last generated December, 2022.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants