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

Command cascades should build an AST instead of functions #80

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

Omikhleia
Copy link
Owner

@Omikhleia Omikhleia commented Jul 11, 2023

Kind of an edge case, but this may happen more easily when using resilient and its style paradigm: Span expansion (in a possible cascade of styling) used the (equivalent of the) SILE.call("...", ..., function() ... end) programming paradigm.
This does cause an issue actually when some low-level commands there involve input filters or anything working directly on the text element in an AST content (text casing, sub/superscript faking, etc.)

Easy way to cause the issue:

This is [super ==script==]{ custom-style=textsuperscript }

If using such function calls, this either fails with an error (because textsuperscript assumes an AST content, not a function) or doesn't do the expected things anyway.
On the other hand, it does work if we use the SILE.call("...", ..., { ... }) programming paradigm, i.e build an AST equivalent of what we would have done in the functional approach.

Another way (naive):

Bad:

SILE.call("uppercase", {}, function ()
  SILE.call("font", { style="italic" }, content)
end)

Good (ie. working... but is is so good?)

SILE.call("uppercase", {}, {
  utils.createStructuredCommand("font", { style="italic" }, utils.subTreeContent(content))
})

@Omikhleia Omikhleia self-assigned this Jul 11, 2023
@Omikhleia Omikhleia added bug Something isn't working refactor Something needs to be refactored labels Jul 11, 2023
@Omikhleia Omikhleia changed the title refactor: command cascades should build an AST instead of functions Command cascades should build an AST instead of functions Jul 11, 2023
@Omikhleia Omikhleia merged commit f9ba0ab into main Jul 11, 2023
@Omikhleia Omikhleia deleted the refactor-styles-cascade branch July 11, 2023 08:16
Omikhleia added a commit to Omikhleia/resilient.sile that referenced this pull request Jul 11, 2023
For case and sub/superscript to work better recursing the AST.
That's quite a change in coding paradigm...
See also Omikhleia/markdown.sile#80
@Omikhleia Omikhleia added this to the 1.4.0 milestone Jul 12, 2023
Omikhleia added a commit to Omikhleia/resilient.sile that referenced this pull request Aug 4, 2023
For case and sub/superscript to work better recursing the AST.
That's quite a change in coding paradigm...
See also Omikhleia/markdown.sile#80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor Something needs to be refactored
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant