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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

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!

@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.

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.
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