-
Notifications
You must be signed in to change notification settings - Fork 402
feat: Support rendering multiple emails #13882
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
Draft
juleswg23
wants to merge
14
commits into
quarto-dev:main
Choose a base branch
from
juleswg23:email-multiple-emails
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+634
−155
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
753a0e6
first pass multiple email filter
juleswg23 4d4f495
change v1 trigger to the existence of top level metadata
juleswg23 b3f8c49
Merge branch 'quarto-dev:main' into email-multiple-emails
juleswg23 5c2b817
sniff for connect version
juleswg23 8315c78
refactor connect verison logic
juleswg23 ee6cc47
ensure v1 email previewing
juleswg23 b1c2465
update tests
juleswg23 0ff82b0
test with divs outside of the email div
juleswg23 cec0120
rename email-subject-document-level.qmd
juleswg23 dee3ad4
re-factor to enforce v1 output with non-nested structured input
juleswg23 abcf29e
remove logs and some warnings
juleswg23 8f49292
add multi-email tests
juleswg23 9599c57
resolve bug with conflicting email-scheduled fields
juleswg23 d792ad1
import connectversion module as object
juleswg23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --[[ | ||
| Connect version sniffing utilities for email extension | ||
|
|
||
| Functions to detect and compare Posit Connect versions from environment variables | ||
| ]] | ||
|
|
||
| -- Parse Connect version from SPARK_CONNECT_USER_AGENT | ||
| -- Format: posit-connect/2024.09.0 | ||
| -- posit-connect/2024.09.0-dev+26-dirty-g51b853f70e | ||
| -- Returns: "2024.09.0" or nil | ||
| function get_connect_version() | ||
| local user_agent = os.getenv("SPARK_CONNECT_USER_AGENT") | ||
| if not user_agent then | ||
| return nil | ||
| end | ||
|
|
||
| -- Extract the version after "posit-connect/" | ||
| local version_with_suffix = string.match(user_agent, "posit%-connect/([%d%.%-+a-z]+)") | ||
| if not version_with_suffix then | ||
| return nil | ||
| end | ||
|
|
||
| -- Strip everything after the first "-" (e.g., "-dev+88-gda902918eb") | ||
| local idx = string.find(version_with_suffix, "-") | ||
| if idx then | ||
| return string.sub(version_with_suffix, 1, idx - 1) | ||
| end | ||
|
|
||
| return version_with_suffix | ||
| end | ||
|
|
||
| -- Parse a version string into components | ||
| -- Versions are in format "X.Y.Z", with all integral components (e.g., "2025.11.0") | ||
| -- Returns: {major=2025, minor=11, patch=0} or nil | ||
| function parse_version_components(version_string) | ||
| if not version_string then | ||
| return nil | ||
| end | ||
|
|
||
| -- Parse version (e.g., "2025.11.0" or "2025.11") | ||
| local major, minor, patch = string.match(version_string, "^(%d+)%.(%d+)%.?(%d*)$") | ||
| if not major then | ||
| return nil | ||
| end | ||
|
|
||
| return { | ||
| major = tonumber(major), | ||
| minor = tonumber(minor), | ||
| patch = patch ~= "" and tonumber(patch) or 0 | ||
| } | ||
| end | ||
|
|
||
| -- Check if Connect version is >= target version | ||
| -- Versions are in format "YYYY.MM.patch" (e.g., "2025.11.0") | ||
| function is_connect_version_at_least(target_version) | ||
| local current_version = get_connect_version() | ||
| local current = parse_version_components(current_version) | ||
| local target = parse_version_components(target_version) | ||
|
|
||
| if not current or not target then | ||
| return false | ||
| end | ||
|
|
||
| -- Convert to numeric YYYYMMPP format and compare | ||
| local current_num = current.major * 10000 + current.minor * 100 + current.patch | ||
| local target_num = target.major * 10000 + target.minor * 100 + target.patch | ||
|
|
||
| return current_num >= target_num | ||
| end | ||
|
|
||
| -- Export functions for module usage | ||
| return { | ||
| is_connect_version_at_least = is_connect_version_at_least | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any obvious tests for the files around here, but this kind of logic would be lovely to have tests for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hacky solution was to pass in different mock environments to the rendering tests, since the rendered output is conditioned on the environment quarto is in.
https://github.com/quarto-dev/quarto-cli/pull/13882/files#diff-38d1762233fec375a94fb002d3b59de5322b5a1b7d23fbad65c3c2a04f8f256fR128-R130
As far as I can tell, modules like this one don't have their own unit tests in this repo, but I could also be missing them somewhere.