Skip to content

Commit

Permalink
Merge pull request #6181 from quarto-dev/feature/email-extension
Browse files Browse the repository at this point in the history
Email extension for Quarto
  • Loading branch information
dragonstyle authored Oct 19, 2023
2 parents 7fba83a + 05b36f8 commit dd60f8c
Show file tree
Hide file tree
Showing 11 changed files with 478 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/command/capabilities/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async function formats() {
"revealjs",
"gfm",
"epub",
"email",
];

const excludedFormats = [
Expand Down
1 change: 1 addition & 0 deletions src/core/lib/yaml-schema/front-matter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function makeFrontMatterFormatSchema(nonStrict = false) {
const formatSchemaDescriptorList = (await pandocFormatsResource()).concat(
"md", // alias for 'commonmark'
"hugo", // tolerage for compatibility: initially built-in, now referrred to as 'hugo-md'
"email", // for the HTML email format (used with Posit Connect)
)
.map(
(format) => {
Expand Down
7 changes: 7 additions & 0 deletions src/core/pandoc/pandoc-formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const parseFormatString = (formatStr: string): FormatDescriptor => {
// Static container to hang on to aliases once they've been read once
class FormatAliases {
static pandoc: string[];
static custom: string[];
}

function ensureFormats() {
Expand All @@ -178,6 +179,11 @@ function ensureFormats() {
] as string[];
FormatAliases.pandoc = pandocFormats;
}

// Custom build in aliases
if (!FormatAliases.custom) {
FormatAliases.custom = ["email"];
}
}

export function pandocBuiltInFormats() {
Expand All @@ -189,6 +195,7 @@ function isBuiltInFormat(format: string) {
// Allow either a built in format or a path to a LUA file
ensureFormats();
return FormatAliases.pandoc.includes(format) ||
FormatAliases.custom.includes(format) ||
extname(format) === ".lua";
}

Expand Down
19 changes: 19 additions & 0 deletions src/format/email/format-email.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { mergeConfigs } from "../../core/config.ts";
import { registerWriterFormatHandler } from "../format-handlers.ts";
import { htmlFormat } from "../html/format-html.ts";

export function emailFormat() {
return mergeConfigs(
htmlFormat(7, 5),
);
}

registerWriterFormatHandler((format) => {
switch (format) {
case "email":
return {
format: emailFormat(),
pandocTo: "html",
};
}
});
1 change: 1 addition & 0 deletions src/format/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
import "./html/format-html.ts";
import "./reveal/format-reveal.ts";
import "./asciidoc/format-asciidoc.ts";
import "./email/format-email.ts";
14 changes: 8 additions & 6 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20158,6 +20158,7 @@ var require_yaml_intelligence_resources = __commonJS({
short: "Apply explicit table column widths",
long: "Apply explicit table column widths for markdown grid tables and pipe\ntables that are more than <code>columns</code> characters wide (72 by\ndefault).\nSome formats (e.g.&nbsp;HTML) do an excellent job automatically sizing\ntable columns and so don\u2019t benefit much from column width\nspecifications. Other formats (e.g.&nbsp;LaTeX) require table column sizes in\norder to correctly flow longer cell content (this is a major reason why\ntables &gt; 72 columns wide are assigned explicit widths by Pandoc).\nThis can be specified as:"
},
"If <code>none</code>, do not process raw HTML table in cell output\nand leave it as-is",
{
short: "Include the results of executing the code in the output (specify\n<code>asis</code> to treat output as raw markdown with no enclosing\ncontainers).",
long: "Include the results of executing the code in the output. Possible\nvalues:"
Expand Down Expand Up @@ -21927,8 +21928,7 @@ var require_yaml_intelligence_resources = __commonJS({
},
"Disambiguating year suffix in author-date styles (e.g.&nbsp;\u201Ca\u201D in \u201CDoe,\n1999a\u201D).",
"Manuscript configuration",
"internal-schema-hack",
"If <code>none</code>, do not process raw HTML table in cell output\nand leave it as-is"
"internal-schema-hack"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -22152,12 +22152,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 168429,
_internalId: 171001,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 168421,
_internalId: 170993,
type: "enum",
enum: [
"png",
Expand All @@ -22173,7 +22173,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 168428,
_internalId: 171e3,
type: "anyOf",
anyOf: [
{
Expand Down Expand Up @@ -31703,8 +31703,10 @@ async function makeFrontMatterFormatSchema(nonStrict = false) {
const formatSchemaDescriptorList = (await pandocFormatsResource()).concat(
"md",
// alias for 'commonmark'
"hugo"
"hugo",
// tolerage for compatibility: initially built-in, now referrred to as 'hugo-md'
"email"
// for the HTML email format (used with Posit Connect)
).map(
(format) => {
const {
Expand Down
14 changes: 8 additions & 6 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -13130,6 +13130,7 @@
"short": "Apply explicit table column widths",
"long": "Apply explicit table column widths for markdown grid tables and pipe\ntables that are more than <code>columns</code> characters wide (72 by\ndefault).\nSome formats (e.g.&nbsp;HTML) do an excellent job automatically sizing\ntable columns and so don’t benefit much from column width\nspecifications. Other formats (e.g.&nbsp;LaTeX) require table column sizes in\norder to correctly flow longer cell content (this is a major reason why\ntables &gt; 72 columns wide are assigned explicit widths by Pandoc).\nThis can be specified as:"
},
"If <code>none</code>, do not process raw HTML table in cell output\nand leave it as-is",
{
"short": "Include the results of executing the code in the output (specify\n<code>asis</code> to treat output as raw markdown with no enclosing\ncontainers).",
"long": "Include the results of executing the code in the output. Possible\nvalues:"
Expand Down Expand Up @@ -14899,8 +14900,7 @@
},
"Disambiguating year suffix in author-date styles (e.g.&nbsp;“a” in “Doe,\n1999a”).",
"Manuscript configuration",
"internal-schema-hack",
"If <code>none</code>, do not process raw HTML table in cell output\nand leave it as-is"
"internal-schema-hack"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -15124,12 +15124,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 168429,
"_internalId": 171001,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 168421,
"_internalId": 170993,
"type": "enum",
"enum": [
"png",
Expand All @@ -15145,7 +15145,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 168428,
"_internalId": 171000,
"type": "anyOf",
"anyOf": [
{
Expand Down
2 changes: 2 additions & 0 deletions src/resources/filters/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import("./quarto-post/cellcleanup.lua")
import("./quarto-post/bibliography.lua")
import("./quarto-post/code.lua")
import("./quarto-post/html.lua")
import("./quarto-post/email.lua")

import("./quarto-finalize/dependencies.lua")
import("./quarto-finalize/book-cleanup.lua")
Expand Down Expand Up @@ -344,6 +345,7 @@ local quarto_post_filters = {
{ name = "post-render-html-fixups", filter = render_html_fixups() },
{ name = "post-render-ipynb-fixups", filter = render_ipynb_fixups() },
{ name = "post-render-typst-fixups", filter = render_typst_fixups() },
{ name = "post-render-email", filter = render_email() },
}

local quarto_finalize_filters = {
Expand Down
Loading

0 comments on commit dd60f8c

Please sign in to comment.