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

General lua improvements #11526

Merged
merged 5 commits into from
Dec 9, 2024
Merged

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Nov 25, 2024

Description

Improve some general Lua functions.

@tarleb tarleb requested a review from cscheid November 25, 2024 11:38
@tarleb tarleb force-pushed the general-lua-improvements branch 6 times, most recently from fe712ce to 2d7ef41 Compare November 26, 2024 10:28
@@ -1,6 +1,10 @@
-- _utils.lua
-- Copyright (C) 2020-2022 Posit Software, PBC

--- The pandoc module. Imported to avoid 'no such variable'
--- warnings in some editors.
local pandoc = require 'pandoc'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be careful with require() because of https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/pandoc/datadir/init.lua#L1403

I'm not sure I want to add it to this PR...

Copy link
Collaborator

@cscheid cscheid left a comment

Choose a reason for hiding this comment

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

Let's remove that potentially risky local pandoc = require('pandoc'). But, aside from it, this looks great, thanks!

@tarleb tarleb force-pushed the general-lua-improvements branch from 2d7ef41 to 4274ec0 Compare November 26, 2024 17:18
@cscheid
Copy link
Collaborator

cscheid commented Nov 26, 2024

Great, thanks! We can talk about require() and IDE support on our next eng meeting.

@cscheid
Copy link
Collaborator

cscheid commented Nov 26, 2024

One final thing. quarto is the public Lua API, so we should add something to the 1.7 changelog about quarto.utils.is_empty_node

@tarleb
Copy link
Collaborator Author

tarleb commented Nov 26, 2024

Oh, in that case we might also want to redefine that function to be more robust.

Also maybe it should only check whether there is any text in the node?

@cscheid
Copy link
Collaborator

cscheid commented Nov 26, 2024

I'm wary of overdesigning it without a concrete reason to. "More robust" isn't as actionable as "robust with respect to xyz" - what scenario do you have in mind?

@tarleb
Copy link
Collaborator Author

tarleb commented Nov 27, 2024

No, you're right. The suggested alternative wouldn't even work. I think the original version is fine.

@tarleb tarleb force-pushed the general-lua-improvements branch from 4274ec0 to 4a329c7 Compare November 27, 2024 14:08
@tarleb tarleb force-pushed the general-lua-improvements branch from 4a329c7 to d4b084d Compare December 6, 2024 16:12
This behaves mostly like the built-in `assert`, but respects the general
Quarto scaffolding.
This also fixes unwanted behavior of `as_blocks`, which would treat a
list of Inline elements as a list of singleton Plain elements, leading
to bad results.
@tarleb tarleb force-pushed the general-lua-improvements branch from d4b084d to a347bc1 Compare December 6, 2024 16:47
@tarleb
Copy link
Collaborator Author

tarleb commented Dec 6, 2024

Should be good to merge now.

@tarleb tarleb merged commit b4ce69d into quarto-dev:main Dec 9, 2024
47 checks passed
@tarleb tarleb deleted the general-lua-improvements branch December 9, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants