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

Visual editor doesn't recognize formats starting with live- #546

Open
mine-cetinkaya-rundel opened this issue Sep 18, 2024 · 2 comments
Open
Assignees

Comments

@mine-cetinkaya-rundel
Copy link
Contributor

For using the visual editor with live-* formats (using quarto-live), the visual editor doesn't have the same features as those for the * format.

For example, inserting columns into slides:

  • format: revealjs
Screenshot 2024-09-18 at 11 19 00 AM
  • format: live-revealjs
Screenshot 2024-09-18 at 11 19 15 AM
@cscheid cscheid self-assigned this Sep 18, 2024
@cderv
Copy link
Contributor

cderv commented Sep 18, 2024

I was just curious to learn how we did detection.

// detect reveal document
const formats: string[] = [];
if (isQuartoRevealDoc(code)) {
formats.push("revealjs");
}
if (isQuartoDashboardDoc(code)) {
formats.push("dashboard");
}

const kRegExYAML =
/(^)(---[ \t]*[\r\n]+(?![ \t]*[\r\n]+)[\W\w]*?[\r\n]+(?:---|\.\.\.))([ \t]*)$/gm;
export function isQuartoDocWithFormat(doc: Document | string, format: string) {
if (typeof(doc) !== "string") {
if (isQuartoDoc(doc)) {
doc = doc.getText();
} else {
return false;
}
}
if (doc) {
const match = doc.match(kRegExYAML);
if (match) {
const yaml = match[0];
return (
!!yaml.match(new RegExp("^format:\\s+" + format + "\\s*$","gm")) ||
!!yaml.match(new RegExp("^[ \\t]*" + format + ":\\s*(default)?\\s*$", "gm"))
);
}
}
return false;
}
export function isQuartoRevealDoc(doc: Document | string) {
return isQuartoDocWithFormat(doc, "revealjs");
}

Our regex will be something like ^format:\s+revealjs\s*$ so it will indeed not catch live-revealjs

Thanks for catching this !

We probably need to teach the extension about our format specification in Quarto parseFormatString() if we want to cover all the possible cases !

@cscheid
Copy link
Contributor

cscheid commented Sep 18, 2024

We probably need to teach the extension about our format specification in Quarto parseFormatString() if we want to cover all the possible cases !

That's exactly what I was thinking. Ideally, the extension would be using the FormatDescription type here instead of a string, and using the same code.

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

No branches or pull requests

3 participants