Skip to content

Commit

Permalink
support cap-location in custom crossrefs, use it correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Nov 17, 2023
1 parent 1c48e03 commit 677f29f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 39 deletions.
29 changes: 17 additions & 12 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12251,6 +12251,15 @@ var require_yaml_intelligence_resources = __commonJS({
string: {
description: 'The description of the crossreferenceable object to be used in the title of the "list of" command. If unspecified, the field `name` is used.'
}
},
"cap-location": {
enum: [
"top",
"bottom",
"margin"
],
default: "bottom",
description: "The location of the caption relative to the crossreferenceable content."
}
}
}
Expand Down Expand Up @@ -20807,6 +20816,10 @@ var require_yaml_intelligence_resources = __commonJS({
short: "The math font options for use with <code>xelatex</code> or\n<code>lualatex</code>.",
long: 'The math font options for use with <code>xelatex</code> or\n<code>lualatex</code> allowing any options available through <a href="https://ctan.org/pkg/fontspec"><code>fontspec</code></a>.'
},
{
short: "Adds additional directories to search for fonts when compiling with\nTypst.",
long: "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
},
{
short: "The CJK font options for use with <code>xelatex</code> or\n<code>lualatex</code>.",
long: 'The CJK font options for use with <code>xelatex</code> or\n<code>lualatex</code> allowing any options available through <a href="https://ctan.org/pkg/fontspec"><code>fontspec</code></a>.'
Expand Down Expand Up @@ -21290,10 +21303,6 @@ var require_yaml_intelligence_resources = __commonJS({
short: "The mode to use when previewing this document.",
long: "The mode to use when previewing this document. To disable any special\npreviewing features, pass <code>raw</code> as the preview-mode."
},
{
short: "Adds additional directories to search for fonts when compiling with\nTypst.",
long: "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
},
{
short: "Adds the necessary setup to the document preamble to generate PDF/A\nof the type specified.",
long: 'Adds the necessary setup to the document preamble to generate PDF/A\nof the type specified.\nIf the value is set to <code>true</code>, <code>1b:2005</code> will\nbe used as default.\nTo successfully generate PDF/A the required ICC color profiles have\nto be available and the content and all included files (such as images)\nhave to be standard conforming. The ICC profiles and output intent may\nbe specified using the variables <code>pdfaiccprofile</code> and\n<code>pdfaintent</code>. See also <a href="https://wiki.contextgarden.net/PDF/A">ConTeXt PDFA</a> for more\ndetails.'
Expand Down Expand Up @@ -22245,11 +22254,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",
{
short: "Adds additional directories to search for fonts when compiling with\nTypst.",
long: "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
}
"internal-schema-hack"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -22473,12 +22478,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 178550,
_internalId: 178553,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 178542,
_internalId: 178545,
type: "enum",
enum: [
"png",
Expand All @@ -22494,7 +22499,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 178549,
_internalId: 178552,
type: "anyOf",
anyOf: [
{
Expand Down
29 changes: 17 additions & 12 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.

29 changes: 17 additions & 12 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5223,6 +5223,15 @@
"string": {
"description": "The description of the crossreferenceable object to be used in the title of the \"list of\" command. If unspecified, the field `name` is used."
}
},
"cap-location": {
"enum": [
"top",
"bottom",
"margin"
],
"default": "bottom",
"description": "The location of the caption relative to the crossreferenceable content."
}
}
}
Expand Down Expand Up @@ -13779,6 +13788,10 @@
"short": "The math font options for use with <code>xelatex</code> or\n<code>lualatex</code>.",
"long": "The math font options for use with <code>xelatex</code> or\n<code>lualatex</code> allowing any options available through <a href=\"https://ctan.org/pkg/fontspec\"><code>fontspec</code></a>."
},
{
"short": "Adds additional directories to search for fonts when compiling with\nTypst.",
"long": "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
},
{
"short": "The CJK font options for use with <code>xelatex</code> or\n<code>lualatex</code>.",
"long": "The CJK font options for use with <code>xelatex</code> or\n<code>lualatex</code> allowing any options available through <a href=\"https://ctan.org/pkg/fontspec\"><code>fontspec</code></a>."
Expand Down Expand Up @@ -14262,10 +14275,6 @@
"short": "The mode to use when previewing this document.",
"long": "The mode to use when previewing this document. To disable any special\npreviewing features, pass <code>raw</code> as the preview-mode."
},
{
"short": "Adds additional directories to search for fonts when compiling with\nTypst.",
"long": "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
},
{
"short": "Adds the necessary setup to the document preamble to generate PDF/A\nof the type specified.",
"long": "Adds the necessary setup to the document preamble to generate PDF/A\nof the type specified.\nIf the value is set to <code>true</code>, <code>1b:2005</code> will\nbe used as default.\nTo successfully generate PDF/A the required ICC color profiles have\nto be available and the content and all included files (such as images)\nhave to be standard conforming. The ICC profiles and output intent may\nbe specified using the variables <code>pdfaiccprofile</code> and\n<code>pdfaintent</code>. See also <a href=\"https://wiki.contextgarden.net/PDF/A\">ConTeXt PDFA</a> for more\ndetails."
Expand Down Expand Up @@ -15217,11 +15226,7 @@
},
"Disambiguating year suffix in author-date styles (e.g.&nbsp;“a” in “Doe,\n1999a”).",
"Manuscript configuration",
"internal-schema-hack",
{
"short": "Adds additional directories to search for fonts when compiling with\nTypst.",
"long": "Locally, Typst uses installed system fonts. In addition, some custom\npath can be specified to add directories that should be scanned for\nfonts. Setting this configuration will take precedence over any path set\nin TYPST_FONT_PATHS environment variable."
}
"internal-schema-hack"
],
"schema/external-schemas.yml": [
{
Expand Down Expand Up @@ -15445,12 +15450,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 178550,
"_internalId": 178553,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 178542,
"_internalId": 178545,
"type": "enum",
"enum": [
"png",
Expand All @@ -15466,7 +15471,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 178549,
"_internalId": 178552,
"type": "anyOf",
"anyOf": [
{
Expand Down
10 changes: 7 additions & 3 deletions src/resources/filters/crossref/custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ function initialize_custom_crossref_categories(meta)
["ref-type"] = function(v) return pandoc.utils.stringify(v) end,
["latex-env"] = function(v) return pandoc.utils.stringify(v) end,
["latex-list-of-file-extension"] = function(v) return pandoc.utils.stringify(v) end,
["cap-location"] = function(v) return pandoc.utils.stringify(v) end,
["latex-list-of-description"] = function(v) return pandoc.utils.stringify(v) end,
["space-before-numbering"] = function(v) return v end,
}
local obj_mapping = {
["default-caption-location"] = "default_caption_location",
["latex-env"] = "latex_env",
["latex-list-of-file-extension"] = "latex_list_of_file_extension",
["cap-location"] = "cap_location",
["latex-list-of-description"] = "latex_list_of_description",
["ref-type"] = "ref_type",
["space-before-numbering"] = "space_before_numbering",
Expand Down Expand Up @@ -71,13 +73,11 @@ function initialize_custom_crossref_categories(meta)
local ref_type = entry["ref-type"]
local list_of_name = entry["latex-list-of-file-extension"] or ("lo" .. ref_type)
local list_of_description = entry["latex-list-of-description"] or name
local cap_location = entry["cap-location"] or "bottom"
local space_before_numbering = entry["space-before-numbering"]
if space_before_numbering == nil then
space_before_numbering = true
end

-- FIXME do we need different "lop" extensions for each category?
-- we should be able to test this by creating a document with listings and diagrams

inject(
usePackage("float") .. "\n" ..
Expand All @@ -86,6 +86,10 @@ function initialize_custom_crossref_categories(meta)
"\\floatname{".. env_name .. "}{" .. as_latex(title(ref_type, env_prefix)) .. "}\n"
)

if cap_location == "top" then
inject("\\floatstyle{plaintop}\n\\restylefloat{" .. env_name .. "}\n")
end

-- FIXME this is a bit of hack for the case of custom categories with
-- space-before-numbering: false
--
Expand Down
4 changes: 4 additions & 0 deletions src/resources/schema/document-crossref.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
latex-list-of-description:
string:
description: The description of the crossreferenceable object to be used in the title of the "list of" command. If unspecified, the field `name` is used.
cap-location:
enum: [top, bottom, margin]
default: bottom
description: The location of the caption relative to the crossreferenceable content.

chapters:
boolean:
Expand Down

0 comments on commit 677f29f

Please sign in to comment.