diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58bd57c567..02708cc7cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,13 @@ # Copyright 2018-2024 The Khronos Group Inc. -# # SPDX-License-Identifier: Apache-2.0 # Gitlab CI file for vulkan spec and header generation # All stages use the same Docker image, so there are no prerequisites -# We now refer to the container by its SHA instead of the name, to prevent +# Refer to the container by its SHA instead of the name, to prevent # caching problems when updating the image. # image: khronosgroup/docker-images:asciidoctor-spec -image: khronosgroup/docker-images@sha256:42123ba13792c4e809d037b69152c2230ad97fbf43b677338075ab9c928ab6ed +image: khronosgroup/docker-images@sha256:91a1b62399f9804e17110e89d85d62e90bc8d2ad7b94a329bee87784158368a9 # Specify which gitlab runner to use default: diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 751cd71908..d0bd71f2c2 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -14,6 +14,44 @@ appears frequently in the change log. ''' +Change log for June 28, 2024 Vulkan 1.3.289 spec update: + +Internal Issues + + * Add missing zero binding vkUpdateDescriptorSets VU (internal issue + 3890). + * Remove vkCmdBuildAccelerationStructuresKHR VU 03770 (and variants), + which are not needed by implementations (internal issue 3896). + * Fix extensionmetadocgenerator so missing APIs from some extension + interactions are shown in the generated interfaces section (internal + issue 3907). + * Fix typo in VkVideoEncodeH265RateControlInfoKHR (temporalLayerCount -> + subLayerCount) (internal MR 6712). + * Fix typo in VK_QCOM_fragment_density_map_offset regarding + fragmentDensityMapOffset feature (internal MR 6727). + * Improve and combine many vkCmdDraw VUs to properly test in the presence + of dynamic state that must have been set, and not subsequently + invalidated. This batch of changes primarily affects dynamic state with + graphics pipelines (internal MRs 6345, 6653, 6654, 6683, 6721, 6722, + 6723, 6724). + * Add vkCmdSetDepthBoundsTestEnable VU for depthBounds feature (internal + MR 6715). + * Mark VK_KHR_shader_relaxed_extended_instruction as ratified, which was + overlooked when initially released (internal MR 6717). + * Clarify interactions between the VK_ARM_render_pass_striped extension + and render pass suspend resume (internal MR 6734). + * Allow VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT to be used with + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT, + reserving a descriptor set slot when using DebugPrintF in the validation + layers (internal MR 6744). + * Update the bundled KaTeX distribution to 0.16.10 (internal MR 6746). + +New Extensions + + * VK_KHR_maintenance7 + +''' + Change log for June 14, 2024 Vulkan 1.3.288 spec update: Public Issues diff --git a/ChangeLogSC.adoc b/ChangeLogSC.adoc index 7bef546a0c..e9fcf3cb43 100644 --- a/ChangeLogSC.adoc +++ b/ChangeLogSC.adoc @@ -12,6 +12,42 @@ with any public pull requests that have been accepted. ----------------------------------------------------- +Change log for June 17, 2023 Vulkan SC 1.0.15 spec update: + + * update release number to 15 for this update and reflow spec language + +Public issues: + + * None + +Internal issues: + + * Merge VK 1.3.274 tag to sc_main (!362) + * Merge 2024 copyright fixes to sc_main (!365) + * Update memory reservation common validity to support extension object + types (!363) + * Merge VK 1.3.278 tag to sc_main (!369) + * Make pipeline cache data alignment requirements + implementation-specific (#212/!366) + * Include shader module VUs for completeness (#214/!368) + * Merge VK 1.3.281 tag to sc_main (!370) + * Add extension processing script (!367) + * Enable winrt acquire display extension for Vulkan SC (!372) + * Merge VK 1.3.286 tag to sc_main (!375) + * Record new Vulkan SC ratified extensions (!376) + * Various fixes for auto-generated vulkan_json_parser.hpp (!374) + +New Extensions: + + * apiext:VK_NV_acquire_winrt_display (!372) + * apiext:VK_KHR_calibrated_timestamps (replaces VK_EXT_calibrated_timestamps) + * apiext:VK_KHR_global_priority (replaces VK_EXT_global_priority) + * apiext:VK_KHR_vertex_attribute_divisor (replaces VK_EXT_vertex_attribute_divisor) + * apiext:VK_KHR_index_type_uint8 + * apiext:VK_KHR_line_rasterization + +----------------------------------------------------- + Change log for December 15, 2023 Vulkan SC 1.0.14 spec update: * update release number to 14 for this update and reflow spec language diff --git a/Makefile b/Makefile index 9c7861a743..1b07c6e397 100644 --- a/Makefile +++ b/Makefile @@ -138,12 +138,12 @@ VERBOSE = # ADOCOPTS options for asciidoc->HTML5 output NOTEOPTS = -a editing-notes -a implementation-guide -PATCHVERSION = 288 +PATCHVERSION = 289 BASEOPTS = ifneq (,$(findstring VKSC_VERSION_1_0,$(VERSIONS))) VKSPECREVISION := 1.2.$(PATCHVERSION) -SCPATCHVERSION = 14 +SCPATCHVERSION = 15 SPECREVISION = 1.0.$(SCPATCHVERSION) BASEOPTS = -a baserevnumber="$(VKSPECREVISION)" else @@ -512,11 +512,11 @@ check-consistency: check-undefined: $(SCRIPTS)/ci/check_undefined -# Look for '.txt' files, which should almost all be .adoc now -CHECK_TXTFILES = find . -name '*.txt' | egrep -v -E -f $(ROOTDIR)/config/CI/txt-files-allowed +# Look for '.txt' and '.asciidoc' files, which should almost all be .adoc now +CHECK_TXTFILES = find . -name '*.txt' -o -name '*.asciidoc' | egrep -v -E -f $(ROOTDIR)/config/CI/txt-files-allowed check-txtfiles: if test `$(CHECK_TXTFILES) | wc -l` != 0 ; then \ - echo "*.txt files found that are not allowed (use .adoc):" ; \ + echo "*.txt and/or .asciidoc files found that are not allowed (use .adoc):" ; \ $(CHECK_TXTFILES) ; \ exit 1 ; \ fi diff --git a/appendices/VK_KHR_maintenance7.adoc b/appendices/VK_KHR_maintenance7.adoc new file mode 100644 index 0000000000..7680d56775 --- /dev/null +++ b/appendices/VK_KHR_maintenance7.adoc @@ -0,0 +1,65 @@ +// Copyright 2024 The Khronos Group Inc. +// SPDX-License-Identifier: CC-BY-4.0 + +include::{generated}/meta/{refprefix}VK_KHR_maintenance7.adoc[] + +=== Other Extension Metadata + +*Last Modified Date*:: + 2024-01-30 + +*Interactions and External Dependencies*:: + +*Contributors*:: + - Mike Blumenkrantz, Valve + - Hans-Kristian Arntzen, Valve + - Pan Gao, Huawei + - Tobias Hector, AMD + - Jon Leech, Khronos + - Daniel Story, Nintendo + - Shahbaz Youssefi, Google + - Yiwei Zhang, Google + - Matthew Netsch, Qualcomm + +=== Description + +apiext:VK_KHR_maintenance7 adds a collection of minor features, none of +which would warrant an entire extension of their own. + +The proposed new features are as follows: + + * Add a property query to determine if a framebuffer writes to depth or + stencil aspect does not trigger a write access in the sibling aspect. + For example, this allows sampling stencil aspect as a texture while + rendering to the sibling depth attachment and vice-versa given + appropriate image layouts. + * Add a way to query information regarding the underlying devices in + environments where the Vulkan implementation is provided through layered + implementations. + For example, running on Mesa/Venus, driver ID is returned as + ename:VK_DRIVER_ID_MESA_VENUS, but it can be necessary to know what the + real driver under the hood is. + The new slink:VkPhysicalDeviceLayeredApiPropertiesKHR structure can be + used to gather information regarding layers underneath the top-level + physical device. + * Promote ename:VK_RENDERING_CONTENTS_INLINE_BIT_EXT and + ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT to + KHR + * Add a limit to report the maximum total count of dynamic uniform buffers + and dynamic storage buffers that can be included in a pipeline layout. + * Require that for an unsigned integer query, the 32-bit result value + must: be equal to the 32 least significant bits of the equivalent 64-bit + result value. + * Add query for robust access support when using fragment shading rate + attachments + +include::{generated}/interfaces/VK_KHR_maintenance7.adoc[] + +=== Issues + +None. + +=== Version History + + * Revision 1, 2024-01-30 (Jon Leech) + ** Initial revision diff --git a/appendices/VK_QCOM_fragment_density_map_offset.adoc b/appendices/VK_QCOM_fragment_density_map_offset.adoc index a1c4605505..e4e389a1dd 100644 --- a/appendices/VK_QCOM_fragment_density_map_offset.adoc +++ b/appendices/VK_QCOM_fragment_density_map_offset.adoc @@ -7,12 +7,13 @@ include::{generated}/meta/{refprefix}VK_QCOM_fragment_density_map_offset.adoc[] === Other Extension Metadata *Last Modified Date*:: - 2021-09-03 + 2024-06-17 *Contributors*:: - Matthew Netsch, Qualcomm Technologies, Inc. - Jonathan Wicks, Qualcomm Technologies, Inc. - Jonathan Tinkham, Qualcomm Technologies, Inc. - Jeff Leger, Qualcomm Technologies, Inc. + - Manan Katwala, Qualcomm Technologies, Inc. === Description @@ -96,6 +97,8 @@ endif::isrefpage[] === Version History + * Revision 2, 2024-06-17 (Matthew Netsch) + ** Fix typo in spec regarding fragmentDensityMapOffset feature * Revision 1, 2021-09-03 (Matthew Netsch) ** Initial version diff --git a/chapters/VK_EXT_validation_features.adoc b/chapters/VK_EXT_validation_features.adoc index 6443aaad59..96049d1c14 100644 --- a/chapters/VK_EXT_validation_features.adoc +++ b/chapters/VK_EXT_validation_features.adoc @@ -30,7 +30,8 @@ include::{generated}/api/structs/VkValidationFeaturesEXT.adoc[] If the pname:pEnabledValidationFeatures array contains ename:VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT, then it must: also contain - ename:VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT + ename:VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT or + ename:VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT * [[VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968]] If the pname:pEnabledValidationFeatures array contains ename:VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT, then it must: not diff --git a/chapters/VK_KHR_display_swapchain/create_shared_swapchains.adoc b/chapters/VK_KHR_display_swapchain/create_shared_swapchains.adoc index d0831e3f25..1a5a9e836f 100644 --- a/chapters/VK_KHR_display_swapchain/create_shared_swapchains.adoc +++ b/chapters/VK_KHR_display_swapchain/create_shared_swapchains.adoc @@ -9,6 +9,7 @@ :refpage: vkCreateSharedSwapchainsKHR :objectnameplural: swapchains :objectnamecamelcase: swapchain +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: pname:swapchainCount When the `apiext:VK_KHR_display_swapchain` extension is enabled, multiple diff --git a/chapters/VK_KHR_swapchain/wsi.adoc b/chapters/VK_KHR_swapchain/wsi.adoc index 1e8b3b692a..312610bb5e 100644 --- a/chapters/VK_KHR_swapchain/wsi.adoc +++ b/chapters/VK_KHR_swapchain/wsi.adoc @@ -88,6 +88,7 @@ endif::VK_KHR_shared_presentable_image[] :refpage: vkCreateSwapchainKHR :objectnameplural: swapchains :objectnamecamelcase: swapchain +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a swapchain, call: diff --git a/chapters/VK_NV_acquire_winrt_display/acquire_winrt_display.adoc b/chapters/VK_NV_acquire_winrt_display/acquire_winrt_display.adoc index 6f89b25310..eb3da3c97f 100644 --- a/chapters/VK_NV_acquire_winrt_display/acquire_winrt_display.adoc +++ b/chapters/VK_NV_acquire_winrt_display/acquire_winrt_display.adoc @@ -1,9 +1,11 @@ -// Copyright (c) 2020 NVIDIA Corporation +// Copyright 2020-2024 NVIDIA Corporation // // SPDX-License-Identifier: CC-BY-4.0 [open,refpage='vkAcquireWinrtDisplayNV',desc='Acquire access to a VkDisplayKHR',type='protos'] -- +:refpage: vkAcquireWinrtDisplayNV + To acquire permission to directly access a display in Vulkan on Windows 10, call: @@ -52,11 +54,15 @@ flink:vkAcquireWinrtDisplayNV does not itself cause DWM to release a display; this action must be performed outside of Vulkan. ==== +include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] + include::{generated}/validity/protos/vkAcquireWinrtDisplayNV.adoc[] -- [open,refpage='vkGetWinrtDisplayNV',desc='Query the VkDisplayKHR corresponding to a WinRT DisplayTarget',type='protos'] -- +:refpage: vkGetWinrtDisplayNV + When acquiring displays on Windows 10, an application may also wish to enumerate and identify them using a native handle rather than a sname:VkDisplayKHR handle. @@ -86,5 +92,7 @@ If there is no slink:VkDisplayKHR corresponding to pname:deviceRelativeId on pname:physicalDevice, dlink:VK_NULL_HANDLE must: be returned in pname:pDisplay. +include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] + include::{generated}/validity/protos/vkGetWinrtDisplayNV.adoc[] -- diff --git a/chapters/cmdbuffers.adoc b/chapters/cmdbuffers.adoc index 2895e1b131..4b622d31d9 100644 --- a/chapters/cmdbuffers.adoc +++ b/chapters/cmdbuffers.adoc @@ -163,6 +163,7 @@ include::{generated}/api/handles/VkCommandPool.adoc[] :refpage: vkCreateCommandPool :objectnameplural: command pools :objectnamecamelcase: commandPool +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a command pool, call: @@ -2080,7 +2081,8 @@ endif::VK_KHR_device_group_creation,VK_VERSION_1_1[] ifdef::VK_ARM_render_pass_striped[] * [[VUID-VkCommandBufferSubmitInfo-commandBuffer-09445]] If any render pass instance in pname:commandBuffer was recorded with a - slink:VkRenderPassStripeBeginInfoARM structure in its pNext chain, a + slink:VkRenderPassStripeBeginInfoARM structure in its pNext chain and + did not specify the ename:VK_RENDERING_RESUMING_BIT flag, a slink:VkRenderPassStripeSubmitInfoARM must: be included in the pname:pNext chain * [[VUID-VkCommandBufferSubmitInfo-pNext-09446]] @@ -2089,7 +2091,8 @@ ifdef::VK_ARM_render_pass_striped[] slink:VkRenderPassStripeSubmitInfoARM::pname:stripeSemaphoreInfoCount must: be equal to the sum of the slink:VkRenderPassStripeBeginInfoARM::pname:stripeInfoCount parameters - provided to render pass instances recorded in pname:commandBuffer + provided to render pass instances recorded in pname:commandBuffer that + did not specify the ename:VK_RENDERING_RESUMING_BIT flag endif::VK_ARM_render_pass_striped[] **** @@ -2128,6 +2131,12 @@ all views in the view mask. In a render pass instance with pname:layerCount greater than 1, the stripe includes all layers. +Render pass instances that specify the ename:VK_RENDERING_RESUMING_BIT will +not have any elements of pname:pStripeSemaphoreInfos mapped to them. +Instead, for suspending and resuming render pass instances, this mapping is +done for the first suspending render pass instance, and the per-stripe +semaphores are only signaled for the last resuming render pass instance. + .Valid Usage **** * [[VUID-VkRenderPassStripeSubmitInfoARM-semaphore-09447]] @@ -2887,7 +2896,7 @@ ifdef::VK_EXT_nested_command_buffer[, or ename:VK_SUBPASS_CONTENTS_INLINE_AND_SE instance, the pname:contents parameter of the last call to flink:vkCmdNextSubpass must: have been set to ename:VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS -ifdef::VK_EXT_nested_command_buffer[, or ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT] +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[, or ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR] * [[VUID-vkCmdExecuteCommands-pCommandBuffers-06019]] If fname:vkCmdExecuteCommands is being called within a render pass instance begun with flink:vkCmdBeginRenderPass, each element of diff --git a/chapters/commonvalidity/build_acceleration_structure_common.adoc b/chapters/commonvalidity/build_acceleration_structure_common.adoc index ccf9ec2690..6ef8ec03c9 100644 --- a/chapters/commonvalidity/build_acceleration_structure_common.adoc +++ b/chapters/commonvalidity/build_acceleration_structure_common.adoc @@ -200,15 +200,6 @@ sname:VkAccelerationStructureBuildRangeInfoKHR structure must: have the same value which was specified when pname:srcAccelerationStructure was last built - * [[VUID-{refpage}-firstVertex-03770]] - For each element of pname:pInfos, if its pname:mode member is - ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, then for each - sname:VkAccelerationStructureGeometryKHR structure referred to by its - pname:pGeometries or pname:ppGeometries members, if the geometry uses - indices, the pname:firstVertex member of its corresponding - sname:VkAccelerationStructureBuildRangeInfoKHR structure must: have the - same value which was specified when pname:srcAccelerationStructure was - last built * [[VUID-{refpage}-pInfos-03801]] For each element of pname:pInfos[i].pname:pGeometries or pname:pInfos[i].pname:ppGeometries with a pname:geometryType of diff --git a/chapters/commonvalidity/draw_common.adoc b/chapters/commonvalidity/draw_common.adoc index b4c4467b44..8de9a5244a 100644 --- a/chapters/commonvalidity/draw_common.adoc +++ b/chapters/commonvalidity/draw_common.adoc @@ -218,30 +218,22 @@ ifdef::VK_EXT_shader_object[] command endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07834]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_BIAS dynamic state enabled then - flink:vkCmdSetDepthBias -ifdef::VK_EXT_depth_bias_control[] - or flink:vkCmdSetDepthBias2EXT -endif::VK_EXT_depth_bias_control[] - must: have been called and not subsequently <> in the current command buffer prior to this drawing - command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08620]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetDepthBiasEnable in the current command - buffer set pname:depthBiasEnable to ename:VK_TRUE, - flink:vkCmdSetDepthBias + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_BIAS dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of pname:depthBiasEnable + is ename:VK_TRUE, then flink:vkCmdSetDepthBounds ifdef::VK_EXT_depth_bias_control[] or flink:vkCmdSetDepthBias2EXT endif::VK_EXT_depth_bias_control[] must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07835]] If the bound graphics pipeline state was created with the ename:VK_DYNAMIC_STATE_BLEND_CONSTANTS dynamic state enabled then @@ -268,77 +260,61 @@ ifdef::VK_EXT_shader_object[] prior to this drawing command endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07836]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_BOUNDS dynamic state enabled, and if the - current pname:depthBoundsTestEnable state is ename:VK_TRUE, then - flink:vkCmdSetDepthBounds must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08622]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetDepthBoundsTestEnable in the current - command buffer set pname:depthBoundsTestEnable to ename:VK_TRUE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_BOUNDS dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:depthBoundsTestEnable is ename:VK_TRUE, then flink:vkCmdSetDepthBounds must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07837]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK dynamic state enabled, and - if the current pname:stencilTestEnable state is ename:VK_TRUE, then - flink:vkCmdSetStencilCompareMask must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08623]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetStencilTestEnable in the current command - buffer set pname:stencilTestEnable to ename:VK_TRUE, + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:stencilTestEnable is ename:VK_TRUE, then flink:vkCmdSetStencilCompareMask must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07838]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_STENCIL_WRITE_MASK dynamic state enabled, and if - the current pname:stencilTestEnable state is ename:VK_TRUE, then - flink:vkCmdSetStencilWriteMask must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08624]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetStencilTestEnable in the current command - buffer set pname:stencilTestEnable to ename:VK_TRUE, + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_STENCIL_WRITE_MASK dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:stencilTestEnable is ename:VK_TRUE, then flink:vkCmdSetStencilWriteMask must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07839]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_STENCIL_REFERENCE dynamic state enabled, and if - the current pname:stencilTestEnable state is ename:VK_TRUE, then - flink:vkCmdSetStencilReference must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08625]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetStencilTestEnable in the current command - buffer set pname:stencilTestEnable to ename:VK_TRUE, + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_STENCIL_REFERENCE dynamic state enabled, the + <> of and + pname:rasterizerDiscardEnable is ename:VK_FALSE, the + <> of + pname:stencilTestEnable is ename:VK_TRUE, then flink:vkCmdSetStencilReference must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] ifdef::VK_VERSION_1_1,VK_KHR_multiview[] * [[VUID-{refpage}-maxMultiviewInstanceIndex-02688]] If the draw is recorded in a render pass instance with multiview @@ -353,149 +329,120 @@ ifdef::VK_EXT_sample_locations[] attachment, then that attachment must: have been created with the ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set * [[VUID-{refpage}-None-06666]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT dynamic state enabled then - flink:vkCmdSetSampleLocationsEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08626]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetSampleLocationsEnableEXT in the current - command buffer set pname:sampleLocationsEnable to ename:VK_TRUE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:sampleLocationsEnable is ename:VK_TRUE, then flink:vkCmdSetSampleLocationsEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] endif::VK_EXT_sample_locations[] ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] * [[VUID-{refpage}-None-07840]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_CULL_MODE dynamic state enabled then - flink:vkCmdSetCullMode must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08627]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_CULL_MODE dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetCullMode must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07841]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_FRONT_FACE dynamic state enabled then - flink:vkCmdSetFrontFace must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08628]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_FRONT_FACE dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetFrontFace must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07843]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE dynamic state enabled then - flink:vkCmdSetDepthTestEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08629]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, flink:vkCmdSetDepthTestEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07844]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE dynamic state enabled then - flink:vkCmdSetDepthWriteEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08630]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetDepthWriteEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07845]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_COMPARE_OP dynamic state enabled then - flink:vkCmdSetDepthCompareOp must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08631]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetDepthTestEnable in the current command - buffer set pname:depthTestEnable to ename:VK_TRUE, then - flink:vkCmdSetDepthCompareOp must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + a shader object is bound to any graphics stage or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_COMPARE_OP dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of pname:depthTestEnable + is ename:VK_TRUE, then flink:vkCmdSetDepthCompareOp must: have been + called and not subsequently <> in + the current command buffer prior to this drawing command * [[VUID-{refpage}-None-07846]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE dynamic state enabled - then flink:vkCmdSetDepthBoundsTestEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If the <> feature is enabled, ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08632]] - If a shader object is bound to any graphics stage, and the - <> feature is enabled, and the - most recent call to flink:vkCmdSetRasterizerDiscardEnable in the current - command buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then - the flink:vkCmdSetDepthBoundsTestEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + a shader object is bound to any graphics stage or endif::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-07847]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE dynamic state enabled then - flink:vkCmdSetStencilTestEnable must: have been called and not + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetDepthBoundsTestEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command + * [[VUID-{refpage}-None-07847]] + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08633]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE dynamic state enabled, and + the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetStencilTestEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-07848]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_STENCIL_OP dynamic state enabled then - flink:vkCmdSetStencilOp must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08634]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetStencilTestEnable in the current command - buffer set pname:stencilTestEnable to ename:VK_TRUE, then - flink:vkCmdSetStencilOp must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + a shader object is bound to any graphics stage or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_STENCIL_OP dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, the + <> of + pname:stencilTestEnable is ename:VK_TRUE, then flink:vkCmdSetStencilOp + must: have been called and not subsequently <> in the current command buffer prior to this drawing + command * [[VUID-{refpage}-viewportCount-03417]] If the bound graphics pipeline state was created with the ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT dynamic state enabled, but @@ -642,82 +589,68 @@ ifdef::VK_NV_scissor_exclusive[] greater or equal to the pname:viewportCount parameter in the last call to flink:vkCmdSetViewportWithCount * [[VUID-{refpage}-None-07878]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV dynamic state enabled - then flink:vkCmdSetExclusiveScissorEnableNV must: have been called and - not subsequently <> in the current - command buffer prior to this drawing command - * [[VUID-{refpage}-None-07879]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV dynamic state enabled then - flink:vkCmdSetExclusiveScissorNV must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-exclusiveScissor-09235]] If the <> feature is - enabled, and a shader object is bound to any graphics stage, then - flink:vkCmdSetExclusiveScissorEnableNV must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command - * [[VUID-{refpage}-None-08638]] + enabled, and +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV dynamic state + enabled, then flink:vkCmdSetExclusiveScissorEnableNV must: have been + called and not subsequently <> in + the current command buffer prior to this drawing command + * [[VUID-{refpage}-None-07879]] If the <> feature is - enabled, and a shader object is bound to any graphics stage, and the - most recent call to flink:vkCmdSetExclusiveScissorEnableNV in the + enabled, +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV dynamic state enabled, and + the most recent call to flink:vkCmdSetExclusiveScissorEnableNV in the current command buffer set any element of pname:pExclusiveScissorEnables to ename:VK_TRUE, then flink:vkCmdSetExclusiveScissorNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] endif::VK_NV_scissor_exclusive[] endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] * [[VUID-{refpage}-None-04876]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE dynamic state enabled + If +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE dynamic state enabled, then flink:vkCmdSetRasterizerDiscardEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08639]] - If a shader object is bound to any graphics stage, then - flink:vkCmdSetRasterizerDiscardEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_shader_object[] * [[VUID-{refpage}-None-04877]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE dynamic state enabled then - flink:vkCmdSetDepthBiasEnable must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08640]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetDepthBiasEnable must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] ifdef::VK_EXT_extended_dynamic_state2[] * [[VUID-{refpage}-logicOp-04878]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_LOGIC_OP_EXT dynamic state enabled then - flink:vkCmdSetLogicOpEXT must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08641]] - If a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT - stage, and the most recent call to flink:vkCmdSetRasterizerDiscardEnable - in the current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, and the most recent call to - flink:vkCmdSetLogicOpEnableEXT set pname:logicOpEnable to ename:VK_TRUE, - then flink:vkCmdSetLogicOpEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_LOGIC_OP_EXT dynamic state enabled, the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of pname:logicOpEnable is + ename:VK_TRUE, then flink:vkCmdSetLogicOpEXT must: have been called and + not subsequently <> in the current + command buffer prior to this drawing command endif::VK_EXT_extended_dynamic_state2[] endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state2[] ifdef::VK_KHR_fragment_shading_rate[] @@ -1396,94 +1329,66 @@ ifdef::VK_EXT_transform_feedback[] endif::VK_EXT_transform_feedback[] endif::VK_EXT_primitives_generated_query[] ifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07619]] - If the bound graphics pipeline state was created with the + If +ifdef::VK_EXT_shader_object[] + a shader object is bound to the + ename:VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the ename:VK_DYNAMIC_STATE_TESSELLATION_DOMAIN_ORIGIN_EXT dynamic state - enabled then flink:vkCmdSetTessellationDomainOriginEXT must: have been + enabled, then flink:vkCmdSetTessellationDomainOriginEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command * [[VUID-{refpage}-None-07620]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT dynamic state enabled then - flink:vkCmdSetDepthClampEnableEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If the <> feature is enabled, ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-09237]] - If a shader object is bound to the - ename:VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT stage, then - flink:vkCmdSetTessellationDomainOriginEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command - * [[VUID-{refpage}-None-08650]] - If the <> feature is enabled, and - a shader object is bound to any graphics stage, and the most recent call - to flink:vkCmdSetRasterizerDiscardEnable in the current command buffer - set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT dynamic state enabled, and + the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetDepthClampEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07621]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_POLYGON_MODE_EXT dynamic state enabled then - flink:vkCmdSetPolygonModeEXT must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08651]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_POLYGON_MODE_EXT dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetPolygonModeEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07622]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT dynamic state enabled - then flink:vkCmdSetRasterizationSamplesEXT must: have been called and - not subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08652]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetRasterizationSamplesEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07623]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_SAMPLE_MASK_EXT dynamic state enabled then - flink:vkCmdSetSampleMaskEXT must: have been called and not subsequently - <> in the current command buffer - prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08653]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_SAMPLE_MASK_EXT dynamic state enabled, and the + <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetSampleMaskEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] - * [[VUID-{refpage}-None-07624]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT dynamic state - enabled then flink:vkCmdSetAlphaToCoverageEnableEXT must: have been - called and not subsequently <> in - the current command buffer prior to this drawing command * [[VUID-{refpage}-alphaToCoverageEnable-08919]] If the bound graphics pipeline state was created with the ename:VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT dynamic state @@ -1494,13 +1399,6 @@ ifdef::VK_EXT_extended_dynamic_state3[] code:Index 0 endif::VK_EXT_extended_dynamic_state3[] ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08654]] - If a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then - flink:vkCmdSetAlphaToCoverageEnableEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command * [[VUID-{refpage}-alphaToCoverageEnable-08920]] If a shader object is bound to any graphics stage, and the most recent call to flink:vkCmdSetAlphaToCoverageEnableEXT in the current command @@ -1509,42 +1407,45 @@ ifdef::VK_EXT_shader_object[] variable for the alpha code:Component word in code:Location 0 at code:Index 0 endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] - * [[VUID-{refpage}-None-07625]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT dynamic state enabled - then flink:vkCmdSetAlphaToOneEnableEXT must: have been called and not +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] + * [[VUID-{refpage}-None-07624]] + If +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetAlphaToCoverageEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + * [[VUID-{refpage}-None-07625]] + If the <> feature is enabled, ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08655]] - If the <> feature is enabled, and - a shader object is bound to any graphics stage, and the most recent call - to flink:vkCmdSetRasterizerDiscardEnable in the current command buffer - set pname:rasterizerDiscardEnable to ename:VK_FALSE, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetAlphaToOneEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07626]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT dynamic state enabled then + If the <> feature is enabled, +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage + or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT dynamic state enabled, and + the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetLogicOpEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08656]] - If the <> feature is enabled, and a - shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage, - and the most recent call to flink:vkCmdSetRasterizerDiscardEnable in the - current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, then flink:vkCmdSetLogicOpEnableEXT must: have been - called and not subsequently <> in - the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07627]] If the bound graphics pipeline state was created with the @@ -1602,83 +1503,66 @@ ifdef::VK_EXT_shader_object[] the current command buffer prior to this drawing command endif::VK_EXT_shader_object[] ifdef::VK_EXT_transform_feedback[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07630]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT dynamic state enabled - then flink:vkCmdSetRasterizationStreamEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08660]] If the <> feature is - enabled, and a shader object is bound to the - ename:VK_SHADER_STAGE_GEOMETRY_BIT stage, then - flink:vkCmdSetRasterizationStreamEXT must: have been called and not + enabled, and +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_GEOMETRY_BIT stage + or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT dynamic state enabled, + then flink:vkCmdSetRasterizationStreamEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_EXT_transform_feedback[] ifdef::VK_EXT_conservative_rasterization[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07631]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT dynamic state - enabled then flink:vkCmdSetConservativeRasterizationModeEXT must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08661]] If the `apiext:VK_EXT_conservative_rasterization` extension is enabled, - and a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetConservativeRasterizationModeEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07632]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT dynamic - state enabled then flink:vkCmdSetExtraPrimitiveOverestimationSizeEXT - must: have been called and not subsequently <> in the current command buffer prior to this drawing - command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08662]] If the `apiext:VK_EXT_conservative_rasterization` extension is enabled, - and a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetConservativeRasterizationModeEXT in the - current command buffer set pname:conservativeRasterizationMode to +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT dynamic + state enabled, the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:conservativeRasterizationMode is ename:VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT, then flink:vkCmdSetExtraPrimitiveOverestimationSizeEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_EXT_conservative_rasterization[] ifdef::VK_EXT_depth_clip_enable[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07633]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT dynamic state enabled then - flink:vkCmdSetDepthClipEnableEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08663]] If the <> feature is - enabled, and a shader object is bound to any graphics stage, then + enabled, and +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT dynamic state, then flink:vkCmdSetDepthClipEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_EXT_depth_clip_enable[] ifdef::VK_EXT_sample_locations[] ifdef::VK_EXT_extended_dynamic_state3[] @@ -1720,24 +1604,21 @@ ifdef::VK_EXT_shader_object[] endif::VK_EXT_shader_object[] endif::VK_EXT_blend_operation_advanced[] ifdef::VK_EXT_provoking_vertex[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07636]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT dynamic state enabled - then flink:vkCmdSetProvokingVertexModeEXT must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If the `apiext:VK_EXT_provoking_vertex` extension is enabled, ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08665]] - If the `apiext:VK_EXT_provoking_vertex` extension is enabled, and a - shader object is bound to the ename:VK_SHADER_STAGE_VERTEX_BIT stage, - and the most recent call to flink:vkCmdSetRasterizerDiscardEnable in the - current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, then flink:vkCmdSetProvokingVertexModeEXT must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command + a shader object is bound to the ename:VK_SHADER_STAGE_VERTEX_BIT stage + or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetProvokingVertexModeEXT must: have been called and not + subsequently <> in the current + command buffer prior to this drawing command +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_EXT_provoking_vertex[] ifdef::VK_KHR_line_rasterization,VK_EXT_line_rasterization[] ifdef::VK_EXT_extended_dynamic_state3[] @@ -1851,231 +1732,189 @@ ifdef::VK_EXT_shader_object[] endif::VK_EXT_shader_object[] endif::VK_KHR_line_rasterization,VK_EXT_line_rasterization[] ifdef::VK_EXT_depth_clip_control[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07639]] - If the bound graphics pipeline state was created with the + If the <> feature is + enabled, and +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the ename:VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT dynamic state - enabled then flink:vkCmdSetDepthClipNegativeOneToOneEXT must: have been + enabled, then flink:vkCmdSetDepthClipNegativeOneToOneEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08673]] - If the <> feature is - enabled, and a shader object is bound to any graphics stage, then - flink:vkCmdSetDepthClipNegativeOneToOneEXT must: have been called and - not subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_EXT_depth_clip_control[] ifdef::VK_NV_clip_space_w_scaling[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07640]] - If the bound graphics pipeline state was created with the + If the `apiext:VK_NV_clip_space_w_scaling` extension is enabled, and +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the ename:VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_ENABLE_NV dynamic state - enabled then flink:vkCmdSetViewportWScalingEnableNV must: have been + enabled, then flink:vkCmdSetViewportWScalingEnableNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08674]] - If the `apiext:VK_NV_clip_space_w_scaling` extension is enabled, and a - shader object is bound to any graphics stage, then - flink:vkCmdSetViewportWScalingEnableNV must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_clip_space_w_scaling[] ifdef::VK_NV_viewport_swizzle[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07641]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV dynamic state enabled then - flink:vkCmdSetViewportSwizzleNV must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If the `apiext:VK_NV_viewport_swizzle` extension is enabled, and ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08675]] - If the `apiext:VK_NV_viewport_swizzle` extension is enabled, and a - shader object is bound to any graphics stage, then + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV dynamic state enabled, then flink:vkCmdSetViewportSwizzleNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_viewport_swizzle[] ifdef::VK_NV_fragment_coverage_to_color[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07642]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_ENABLE_NV dynamic state enabled - then flink:vkCmdSetCoverageToColorEnableNV must: have been called and - not subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08676]] If the `apiext:VK_NV_fragment_coverage_to_color` extension is enabled, - and a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT - stage, and the most recent call to flink:vkCmdSetRasterizerDiscardEnable - in the current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, then flink:vkCmdSetCoverageToColorEnableNV must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage + or endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_ENABLE_NV dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetCoverageToColorEnableNV must: have been called and not + subsequently <> in the current + command buffer prior to this drawing command * [[VUID-{refpage}-None-07643]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_LOCATION_NV dynamic state - enabled then flink:vkCmdSetCoverageToColorLocationNV must: have been - called and not subsequently <> in - the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08677]] If the `apiext:VK_NV_fragment_coverage_to_color` extension is enabled, - and a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT - stage, and the most recent call to flink:vkCmdSetRasterizerDiscardEnable - in the current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, and the most recent call to - flink:vkCmdSetCoverageToColorEnableNV in the current command buffer set - pname:coverageToColorEnable to ename:VK_TRUE, then +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage + or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_LOCATION_NV dynamic state + enabled, the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:coverageToColorEnable is ename:VK_TRUE, then flink:vkCmdSetCoverageToColorLocationNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_fragment_coverage_to_color[] ifdef::VK_NV_framebuffer_mixed_samples[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07644]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV dynamic state enabled - then flink:vkCmdSetCoverageModulationModeNV must: have been called and - not subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08678]] If the `apiext:VK_NV_framebuffer_mixed_samples` extension is enabled, - and a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetCoverageModulationModeNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07645]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_ENABLE_NV dynamic state - enabled then flink:vkCmdSetCoverageModulationTableEnableNV must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08679]] If the `apiext:VK_NV_framebuffer_mixed_samples` extension is enabled, - and a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetCoverageModulationModeNV in the current - command buffer set coverageModulationMode to any value other than +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_ENABLE_NV dynamic state + enabled, the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:coverageModulationMode is any value other than ename:VK_COVERAGE_MODULATION_MODE_NONE_NV, then flink:vkCmdSetCoverageModulationTableEnableNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] -ifdef::VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07646]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_NV dynamic state - enabled then flink:vkCmdSetCoverageModulationTableNV must: have been - called and not subsequently <> in - the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08680]] If the `apiext:VK_NV_framebuffer_mixed_samples` extension is enabled, - and a shader object is bound to any graphics stage, and the most recent - call to flink:vkCmdSetRasterizerDiscardEnable in the current command - buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, and the most - recent call to flink:vkCmdSetCoverageModulationTableEnableNV in the - current command buffer set pname:coverageModulationTableEnable to - ename:VK_TRUE, then flink:vkCmdSetCoverageModulationTableNV must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_NV dynamic state + enabled, the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, and the + <> of + pname:coverageModulationTableEnable is ename:VK_TRUE, then + flink:vkCmdSetCoverageModulationTableNV must: have been called and not + subsequently <> in the current + command buffer prior to this drawing command +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_framebuffer_mixed_samples[] ifdef::VK_NV_shading_rate_image[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07647]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV dynamic state - enabled then flink:vkCmdSetShadingRateImageEnableNV must: have been - called and not subsequently <> in - the current command buffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] + If the <> feature is + enabled, ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetShadingRateImageEnableNV must: have been called and not + subsequently <> in the current + command buffer prior to this drawing command * [[VUID-{refpage}-pipelineFragmentShadingRate-09238]] If the <> feature is enabled, and a shader - object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage, and the - most recent call to flink:vkCmdSetRasterizerDiscardEnable in the current - command buffer set rasterizerDiscardEnable to ename:VK_FALSE, then + pname:pipelineFragmentShadingRate>> feature is enabled, +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage + or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetFragmentShadingRateKHR must: have been called and not subsequently <> in the current command buffer prior to this drawing command - * [[VUID-{refpage}-None-08681]] - If the <> feature is - enabled, and a shader object is bound to any graphics stage, and the - most recent call to flink:vkCmdSetRasterizerDiscardEnable in the current - command buffer set pname:rasterizerDiscardEnable to ename:VK_FALSE, then - flink:vkCmdSetShadingRateImageEnableNV must: have been called and not - subsequently <> in the current - command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_shading_rate_image[] ifdef::VK_NV_representative_fragment_test[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07648]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV dynamic - state enabled then flink:vkCmdSetRepresentativeFragmentTestEnableNV - must: have been called and not subsequently <> in the current command buffer prior to this drawing - command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08682]] If the <> feature is enabled, and a shader - object is bound to any graphics stage, and the most recent call to - flink:vkCmdSetRasterizerDiscardEnable in the current command buffer set - pname:rasterizerDiscardEnable to ename:VK_FALSE, then + pname:representativeFragmentTest>> feature is enabled, +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV dynamic + state enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetRepresentativeFragmentTestEnableNV must: have been called and not subsequently <> in the current command buffer prior to this drawing command -endif::VK_EXT_shader_object[] +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_representative_fragment_test[] ifdef::VK_NV_coverage_reduction_mode[] -ifdef::VK_EXT_extended_dynamic_state3[] +ifdef::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] * [[VUID-{refpage}-None-07649]] - If the bound graphics pipeline state was created with the - ename:VK_DYNAMIC_STATE_COVERAGE_REDUCTION_MODE_NV dynamic state enabled - then flink:vkCmdSetCoverageReductionModeNV must: have been called and - not subsequently <> in the current - command sbuffer prior to this drawing command -endif::VK_EXT_extended_dynamic_state3[] -ifdef::VK_EXT_shader_object[] - * [[VUID-{refpage}-None-08683]] If the <> - feature is enabled, and a shader object is bound to any graphics stage, - and the most recent call to flink:vkCmdSetRasterizerDiscardEnable in the - current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, then flink:vkCmdSetCoverageReductionModeNV must: have - been called and not subsequently <> - in the current command buffer prior to this drawing command + feature is enabled, +ifdef::VK_EXT_shader_object[] + a shader object is bound to any graphics stage or endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the + ename:VK_DYNAMIC_STATE_COVERAGE_REDUCTION_MODE_NV dynamic state enabled, + and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then + flink:vkCmdSetCoverageReductionModeNV must: have been called and not + subsequently <> in the current + command buffer prior to this drawing command +endif::VK_EXT_shader_object,VK_EXT_extended_dynamic_state3[] endif::VK_NV_coverage_reduction_mode[] * [[VUID-{refpage}-pColorBlendEnables-07470]] If the bound graphics pipeline state was created with the @@ -2497,8 +2336,15 @@ ifdef::VK_EXT_mesh_shader[] endif::VK_EXT_mesh_shader[] ifdef::VK_EXT_attachment_feedback_loop_dynamic_state[] * [[VUID-{refpage}-None-08877]] - If the bound graphics pipeline state was created with the + If +ifdef::VK_EXT_shader_object[] + a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT stage + or +endif::VK_EXT_shader_object[] + a graphics pipeline is bound which was created with the ename:VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT dynamic state + enabled, and the <> of + pname:rasterizerDiscardEnable is ename:VK_FALSE, then flink:vkCmdSetAttachmentFeedbackLoopEnableEXT must: have been called and not subsequently <> in the current command buffer prior to this drawing command @@ -2605,18 +2451,6 @@ ifdef::VK_ANDROID_external_format_resolve[] code:StencilRefReplacingEXT execution modes endif::VK_ANDROID_external_format_resolve[] endif::VK_EXT_shader_object[] -ifdef::VK_EXT_attachment_feedback_loop_dynamic_state[] - * [[VUID-{refpage}-None-08880]] - If the <> feature is enabled on the device, - and a shader object is bound to the ename:VK_SHADER_STAGE_FRAGMENT_BIT - stage, and the most recent call to flink:vkCmdSetRasterizerDiscardEnable - in the current command buffer set pname:rasterizerDiscardEnable to - ename:VK_FALSE, then flink:vkCmdSetAttachmentFeedbackLoopEnableEXT must: - have been called and not subsequently <> in the current command buffer prior to this drawing - command -endif::VK_EXT_attachment_feedback_loop_dynamic_state[] ifdef::VK_EXT_shader_tile_image[] * [[VUID-{refpage}-pDynamicStates-08715]] If the bound graphics pipeline state includes a fragment shader stage, diff --git a/chapters/commonvalidity/memory_reservation_request_count_common.adoc b/chapters/commonvalidity/memory_reservation_request_count_common.adoc index 3c48976109..5284c1bf42 100644 --- a/chapters/commonvalidity/memory_reservation_request_count_common.adoc +++ b/chapters/commonvalidity/memory_reservation_request_count_common.adoc @@ -9,7 +9,7 @@ ifdef::VKSC_VERSION_1_0[] The number of {objectnameplural} currently allocated from pname:device plus {objectcount} must: be less than or equal to the total number of {objectnameplural} requested via - slink:VkDeviceObjectReservationCreateInfo::pname:{objectnamecamelcase}RequestCount + slink:{objectnamestruct}::pname:{objectnamecamelcase}RequestCount specified when pname:device was created endif::VKSC_VERSION_1_0[] // Common Valid Usage diff --git a/chapters/descriptorsets.adoc b/chapters/descriptorsets.adoc index be0a83ab17..18428ebc03 100644 --- a/chapters/descriptorsets.adoc +++ b/chapters/descriptorsets.adoc @@ -542,6 +542,7 @@ include::{generated}/api/handles/VkDescriptorSetLayout.adoc[] :refpage: vkCreateDescriptorSetLayout :objectnameplural: descriptor set layouts :objectnamecamelcase: descriptorSetLayout +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create descriptor set layout objects, call: @@ -1681,6 +1682,7 @@ include::{generated}/api/handles/VkPipelineLayout.adoc[] :refpage: vkCreatePipelineLayout :objectnameplural: pipeline layouts :objectnamecamelcase: pipelineLayout +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a pipeline layout, call: @@ -1908,7 +1910,12 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] pname:pSetLayouts must: be less than or equal to sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetUniformBuffers * [[VUID-VkPipelineLayoutCreateInfo-descriptorType-03030]] - The total number of descriptors in descriptor set layouts +ifdef::VK_KHR_maintenance7[] + If the <> feature is not + enabled, the +endif::VK_KHR_maintenance7[] +ifndef::VK_KHR_maintenance7[The] + total number of descriptors in descriptor set layouts ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] created without the ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set @@ -1918,6 +1925,20 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] shader stages and across all elements of pname:pSetLayouts must: be less than or equal to sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetUniformBuffersDynamic +ifdef::VK_KHR_maintenance7[] + * [[VUID-VkPipelineLayoutCreateInfo-maintenance7-10003]] + If the <> feature is enabled, + the total number of descriptors in descriptor set layouts +ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set +endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + with a pname:descriptorType of + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to <> +endif::VK_KHR_maintenance7[] * [[VUID-VkPipelineLayoutCreateInfo-descriptorType-03031]] The total number of descriptors in descriptor set layouts ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] @@ -1929,7 +1950,12 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] pname:pSetLayouts must: be less than or equal to sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetStorageBuffers * [[VUID-VkPipelineLayoutCreateInfo-descriptorType-03032]] - The total number of descriptors in descriptor set layouts +ifdef::VK_KHR_maintenance7[] + If the <> feature is not + enabled, the +endif::VK_KHR_maintenance7[] +ifndef::VK_KHR_maintenance7[The] + total number of descriptors in descriptor set layouts ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] created without the ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set @@ -1939,6 +1965,42 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] shader stages and across all elements of pname:pSetLayouts must: be less than or equal to sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetStorageBuffersDynamic +ifdef::VK_KHR_maintenance7[] + * [[VUID-VkPipelineLayoutCreateInfo-maintenance7-10004]] + If the <> feature is enabled, + the total number of descriptors in descriptor set layouts +ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set +endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + with a pname:descriptorType of + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to <> + * [[VUID-VkPipelineLayoutCreateInfo-None-10005]] + The total number of descriptors in descriptor set layouts +ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set +endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + with a pname:descriptorType of + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to <> +ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] + * [[VUID-VkPipelineLayoutCreateInfo-pSetLayouts-10006]] + The total number of descriptors of the type + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to + <> +endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] +endif::VK_KHR_maintenance7[] * [[VUID-VkPipelineLayoutCreateInfo-descriptorType-03033]] The total number of descriptors in descriptor set layouts ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] @@ -2001,11 +2063,26 @@ ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] or equal to sname:VkPhysicalDeviceDescriptorIndexingProperties::pname:maxDescriptorSetUpdateAfterBindUniformBuffers * [[VUID-VkPipelineLayoutCreateInfo-pSetLayouts-03038]] - The total number of descriptors of the type +ifdef::VK_KHR_maintenance7[] + If the <> feature is not + enabled, the +endif::VK_KHR_maintenance7[] +ifndef::VK_KHR_maintenance7[The] + total number of descriptors of the type ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC accessible across all shader stages and across all elements of pname:pSetLayouts must: be less than or equal to - sname:VkPhysicalDeviceDescriptorIndexingProperties::pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic + sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic +ifdef::VK_KHR_maintenance7[] + * [[VUID-VkPipelineLayoutCreateInfo-maintenance7-10007]] + If the <> feature is enabled, + the total number of descriptors of the type + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to + <> +endif::VK_KHR_maintenance7[] * [[VUID-VkPipelineLayoutCreateInfo-pSetLayouts-03039]] The total number of descriptors of the type ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER accessible across all shader @@ -2013,11 +2090,26 @@ ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] or equal to sname:VkPhysicalDeviceDescriptorIndexingProperties::pname:maxDescriptorSetUpdateAfterBindStorageBuffers * [[VUID-VkPipelineLayoutCreateInfo-pSetLayouts-03040]] - The total number of descriptors of the type +ifdef::VK_KHR_maintenance7[] + If the <> feature is not + enabled, the +endif::VK_KHR_maintenance7[] +ifndef::VK_KHR_maintenance7[The] + total number of descriptors of the type ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible across all shader stages and across all elements of pname:pSetLayouts must: be less than or equal to - sname:VkPhysicalDeviceDescriptorIndexingProperties::pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic + sname:VkPhysicalDeviceLimits::pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic +ifdef::VK_KHR_maintenance7[] + * [[VUID-VkPipelineLayoutCreateInfo-maintenance7-10008]] + If the <> feature is enabled, + the total number of descriptors of the type + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC accessible across all + shader stages and across all elements of pname:pSetLayouts must: be less + than or equal to + <> +endif::VK_KHR_maintenance7[] * [[VUID-VkPipelineLayoutCreateInfo-pSetLayouts-03041]] The total number of descriptors of the type ename:VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, @@ -2272,6 +2364,9 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] or pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] +ifdef::VK_KHR_maintenance7[] +or pname:maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic +endif::VK_KHR_maintenance7[] | uniform buffer dynamic .2+<.^| pname:maxDescriptorSetStorageBuffers ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] @@ -2282,6 +2377,9 @@ endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] or pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic endif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] +ifdef::VK_KHR_maintenance7[] +or pname:maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic +endif::VK_KHR_maintenance7[] | storage buffer dynamic | pname:maxDescriptorSetInputAttachments ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] @@ -2463,6 +2561,7 @@ include::{generated}/api/handles/VkDescriptorPool.adoc[] :refpage: vkCreateDescriptorPool :objectnameplural: descriptor pools :objectnamecamelcase: descriptorPool +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a descriptor pool object, call: @@ -2863,6 +2962,7 @@ include::{generated}/api/handles/VkDescriptorSet.adoc[] :refpage: vkAllocateDescriptorSets :objectnameplural: descriptor sets :objectnamecamelcase: descriptorSet +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: slink:VkDescriptorSetAllocateInfo::pname:descriptorSetCount To allocate descriptor sets from a descriptor pool, call: @@ -3520,6 +3620,9 @@ endif::VK_VERSION_1_3,VK_EXT_inline_uniform_block[] * [[VUID-VkWriteDescriptorSet-dstBinding-00316]] pname:dstBinding must: be a binding with a non-zero pname:descriptorCount + * [[VUID-VkWriteDescriptorSet-dstBinding-10009]] + pname:dstBinding must: be a binding with a non-zero + slink:VkDescriptorSetLayoutCreateInfo::pname:bindingCount * [[VUID-VkWriteDescriptorSet-descriptorCount-00317]] All consecutive bindings updated via a single sname:VkWriteDescriptorSet structure, except those with a pname:descriptorCount of zero, must: have diff --git a/chapters/devsandqueues.adoc b/chapters/devsandqueues.adoc index 6fdcf933ce..ebeb151674 100644 --- a/chapters/devsandqueues.adoc +++ b/chapters/devsandqueues.adoc @@ -1821,6 +1821,24 @@ ifdef::hidden[] is a pointer to incompatible pipeline cache data <>. // end::scdeviation[] endif::hidden[] + +Some implementations may: only accept pipeline cache data pointers that +conform to platform and/or implementation specific alignment requirements. +These alignment requirements cannot exceed 8 bytes. +If any of the pipeline cache data pointers specified in the +pname:pInitialData member of the elements of +slink:VkDeviceObjectReservationCreateInfo::pname:pPipelineCacheCreateInfos +are not aligned according to these requirements, then fname:vkCreateDevice +will return ename:VK_ERROR_INVALID_PIPELINE_CACHE_DATA. +ifdef::hidden[] +// tag::scdeviation[] + * flink:vkCreateDevice returns ename:VK_ERROR_INVALID_PIPELINE_CACHE_DATA + if the pname:pInitialData member of any element of + slink:VkDeviceObjectReservationCreateInfo::pname:pPipelineCacheCreateInfos + is not aligned according to the platform and/or implementation specific + pipeline cache data alignment requirements <>. +// end::scdeviation[] +endif::hidden[] endif::VKSC_VERSION_1_0[] ifdef::VK_EXT_application_parameters[] diff --git a/chapters/features.adoc b/chapters/features.adoc index d7725f43e4..e017dfc925 100644 --- a/chapters/features.adoc +++ b/chapters/features.adoc @@ -2701,7 +2701,7 @@ This structure describes the following feature: * pname:sType is a elink:VkStructureType value identifying this structure. * pname:pNext is `NULL` or a pointer to a structure extending this structure. - * [[features-fragmentDensityMapOffsets]] pname:fragmentDensityMapOffsets + * [[features-fragmentDensityMapOffset]] pname:fragmentDensityMapOffset specifies whether the implementation supports <> @@ -6097,6 +6097,49 @@ include::{generated}/validity/structs/VkPhysicalDeviceMaintenance6FeaturesKHR.ad -- endif::VK_KHR_maintenance6[] +ifdef::VK_KHR_maintenance7[] +[open,refpage='VkPhysicalDeviceMaintenance7FeaturesKHR',desc='Structure describing whether the implementation supports maintenance7 functionality',type='structs'] +-- +The sname:VkPhysicalDeviceMaintenance7FeaturesKHR structure is defined as: + +include::{generated}/api/structs/VkPhysicalDeviceMaintenance7FeaturesKHR.adoc[] + +This structure describes the following feature: + + * pname:sType is a elink:VkStructureType value identifying this structure. + * pname:pNext is `NULL` or a pointer to a structure extending this + structure. + * [[features-maintenance7]] pname:maintenance7 indicates that the + implementation supports the following: + ** The ename:VK_RENDERING_CONTENTS_INLINE_BIT_KHR and + ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR + flags can: be used to record commands in render pass instances both + inline and in secondary command buffers executed with + flink:vkCmdExecuteCommands for dynamic rendering and legacy render + passes respectively. + ** Querying information regarding the underlying devices in environments + where the Vulkan implementation is provided through layered + implementations. + This is done by chaining + slink:VkPhysicalDeviceLayeredApiPropertiesListKHR to + slink:VkPhysicalDeviceProperties2. + ** New limits which indicate the maximum total count of dynamic uniform + buffers and dynamic storage buffers that can: be included in a pipeline + layout. + ** 32-bit timestamp queries must: wrap on overflow + ** A property that indicates whether a fragment shading rate attachment + can have a size that is too small to cover a specified render area. + ** A property that indicates support for writing to one aspect of a + depth/stencil attachment without performing a read-modify-write + operation on the other aspect + +:refpage: VkPhysicalDeviceMaintenance7FeaturesKHR +include::{chapters}/features.adoc[tag=features] + +include::{generated}/validity/structs/VkPhysicalDeviceMaintenance7FeaturesKHR.adoc[] +-- +endif::VK_KHR_maintenance7[] + ifdef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[] [open,refpage='VkPhysicalDeviceDynamicRenderingFeatures',desc='Structure indicating support for dynamic render pass instances',type='structs',alias='VkPhysicalDeviceDynamicRenderingFeaturesKHR'] -- @@ -8238,6 +8281,10 @@ ifdef::VK_KHR_maintenance6[] * <>, if the `apiext:VK_KHR_maintenance6` extension is supported. endif::VK_KHR_maintenance6[] +ifdef::VK_KHR_maintenance7[] + * <>, if the + `apiext:VK_KHR_maintenance7` extension is supported. +endif::VK_KHR_maintenance7[] ifdef::VK_EXT_image_2d_view_of_3d[] * <>, if the `apiext:VK_EXT_image_2d_view_of_3d` extension is supported. diff --git a/chapters/fragops.adoc b/chapters/fragops.adoc index 8088850f78..a4fe82b709 100644 --- a/chapters/fragops.adoc +++ b/chapters/fragops.adoc @@ -1437,6 +1437,9 @@ value used to create the currently active pipeline. .Valid Usage **** include::{chapters}/commonvalidity/dynamic_state_feature_common.adoc[] + * [[VUID-vkCmdSetDepthBoundsTestEnable-depthBounds-10010]] + If the <> feature is not + enabled, pname:depthBoundsTestEnable must: be ename:VK_FALSE **** include::{generated}/validity/protos/vkCmdSetDepthBoundsTestEnable.adoc[] diff --git a/chapters/limits.adoc b/chapters/limits.adoc index b6f2fb07e1..e891318d7d 100644 --- a/chapters/limits.adoc +++ b/chapters/limits.adoc @@ -1843,6 +1843,226 @@ include::{generated}/validity/structs/VkPhysicalDeviceMaintenance6PropertiesKHR. -- endif::VK_KHR_maintenance6[] +ifdef::VK_KHR_maintenance7[] +[open,refpage='VkPhysicalDeviceMaintenance7PropertiesKHR',desc='Structure describing various implementation-defined properties introduced with VK_KHR_maintenance7',type='structs'] +-- +The sname:VkPhysicalDeviceMaintenance7PropertiesKHR structure is defined as: + +include::{generated}/api/structs/VkPhysicalDeviceMaintenance7PropertiesKHR.adoc[] + + * pname:sType is a elink:VkStructureType value identifying this structure. + * pname:pNext is `NULL` or a pointer to a structure extending this + structure. + * [[limits-robustFragmentShadingRateAttachmentAccess]] + pname:robustFragmentShadingRateAttachmentAccess indicates whether the + scaled size of a fragment shading rate attachment can: be less than the + size of the render area. + If pname:robustFragmentShadingRateAttachmentAccess is ename:VK_FALSE, + the size of the attachment multiplied by the texel size must: be greater + than or equal to the size of the render area. + If it is ename:VK_TRUE and the fragment shading rate attachment was + created with slink:VkImageSubresourceRange::pname:baseMipLevel equal to + 0, the scaled size can: be smaller than the render area, and shading + rates for missing texels are defined by <>. + * [[limits-separateDepthStencilAttachmentAccess]] + pname:separateDepthStencilAttachmentAccess indicates support for writing + to one aspect of a depth/stencil attachment without performing + read-modify-write operations on the other aspect. + If this property is ename:VK_TRUE, writes to one aspect must: not result + in read-modify-write operations on the other aspect. + If ename:VK_FALSE, writes to one aspect may: result in writes to the + other aspect as defined by <>, <> and <>. + * [[limits-maxDescriptorSetTotalUniformBuffersDynamic]] + pname:maxDescriptorSetTotalUniformBuffersDynamic is the maximum total + count of dynamic uniform buffers that can: be included in a pipeline + layout. + Descriptors with a type of + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC count against this + limit. + Only descriptors in descriptor set layouts created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set + count against this limit. + See <>. + * [[limits-maxDescriptorSetTotalStorageBuffersDynamic]] + pname:maxDescriptorSetTotalStorageBuffersDynamic is the maximum total + count of dynamic storage buffers that can: be included in a pipeline + layout. + Descriptors with a type of + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC count against this + limit. + Only descriptors in descriptor set layouts created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set + count against this limit. + See <>. + * [[limits-maxDescriptorSetTotalBuffersDynamic]] + pname:maxDescriptorSetTotalBuffersDynamic is the maximum total count of + dynamic uniform buffers and storage buffers that can: be included in a + pipeline layout. + Descriptors with a type of + ename:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or + ename:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC count against this + limit. + Only descriptors in descriptor set layouts created without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit set + count against this limit. + * [[limits-maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic]] + pname:maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic is + similar to pname:maxDescriptorSetTotalUniformBuffersDynamic but counts + descriptors from descriptor sets created with or without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit + set. + * [[limits-maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic]] + pname:maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic is + similar to pname:maxDescriptorSetTotalStorageBuffersDynamic but counts + descriptors from descriptor sets created with or without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit + set. + * [[limits-maxDescriptorSetUpdateAfterBindTotalBuffersDynamic]] + pname:maxDescriptorSetUpdateAfterBindTotalBuffersDynamic is similar to + pname:maxDescriptorSetTotalBuffersDynamic but counts descriptors from + descriptor sets created with or without the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT bit + set. + While an application can: allocate dynamic storage buffer descriptors + from a pool created with the + ename:VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, + bindings for these descriptors must: not be present in any descriptor + set layout that includes bindings created with + ename:VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT. + +:refpage: VkPhysicalDeviceMaintenance7PropertiesKHR +include::{chapters}/limits.adoc[tag=limits_desc] + +include::{generated}/validity/structs/VkPhysicalDeviceMaintenance7PropertiesKHR.adoc[] +-- + +[open,refpage='VkPhysicalDeviceLayeredApiPropertiesListKHR',desc='Structure describing layered implementations underneath the Vulkan physical device',type='structs'] +-- +The sname:VkPhysicalDeviceLayeredApiPropertiesListKHR structure is defined +as: + +include::{generated}/api/structs/VkPhysicalDeviceLayeredApiPropertiesListKHR.adoc[] + + * pname:sType is a elink:VkStructureType value identifying this structure. + * pname:pNext is `NULL` or a pointer to a structure extending this + structure. + * pname:layeredApiCount is an integer related to the number of layered + implementations underneath the Vulkan physical device, as described + below. + * pname:pLayeredApis is a pointer to an array of + slink:VkPhysicalDeviceLayeredApiPropertiesKHR in which information + regarding the layered implementations underneath the Vulkan physical + device are returned. + +If pname:pLayeredApis is `NULL`, then the number of layered implementations +that are underneath the top-most Vulkan physical device (i.e. the one +returned by flink:vkGetPhysicalDeviceProperties2) is returned in +pname:layeredApiCount. +Otherwise, pname:layeredApiCount must: be set by the application to the +number of elements in the pname:pLayeredApis array, and on return the +variable is overwritten with the number of values actually written to +pname:pLayeredApis. +If the value of pname:layeredApiCount is less than the number of layered +implementations underneath the Vulkan physical device, at most +pname:layeredApiCount values will be written to pname:pLayeredApis. +An implementation that is not a layer will return 0 in +pname:layeredApiCount. + +In the presence of multiple layered implementations, each element of +pname:pLayeredApis corresponds to an API implementation that is implemented +on top of the API at the previous index. +If there are layered implementations underneath a non-Vulkan implementation, +they may not be visible in this query as the corresponding APIs may lack +such a query. + +:refpage: VkPhysicalDeviceLayeredApiPropertiesListKHR +include::{chapters}/limits.adoc[tag=limits_desc] + +include::{generated}/validity/structs/VkPhysicalDeviceLayeredApiPropertiesListKHR.adoc[] +-- + +[open,refpage='VkPhysicalDeviceLayeredApiPropertiesKHR',desc='Structure describing a single layered implementation underneath the Vulkan physical device',type='structs'] +-- +The sname:VkPhysicalDeviceLayeredApiPropertiesKHR structure is defined as: + +include::{generated}/api/structs/VkPhysicalDeviceLayeredApiPropertiesKHR.adoc[] + + * pname:sType is a elink:VkStructureType value identifying this structure. + * pname:pNext is `NULL` or a pointer to a structure extending this + structure. + * pname:vendorID is a unique identifier for the vendor of the layered + implementation. + * pname:deviceID is a unique identifier for the layered implementation + among devices available from the vendor. + * pname:layeredAPI is a elink:VkPhysicalDeviceLayeredApiKHR specifying the + API implemented by the layered implementation. + * pname:deviceName is an array of ename:VK_MAX_PHYSICAL_DEVICE_NAME_SIZE + code:char containing a null-terminated UTF-8 string which is the name of + the device. + +If pname:layeredAPI is ename:VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR, +additional Vulkan-specific information can be queried by including the +slink:VkPhysicalDeviceLayeredApiVulkanPropertiesKHR structure in the +pname:pNext chain. +Otherwise if such a structure is included in the pname:pNext chain, it is +ignored. + +include::{generated}/validity/structs/VkPhysicalDeviceLayeredApiPropertiesKHR.adoc[] +-- + +[open,refpage='VkPhysicalDeviceLayeredApiKHR',desc='API implemented by the layered implementation',type='enums'] +-- +The list of possible API implementations of a layered implementation +underneath the Vulkan physical device, as returned in +slink:VkPhysicalDeviceLayeredApiPropertiesKHR::pname:layeredAPI, are: + +include::{generated}/api/enums/VkPhysicalDeviceLayeredApiKHR.adoc[] + + * ename:VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR - the device implements + the Vulkan API. + * ename:VK_PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR - the device implements + the D3D12 API. + * ename:VK_PHYSICAL_DEVICE_LAYERED_API_METAL_KHR - the device implements + the Metal API. + * ename:VK_PHYSICAL_DEVICE_LAYERED_API_OPENGL_KHR - the device implements + the OpenGL API. + * ename:VK_PHYSICAL_DEVICE_LAYERED_API_OPENGLES_KHR - the device + implements the OpenGL ES API. +-- + +[open,refpage='VkPhysicalDeviceLayeredApiVulkanPropertiesKHR',desc='Structure describing physical device properties of a layered Vulkan implementation underneath the Vulkan physical device',type='structs'] +-- +The sname:VkPhysicalDeviceLayeredApiVulkanPropertiesKHR structure is defined +as: + +include::{generated}/api/structs/VkPhysicalDeviceLayeredApiVulkanPropertiesKHR.adoc[] + + * pname:sType is a elink:VkStructureType value identifying this structure. + * pname:pNext is `NULL` or a pointer to a structure extending this + structure. + * pname:properties is a slink:VkPhysicalDeviceProperties2 in which + properties of the underlying layered Vulkan implementation are returned. + +The implementation must: zero-fill the contents of +pname:properties.properties.limits and +pname:properties.properties.sparseProperties. + +.Valid Usage +**** + * [[VUID-VkPhysicalDeviceLayeredApiVulkanPropertiesKHR-pNext-10011]] + Only slink:VkPhysicalDeviceDriverProperties and + slink:VkPhysicalDeviceIDProperties are allowed in the pname:pNext chain + of pname:properties +**** + +include::{generated}/validity/structs/VkPhysicalDeviceLayeredApiVulkanPropertiesKHR.adoc[] +-- +endif::VK_KHR_maintenance7[] + ifdef::VK_NV_mesh_shader[] [open,refpage='VkPhysicalDeviceMeshShaderPropertiesNV',desc='Structure describing mesh shading properties',type='structs'] -- @@ -4907,7 +5127,7 @@ ifdef::VK_EXT_fragment_density_map2[] | code:uint32_t | pname:maxDescriptorSetSubsampledSamplers | `apiext:VK_EXT_fragment_density_map2` endif::VK_EXT_fragment_density_map2[] ifdef::VK_QCOM_fragment_density_map_offset[] -| slink:VkExtent2D | pname:fragmentDensityOffsetGranularity | `<>` +| slink:VkExtent2D | pname:fragmentDensityOffsetGranularity | `<>` endif::VK_QCOM_fragment_density_map_offset[] endif::VK_EXT_fragment_density_map[] ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] @@ -5087,6 +5307,15 @@ endif::VK_NV_extended_sparse_address_space[] ifdef::VK_MESA_image_alignment_control[] | code:uint32_t | pname:supportedImageAlignmentMask | `<>` endif::VK_MESA_image_alignment_control[] +ifdef::VK_KHR_maintenance7[] +| basetype:VkBool32 | pname:separateDepthStencilAttachmentAccess | <> +| code:uint32_t | pname:maxDescriptorSetTotalUniformBuffersDynamic | `<>` +| code:uint32_t | pname:maxDescriptorSetTotalStorageBuffersDynamic | `<>` +| code:uint32_t | pname:maxDescriptorSetTotalBuffersDynamic | `<>` +| code:uint32_t | pname:maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic | `<>` +| code:uint32_t | pname:maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic | `<>` +| code:uint32_t | pname:maxDescriptorSetUpdateAfterBindTotalBuffersDynamic | `<>` +endif::VK_KHR_maintenance7[] |==== [[limits-required]] @@ -5120,6 +5349,11 @@ endif::VK_MESA_image_alignment_control[] | pname:maxDescriptorSetUniformBuffersDynamic| - | 8 | min | pname:maxDescriptorSetStorageBuffers | - | 24 ^8^ | min, _n_ {times} PerStage | pname:maxDescriptorSetStorageBuffersDynamic| - | 4 | min +ifdef::VK_KHR_maintenance7[] +| pname:maxDescriptorSetTotalUniformBuffersDynamic | - | pname:maxDescriptorSetUniformBuffersDynamic | min +| pname:maxDescriptorSetTotalStorageBuffersDynamic | - | pname:maxDescriptorSetStorageBuffersDynamic | min +| pname:maxDescriptorSetTotalBuffersDynamic | - | [eq]#pname:maxDescriptorSetUniformBuffersDynamic {plus} pname:maxDescriptorSetStorageBuffersDynamic#| min +endif::VK_KHR_maintenance7[] | pname:maxDescriptorSetSampledImages | - | 96 ^8^ | min, _n_ {times} PerStage | pname:maxDescriptorSetStorageImages | - | 24 ^8^ | min, _n_ {times} PerStage | pname:maxDescriptorSetInputAttachments | - | 4 | min @@ -5286,6 +5520,11 @@ ifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[] | pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic| 0^9^ |8 ^9^ | min | pname:maxDescriptorSetUpdateAfterBindStorageBuffers | 0^9^ |500000 ^9^ | min | pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic| 0^9^ |4 ^9^ | min +ifdef::VK_KHR_maintenance7[] +| pname:maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic | 0^9^ | pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic | min +| pname:maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic | 0^9^ | pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic | min +| pname:maxDescriptorSetUpdateAfterBindTotalBuffersDynamic | 0^9^ | [eq]#pname:maxDescriptorSetUpdateAfterBindUniformBuffersDynamic {plus} pname:maxDescriptorSetUpdateAfterBindStorageBuffersDynamic# | min +endif::VK_KHR_maintenance7[] | pname:maxDescriptorSetUpdateAfterBindSampledImages | 0^9^ |500000 ^9^ | min | pname:maxDescriptorSetUpdateAfterBindStorageImages | 0^9^ |500000 ^9^ | min | pname:maxDescriptorSetUpdateAfterBindInputAttachments | 0^9^ |4 ^9^ | min @@ -5569,6 +5808,9 @@ endif::VK_EXT_map_memory_placed[] ifdef::VK_MESA_image_alignment_control[] | pname:supportedImageAlignmentMask | - | 1 | min endif::VK_MESA_image_alignment_control[] +ifdef::VK_KHR_maintenance7[] +| pname:separateDepthStencilAttachmentAccess | false | - | implementation-dependent +endif::VK_KHR_maintenance7[] |==== 1:: diff --git a/chapters/memory.adoc b/chapters/memory.adoc index 1fe37eeba8..c35fa9d2d7 100644 --- a/chapters/memory.adoc +++ b/chapters/memory.adoc @@ -1032,6 +1032,7 @@ include::{generated}/api/handles/VkDeviceMemory.adoc[] :refpage: vkAllocateMemory :objectnameplural: device memory objects :objectnamecamelcase: deviceMemory +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To allocate memory objects, call: diff --git a/chapters/pipelines.adoc b/chapters/pipelines.adoc index 6a912fb79d..f66e46dddf 100644 --- a/chapters/pipelines.adoc +++ b/chapters/pipelines.adoc @@ -205,6 +205,7 @@ endif::VKSC_VERSION_1_0[] :refpage: vkCreateComputePipelines :objectnameplural: compute pipelines :objectnamecamelcase: computePipeline +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: pname:createInfoCount To create compute pipelines, call: @@ -1286,6 +1287,7 @@ fixed-function pipeline stages, and a pipeline layout. :refpage: vkCreateGraphicsPipelines :objectnameplural: graphics pipelines :objectnamecamelcase: graphicsPipeline +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: pname:createInfoCount To create graphics pipelines, call: @@ -7124,6 +7126,7 @@ include::{generated}/api/handles/VkPipelineCache.adoc[] :refpage: vkCreatePipelineCache :objectnameplural: pipeline caches :objectnamecamelcase: pipelineCache +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create pipeline cache objects, call: @@ -7201,11 +7204,14 @@ ifdef::VKSC_VERSION_1_0[] .Valid Usage **** * [[VUID-vkCreatePipelineCache-pCreateInfo-05045]] - The contents of the structure pointed to by pname:pCreateInfo and the - data pointed to by pname:pCreateInfo->pInitialData must: be the same as - specified in one of the - slink:VkDeviceObjectReservationCreateInfo::pname:pPipelineCacheCreateInfos - structures when the device was created + The values of the pname:flags, pname:initialDataSize, and + pname:pInitialData members of the structure pointed to by + pname:pCreateInfo and the data pointed to by + pname:pCreateInfo->pInitialData must: be the same as specified in one of + the elements of the pname:pPipelineCacheCreateInfos array member of a + slink:VkDeviceObjectReservationCreateInfo structure specified in the + pname:pNext chain of the slink:VkDeviceCreateInfo structure pname:device + was created with include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] **** endif::VKSC_VERSION_1_0[] diff --git a/chapters/primsrast.adoc b/chapters/primsrast.adoc index 7dc5181b1f..880145824e 100644 --- a/chapters/primsrast.adoc +++ b/chapters/primsrast.adoc @@ -1290,24 +1290,27 @@ slink:VkFragmentShadingRateAttachmentInfoKHR. If <> and the shading rate attachment has multiple layers, the shading rate attachment texel is -selected from the layer determined by the -<> built-in. +selected using [eq]#layer = +<>#. If <>, and both the shading rate attachment and the framebuffer have multiple layers, the -shading rate attachment texel is selected from the layer determined by the -<> built-in. -Otherwise, the texel is unconditionally selected from the first layer of the -attachment. +shading rate attachment texel is selected using [eq]#layer = +<>#. +Otherwise, [eq]#layer = 0#. -The fragment size is encoded into the first component of the identified -texel as follows: +The texel is read from the fragment shading rate attachment image as a +<> without a sampler, using integer +coordinates [eq]#i = x'#, [eq]#j = y'#, [eq]#k = 0#, [eq]#l = layer#, and +[eq]#s = 0#. +The fragment size is encoded into the first component of the result of that +operation as follows: {empty}:: [eq]#size~w~ = 2^((texel/4)&3)^# {empty}:: [eq]#size~h~ = 2^(texel&3)^# -where [eq]#texel# is the value in the first component of the identified -texel, and [eq]#size~w~# and [eq]#size~h~# are the width and height of the -fragment size, decoded from the texel. +where [eq]#texel# is the value in the first component of the returned value, +and [eq]#size~w~# and [eq]#size~h~# are the width and height of the fragment +size, decoded from the texel. If no fragment shading rate attachment is specified, this size is calculated as [eq]#size~w~ = size~h~ = 1#. diff --git a/chapters/queries.adoc b/chapters/queries.adoc index dcc74d5b3d..af10317e12 100644 --- a/chapters/queries.adoc +++ b/chapters/queries.adoc @@ -66,6 +66,7 @@ include::{generated}/api/handles/VkQueryPool.adoc[] :refpage: vkCreateQueryPool :objectnameplural: query pools :objectnamecamelcase: queryPool +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a query pool, call: @@ -1160,6 +1161,11 @@ ifdef::VK_KHR_video_queue[or status] values are written as an array of 32-bit values. If an unsigned integer query's value overflows the result type, the value may: either wrap or saturate. +ifdef::VK_KHR_maintenance7[] +If the <> feature is enabled, for +an unsigned integer query, the 32-bit result value must: be equal to the 32 +least significant bits of the equivalent 64-bit result value. +endif::VK_KHR_maintenance7[] ifdef::VK_KHR_performance_query[] If a signed integer query's value overflows the result type, the value is undefined:. @@ -1415,6 +1421,11 @@ ifdef::VK_KHR_video_queue[or status] values are written as an array of 32-bit values. If an unsigned integer query's value overflows the result type, the value may: either wrap or saturate. +ifdef::VK_KHR_maintenance7[] +If the <> feature is enabled, for +an unsigned integer query, the 32-bit result value must: be equal to the 32 +least significant bits of the equivalent 64-bit result value. +endif::VK_KHR_maintenance7[] ifdef::VK_KHR_performance_query[] If a signed integer query's value overflows the result type, the value is undefined:. diff --git a/chapters/renderpass.adoc b/chapters/renderpass.adoc index ca29875f08..80f3cc6b25 100644 --- a/chapters/renderpass.adoc +++ b/chapters/renderpass.adoc @@ -578,10 +578,19 @@ endif::VK_EXT_fragment_density_map[] ifdef::VK_KHR_fragment_shading_rate[] * [[VUID-VkRenderingInfo-pNext-06119]] If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] ifdef::VK_VERSION_1_1,VK_KHR_device_group[] the pname:pNext chain does not contain slink:VkDeviceGroupRenderPassBeginInfo or its - pname:deviceRenderAreaCount member is equal to 0 and + pname:deviceRenderAreaCount member is equal to 0, and endif::VK_VERSION_1_1,VK_KHR_device_group[] the pname:imageView member of a slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure included @@ -590,6 +599,15 @@ endif::VK_VERSION_1_1,VK_KHR_device_group[] latexmath:[\left\lceil{\frac{renderArea_{x}+renderArea_{width}}{shadingRateAttachmentTexelSize_{width}}}\right\rceil] * [[VUID-VkRenderingInfo-pNext-06121]] If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] ifdef::VK_VERSION_1_1,VK_KHR_device_group[] the pname:pNext chain does not contain slink:VkDeviceGroupRenderPassBeginInfo or its @@ -602,21 +620,41 @@ endif::VK_VERSION_1_1,VK_KHR_device_group[] latexmath:[\left\lceil{\frac{renderArea_{y}+renderArea_{height}}{shadingRateAttachmentTexelSize_{height}}}\right\rceil] ifdef::VK_VERSION_1_1,VK_KHR_device_group[] * [[VUID-VkRenderingInfo-pNext-06120]] - If the pname:pNext chain contains a - slink:VkDeviceGroupRenderPassBeginInfo structure, its - pname:deviceRenderAreaCount member is not 0, and the pname:imageView - member of a slink:VkRenderingFragmentShadingRateAttachmentInfoKHR - structure included in the pname:pNext chain is not dlink:VK_NULL_HANDLE, - pname:imageView must: have a width greater than or equal to + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] + the pname:pNext chain contains a slink:VkDeviceGroupRenderPassBeginInfo + structure, its pname:deviceRenderAreaCount member is not 0, and the + pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure included + in the pname:pNext chain is not dlink:VK_NULL_HANDLE, pname:imageView + must: have a width greater than or equal to latexmath:[\left\lceil{\frac{pDeviceRenderAreas_{x}+pDeviceRenderAreas_{width}}{shadingRateAttachmentTexelSize_{width}}}\right\rceil] for each element of pname:pDeviceRenderAreas * [[VUID-VkRenderingInfo-pNext-06122]] - If the pname:pNext chain contains a - slink:VkDeviceGroupRenderPassBeginInfo structure, its - pname:deviceRenderAreaCount member is not 0, and the pname:imageView - member of a slink:VkRenderingFragmentShadingRateAttachmentInfoKHR - structure included in the pname:pNext chain is not dlink:VK_NULL_HANDLE, - pname:imageView must: have a height greater than or equal to + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] + the pname:pNext chain contains a slink:VkDeviceGroupRenderPassBeginInfo + structure, its pname:deviceRenderAreaCount member is not 0, and the + pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure included + in the pname:pNext chain is not dlink:VK_NULL_HANDLE, pname:imageView + must: have a height greater than or equal to latexmath:[\left\lceil{\frac{pDeviceRenderAreas_{y}+pDeviceRenderAreas_{height}}{shadingRateAttachmentTexelSize_{height}}}\right\rceil] for each element of pname:pDeviceRenderAreas endif::VK_VERSION_1_1,VK_KHR_device_group[] @@ -679,12 +717,17 @@ endif::VK_QCOM_multiview_per_view_render_areas[] Valid attachments specified by this structure must: not be bound to memory locations that are bound to any other valid attachments specified by this structure +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] + * [[VUID-VkRenderingInfo-flags-10012]] + If pname:flags includes ename:VK_RENDERING_CONTENTS_INLINE_BIT_KHR then + at least one of the following features must: be enabled +ifdef::VK_KHR_maintenance7[] + ** <> +endif::VK_KHR_maintenance7[] ifdef::VK_EXT_nested_command_buffer[] - * [[VUID-VkRenderingInfo-flags-09381]] - If pname:flags includes ename:VK_RENDERING_CONTENTS_INLINE_BIT_EXT then - the <> feature - must: be enabled + ** <> endif::VK_EXT_nested_command_buffer[] +endif::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] ifdef::VK_ANDROID_external_format_resolve[] * [[VUID-VkRenderingInfo-pDepthAttachment-09318]] pname:pDepthAttachment->resolveMode must: not be @@ -808,15 +851,14 @@ ifdef::VK_EXT_legacy_dithering+VK_KHR_maintenance5[] <> is enabled for the render pass instance. endif::VK_EXT_legacy_dithering+VK_KHR_maintenance5[] -ifdef::VK_EXT_nested_command_buffer[] - * ename:VK_RENDERING_CONTENTS_INLINE_BIT_EXT specifies that draw calls for +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] + * ename:VK_RENDERING_CONTENTS_INLINE_BIT_KHR specifies that draw calls for the render pass instance can: be recorded inline within the current command buffer. - When the <> - feature is enabled this can: be combined with the + This can: be combined with the ename:VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT bit to allow draw calls to be recorded both inline and in secondary command buffers. -endif::VK_EXT_nested_command_buffer[] +endif::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] [[renderpass-suspension]] The contents of pname:pRenderingInfo must: match between suspended render @@ -1621,6 +1663,7 @@ include::{generated}/api/enums/VK_ATTACHMENT_UNUSED.adoc[] :refpage: vkCreateRenderPass :objectnameplural: render passes :objectnamecamelcase: renderPass +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a render pass, call: @@ -3250,6 +3293,7 @@ A more extensible version of render pass creation is also defined below. :refpage: vkCreateRenderPass2 :objectnameplural: render passes :objectnamecamelcase: renderPass +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a render pass, call: @@ -4791,6 +4835,7 @@ include::{generated}/api/handles/VkFramebuffer.adoc[] :refpage: vkCreateFramebuffer :objectnameplural: framebuffers :objectnamecamelcase: framebuffer +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a framebuffer, call: @@ -5020,9 +5065,18 @@ ifdef::VK_VERSION_1_1,VK_KHR_multiview[] the index of the most significant bit set in any of those view masks endif::VK_VERSION_1_1,VK_KHR_multiview[] * [[VUID-VkFramebufferCreateInfo-flags-04539]] - If pname:flags does not include - ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, an element of - pname:pAttachments that is used as a + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] + pname:flags does not include ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, + an element of pname:pAttachments that is used as a <> must: have a width at least as large as [eq]#{lceil}pname:width / code:texelWidth{rceil}#, where code:texelWidth @@ -5030,9 +5084,18 @@ endif::VK_VERSION_1_1,VK_KHR_multiview[] slink:VkFragmentShadingRateAttachmentInfoKHR which references that attachment * [[VUID-VkFramebufferCreateInfo-flags-04540]] - If pname:flags does not include - ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, an element of - pname:pAttachments that is used as a + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, +endif::VK_KHR_maintenance7[] + pname:flags does not include ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, + an element of pname:pAttachments that is used as a <> must: have a height at least as large as [eq]#{lceil}pname:height / code:texelHeight{rceil}#, where @@ -5124,7 +5187,17 @@ ifdef::VK_EXT_fragment_density_map[] endif::VK_EXT_fragment_density_map[] ifdef::VK_KHR_fragment_shading_rate[] * [[VUID-VkFramebufferCreateInfo-flags-04543]] - If pname:flags includes ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, the + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, and +endif::VK_KHR_maintenance7[] + pname:flags includes ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, the pname:width member of any element of the pname:pAttachmentImageInfos member of a slink:VkFramebufferAttachmentsCreateInfo structure in the pname:pNext chain that is used as a @@ -5135,7 +5208,17 @@ ifdef::VK_KHR_fragment_shading_rate[] slink:VkFragmentShadingRateAttachmentInfoKHR which references that attachment * [[VUID-VkFramebufferCreateInfo-flags-04544]] - If pname:flags includes ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, the + If +ifdef::VK_KHR_maintenance7[] + <> is not enabled or the + <> limit is + ename:VK_FALSE or the pname:imageView member of a + slink:VkRenderingFragmentShadingRateAttachmentInfoKHR structure was + created with slink:VkImageSubresourceRange::pname:baseMipLevel greater + than 0, and +endif::VK_KHR_maintenance7[] + pname:flags includes ename:VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, the pname:height member of any element of the pname:pAttachmentImageInfos member of a slink:VkFramebufferAttachmentsCreateInfo structure in the pname:pNext chain that is used as a @@ -5481,8 +5564,14 @@ render pass instance. However, any writes performed by a load operation (as defined by its access masks) to a given attachment may: read and write back any memory locations within the image subresource bound for that attachment. -For depth/stencil images, writes to one aspect may: also result in -read-modify-write operations for the other aspect. +For depth/stencil images, +ifdef::VK_KHR_maintenance7[] +if <> is not enabled on the device or +<> +is ename:VK_FALSE, +endif::VK_KHR_maintenance7[] +writes to one aspect may: also result in read-modify-write operations for +the other aspect. ifdef::VK_EXT_attachment_feedback_loop_layout[] If the subresource is in the ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout, @@ -5579,8 +5668,14 @@ render pass instance. However, any writes performed by a store operation (as defined by its access masks) to a given attachment may: read and write back any memory locations within the image subresource bound for that attachment. -For depth/stencil images writes to one aspect may: also result in -read-modify-write operations for the other aspect. +For depth/stencil images, +ifdef::VK_KHR_maintenance7[] +if +<> +is ename:VK_FALSE, +endif::VK_KHR_maintenance7[] +writes to one aspect may: also result in read-modify-write operations for +the other aspect. ifdef::VK_EXT_attachment_feedback_loop_layout[] If the subresource is in the ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout, @@ -5672,8 +5767,14 @@ render pass instance. However, any writes performed by a resolve operation (as defined by its access masks) to a given attachment may: read and write back any memory locations within the image subresource bound for that attachment. -For depth/stencil images writes to one aspect may: also result in -read-modify-write operations for the other aspect. +For depth/stencil images, +ifdef::VK_KHR_maintenance7[] +if +<> +is ename:VK_FALSE, +endif::VK_KHR_maintenance7[] +writes to one aspect may: also result in read-modify-write operations for +the other aspect. ifdef::VK_EXT_attachment_feedback_loop_layout[] If the subresource is in the ename:VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT layout, @@ -5962,13 +6063,18 @@ ifdef::VK_KHR_dynamic_rendering_local_read[] ename:VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT or ename:VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT endif::VK_KHR_dynamic_rendering_local_read[] -ifdef::VK_EXT_nested_command_buffer[] +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] * [[VUID-vkCmdBeginRenderPass-contents-09640]] If pname:contents is - ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT, then - <> must: be - enabled + ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR, then + at least one of the following features must: be enabled: +ifdef::VK_KHR_maintenance7[] + ** <> +endif::VK_KHR_maintenance7[] +ifdef::VK_EXT_nested_command_buffer[] + ** <> endif::VK_EXT_nested_command_buffer[] +endif::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] **** include::{generated}/validity/protos/vkCmdBeginRenderPass.adoc[] @@ -6684,16 +6790,21 @@ endif::VK_KHR_create_renderpass2[] * pname:contents is a elink:VkSubpassContents value specifying how the commands in the next subpass will be provided. -ifdef::VK_EXT_nested_command_buffer[] +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] .Valid Usage **** * [[VUID-VkSubpassBeginInfo-contents-09382]] If pname:contents is - ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT, then - <> must: be - enabled -**** + ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR, then + at least one of the following features must: be enabled: +ifdef::VK_KHR_maintenance7[] + ** <> +endif::VK_KHR_maintenance7[] +ifdef::VK_EXT_nested_command_buffer[] + ** <> endif::VK_EXT_nested_command_buffer[] +**** +endif::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] include::{generated}/validity/structs/VkSubpassBeginInfo.adoc[] @@ -6715,12 +6826,12 @@ include::{generated}/api/enums/VkSubpassContents.adoc[] from the primary command buffer, and flink:vkCmdExecuteCommands is the only valid command in the command buffer until flink:vkCmdNextSubpass or flink:vkCmdEndRenderPass. -ifdef::VK_EXT_nested_command_buffer[] - * ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT +ifdef::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] + * ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR specifies that the contents of the subpass can: be recorded both inline and in secondary command buffers executed from this command buffer with flink:vkCmdExecuteCommands. -endif::VK_EXT_nested_command_buffer[] +endif::VK_EXT_nested_command_buffer,VK_KHR_maintenance7[] -- ifdef::VK_VERSION_1_1,VK_KHR_device_group[] @@ -7208,8 +7319,8 @@ used for <>. .Valid Usage **** * [[VUID-VkSubpassFragmentDensityMapOffsetEndInfoQCOM-fragmentDensityMapOffsets-06503]] - If the <> feature is not enabled or fragment + If the <> feature is not enabled or fragment density map is not enabled in the render pass, pname:fragmentDensityOffsetCount must: equal `0` * [[VUID-VkSubpassFragmentDensityMapOffsetEndInfoQCOM-fragmentDensityMapAttachment-06504]] diff --git a/chapters/resources.adoc b/chapters/resources.adoc index cec0540834..5ed0bec1b2 100644 --- a/chapters/resources.adoc +++ b/chapters/resources.adoc @@ -40,6 +40,7 @@ include::{generated}/api/handles/VkBuffer.adoc[] :refpage: vkCreateBuffer :objectnameplural: buffers :objectnamecamelcase: buffer +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create buffers, call: @@ -66,8 +67,9 @@ endif::VK_KHR_video_encode_queue[] ifdef::VK_KHR_video_decode_queue[] ename:VK_QUEUE_VIDEO_DECODE_BIT_KHR, endif::VK_KHR_video_decode_queue[] - ename:VK_QUEUE_SPARSE_BINDING_BIT, ename:VK_QUEUE_TRANSFER_BIT, - ename:VK_QUEUE_COMPUTE_BIT, or ename:VK_QUEUE_GRAPHICS_BIT capabilities +ifndef::VKSC_VERSION_1_0[ename:VK_QUEUE_SPARSE_BINDING_BIT,] + ename:VK_QUEUE_TRANSFER_BIT, ename:VK_QUEUE_COMPUTE_BIT, or + ename:VK_QUEUE_GRAPHICS_BIT capabilities ifndef::VKSC_VERSION_1_0[] * [[VUID-vkCreateBuffer-flags-00911]] If the pname:flags member of pname:pCreateInfo includes @@ -981,6 +983,7 @@ include::{generated}/api/handles/VkBufferView.adoc[] :refpage: vkCreateBufferView :objectnameplural: buffer views :objectnamecamelcase: bufferView +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a buffer view, call: @@ -1231,6 +1234,7 @@ include::{generated}/api/handles/VkImage.adoc[] :refpage: vkCreateImage :objectnameplural: images :objectnamecamelcase: image +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create images, call: @@ -1260,8 +1264,9 @@ endif::VK_KHR_video_decode_queue[] ifdef::VK_NV_optical_flow[] ename:VK_QUEUE_OPTICAL_FLOW_BIT_NV, endif::VK_NV_optical_flow[] - ename:VK_QUEUE_SPARSE_BINDING_BIT, ename:VK_QUEUE_TRANSFER_BIT, - ename:VK_QUEUE_COMPUTE_BIT, or ename:VK_QUEUE_GRAPHICS_BIT capabilities +ifndef::VKSC_VERSION_1_0[ename:VK_QUEUE_SPARSE_BINDING_BIT,] + ename:VK_QUEUE_TRANSFER_BIT, ename:VK_QUEUE_COMPUTE_BIT, or + ename:VK_QUEUE_GRAPHICS_BIT capabilities ifndef::VKSC_VERSION_1_0[] * [[VUID-vkCreateImage-flags-00939]] If the pname:flags member of pname:pCreateInfo includes @@ -1895,13 +1900,13 @@ ifndef::VK_QCOM_fragment_density_map_offset[] endif::VK_QCOM_fragment_density_map_offset[] ifdef::VK_QCOM_fragment_density_map_offset[] * [[VUID-VkImageCreateInfo-fragmentDensityMapOffset-06514]] - If the <> feature is not enabled and pname:usage includes ename:VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, pname:extent.width must: be less than or equal to latexmath:[\left\lceil{\frac{maxFramebufferWidth}{minFragmentDensityTexelSize_{width}}}\right\rceil] * [[VUID-VkImageCreateInfo-fragmentDensityMapOffset-06515]] - If the <> feature is not enabled and pname:usage includes ename:VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, pname:extent.height must: be less than or equal to @@ -4702,6 +4707,7 @@ include::{generated}/api/enums/VkImageViewType.adoc[] :refpage: vkCreateImageView :objectnameplural: image views :objectnamecamelcase: imageView +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create an image view, call: diff --git a/chapters/samplers.adoc b/chapters/samplers.adoc index 75e8b4506b..b8c9b0f662 100644 --- a/chapters/samplers.adoc +++ b/chapters/samplers.adoc @@ -21,6 +21,7 @@ include::{generated}/api/handles/VkSampler.adoc[] :refpage: vkCreateSampler :objectnameplural: samplers :objectnamecamelcase: sampler +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a sampler object, call: @@ -800,6 +801,7 @@ endif::VK_KHR_sampler_ycbcr_conversion[] :refpage: vkCreateSamplerYcbcrConversion :objectnameplural: sampler conversions :objectnamecamelcase: samplerYcbcrConversion +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a slink:VkSamplerYcbcrConversion, call: diff --git a/chapters/shaders.adoc b/chapters/shaders.adoc index 0e01096739..8fe69ba1c6 100644 --- a/chapters/shaders.adoc +++ b/chapters/shaders.adoc @@ -1268,6 +1268,36 @@ In Vulkan SC, the shader modules and pipeline state are supplied to an offline compiler which creates a pipeline cache entry which is loaded at <> creation time. +Accordingly, SPIR-V module validation rules defined in the <> +section are only indirectly applied in Vulkan SC, as the SPIR-V modules that +must: adhere to these validation rules are the inputs of the +<> +process, while the Vulkan SC API only consumes the implementation-specific +pipeline caches resulting from this process. +However, violations of SPIR-V module validation rules may: be detected and +reported by validation layers when the corresponding pipeline cache entry +contains <> +entries with SPIR-V module data. + +For completeness, this specification also includes the following shader +module creation valid usage clauses that are expected to be referred to by +validation layers to report SPIR-V module validation errors: + + * Let pname:pCode be a pointer to the SPIR-V module data of the + <>. + * Let pname:codeSize be the corresponding member of the + slink:VkPipelineCacheStageValidationIndexEntry structure describing the + <>. + +.Valid Usage +**** +:refpage: VkShaderModuleCreateInfo +:prefixCondition: If pname:pCode is a pointer to SPIR-V code, +include::{chapters}/commonvalidity/shader_create_spv_common.adoc[] +**** + ifdef::hidden[] // tag::scremoved[] * elink:VkStructureType diff --git a/chapters/synchronization.adoc b/chapters/synchronization.adoc index e3833768f9..abffe8e065 100644 --- a/chapters/synchronization.adoc +++ b/chapters/synchronization.adoc @@ -1968,6 +1968,7 @@ include::{generated}/api/handles/VkFence.adoc[] :refpage: vkCreateFence :objectnameplural: fences :objectnamecamelcase: fence +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a fence, call: @@ -3318,6 +3319,7 @@ include::{generated}/api/handles/VkSemaphore.adoc[] :refpage: vkCreateSemaphore :objectnameplural: semaphores :objectnamecamelcase: semaphore +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create a semaphore, call: @@ -4093,6 +4095,10 @@ slink:VkSemaphoreCreateInfo. [open,refpage='vkCreateSemaphoreSciSyncPoolNV',desc='Create a slink:VkSemaphoreSciSyncPoolNV object',type='protos'] -- :refpage: vkCreateSemaphoreSciSyncPoolNV +:objectnameplural: semaphore pools +:objectnamecamelcase: semaphoreSciSyncPool +:objectnamestruct: VkDeviceSemaphoreSciSyncPoolReservationCreateInfoNV +:objectcount: 1 To create a sname:VkSemaphoreSciSyncPoolNV, call: @@ -4111,18 +4117,11 @@ include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[] .Valid Usage **** -ifdef::VKSC_VERSION_1_0[] - * [[VUID-vkCreateSemaphoreSciSyncPoolNV-device-05150]] - The number of semaphore pools currently allocated from pname:device plus - 1 must: be less than or equal to the total number of semaphore pools - requested via - slink:VkDeviceSemaphoreSciSyncPoolReservationCreateInfoNV::pname:semaphoreSciSyncPoolRequestCount - specified when pname:device was created -endif::VKSC_VERSION_1_0[] * [[VUID-vkCreateSemaphoreSciSyncPoolNV-sciSyncSemaphore2-05151]] The <> feature must: be enabled +include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[] **** include::{generated}/validity/protos/vkCreateSemaphoreSciSyncPoolNV.adoc[] @@ -5317,6 +5316,7 @@ include::{generated}/api/handles/VkEvent.adoc[] :refpage: vkCreateEvent :objectnameplural: events :objectnamecamelcase: event +:objectnamestruct: VkDeviceObjectReservationCreateInfo :objectcount: 1 To create an event, call: diff --git a/chapters/textures.adoc b/chapters/textures.adoc index b4c0b0a4b7..0db1ac1bd7 100644 --- a/chapters/textures.adoc +++ b/chapters/textures.adoc @@ -384,6 +384,7 @@ where: {empty}:: [eq]#B = 15# (exponent bias) +[[textures-input]] == Texel Input Operations _Texel input instructions_ are SPIR-V image instructions that read from an diff --git a/chapters/video/h265_encode.adoc b/chapters/video/h265_encode.adoc index fb497f6b47..d5bd4c8bec 100644 --- a/chapters/video/h265_encode.adoc +++ b/chapters/video/h265_encode.adoc @@ -1382,8 +1382,8 @@ include::{generated}/api/structs/VkVideoEncodeH265RateControlInfoKHR.adoc[] If it is set to code:UINT32_MAX, the IDR period is treated as infinite. * pname:consecutiveBFrameCount is the number of consecutive B frames between I and/or P frames within the <>. - * pname:temporalLayerCount specifies the number of H.265 sub-layers that - the application intends to use. + * pname:subLayerCount specifies the number of H.265 sub-layers that the + application intends to use. When an instance of this structure is included in the pname:pNext chain of the slink:VkVideoCodingControlInfoKHR structure passed to the diff --git a/config/CI/contractions-allowed b/config/CI/contractions-allowed index 031d92971a..9ca37866f2 100644 --- a/config/CI/contractions-allowed +++ b/config/CI/contractions-allowed @@ -1,4 +1,5 @@ ^katex/ +^Binary file ^LICENSES/Apache-2\.0\.txt ^scripts/asciidoctor-chunker/asciidoctor-chunker\.js: ^config/chunkindex/lunr\.js: diff --git a/katex/README.md b/katex/README.md index 5868416eda..88e5df8f2c 100644 --- a/katex/README.md +++ b/katex/README.md @@ -1,20 +1,28 @@ -# [KaTeX](https://katex.org/) +

+ + + KaTeX + +

+ [![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex) -[![CircleCI](https://circleci.com/gh/KaTeX/KaTeX.svg?style=shield)](https://circleci.com/gh/KaTeX/KaTeX) -[![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX) -[![Join the chat at https://gitter.im/KaTeX/KaTeX](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/KaTeX/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=KaTeX/KaTeX)](https://dependabot.com) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/main/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX) +[![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex) -![](https://img.badgesize.io/KaTeX/KaTeX/v0.11.1/dist/katex.min.js?compression=gzip) +![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX) +[![Financial Contributors on Open Collective](https://opencollective.com/katex/all/badge.svg?label=financial+contributors)](https://opencollective.com/katex) KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. - * **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](http://www.intmath.com/cg5/katex-mathjax-comparison.php). + * **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](https://www.intmath.com/cg5/katex-mathjax-comparison.php). * **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting. * **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources. * **Server side rendering:** KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML. -KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11. +KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11. KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html). @@ -29,13 +37,13 @@ Try out KaTeX [on the demo page](https://katex.org/#demo)! - + - + - ... @@ -82,10 +90,36 @@ hover text. For other available options, see the Learn more about using KaTeX [on the website](https://katex.org)! -## Contributing +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). +Code contributors + +### Financial Contributors + +Become a financial contributor and help us sustain our community. + +#### Individuals + +Contribute on Open Collective + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. -See [CONTRIBUTING.md](CONTRIBUTING.md) +Organization 1 +Organization 2 +Organization 3 +Organization 4 +Organization 5 +Organization 6 +Organization 7 +Organization 8 +Organization 9 +Organization 10 ## License -KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT). +KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/katex/contrib/auto-render.js b/katex/contrib/auto-render.js index d31cc7cfb4..d02b742ae2 100644 --- a/katex/contrib/auto-render.js +++ b/katex/contrib/auto-render.js @@ -7,121 +7,98 @@ exports["renderMathInElement"] = factory(require("katex")); else root["renderMathInElement"] = factory(root["katex"]); -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__0__) { -return /******/ (function(modules) { // webpackBootstrap +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 771: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__771__; + +/***/ }) + +/******/ }); +/************************************************************************/ /******/ // The module cache -/******/ var installedModules = {}; -/******/ +/******/ var __webpack_module_cache__ = {}; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) +/******/ /************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__0__; - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { -"use strict"; -__webpack_require__.r(__webpack_exports__); +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ auto_render; } +}); // EXTERNAL MODULE: external "katex" -var external_katex_ = __webpack_require__(0); +var external_katex_ = __webpack_require__(771); var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); - -// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js +;// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js /* eslint no-constant-condition:0 */ -var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { +const findEndOfMath = function (delimiter, text, startIndex) { // Adapted from // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx - var index = startIndex; - var braceLevel = 0; - var delimLength = delimiter.length; + let index = startIndex; + let braceLevel = 0; + const delimLength = delimiter.length; while (index < text.length) { - var character = text[index]; + const character = text[index]; if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { return index; @@ -139,104 +116,88 @@ var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { return -1; }; -var splitAtDelimiters = function splitAtDelimiters(startData, leftDelim, rightDelim, display) { - var finalData = []; - - for (var i = 0; i < startData.length; i++) { - if (startData[i].type === "text") { - var text = startData[i].data; - var lookingForLeft = true; - var currIndex = 0; - var nextIndex = void 0; - nextIndex = text.indexOf(leftDelim); - - if (nextIndex !== -1) { - currIndex = nextIndex; - finalData.push({ - type: "text", - data: text.slice(0, currIndex) - }); - lookingForLeft = false; - } +const escapeRegex = function (string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; - while (true) { - if (lookingForLeft) { - nextIndex = text.indexOf(leftDelim, currIndex); - - if (nextIndex === -1) { - break; - } - - finalData.push({ - type: "text", - data: text.slice(currIndex, nextIndex) - }); - currIndex = nextIndex; - } else { - nextIndex = findEndOfMath(rightDelim, text, currIndex + leftDelim.length); - - if (nextIndex === -1) { - break; - } - - finalData.push({ - type: "math", - data: text.slice(currIndex + leftDelim.length, nextIndex), - rawData: text.slice(currIndex, nextIndex + rightDelim.length), - display: display - }); - currIndex = nextIndex + rightDelim.length; - } +const amsRegex = /^\\begin{/; - lookingForLeft = !lookingForLeft; - } +const splitAtDelimiters = function (text, delimiters) { + let index; + const data = []; + const regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); - finalData.push({ - type: "text", - data: text.slice(currIndex) - }); - } else { - finalData.push(startData[i]); + while (true) { + index = text.search(regexLeft); + + if (index === -1) { + break; } - } - return finalData; -}; + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index) + }); + text = text.slice(index); // now text starts with delimiter + } // ... so this always succeeds: -/* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters); -// CONCATENATED MODULE: ./contrib/auto-render/auto-render.js -/* eslint no-console:0 */ + const i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } -var auto_render_splitWithDelimiters = function splitWithDelimiters(text, delimiters) { - var data = [{ - type: "text", - data: text - }]; + const rawData = text.slice(0, index + delimiters[i].right.length); + const math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } - for (var i = 0; i < delimiters.length; i++) { - var delimiter = delimiters[i]; - data = auto_render_splitAtDelimiters(data, delimiter.left, delimiter.right, delimiter.display || false); + if (text !== "") { + data.push({ + type: "text", + data: text + }); } return data; }; + +/* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters); +;// CONCATENATED MODULE: ./contrib/auto-render/auto-render.js +/* eslint no-console:0 */ + + /* Note: optionsCopy is mutated by this method. If it is ever exposed in the * API, we should copy it before mutating. */ +const renderMathInText = function (text, optionsCopy) { + const data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters); + + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } -var auto_render_renderMathInText = function renderMathInText(text, optionsCopy) { - var data = auto_render_splitWithDelimiters(text, optionsCopy.delimiters); - var fragment = document.createDocumentFragment(); + const fragment = document.createDocumentFragment(); - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { if (data[i].type === "text") { fragment.appendChild(document.createTextNode(data[i].data)); } else { - var span = document.createElement("span"); - var math = data[i].data; // Override any display mode defined in the settings with that + const span = document.createElement("span"); + let math = data[i].data; // Override any display mode defined in the settings with that // defined by the text itself optionsCopy.displayMode = data[i].display; @@ -246,9 +207,9 @@ var auto_render_renderMathInText = function renderMathInText(text, optionsCopy) math = optionsCopy.preProcess(math); } - external_katex_default.a.render(math, span, optionsCopy); + external_katex_default().render(math, span, optionsCopy); } catch (e) { - if (!(e instanceof external_katex_default.a.ParseError)) { + if (!(e instanceof (external_katex_default()).ParseError)) { throw e; } @@ -264,40 +225,61 @@ var auto_render_renderMathInText = function renderMathInText(text, optionsCopy) return fragment; }; -var renderElem = function renderElem(elem, optionsCopy) { - for (var i = 0; i < elem.childNodes.length; i++) { - var childNode = elem.childNodes[i]; +const renderElem = function (elem, optionsCopy) { + for (let i = 0; i < elem.childNodes.length; i++) { + const childNode = elem.childNodes[i]; if (childNode.nodeType === 3) { // Text node - var frag = auto_render_renderMathInText(childNode.textContent, optionsCopy); - i += frag.childNodes.length - 1; - elem.replaceChild(frag, childNode); - } else if (childNode.nodeType === 1) { - (function () { - // Element node - var className = ' ' + childNode.className + ' '; - var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(function (x) { - return className.indexOf(' ' + x + ' ') === -1; - }); - - if (shouldRender) { - renderElem(childNode, optionsCopy); + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + let textContentConcat = childNode.textContent; + let sibling = childNode.nextSibling; + let nSiblings = 0; + + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + textContentConcat += sibling.textContent; + sibling = sibling.nextSibling; + nSiblings++; + } + + const frag = renderMathInText(textContentConcat, optionsCopy); + + if (frag) { + // Remove extra text nodes + for (let j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); } - })(); + + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + const className = ' ' + childNode.className + ' '; + const shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1); + + if (shouldRender) { + renderElem(childNode, optionsCopy); + } } // Otherwise, it's something else, and ignore it. } }; -var renderMathInElement = function renderMathInElement(elem, options) { +const renderMathInElement = function (elem, options) { if (!elem) { throw new Error("No element provided to render"); } - var optionsCopy = {}; // Object.assign(optionsCopy, option) + const optionsCopy = {}; // Object.assign(optionsCopy, option) - for (var option in options) { + for (const option in options) { if (options.hasOwnProperty(option)) { optionsCopy[option] = options[option]; } @@ -314,16 +296,34 @@ var renderMathInElement = function renderMathInElement(elem, options) { display: false }, // LaTeX uses $…$, but it ruins the display of normal `$` in text: // {left: "$", right: "$", display: false}, - // \[…\] must come last in this array. Otherwise, renderMathInElement - // will search for \[ before it searches for $$ or \( - // That makes it susceptible to finding a \\[0.3em] row delimiter and - // treating it as if it were the start of a KaTeX math zone. + // $ must come after $$ + // Render AMS environments even if outside $$…$$ delimiters. { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { left: "\\[", right: "\\]", display: true }]; - optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code"]; + optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"]; optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different // math elements within a single call to `renderMathInElement`. @@ -332,8 +332,10 @@ var renderMathInElement = function renderMathInElement(elem, options) { renderElem(elem, optionsCopy); }; -/* harmony default export */ var auto_render = __webpack_exports__["default"] = (renderMathInElement); - -/***/ }) -/******/ ])["default"]; +/* harmony default export */ var auto_render = (renderMathInElement); +}(); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/contrib/auto-render.min.js b/katex/contrib/auto-render.min.js index 3a6d663904..46d62af28d 100644 --- a/katex/contrib/auto-render.min.js +++ b/katex/contrib/auto-render.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=function(e,t,r){for(var n=r,o=0,a=e.length;ne.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))).join("|")+")");for(;r=e.search(a),-1!==r;){r>0&&(o.push({type:"text",data:e.slice(0,r)}),e=e.slice(r));const a=t.findIndex((t=>e.startsWith(t.left)));if(r=n(t[a].right,e,t[a].left.length),-1===r)break;const l=e.slice(0,r+t[a].right.length),s=i.test(l)?l:e.slice(t[a].left.length,r);o.push({type:"math",data:s,rawData:l,display:t[a].display}),e=e.slice(r+t[a].right.length)}return""!==e&&o.push({type:"text",data:e}),o};const l=function(e,n){const r=a(e,n.delimiters);if(1===r.length&&"text"===r[0].type)return null;const o=document.createDocumentFragment();for(let e=0;e-1===e.indexOf(" "+t+" ")))&&s(r,t)}}};var d=function(e,t){if(!e)throw new Error("No element provided to render");const n={};for(const e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);n.delimiters=n.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},s(e,n)}}(),o=o.default}()})); \ No newline at end of file diff --git a/katex/contrib/auto-render.mjs b/katex/contrib/auto-render.mjs index 58de8b67be..5ad25e6bc3 100644 --- a/katex/contrib/auto-render.mjs +++ b/katex/contrib/auto-render.mjs @@ -1,15 +1,15 @@ import katex from '../katex.mjs'; /* eslint no-constant-condition:0 */ -const findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { +var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { // Adapted from // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx - let index = startIndex; - let braceLevel = 0; - const delimLength = delimiter.length; + var index = startIndex; + var braceLevel = 0; + var delimLength = delimiter.length; while (index < text.length) { - const character = text[index]; + var character = text[index]; if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { return index; @@ -27,100 +27,84 @@ const findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { return -1; }; -const splitAtDelimiters = function splitAtDelimiters(startData, leftDelim, rightDelim, display) { - const finalData = []; - - for (let i = 0; i < startData.length; i++) { - if (startData[i].type === "text") { - const text = startData[i].data; - let lookingForLeft = true; - let currIndex = 0; - let nextIndex; - nextIndex = text.indexOf(leftDelim); - - if (nextIndex !== -1) { - currIndex = nextIndex; - finalData.push({ - type: "text", - data: text.slice(0, currIndex) - }); - lookingForLeft = false; - } +var escapeRegex = function escapeRegex(string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; - while (true) { - if (lookingForLeft) { - nextIndex = text.indexOf(leftDelim, currIndex); - - if (nextIndex === -1) { - break; - } - - finalData.push({ - type: "text", - data: text.slice(currIndex, nextIndex) - }); - currIndex = nextIndex; - } else { - nextIndex = findEndOfMath(rightDelim, text, currIndex + leftDelim.length); - - if (nextIndex === -1) { - break; - } - - finalData.push({ - type: "math", - data: text.slice(currIndex + leftDelim.length, nextIndex), - rawData: text.slice(currIndex, nextIndex + rightDelim.length), - display: display - }); - currIndex = nextIndex + rightDelim.length; - } +var amsRegex = /^\\begin{/; - lookingForLeft = !lookingForLeft; - } +var splitAtDelimiters = function splitAtDelimiters(text, delimiters) { + var index; + var data = []; + var regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); + + while (true) { + index = text.search(regexLeft); - finalData.push({ + if (index === -1) { + break; + } + + if (index > 0) { + data.push({ type: "text", - data: text.slice(currIndex) + data: text.slice(0, index) }); - } else { - finalData.push(startData[i]); - } - } + text = text.slice(index); // now text starts with delimiter + } // ... so this always succeeds: - return finalData; -}; -/* eslint no-console:0 */ + var i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); -const splitWithDelimiters = function splitWithDelimiters(text, delimiters) { - let data = [{ - type: "text", - data: text - }]; + if (index === -1) { + break; + } - for (let i = 0; i < delimiters.length; i++) { - const delimiter = delimiters[i]; - data = splitAtDelimiters(data, delimiter.left, delimiter.right, delimiter.display || false); + var rawData = text.slice(0, index + delimiters[i].right.length); + var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } + + if (text !== "") { + data.push({ + type: "text", + data: text + }); } return data; }; + +/* eslint no-console:0 */ /* Note: optionsCopy is mutated by this method. If it is ever exposed in the * API, we should copy it before mutating. */ +var renderMathInText = function renderMathInText(text, optionsCopy) { + var data = splitAtDelimiters(text, optionsCopy.delimiters); + + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } -const renderMathInText = function renderMathInText(text, optionsCopy) { - const data = splitWithDelimiters(text, optionsCopy.delimiters); - const fragment = document.createDocumentFragment(); + var fragment = document.createDocumentFragment(); - for (let i = 0; i < data.length; i++) { + for (var i = 0; i < data.length; i++) { if (data[i].type === "text") { fragment.appendChild(document.createTextNode(data[i].data)); } else { - const span = document.createElement("span"); - let math = data[i].data; // Override any display mode defined in the settings with that + var span = document.createElement("span"); + var math = data[i].data; // Override any display mode defined in the settings with that // defined by the text itself optionsCopy.displayMode = data[i].display; @@ -148,36 +132,63 @@ const renderMathInText = function renderMathInText(text, optionsCopy) { return fragment; }; -const renderElem = function renderElem(elem, optionsCopy) { - for (let i = 0; i < elem.childNodes.length; i++) { - const childNode = elem.childNodes[i]; +var renderElem = function renderElem(elem, optionsCopy) { + for (var i = 0; i < elem.childNodes.length; i++) { + var childNode = elem.childNodes[i]; if (childNode.nodeType === 3) { // Text node - const frag = renderMathInText(childNode.textContent, optionsCopy); - i += frag.childNodes.length - 1; - elem.replaceChild(frag, childNode); - } else if (childNode.nodeType === 1) { - // Element node - const className = ' ' + childNode.className + ' '; - const shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1); + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + var textContentConcat = childNode.textContent; + var sibling = childNode.nextSibling; + var nSiblings = 0; + + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + textContentConcat += sibling.textContent; + sibling = sibling.nextSibling; + nSiblings++; + } + + var frag = renderMathInText(textContentConcat, optionsCopy); + + if (frag) { + // Remove extra text nodes + for (var j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); + } - if (shouldRender) { - renderElem(childNode, optionsCopy); + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; } + } else if (childNode.nodeType === 1) { + (function () { + // Element node + var className = ' ' + childNode.className + ' '; + var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1); + + if (shouldRender) { + renderElem(childNode, optionsCopy); + } + })(); } // Otherwise, it's something else, and ignore it. } }; -const renderMathInElement = function renderMathInElement(elem, options) { +var renderMathInElement = function renderMathInElement(elem, options) { if (!elem) { throw new Error("No element provided to render"); } - const optionsCopy = {}; // Object.assign(optionsCopy, option) + var optionsCopy = {}; // Object.assign(optionsCopy, option) - for (const option in options) { + for (var option in options) { if (options.hasOwnProperty(option)) { optionsCopy[option] = options[option]; } @@ -194,16 +205,34 @@ const renderMathInElement = function renderMathInElement(elem, options) { display: false }, // LaTeX uses $…$, but it ruins the display of normal `$` in text: // {left: "$", right: "$", display: false}, - // \[…\] must come last in this array. Otherwise, renderMathInElement - // will search for \[ before it searches for $$ or \( - // That makes it susceptible to finding a \\[0.3em] row delimiter and - // treating it as if it were the start of a KaTeX math zone. + // $ must come after $$ + // Render AMS environments even if outside $$…$$ delimiters. { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { left: "\\[", right: "\\]", display: true }]; - optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code"]; + optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"]; optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different // math elements within a single call to `renderMathInElement`. @@ -212,4 +241,4 @@ const renderMathInElement = function renderMathInElement(elem, options) { renderElem(elem, optionsCopy); }; -export default renderMathInElement; +export { renderMathInElement as default }; diff --git a/katex/contrib/copy-tex.css b/katex/contrib/copy-tex.css deleted file mode 100644 index 90801d8428..0000000000 --- a/katex/contrib/copy-tex.css +++ /dev/null @@ -1,14 +0,0 @@ -/* Force selection of entire .katex/.katex-display blocks, so that we can - * copy/paste the entire source code. If you omit this CSS, partial - * selections of a formula will work, but will copy the ugly HTML - * representation instead of the LaTeX source code. (Full selections will - * still produce the LaTeX source code.) - */ -.katex, -.katex-display { - user-select: all; - -moz-user-select: all; - -webkit-user-select: all; - -ms-user-select: all; -} - diff --git a/katex/contrib/copy-tex.js b/katex/contrib/copy-tex.js index 4649f8f7e9..8cfa7d684f 100644 --- a/katex/contrib/copy-tex.js +++ b/katex/contrib/copy-tex.js @@ -8,111 +8,13 @@ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })((typeof self !== 'undefined' ? self : this), function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -// extracted by mini-css-extract-plugin - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); - -// EXTERNAL MODULE: ./contrib/copy-tex/copy-tex.css -var copy_tex = __webpack_require__(0); - -// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +var __webpack_exports__ = {}; + +;// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js // Set these to how you want inline and display math to be delimited. -var defaultCopyDelimiters = { +const defaultCopyDelimiters = { inline: ['$', '$'], // alternative: ['\(', '\)'] display: ['$$', '$$'] // alternative: ['\[', '\]'] @@ -121,39 +23,38 @@ var defaultCopyDelimiters = { // Modifies fragment in-place. Useful for writing your own 'copy' handler, // as in copy-tex.js. -var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) { +function katexReplaceWithTex(fragment, copyDelimiters) { if (copyDelimiters === void 0) { copyDelimiters = defaultCopyDelimiters; } // Remove .katex-html blocks that are preceded by .katex-mathml blocks // (which will get replaced below). - var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); - for (var i = 0; i < katexHtml.length; i++) { - var element = katexHtml[i]; + for (let i = 0; i < katexHtml.length; i++) { + const element = katexHtml[i]; if (element.remove) { - element.remove(null); - } else { + element.remove(); + } else if (element.parentNode) { element.parentNode.removeChild(element); } } // Replace .katex-mathml elements with their annotation (TeX source) // descendant, with inline delimiters. - var katexMathml = fragment.querySelectorAll('.katex-mathml'); - - for (var _i = 0; _i < katexMathml.length; _i++) { - var _element = katexMathml[_i]; + const katexMathml = fragment.querySelectorAll('.katex-mathml'); - var texSource = _element.querySelector('annotation'); + for (let i = 0; i < katexMathml.length; i++) { + const element = katexMathml[i]; + const texSource = element.querySelector('annotation'); if (texSource) { - if (_element.replaceWith) { - _element.replaceWith(texSource); - } else { - _element.parentNode.replaceChild(texSource, _element); + if (element.replaceWith) { + element.replaceWith(texSource); + } else if (element.parentNode) { + element.parentNode.replaceChild(texSource, element); } texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; @@ -161,53 +62,66 @@ var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) } // Switch display math to display delimiters. - var displays = fragment.querySelectorAll('.katex-display annotation'); + const displays = fragment.querySelectorAll('.katex-display annotation'); - for (var _i2 = 0; _i2 < displays.length; _i2++) { - var _element2 = displays[_i2]; - _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + for (let i = 0; i < displays.length; i++) { + const element = displays[i]; + element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; } return fragment; -}; +} /* harmony default export */ var katex2tex = (katexReplaceWithTex); -// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js - // Global copy handler to modify behavior on .katex elements. +;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js + // Return
element containing node, or null if not found. + +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + const element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} // Global copy handler to modify behavior on/within .katex elements. + document.addEventListener('copy', function (event) { - var selection = window.getSelection(); + const selection = window.getSelection(); - if (selection.isCollapsed) { - return; // default action OK if selection is empty + if (selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable } - var fragment = selection.getRangeAt(0).cloneContents(); + const clipboardData = event.clipboardData; + const range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula. - if (!fragment.querySelector('.katex-mathml')) { - return; // default action OK if no .katex-mathml elements - } // Preserve usual HTML copy/paste behavior. + const startKatex = closestKatex(range.startContainer); + + if (startKatex) { + range.setStartBefore(startKatex); + } // Similarly, when end point is within a formula, expand to entire formula. - var html = []; + const endKatex = closestKatex(range.endContainer); - for (var i = 0; i < fragment.childNodes.length; i++) { - html.push(fragment.childNodes[i].outerHTML); + if (endKatex) { + range.setEndAfter(endKatex); } - event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version. + const fragment = range.cloneContents(); - event.clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling. + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } - event.preventDefault(); -}); -// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.webpack.js -/** - * This is the webpack entry point for KaTeX. As ECMAScript doesn't support - * CSS modules natively, a separate entry point is used. - */ + const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version. + clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling. -/***/ }) -/******/ ])["default"]; + event.preventDefault(); +}); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/contrib/copy-tex.min.css b/katex/contrib/copy-tex.min.css deleted file mode 100644 index 555ed1156b..0000000000 --- a/katex/contrib/copy-tex.min.css +++ /dev/null @@ -1 +0,0 @@ -.katex,.katex-display{user-select:all;-moz-user-select:all;-webkit-user-select:all;-ms-user-select:all} diff --git a/katex/contrib/copy-tex.min.js b/katex/contrib/copy-tex.min.js index e0354d6b9f..a826f4f57e 100644 --- a/katex/contrib/copy-tex.min.js +++ b/katex/contrib/copy-tex.min.js @@ -1 +1 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){},function(e,t,n){"use strict";n.r(t);n(0);var r={inline:["$","$"],display:["$$","$$"]},o=function(e,t){void 0===t&&(t=r);for(var n=e.querySelectorAll(".katex-mathml + .katex-html"),o=0;oe instanceof Text?e.textContent:e.outerHTML)).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()})),e=e.default}()})); \ No newline at end of file diff --git a/katex/contrib/copy-tex.mjs b/katex/contrib/copy-tex.mjs index b6ed1eef0e..cb9d657269 100644 --- a/katex/contrib/copy-tex.mjs +++ b/katex/contrib/copy-tex.mjs @@ -1,5 +1,5 @@ // Set these to how you want inline and display math to be delimited. -const defaultCopyDelimiters = { +var defaultCopyDelimiters = { inline: ['$', '$'], // alternative: ['\(', '\)'] display: ['$$', '$$'] // alternative: ['\[', '\]'] @@ -8,38 +8,39 @@ const defaultCopyDelimiters = { // Modifies fragment in-place. Useful for writing your own 'copy' handler, // as in copy-tex.js. -const katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) { +function katexReplaceWithTex(fragment, copyDelimiters) { if (copyDelimiters === void 0) { copyDelimiters = defaultCopyDelimiters; } // Remove .katex-html blocks that are preceded by .katex-mathml blocks // (which will get replaced below). - const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); - for (let i = 0; i < katexHtml.length; i++) { - const element = katexHtml[i]; + for (var i = 0; i < katexHtml.length; i++) { + var element = katexHtml[i]; if (element.remove) { - element.remove(null); - } else { + element.remove(); + } else if (element.parentNode) { element.parentNode.removeChild(element); } } // Replace .katex-mathml elements with their annotation (TeX source) // descendant, with inline delimiters. - const katexMathml = fragment.querySelectorAll('.katex-mathml'); + var katexMathml = fragment.querySelectorAll('.katex-mathml'); - for (let i = 0; i < katexMathml.length; i++) { - const element = katexMathml[i]; - const texSource = element.querySelector('annotation'); + for (var _i = 0; _i < katexMathml.length; _i++) { + var _element = katexMathml[_i]; + + var texSource = _element.querySelector('annotation'); if (texSource) { - if (element.replaceWith) { - element.replaceWith(texSource); - } else { - element.parentNode.replaceChild(texSource, element); + if (_element.replaceWith) { + _element.replaceWith(texSource); + } else if (_element.parentNode) { + _element.parentNode.replaceChild(texSource, _element); } texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; @@ -47,39 +48,58 @@ const katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiter } // Switch display math to display delimiters. - const displays = fragment.querySelectorAll('.katex-display annotation'); + var displays = fragment.querySelectorAll('.katex-display annotation'); - for (let i = 0; i < displays.length; i++) { - const element = displays[i]; - element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + for (var _i2 = 0; _i2 < displays.length; _i2++) { + var _element2 = displays[_i2]; + _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; } return fragment; -}; +} + +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + var element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} // Global copy handler to modify behavior on/within .katex elements. + document.addEventListener('copy', function (event) { - const selection = window.getSelection(); + var selection = window.getSelection(); - if (selection.isCollapsed) { - return; // default action OK if selection is empty + if (selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable } - const fragment = selection.getRangeAt(0).cloneContents(); + var clipboardData = event.clipboardData; + var range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula. - if (!fragment.querySelector('.katex-mathml')) { - return; // default action OK if no .katex-mathml elements - } // Preserve usual HTML copy/paste behavior. + var startKatex = closestKatex(range.startContainer); + + if (startKatex) { + range.setStartBefore(startKatex); + } // Similarly, when end point is within a formula, expand to entire formula. - const html = []; + var endKatex = closestKatex(range.endContainer); - for (let i = 0; i < fragment.childNodes.length; i++) { - html.push(fragment.childNodes[i].outerHTML); + if (endKatex) { + range.setEndAfter(endKatex); } - event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version. + var fragment = range.cloneContents(); + + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + + var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior. + + clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version. - event.clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling. + clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling. event.preventDefault(); }); diff --git a/katex/contrib/mathtex-script-type.js b/katex/contrib/mathtex-script-type.js index daa01a6336..48ce856dab 100644 --- a/katex/contrib/mathtex-script-type.js +++ b/katex/contrib/mathtex-script-type.js @@ -7,121 +7,94 @@ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__0__) { -return /******/ (function(modules) { // webpackBootstrap +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 771: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__771__; + +/***/ }) + +/******/ }); +/************************************************************************/ /******/ // The module cache -/******/ var installedModules = {}; -/******/ +/******/ var __webpack_module_cache__ = {}; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) +/******/ /************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__0__; - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771); /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); -var scripts = document.body.getElementsByTagName("script"); +let scripts = document.body.getElementsByTagName("script"); scripts = Array.prototype.slice.call(scripts); scripts.forEach(function (script) { if (!script.type || !script.type.match(/math\/tex/i)) { return -1; } - var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; - var katexElement = document.createElement(display ? "div" : "span"); + const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + const katexElement = document.createElement(display ? "div" : "span"); katexElement.setAttribute("class", display ? "equation" : "inline-equation"); try { - katex__WEBPACK_IMPORTED_MODULE_0___default.a.render(script.text, katexElement, { + katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, { displayMode: display }); } catch (err) { @@ -131,7 +104,9 @@ scripts.forEach(function (script) { script.parentNode.replaceChild(katexElement, script); }); - -/***/ }) -/******/ ])["default"]; +}(); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/contrib/mathtex-script-type.min.js b/katex/contrib/mathtex-script-type.min.js index ae9f528691..8ff1413c2f 100644 --- a/katex/contrib/mathtex-script-type.min.js +++ b/katex/contrib/mathtex-script-type.min.js @@ -1 +1 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),u=document.body.getElementsByTagName("script");(u=Array.prototype.slice.call(u)).forEach(function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;var t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(t?"div":"span");r.setAttribute("class",t?"equation":"inline-equation");try{o.a.render(e.text,r,{displayMode:t})}catch(t){r.textContent=e.text}e.parentNode.replaceChild(r,e)})}]).default}); \ No newline at end of file +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var n="object"==typeof exports?t(require("katex")):t(e.katex);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};return function(){var e=r(771),t=r.n(e);let n=document.body.getElementsByTagName("script");n=Array.prototype.slice.call(n),n.forEach((function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const n=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(n?"div":"span");r.setAttribute("class",n?"equation":"inline-equation");try{t().render(e.text,r,{displayMode:n})}catch(t){r.textContent=e.text}e.parentNode.replaceChild(r,e)}))}(),o=o.default}()})); \ No newline at end of file diff --git a/katex/contrib/mathtex-script-type.mjs b/katex/contrib/mathtex-script-type.mjs index 7cfb90e98f..1083b9279f 100644 --- a/katex/contrib/mathtex-script-type.mjs +++ b/katex/contrib/mathtex-script-type.mjs @@ -1,14 +1,14 @@ import katex from '../katex.mjs'; -let scripts = document.body.getElementsByTagName("script"); +var scripts = document.body.getElementsByTagName("script"); scripts = Array.prototype.slice.call(scripts); scripts.forEach(function (script) { if (!script.type || !script.type.match(/math\/tex/i)) { return -1; } - const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; - const katexElement = document.createElement(display ? "div" : "span"); + var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + var katexElement = document.createElement(display ? "div" : "span"); katexElement.setAttribute("class", display ? "equation" : "inline-equation"); try { diff --git a/katex/contrib/mhchem.js b/katex/contrib/mhchem.js index f84566ef49..531c1734d7 100644 --- a/katex/contrib/mhchem.js +++ b/katex/contrib/mhchem.js @@ -7,110 +7,83 @@ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__0__) { -return /******/ (function(modules) { // webpackBootstrap +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 771: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__771__; + +/***/ }) + +/******/ }); +/************************************************************************/ /******/ // The module cache -/******/ var installedModules = {}; -/******/ +/******/ var __webpack_module_cache__ = {}; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) +/******/ /************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__0__; - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771); /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); /* eslint-disable */ -/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ @@ -160,28 +133,28 @@ __webpack_require__.r(__webpack_exports__); // - use "" for strings that need to stay untouched // version: "3.3.0" for MathJax and KaTeX // Add \ce, \pu, and \tripledash to the KaTeX macros. -katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\ce", function (context) { +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\ce", function (context) { return chemParse(context.consumeArgs(1)[0], "ce"); }); -katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\pu", function (context) { +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\pu", function (context) { return chemParse(context.consumeArgs(1)[0], "pu"); }); // Needed for \bond for the ~ forms // Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not // a mathematical minus, U+2212. So we need that extra 0.56. -katex__WEBPACK_IMPORTED_MODULE_0___default.a.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); // // This is the main function for handing the \ce and \pu commands. // It takes the argument to \ce or \pu and returns the corresponding TeX string. // -var chemParse = function chemParse(tokens, stateMachine) { +var chemParse = function (tokens, stateMachine) { // Recreate the argument string from KaTeX's array of tokens. var str = ""; - var expectedLoc = tokens[tokens.length - 1].loc.start; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; for (var i = tokens.length - 1; i >= 0; i--) { if (tokens[i].loc.start > expectedLoc) { @@ -210,7 +183,7 @@ var mhchemParser = { // Call like // go("H2O"); // - go: function go(input, stateMachine) { + go: function (input, stateMachine) { if (!input) { return []; } @@ -342,7 +315,7 @@ var mhchemParser = { } } }, - concatArray: function concatArray(a, b) { + concatArray: function (a, b) { if (b) { if (Array.isArray(b)) { for (var iB = 0; iB < b.length; iB++) { @@ -378,7 +351,7 @@ var mhchemParser = { 'digits': /^[0-9]+/, '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/, '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/, - '(-)(9.,9)(e)(99)': function e99(input) { + '(-)(9.,9)(e)(99)': function (input) { var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/); if (m && m[0]) { @@ -390,7 +363,7 @@ var mhchemParser = { return null; }, - '(-)(9)^(-9)': function _(input) { + '(-)(9)^(-9)': function (input) { var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/); if (m && m[0]) { @@ -402,7 +375,7 @@ var mhchemParser = { return null; }, - 'state of aggregation $': function stateOfAggregation$(input) { + 'state of aggregation $': function (input) { // ... or crystal system var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat) @@ -431,51 +404,51 @@ var mhchemParser = { '. ': /^([.\u22C5\u00B7\u2022])\s*/, '...': /^\.\.\.(?=$|[^.])/, '* ': /^([*])\s*/, - '^{(...)}': function _(input) { + '^{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}"); }, - '^($...$)': function $$(input) { + '^($...$)': function (input) { return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", ""); }, '^a': /^\^([0-9]+|[^\\_])/, - '^\\x{}{}': function x(input) { + '^\\x{}{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); }, - '^\\x{}': function x(input) { + '^\\x{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", ""); }, '^\\x': /^\^(\\[a-zA-Z]+)\s*/, '^(-1)': /^\^(-?\d+)/, '\'': /^'/, - '_{(...)}': function _(input) { + '_{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}"); }, - '_($...$)': function _$$(input) { + '_($...$)': function (input) { return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", ""); }, '_9': /^_([+\-]?[0-9]+|[^\\])/, - '_\\x{}{}': function _X(input) { + '_\\x{}{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); }, - '_\\x{}': function _X(input) { + '_\\x{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", ""); }, '_\\x': /^_(\\[a-zA-Z]+)\s*/, '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/, '{}': /^\{\}/, - '{...}': function _(input) { + '{...}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", ""); }, - '{(...)}': function _(input) { + '{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}"); }, - '$...$': function $$(input) { + '$...$': function (input) { return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); }, - '${(...)}$': function $$(input) { + '${(...)}$': function (input) { return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$"); }, - '$(...)$': function $$(input) { + '$(...)$': function (input) { return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$"); }, '=<>': /^[=<>]/, @@ -489,21 +462,21 @@ var mhchemParser = { 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/, 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/, 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/, - '\\bond{(...)}': function bond(input) { + '\\bond{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}"); }, '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/, 'CMT': /^[CMT](?=\[)/, - '[(...)]': function _(input) { + '[(...)]': function (input) { return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]"); }, '1st-level escape': /^(&|\\\\|\\hline)\s*/, '\\,': /^(?:\\[,\ ;:])/, // \\x - but output no space before - '\\x{}{}': function x(input) { + '\\x{}{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); }, - '\\x{}': function x(input) { + '\\x{}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", ""); }, '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/, @@ -511,28 +484,28 @@ var mhchemParser = { 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/, // only those with numbers in front, because the others will be formatted correctly anyway 'others': /^[\/~|]/, - '\\frac{(...)}': function frac(input) { + '\\frac{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}"); }, - '\\overset{(...)}': function overset(input) { + '\\overset{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}"); }, - "\\underset{(...)}": function underset(input) { + '\\underset{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}"); }, - "\\underbrace{(...)}": function underbrace(input) { + '\\underbrace{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}"); }, - '\\color{(...)}0': function color0(input) { + '\\color{(...)}0': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}"); }, - '\\color{(...)}{(...)}1': function color1(input) { + '\\color{(...)}{(...)}1': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}"); }, - '\\color(...){(...)}2': function color2(input) { + '\\color(...){(...)}2': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}"); }, - '\\ce{(...)}': function ce(input) { + '\\ce{(...)}': function (input) { return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}"); }, 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, @@ -540,7 +513,7 @@ var mhchemParser = { // 0 could be oxidation or charge 'roman numeral': /^[IVX]+/, '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/, - 'amount': function amount(input) { + 'amount': function (input) { var match; // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/); @@ -568,11 +541,11 @@ var mhchemParser = { return null; }, - 'amount2': function amount2(input) { + 'amount2': function (input) { return this['amount'](input); }, '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/, - 'formula$': function formula$(input) { + 'formula$': function (input) { if (input.match(/^\([a-z]+\)$/)) { return null; } // state of aggregation = no formula @@ -594,9 +567,9 @@ var mhchemParser = { '//': /^\s*(\/\/)\s*/, '*': /^\s*[*.]\s*/ }, - findObserveGroups: function findObserveGroups(input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { + findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { /** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */ - var _match = function _match(input, pattern) { + var _match = function (input, pattern) { if (typeof pattern === "string") { if (input.indexOf(pattern) !== 0) { return null; @@ -616,7 +589,7 @@ var mhchemParser = { /** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */ - var _findObserveGroups = function _findObserveGroups(input, i, endChars) { + var _findObserveGroups = function (input, i, endChars) { var braces = 0; while (i < input.length) { @@ -696,7 +669,7 @@ var mhchemParser = { // e.g. match("a", input) will look for the regexp called "a" and see if it matches // returns null or {match_:"a", remainder:"bc"} // - match_: function match_(m, input) { + match_: function (m, input) { var pattern = mhchemParser.patterns.patterns[m]; if (pattern === undefined) { @@ -732,88 +705,88 @@ var mhchemParser = { // Generic state machine actions // actions: { - 'a=': function a(buffer, m) { + 'a=': function (buffer, m) { buffer.a = (buffer.a || "") + m; }, - 'b=': function b(buffer, m) { + 'b=': function (buffer, m) { buffer.b = (buffer.b || "") + m; }, - 'p=': function p(buffer, m) { + 'p=': function (buffer, m) { buffer.p = (buffer.p || "") + m; }, - 'o=': function o(buffer, m) { + 'o=': function (buffer, m) { buffer.o = (buffer.o || "") + m; }, - 'q=': function q(buffer, m) { + 'q=': function (buffer, m) { buffer.q = (buffer.q || "") + m; }, - 'd=': function d(buffer, m) { + 'd=': function (buffer, m) { buffer.d = (buffer.d || "") + m; }, - 'rm=': function rm(buffer, m) { + 'rm=': function (buffer, m) { buffer.rm = (buffer.rm || "") + m; }, - 'text=': function text(buffer, m) { + 'text=': function (buffer, m) { buffer.text_ = (buffer.text_ || "") + m; }, - 'insert': function insert(buffer, m, a) { + 'insert': function (buffer, m, a) { return { type_: a }; }, - 'insert+p1': function insertP1(buffer, m, a) { + 'insert+p1': function (buffer, m, a) { return { type_: a, p1: m }; }, - 'insert+p1+p2': function insertP1P2(buffer, m, a) { + 'insert+p1+p2': function (buffer, m, a) { return { type_: a, p1: m[0], p2: m[1] }; }, - 'copy': function copy(buffer, m) { + 'copy': function (buffer, m) { return m; }, - 'rm': function rm(buffer, m) { + 'rm': function (buffer, m) { return { type_: 'rm', p1: m || "" }; }, - 'text': function text(buffer, m) { + 'text': function (buffer, m) { return mhchemParser.go(m, 'text'); }, - '{text}': function text(buffer, m) { + '{text}': function (buffer, m) { var ret = ["{"]; mhchemParser.concatArray(ret, mhchemParser.go(m, 'text')); ret.push("}"); return ret; }, - 'tex-math': function texMath(buffer, m) { + 'tex-math': function (buffer, m) { return mhchemParser.go(m, 'tex-math'); }, - 'tex-math tight': function texMathTight(buffer, m) { + 'tex-math tight': function (buffer, m) { return mhchemParser.go(m, 'tex-math tight'); }, - 'bond': function bond(buffer, m, k) { + 'bond': function (buffer, m, k) { return { type_: 'bond', kind_: k || m }; }, - 'color0-output': function color0Output(buffer, m) { + 'color0-output': function (buffer, m) { return { type_: 'color0', color: m[0] }; }, - 'ce': function ce(buffer, m) { + 'ce': function (buffer, m) { return mhchemParser.go(m); }, - '1/2': function _(buffer, m) { + '1/2': function (buffer, m) { /** @type {ParserOutput[]} */ var ret = []; @@ -840,7 +813,7 @@ var mhchemParser = { return ret; }, - '9,9': function _(buffer, m) { + '9,9': function (buffer, m) { return mhchemParser.go(m, '9,9'); } }, @@ -849,7 +822,7 @@ var mhchemParser = { // convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] } // with expansion of 'a|b' to 'a' and 'b' (at 2 places) // - createTransitions: function createTransitions(o) { + createTransitions: function (o) { var pattern, state; /** @type {string[]} */ @@ -1485,7 +1458,7 @@ mhchemParser.stateMachines = { nextState: '3' } }, - "\\underset{(...)}": { + '\\underset{(...)}': { '*': { action_: [{ type_: 'output', @@ -1494,7 +1467,7 @@ mhchemParser.stateMachines = { nextState: '3' } }, - "\\underbrace{(...)}": { + '\\underbrace{(...)}': { '*': { action_: [{ type_: 'output', @@ -1580,7 +1553,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'o after d': function oAfterD(buffer, m) { + 'o after d': function (buffer, m) { var ret; if ((buffer.d || "").match(/^[0-9]+$/)) { @@ -1595,11 +1568,11 @@ mhchemParser.stateMachines = { mhchemParser.actions['o='](buffer, m); return ret; }, - 'd= kv': function dKv(buffer, m) { + 'd= kv': function (buffer, m) { buffer.d = m; buffer.dType = 'kv'; }, - 'charge or bond': function chargeOrBond(buffer, m) { + 'charge or bond': function (buffer, m) { if (buffer['beginsWithBond']) { /** @type {ParserOutput[]} */ var ret = []; @@ -1610,7 +1583,7 @@ mhchemParser.stateMachines = { buffer.d = m; } }, - '- after o/d': function afterOD(buffer, m, isAfterD) { + '- after o/d': function (buffer, m, isAfterD) { var c1 = mhchemParser.patterns.match_('orbital', buffer.o || ""); var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || ""); var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || ""); @@ -1644,35 +1617,35 @@ mhchemParser.stateMachines = { return ret; }, - 'a to o': function aToO(buffer) { + 'a to o': function (buffer) { buffer.o = buffer.a; buffer.a = undefined; }, - 'sb=true': function sbTrue(buffer) { + 'sb=true': function (buffer) { buffer.sb = true; }, - 'sb=false': function sbFalse(buffer) { + 'sb=false': function (buffer) { buffer.sb = false; }, - 'beginsWithBond=true': function beginsWithBondTrue(buffer) { + 'beginsWithBond=true': function (buffer) { buffer['beginsWithBond'] = true; }, - 'beginsWithBond=false': function beginsWithBondFalse(buffer) { + 'beginsWithBond=false': function (buffer) { buffer['beginsWithBond'] = false; }, - 'parenthesisLevel++': function parenthesisLevel(buffer) { + 'parenthesisLevel++': function (buffer) { buffer['parenthesisLevel']++; }, - 'parenthesisLevel--': function parenthesisLevel(buffer) { + 'parenthesisLevel--': function (buffer) { buffer['parenthesisLevel']--; }, - 'state of aggregation': function stateOfAggregation(buffer, m) { + 'state of aggregation': function (buffer, m) { return { type_: 'state of aggregation', p1: mhchemParser.go(m, 'o') }; }, - 'comma': function comma(buffer, m) { + 'comma': function (buffer, m) { var a = m.replace(/\s*$/, ''); var withSpace = a !== m; @@ -1688,7 +1661,7 @@ mhchemParser.stateMachines = { }; } }, - 'output': function output(buffer, m, entityFollows) { + 'output': function (buffer, m, entityFollows) { // entityFollows: // undefined = if we have nothing else to output, also ignore the just read space (buffer.sb) // 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1) @@ -1783,63 +1756,63 @@ mhchemParser.stateMachines = { return ret; }, - 'oxidation-output': function oxidationOutput(buffer, m) { + 'oxidation-output': function (buffer, m) { var ret = ["{"]; mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation')); ret.push("}"); return ret; }, - 'frac-output': function fracOutput(buffer, m) { + 'frac-output': function (buffer, m) { return { type_: 'frac-ce', p1: mhchemParser.go(m[0]), p2: mhchemParser.go(m[1]) }; }, - 'overset-output': function oversetOutput(buffer, m) { + 'overset-output': function (buffer, m) { return { type_: 'overset', p1: mhchemParser.go(m[0]), p2: mhchemParser.go(m[1]) }; }, - 'underset-output': function undersetOutput(buffer, m) { + 'underset-output': function (buffer, m) { return { type_: 'underset', p1: mhchemParser.go(m[0]), p2: mhchemParser.go(m[1]) }; }, - 'underbrace-output': function underbraceOutput(buffer, m) { + 'underbrace-output': function (buffer, m) { return { type_: 'underbrace', p1: mhchemParser.go(m[0]), p2: mhchemParser.go(m[1]) }; }, - 'color-output': function colorOutput(buffer, m) { + 'color-output': function (buffer, m) { return { type_: 'color', color1: m[0], color2: mhchemParser.go(m[1]) }; }, - 'r=': function r(buffer, m) { + 'r=': function (buffer, m) { buffer.r = m; }, - 'rdt=': function rdt(buffer, m) { + 'rdt=': function (buffer, m) { buffer.rdt = m; }, - 'rd=': function rd(buffer, m) { + 'rd=': function (buffer, m) { buffer.rd = m; }, - 'rqt=': function rqt(buffer, m) { + 'rqt=': function (buffer, m) { buffer.rqt = m; }, - 'rq=': function rq(buffer, m) { + 'rq=': function (buffer, m) { buffer.rq = m; }, - 'operator': function operator(buffer, m, p1) { + 'operator': function (buffer, m, p1) { return { type_: 'operator', kind_: p1 || m @@ -1971,7 +1944,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'output': function output(buffer) { + 'output': function (buffer) { if (buffer.text_) { /** @type {ParserOutput} */ var ret = { @@ -2087,13 +2060,13 @@ mhchemParser.stateMachines = { } }), actions: { - 'state of aggregation': function stateOfAggregation(buffer, m) { + 'state of aggregation': function (buffer, m) { return { type_: 'state of aggregation subscript', p1: mhchemParser.go(m, 'o') }; }, - 'color-output': function colorOutput(buffer, m) { + 'color-output': function (buffer, m) { return { type_: 'color', color1: m[0], @@ -2201,7 +2174,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'color-output': function colorOutput(buffer, m) { + 'color-output': function (buffer, m) { return { type_: 'color', color1: m[0], @@ -2232,7 +2205,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'roman-numeral': function romanNumeral(buffer, m) { + 'roman-numeral': function (buffer, m) { return { type_: 'roman numeral', p1: m || "" @@ -2264,7 +2237,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'output': function output(buffer) { + 'output': function (buffer) { if (buffer.o) { /** @type {ParserOutput} */ var ret = { @@ -2310,10 +2283,10 @@ mhchemParser.stateMachines = { } }), actions: { - 'tight operator': function tightOperator(buffer, m) { + 'tight operator': function (buffer, m) { buffer.o = (buffer.o || "") + "{" + m + "}"; }, - 'output': function output(buffer) { + 'output': function (buffer) { if (buffer.o) { /** @type {ParserOutput} */ var ret = { @@ -2347,7 +2320,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'comma': function comma() { + 'comma': function () { return { type_: 'commaDecimal' }; @@ -2434,7 +2407,7 @@ mhchemParser.stateMachines = { } }), actions: { - 'enumber': function enumber(buffer, m) { + 'enumber': function (buffer, m) { /** @type {ParserOutput[]} */ var ret = []; @@ -2478,7 +2451,7 @@ mhchemParser.stateMachines = { return ret; }, - 'number^': function number(buffer, m) { + 'number^': function (buffer, m) { /** @type {ParserOutput[]} */ var ret = []; @@ -2492,18 +2465,18 @@ mhchemParser.stateMachines = { ret.push("^{" + m[2] + "}"); return ret; }, - 'operator': function operator(buffer, m, p1) { + 'operator': function (buffer, m, p1) { return { type_: 'operator', kind_: p1 || m }; }, - 'space': function space() { + 'space': function () { return { type_: 'pu-space-1' }; }, - 'output': function output(buffer) { + 'output': function (buffer) { /** @type {ParserOutput | ParserOutput[]} */ var ret; var md = mhchemParser.patterns.match_('{(...)}', buffer.d || ""); @@ -2613,20 +2586,20 @@ mhchemParser.stateMachines = { } }), actions: { - 'cdot': function cdot() { + 'cdot': function () { return { type_: 'tight cdot' }; }, - '^(-1)': function _(buffer, m) { + '^(-1)': function (buffer, m) { buffer.rm += "^{" + m + "}"; }, - 'space': function space() { + 'space': function () { return { type_: 'pu-space-2' }; }, - 'output': function output(buffer) { + 'output': function (buffer) { /** @type {ParserOutput | ParserOutput[]} */ var ret = []; @@ -2680,12 +2653,12 @@ mhchemParser.stateMachines = { } }), actions: { - 'comma': function comma() { + 'comma': function () { return { type_: 'commaDecimal' }; }, - 'output-0': function output0(buffer) { + 'output-0': function (buffer) { /** @type {ParserOutput[]} */ var ret = []; buffer.text_ = buffer.text_ || ""; @@ -2716,7 +2689,7 @@ mhchemParser.stateMachines = { return ret; }, - 'output-o': function outputO(buffer) { + 'output-o': function (buffer) { /** @type {ParserOutput[]} */ var ret = []; buffer.text_ = buffer.text_ || ""; @@ -2742,9 +2715,9 @@ mhchemParser.stateMachines = { return ret; } - } //#endregion + } + } //#endregion - } }; // // texify: Take MhchemParser output and convert it to TeX // @@ -2752,7 +2725,7 @@ mhchemParser.stateMachines = { /** @type {Texify} */ var texify = { - go: function go(input, isInner) { + go: function (input, isInner) { // (recursive, max 4 levels) if (!input) { return ""; @@ -2781,14 +2754,14 @@ var texify = { return res; }, - _goInner: function _goInner(input) { + _goInner: function (input) { if (!input) { return input; } return texify.go(input, true); }, - _go2: function _go2(buf) { + _go2: function (buf) { /** @type {undefined | string} */ var res; @@ -3079,7 +3052,7 @@ var texify = { assertString(res); return res; }, - _getArrow: function _getArrow(a) { + _getArrow: function (a) { switch (a) { case "->": return "rightarrow"; @@ -3116,7 +3089,7 @@ var texify = { throw ["MhchemBugT", "mhchem bug T. Please report."]; } }, - _getBond: function _getBond(a) { + _getBond: function (a) { switch (a) { case "-": return "{-}"; @@ -3174,7 +3147,7 @@ var texify = { throw ["MhchemBugT", "mhchem bug T. Please report."]; } }, - _getOperator: function _getOperator(a) { + _getOperator: function (a) { switch (a) { case "+": return " {}+{} "; @@ -3224,7 +3197,7 @@ var texify = { } } }; // -// Helpers for code anaylsis +// Helpers for code analysis // Will show type error at calling position // @@ -3235,7 +3208,9 @@ function assertNever(a) {} function assertString(a) {} - -/***/ }) -/******/ ])["default"]; +}(); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/contrib/mhchem.min.js b/katex/contrib/mhchem.min.js index 8fd9cca8f9..63c7ec0f67 100644 --- a/katex/contrib/mhchem.min.js +++ b/katex/contrib/mhchem.min.js @@ -1 +1 @@ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],e);else{var n="object"==typeof exports?e(require("katex")):e(t.katex);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}("undefined"!=typeof self?self:this,function(t){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(o,a,function(e){return t[e]}.bind(null,a));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e);var o=n(0),a=n.n(o);a.a.__defineMacro("\\ce",function(t){return r(t.consumeArgs(1)[0],"ce")}),a.a.__defineMacro("\\pu",function(t){return r(t.consumeArgs(1)[0],"pu")}),a.a.__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var r=function(t,e){for(var n="",o=t[t.length-1].loc.start,a=t.length-1;a>=0;a--)t[a].loc.start>o&&(n+=" ",o=t[a].loc.start),n+=t[a].text,o+=t[a].text.length;return c.go(i.go(n,e))},i={go:function(t,e){if(!t)return[];void 0===e&&(e="ce");var n,o="0",a={};a.parenthesisLevel=0,t=(t=(t=t.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var r=10,c=[];;){n!==t?(r=10,n=t):r--;var u=i.stateMachines[e],p=u.transitions[o]||u.transitions["*"];t:for(var s=0;s0))return c;if(d.revisit||(t=_.remainder),!d.toContinue)break t}}if(r<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(t,e){if(e)if(Array.isArray(e))for(var n=0;n":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]\/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(t){return i.patterns.findObserveGroups(t,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(t){return i.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(t){return i.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(t){return i.patterns.findObserveGroups(t,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(t){return i.patterns.findObserveGroups(t,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(t){return i.patterns.findObserveGroups(t,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(t){return i.patterns.findObserveGroups(t,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(t){var e;if(e=t.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:e[0],remainder:t.substr(e[0].length)};var n=i.patterns.findObserveGroups(t,"","$","$","");return n&&(e=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:e[0],remainder:t.substr(e[0].length)}:null},amount2:function(t){return this.amount(t)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(t){if(t.match(/^\([a-z]+\)$/))return null;var e=t.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return e?{match_:e[0],remainder:t.substr(e[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(t,e,n,o,a,r,i,c,u,p){var s=function(t,e){if("string"==typeof e)return 0!==t.indexOf(e)?null:e;var n=t.match(e);return n?n[0]:null},_=s(t,e);if(null===_)return null;if(t=t.substr(_.length),null===(_=s(t,n)))return null;var d=function(t,e,n){for(var o=0;e":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(t,e){var n;if((t.d||"").match(/^[0-9]+$/)){var o=t.d;t.d=void 0,n=this.output(t),t.b=o}else n=this.output(t);return i.actions["o="](t,e),n},"d= kv":function(t,e){t.d=e,t.dType="kv"},"charge or bond":function(t,e){if(t.beginsWithBond){var n=[];return i.concatArray(n,this.output(t)),i.concatArray(n,i.actions.bond(t,e,"-")),n}t.d=e},"- after o/d":function(t,e,n){var o=i.patterns.match_("orbital",t.o||""),a=i.patterns.match_("one lowercase greek letter $",t.o||""),r=i.patterns.match_("one lowercase latin letter $",t.o||""),c=i.patterns.match_("$one lowercase latin letter$ $",t.o||""),u="-"===e&&(o&&""===o.remainder||a||r||c);!u||t.a||t.b||t.p||t.d||t.q||o||!r||(t.o="$"+t.o+"$");var p=[];return u?(i.concatArray(p,this.output(t)),p.push({type_:"hyphen"})):(o=i.patterns.match_("digits",t.d||""),n&&o&&""===o.remainder?(i.concatArray(p,i.actions["d="](t,e)),i.concatArray(p,this.output(t))):(i.concatArray(p,this.output(t)),i.concatArray(p,i.actions.bond(t,e,"-")))),p},"a to o":function(t){t.o=t.a,t.a=void 0},"sb=true":function(t){t.sb=!0},"sb=false":function(t){t.sb=!1},"beginsWithBond=true":function(t){t.beginsWithBond=!0},"beginsWithBond=false":function(t){t.beginsWithBond=!1},"parenthesisLevel++":function(t){t.parenthesisLevel++},"parenthesisLevel--":function(t){t.parenthesisLevel--},"state of aggregation":function(t,e){return{type_:"state of aggregation",p1:i.go(e,"o")}},comma:function(t,e){var n=e.replace(/\s*$/,"");return n!==e&&0===t.parenthesisLevel?{type_:"comma enumeration L",p1:n}:{type_:"comma enumeration M",p1:n}},output:function(t,e,n){var o,a,r;t.r?(a="M"===t.rdt?i.go(t.rd,"tex-math"):"T"===t.rdt?[{type_:"text",p1:t.rd||""}]:i.go(t.rd),r="M"===t.rqt?i.go(t.rq,"tex-math"):"T"===t.rqt?[{type_:"text",p1:t.rq||""}]:i.go(t.rq),o={type_:"arrow",r:t.r,rd:a,rq:r}):(o=[],(t.a||t.b||t.p||t.o||t.q||t.d||n)&&(t.sb&&o.push({type_:"entitySkip"}),t.o||t.q||t.d||t.b||t.p||2===n?t.o||t.q||t.d||!t.b&&!t.p?t.o&&"kv"===t.dType&&i.patterns.match_("d-oxidation$",t.d||"")?t.dType="oxidation":t.o&&"kv"===t.dType&&!t.q&&(t.dType=void 0):(t.o=t.a,t.d=t.b,t.q=t.p,t.a=t.b=t.p=void 0):(t.o=t.a,t.a=void 0),o.push({type_:"chemfive",a:i.go(t.a,"a"),b:i.go(t.b,"bd"),p:i.go(t.p,"pq"),o:i.go(t.o,"o"),q:i.go(t.q,"pq"),d:i.go(t.d,"oxidation"===t.dType?"oxidation":"bd"),dType:t.dType})));for(var c in t)"parenthesisLevel"!==c&&"beginsWithBond"!==c&&delete t[c];return o},"oxidation-output":function(t,e){var n=["{"];return i.concatArray(n,i.go(e,"oxidation")),n.push("}"),n},"frac-output":function(t,e){return{type_:"frac-ce",p1:i.go(e[0]),p2:i.go(e[1])}},"overset-output":function(t,e){return{type_:"overset",p1:i.go(e[0]),p2:i.go(e[1])}},"underset-output":function(t,e){return{type_:"underset",p1:i.go(e[0]),p2:i.go(e[1])}},"underbrace-output":function(t,e){return{type_:"underbrace",p1:i.go(e[0]),p2:i.go(e[1])}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:i.go(e[1])}},"r=":function(t,e){t.r=e},"rdt=":function(t,e){t.rdt=e},"rd=":function(t,e){t.rd=e},"rqt=":function(t,e){t.rqt=e},"rq=":function(t,e){t.rq=e},operator:function(t,e,n){return{type_:"operator",kind_:n||e}}}},a:{transitions:i.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:i.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:i.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(t){if(t.text_){var e={type_:"text",p1:t.text_};for(var n in t)delete t[n];return e}}}},pq:{transitions:i.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(t,e){return{type_:"state of aggregation subscript",p1:i.go(e,"o")}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:i.go(e[1],"pq")}}}},bd:{transitions:i.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(t,e){return{type_:"color",color1:e[0],color2:i.go(e[1],"bd")}}}},oxidation:{transitions:i.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(t,e){return{type_:"roman numeral",p1:e||""}}}},"tex-math":{transitions:i.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"tex-math tight":{transitions:i.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(t,e){t.o=(t.o||"")+"{"+e+"}"},output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"9,9":{transitions:i.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:i.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),e[1]&&(i.concatArray(n,i.go(e[1],"pu-9,9")),e[2]&&(e[2].match(/[,.]/)?i.concatArray(n,i.go(e[2],"pu-9,9")):n.push(e[2])),e[3]=e[4]||e[3],e[3]&&(e[3]=e[3].trim(),"e"===e[3]||"*"===e[3].substr(0,1)?n.push({type_:"cdot"}):n.push({type_:"times"}))),e[3]&&n.push("10^{"+e[5]+"}"),n},"number^":function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),i.concatArray(n,i.go(e[1],"pu-9,9")),n.push("^{"+e[2]+"}"),n},operator:function(t,e,n){return{type_:"operator",kind_:n||e}},space:function(){return{type_:"pu-space-1"}},output:function(t){var e,n=i.patterns.match_("{(...)}",t.d||"");n&&""===n.remainder&&(t.d=n.match_);var o=i.patterns.match_("{(...)}",t.q||"");if(o&&""===o.remainder&&(t.q=o.match_),t.d&&(t.d=t.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.d=t.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),t.q){t.q=t.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.q=t.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var a={d:i.go(t.d,"pu"),q:i.go(t.q,"pu")};"//"===t.o?e={type_:"pu-frac",p1:a.d,p2:a.q}:(e=a.d,a.d.length>1||a.q.length>1?e.push({type_:" / "}):e.push({type_:"/"}),i.concatArray(e,a.q))}else e=i.go(t.d,"pu-2");for(var r in t)delete t[r];return e}}},"pu-2":{transitions:i.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(t,e){t.rm+="^{"+e+"}"},space:function(){return{type_:"pu-space-2"}},output:function(t){var e=[];if(t.rm){var n=i.patterns.match_("{(...)}",t.rm||"");e=n&&""===n.remainder?i.go(n.match_,"pu"):{type_:"rm",p1:t.rm}}for(var o in t)delete t[o];return e}}},"pu-9,9":{transitions:i.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){var n=t.text_.length%3;0===n&&(n=3);for(var o=t.text_.length-3;o>0;o-=3)e.push(t.text_.substr(o,3)),e.push({type_:"1000 separator"});e.push(t.text_.substr(0,n)),e.reverse()}else e.push(t.text_);for(var a in t)delete t[a];return e},"output-o":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){for(var n=t.text_.length-3,o=0;o":case"\u2192":case"\u27f6":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"rightleftarrows";case"<=>":case"\u21cc":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(t){switch(t){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(t){switch(t){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}}}]).default}); \ No newline at end of file +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],e);else{var n="object"==typeof exports?e(require("katex")):e(t.katex);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}("undefined"!=typeof self?self:this,(function(t){return function(){"use strict";var e={771:function(e){e.exports=t}},n={};function o(t){var a=n[t];if(void 0!==a)return a.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,{a:e}),e},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var a={};return function(){var t=o(771),e=o.n(t);e().__defineMacro("\\ce",(function(t){return n(t.consumeArgs(1)[0],"ce")})),e().__defineMacro("\\pu",(function(t){return n(t.consumeArgs(1)[0],"pu")})),e().__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var n=function(t,e){for(var n="",o=t.length&&t[t.length-1].loc.start,i=t.length-1;i>=0;i--)t[i].loc.start>o&&(n+=" ",o=t[i].loc.start),n+=t[i].text,o+=t[i].text.length;return r.go(a.go(n,e))},a={go:function(t,e){if(!t)return[];void 0===e&&(e="ce");var n,o="0",r={};r.parenthesisLevel=0,t=(t=(t=t.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var i=10,c=[];;){n!==t?(i=10,n=t):i--;var u=a.stateMachines[e],p=u.transitions[o]||u.transitions["*"];t:for(var s=0;s0))return c;if(d.revisit||(t=_.remainder),!d.toContinue)break t}}if(i<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(t,e){if(e)if(Array.isArray(e))for(var n=0;n":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(t){return a.patterns.findObserveGroups(t,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(t){return a.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(t){return a.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(t){return a.patterns.findObserveGroups(t,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(t){return a.patterns.findObserveGroups(t,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(t){return a.patterns.findObserveGroups(t,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(t){return a.patterns.findObserveGroups(t,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(t){var e;if(e=t.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:e[0],remainder:t.substr(e[0].length)};var n=a.patterns.findObserveGroups(t,"","$","$","");return n&&(e=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:e[0],remainder:t.substr(e[0].length)}:null},amount2:function(t){return this.amount(t)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(t){if(t.match(/^\([a-z]+\)$/))return null;var e=t.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return e?{match_:e[0],remainder:t.substr(e[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(t,e,n,o,a,r,i,c,u,p){var s=function(t,e){if("string"==typeof e)return 0!==t.indexOf(e)?null:e;var n=t.match(e);return n?n[0]:null},_=s(t,e);if(null===_)return null;if(t=t.substr(_.length),null===(_=s(t,n)))return null;var d=function(t,e,n){for(var o=0;e":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(t,e){var n;if((t.d||"").match(/^[0-9]+$/)){var o=t.d;t.d=void 0,n=this.output(t),t.b=o}else n=this.output(t);return a.actions["o="](t,e),n},"d= kv":function(t,e){t.d=e,t.dType="kv"},"charge or bond":function(t,e){if(t.beginsWithBond){var n=[];return a.concatArray(n,this.output(t)),a.concatArray(n,a.actions.bond(t,e,"-")),n}t.d=e},"- after o/d":function(t,e,n){var o=a.patterns.match_("orbital",t.o||""),r=a.patterns.match_("one lowercase greek letter $",t.o||""),i=a.patterns.match_("one lowercase latin letter $",t.o||""),c=a.patterns.match_("$one lowercase latin letter$ $",t.o||""),u="-"===e&&(o&&""===o.remainder||r||i||c);!u||t.a||t.b||t.p||t.d||t.q||o||!i||(t.o="$"+t.o+"$");var p=[];return u?(a.concatArray(p,this.output(t)),p.push({type_:"hyphen"})):(o=a.patterns.match_("digits",t.d||""),n&&o&&""===o.remainder?(a.concatArray(p,a.actions["d="](t,e)),a.concatArray(p,this.output(t))):(a.concatArray(p,this.output(t)),a.concatArray(p,a.actions.bond(t,e,"-")))),p},"a to o":function(t){t.o=t.a,t.a=void 0},"sb=true":function(t){t.sb=!0},"sb=false":function(t){t.sb=!1},"beginsWithBond=true":function(t){t.beginsWithBond=!0},"beginsWithBond=false":function(t){t.beginsWithBond=!1},"parenthesisLevel++":function(t){t.parenthesisLevel++},"parenthesisLevel--":function(t){t.parenthesisLevel--},"state of aggregation":function(t,e){return{type_:"state of aggregation",p1:a.go(e,"o")}},comma:function(t,e){var n=e.replace(/\s*$/,"");return n!==e&&0===t.parenthesisLevel?{type_:"comma enumeration L",p1:n}:{type_:"comma enumeration M",p1:n}},output:function(t,e,n){var o,r,i;t.r?(r="M"===t.rdt?a.go(t.rd,"tex-math"):"T"===t.rdt?[{type_:"text",p1:t.rd||""}]:a.go(t.rd),i="M"===t.rqt?a.go(t.rq,"tex-math"):"T"===t.rqt?[{type_:"text",p1:t.rq||""}]:a.go(t.rq),o={type_:"arrow",r:t.r,rd:r,rq:i}):(o=[],(t.a||t.b||t.p||t.o||t.q||t.d||n)&&(t.sb&&o.push({type_:"entitySkip"}),t.o||t.q||t.d||t.b||t.p||2===n?t.o||t.q||t.d||!t.b&&!t.p?t.o&&"kv"===t.dType&&a.patterns.match_("d-oxidation$",t.d||"")?t.dType="oxidation":t.o&&"kv"===t.dType&&!t.q&&(t.dType=void 0):(t.o=t.a,t.d=t.b,t.q=t.p,t.a=t.b=t.p=void 0):(t.o=t.a,t.a=void 0),o.push({type_:"chemfive",a:a.go(t.a,"a"),b:a.go(t.b,"bd"),p:a.go(t.p,"pq"),o:a.go(t.o,"o"),q:a.go(t.q,"pq"),d:a.go(t.d,"oxidation"===t.dType?"oxidation":"bd"),dType:t.dType})));for(var c in t)"parenthesisLevel"!==c&&"beginsWithBond"!==c&&delete t[c];return o},"oxidation-output":function(t,e){var n=["{"];return a.concatArray(n,a.go(e,"oxidation")),n.push("}"),n},"frac-output":function(t,e){return{type_:"frac-ce",p1:a.go(e[0]),p2:a.go(e[1])}},"overset-output":function(t,e){return{type_:"overset",p1:a.go(e[0]),p2:a.go(e[1])}},"underset-output":function(t,e){return{type_:"underset",p1:a.go(e[0]),p2:a.go(e[1])}},"underbrace-output":function(t,e){return{type_:"underbrace",p1:a.go(e[0]),p2:a.go(e[1])}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:a.go(e[1])}},"r=":function(t,e){t.r=e},"rdt=":function(t,e){t.rdt=e},"rd=":function(t,e){t.rd=e},"rqt=":function(t,e){t.rqt=e},"rq=":function(t,e){t.rq=e},operator:function(t,e,n){return{type_:"operator",kind_:n||e}}}},a:{transitions:a.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:a.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:a.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(t){if(t.text_){var e={type_:"text",p1:t.text_};for(var n in t)delete t[n];return e}}}},pq:{transitions:a.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(t,e){return{type_:"state of aggregation subscript",p1:a.go(e,"o")}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:a.go(e[1],"pq")}}}},bd:{transitions:a.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(t,e){return{type_:"color",color1:e[0],color2:a.go(e[1],"bd")}}}},oxidation:{transitions:a.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(t,e){return{type_:"roman numeral",p1:e||""}}}},"tex-math":{transitions:a.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"tex-math tight":{transitions:a.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(t,e){t.o=(t.o||"")+"{"+e+"}"},output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"9,9":{transitions:a.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:a.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),e[1]&&(a.concatArray(n,a.go(e[1],"pu-9,9")),e[2]&&(e[2].match(/[,.]/)?a.concatArray(n,a.go(e[2],"pu-9,9")):n.push(e[2])),e[3]=e[4]||e[3],e[3]&&(e[3]=e[3].trim(),"e"===e[3]||"*"===e[3].substr(0,1)?n.push({type_:"cdot"}):n.push({type_:"times"}))),e[3]&&n.push("10^{"+e[5]+"}"),n},"number^":function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),a.concatArray(n,a.go(e[1],"pu-9,9")),n.push("^{"+e[2]+"}"),n},operator:function(t,e,n){return{type_:"operator",kind_:n||e}},space:function(){return{type_:"pu-space-1"}},output:function(t){var e,n=a.patterns.match_("{(...)}",t.d||"");n&&""===n.remainder&&(t.d=n.match_);var o=a.patterns.match_("{(...)}",t.q||"");if(o&&""===o.remainder&&(t.q=o.match_),t.d&&(t.d=t.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.d=t.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),t.q){t.q=t.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.q=t.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var r={d:a.go(t.d,"pu"),q:a.go(t.q,"pu")};"//"===t.o?e={type_:"pu-frac",p1:r.d,p2:r.q}:(e=r.d,r.d.length>1||r.q.length>1?e.push({type_:" / "}):e.push({type_:"/"}),a.concatArray(e,r.q))}else e=a.go(t.d,"pu-2");for(var i in t)delete t[i];return e}}},"pu-2":{transitions:a.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(t,e){t.rm+="^{"+e+"}"},space:function(){return{type_:"pu-space-2"}},output:function(t){var e=[];if(t.rm){var n=a.patterns.match_("{(...)}",t.rm||"");e=n&&""===n.remainder?a.go(n.match_,"pu"):{type_:"rm",p1:t.rm}}for(var o in t)delete t[o];return e}}},"pu-9,9":{transitions:a.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){var n=t.text_.length%3;0===n&&(n=3);for(var o=t.text_.length-3;o>0;o-=3)e.push(t.text_.substr(o,3)),e.push({type_:"1000 separator"});e.push(t.text_.substr(0,n)),e.reverse()}else e.push(t.text_);for(var a in t)delete t[a];return e},"output-o":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){for(var n=t.text_.length-3,o=0;o":case"\u2192":case"\u27f6":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"rightleftarrows";case"<=>":case"\u21cc":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(t){switch(t){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(t){switch(t){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}}}(),a=a.default}()})); \ No newline at end of file diff --git a/katex/contrib/mhchem.mjs b/katex/contrib/mhchem.mjs index 46241b5f70..7d93825252 100644 --- a/katex/contrib/mhchem.mjs +++ b/katex/contrib/mhchem.mjs @@ -2,7 +2,7 @@ import katex from '../katex.mjs'; /* eslint-disable */ -/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ @@ -71,7 +71,7 @@ katex.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2m var chemParse = function chemParse(tokens, stateMachine) { // Recreate the argument string from KaTeX's array of tokens. var str = ""; - var expectedLoc = tokens[tokens.length - 1].loc.start; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; for (var i = tokens.length - 1; i >= 0; i--) { if (tokens[i].loc.start > expectedLoc) { @@ -2631,9 +2631,9 @@ mhchemParser.stateMachines = { return ret; } - } //#endregion + } + } //#endregion - } }; // // texify: Take MhchemParser output and convert it to TeX // diff --git a/katex/contrib/render-a11y-string.js b/katex/contrib/render-a11y-string.js index 34643ec2ea..8f7d669f0b 100644 --- a/katex/contrib/render-a11y-string.js +++ b/katex/contrib/render-a11y-string.js @@ -7,106 +7,79 @@ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__0__) { -return /******/ (function(modules) { // webpackBootstrap +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 771: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__771__; + +/***/ }) + +/******/ }); +/************************************************************************/ /******/ // The module cache -/******/ var installedModules = {}; -/******/ +/******/ var __webpack_module_cache__ = {}; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) +/******/ /************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__0__; - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771); /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); /** * renderA11yString returns a readable string. @@ -127,7 +100,7 @@ __webpack_require__.r(__webpack_exports__); // included in the build. // $FlowIgnore: we import the types directly anyways -var stringMap = { +const stringMap = { "(": "left parenthesis", ")": "right parenthesis", "[": "open bracket", @@ -200,22 +173,22 @@ var stringMap = { "\\hat": "hat", "\\acute": "acute" }; -var powerMap = { +const powerMap = { "prime": "prime", "degree": "degrees", "circle": "degrees", "2": "squared", "3": "cubed" }; -var openMap = { +const openMap = { "|": "open vertical bar", ".": "" }; -var closeMap = { +const closeMap = { "|": "close vertical bar", ".": "" }; -var binMap = { +const binMap = { "+": "plus", "-": "minus", "\\pm": "plus minus", @@ -227,7 +200,7 @@ var binMap = { "\\circ": "circle", "\\bullet": "bullet" }; -var relMap = { +const relMap = { "=": "equals", "\\approx": "approximately equals", "≠": "does not equal", @@ -243,7 +216,7 @@ var relMap = { "\\Rightarrow": "right arrow", ":": "colon" }; -var accentUnderMap = { +const accentUnderMap = { "\\underleftarrow": "left arrow", "\\underrightarrow": "right arrow", "\\underleftrightarrow": "left-right arrow", @@ -252,12 +225,12 @@ var accentUnderMap = { "\\utilde": "tilde" }; -var buildString = function buildString(str, type, a11yStrings) { +const buildString = (str, type, a11yStrings) => { if (!str) { return; } - var ret; + let ret; if (type === "open") { ret = str in openMap ? openMap[str] : stringMap[str] || str; @@ -276,7 +249,8 @@ var buildString = function buildString(str, type, a11yStrings) { if (/^\d+$/.test(ret) && a11yStrings.length > 0 && // TODO(kevinb): check that the last item in a11yStrings is a string // I think we might be able to drop the nested arrays, which would make - // this easier to type - $FlowFixMe + // this easier to type + // $FlowFixMe /^\d+$/.test(a11yStrings[a11yStrings.length - 1])) { a11yStrings[a11yStrings.length - 1] += ret; } else if (ret) { @@ -284,18 +258,18 @@ var buildString = function buildString(str, type, a11yStrings) { } }; -var buildRegion = function buildRegion(a11yStrings, callback) { - var regionStrings = []; +const buildRegion = (a11yStrings, callback) => { + const regionStrings = []; a11yStrings.push(regionStrings); callback(regionStrings); }; -var handleObject = function handleObject(tree, a11yStrings, atomType) { +const handleObject = (tree, a11yStrings, atomType) => { // Everything else is assumed to be an object... switch (tree.type) { case "accent": { - buildRegion(a11yStrings, function (a11yStrings) { + buildRegion(a11yStrings, a11yStrings => { buildA11yStrings(tree.base, a11yStrings, atomType); a11yStrings.push("with"); buildString(tree.label, "normal", a11yStrings); @@ -306,7 +280,7 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "accentUnder": { - buildRegion(a11yStrings, function (a11yStrings) { + buildRegion(a11yStrings, a11yStrings => { buildA11yStrings(tree.base, a11yStrings, atomType); a11yStrings.push("with"); buildString(accentUnderMap[tree.label], "normal", a11yStrings); @@ -323,7 +297,9 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "atom": { - var text = tree.text; + const { + text + } = tree; switch (tree.family) { case "bin": @@ -375,8 +351,8 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "color": { - var color = tree.color.replace(/katex-/, ""); - buildRegion(a11yStrings, function (regionStrings) { + const color = tree.color.replace(/katex-/, ""); + buildRegion(a11yStrings, regionStrings => { regionStrings.push("start color " + color); buildA11yStrings(tree.body, regionStrings, atomType); regionStrings.push("end color " + color); @@ -402,10 +378,12 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "genfrac": { - buildRegion(a11yStrings, function (regionStrings) { + buildRegion(a11yStrings, regionStrings => { // genfrac can have unbalanced delimiters - var leftDelim = tree.leftDelim, - rightDelim = tree.rightDelim; // NOTE: Not sure if this is a safe assumption + const { + leftDelim, + rightDelim + } = tree; // NOTE: Not sure if this is a safe assumption // hasBarLine true -> fraction, false -> binomial if (tree.hasBarLine) { @@ -429,6 +407,12 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { break; } + case "hbox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": { // No op: we don't attempt to present kerning information @@ -438,7 +422,7 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "leftright": { - buildRegion(a11yStrings, function (regionStrings) { + buildRegion(a11yStrings, regionStrings => { buildString(tree.left, "open", regionStrings); buildA11yStrings(tree.body, regionStrings, atomType); buildString(tree.right, "close", regionStrings); @@ -466,8 +450,10 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "op": { - var body = tree.body, - name = tree.name; + const { + body, + name + } = tree; if (body) { buildA11yStrings(body, a11yStrings, atomType); @@ -501,6 +487,12 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { break; } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": { a11yStrings.push("empty space"); @@ -540,12 +532,14 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "sqrt": { - buildRegion(a11yStrings, function (regionStrings) { - var body = tree.body, - index = tree.index; + buildRegion(a11yStrings, regionStrings => { + const { + body, + index + } = tree; if (index) { - var indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); + const indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); if (indexString === "3") { regionStrings.push("cube root of"); @@ -570,10 +564,12 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { case "supsub": { - var base = tree.base, - sub = tree.sub, - sup = tree.sup; - var isLog = false; + const { + base, + sub, + sup + } = tree; + let isLog = false; if (base) { buildA11yStrings(base, a11yStrings, atomType); @@ -581,7 +577,7 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { } if (sub) { - var regionName = isLog ? "base" : "subscript"; + const regionName = isLog ? "base" : "subscript"; buildRegion(a11yStrings, function (regionStrings) { regionStrings.push("start " + regionName); buildA11yStrings(sub, regionStrings, atomType); @@ -591,7 +587,7 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { if (sup) { buildRegion(a11yStrings, function (regionStrings) { - var supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); + const supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); if (supString in powerMap) { regionStrings.push(powerMap[supString]); @@ -665,11 +661,24 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { regionStrings.push("end strikeout"); }); break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; } throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); } + case "vcenter": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "vphantom": { throw new Error("KaTeX-a11y: vphantom not implemented yet"); @@ -779,20 +788,29 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { throw new Error("KaTeX-a11y: xArrow not implemented yet"); } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": { // \neq and \ne are macros so we let "htmlmathml" render the mathmal // side of things and extract the text from that. - var _atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass - + const atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass - buildA11yStrings(tree.body, a11yStrings, _atomType); + buildA11yStrings(tree.body, a11yStrings, atomType); break; } case "mathchoice": { - // TODO: track which which style we're using, e.g. dispaly, text, etc. + // TODO: track which style we're using, e.g. display, text, etc. // default to text style if even that may not be the correct style buildA11yStrings(tree.text, a11yStrings, atomType); break; @@ -810,19 +828,31 @@ var handleObject = function handleObject(tree, a11yStrings, atomType) { break; } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + + case "html": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: tree.type; throw new Error("KaTeX a11y un-recognized type: " + tree.type); } }; -var buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { +const buildA11yStrings = function (tree, a11yStrings, atomType) { if (a11yStrings === void 0) { a11yStrings = []; } if (tree instanceof Array) { - for (var i = 0; i < tree.length; i++) { + for (let i = 0; i < tree.length; i++) { buildA11yStrings(tree[i], a11yStrings, atomType); } } else { @@ -832,8 +862,8 @@ var buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { return a11yStrings; }; -var flatten = function flatten(array) { - var result = []; +const flatten = function (array) { + let result = []; array.forEach(function (item) { if (item instanceof Array) { result = result.concat(flatten(item)); @@ -844,15 +874,17 @@ var flatten = function flatten(array) { return result; }; -var renderA11yString = function renderA11yString(text, settings) { - var tree = katex__WEBPACK_IMPORTED_MODULE_0___default.a.__parse(text, settings); +const renderA11yString = function (text, settings) { + const tree = katex__WEBPACK_IMPORTED_MODULE_0___default().__parse(text, settings); - var a11yStrings = buildA11yStrings(tree, [], "normal"); + const a11yStrings = buildA11yStrings(tree, [], "normal"); return flatten(a11yStrings).join(", "); }; /* harmony default export */ __webpack_exports__["default"] = (renderA11yString); - -/***/ }) -/******/ ])["default"]; +}(); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/contrib/render-a11y-string.min.js b/katex/contrib/render-a11y-string.min.js index 0dcac271a1..8bd1cd285c 100644 --- a/katex/contrib/render-a11y-string.min.js +++ b/katex/contrib/render-a11y-string.min.js @@ -1 +1 @@ -!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var t="object"==typeof exports?r(require("katex")):r(e.katex);for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}("undefined"!=typeof self?self:this,function(e){return function(e){var r={};function t(a){if(r[a])return r[a].exports;var o=r[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(a,o,function(r){return e[r]}.bind(null,o));return a},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(r,t){r.exports=e},function(e,r,t){"use strict";t.r(r);var a=t(0),o=t.n(a),n={"(":"left parenthesis",")":"right parenthesis","[":"open bracket","]":"close bracket","\\{":"left brace","\\}":"right brace","\\lvert":"open vertical bar","\\rvert":"close vertical bar","|":"vertical bar","\\uparrow":"up arrow","\\Uparrow":"up arrow","\\downarrow":"down arrow","\\Downarrow":"down arrow","\\updownarrow":"up down arrow","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow","\\langle":"open angle","\\rangle":"close angle","\\lfloor":"open floor","\\rfloor":"close floor","\\int":"integral","\\intop":"integral","\\lim":"limit","\\ln":"natural log","\\log":"log","\\sin":"sine","\\cos":"cosine","\\tan":"tangent","\\cot":"cotangent","\\sum":"sum","/":"slash",",":"comma",".":"point","-":"negative","+":"plus","~":"tilde",":":"colon","?":"question mark","'":"apostrophe","\\%":"percent"," ":"space","\\ ":"space","\\$":"dollar sign","\\angle":"angle","\\degree":"degree","\\circ":"circle","\\vec":"vector","\\triangle":"triangle","\\pi":"pi","\\prime":"prime","\\infty":"infinity","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\omega":"omega","\\theta":"theta","\\sigma":"sigma","\\lambda":"lambda","\\tau":"tau","\\Delta":"delta","\\delta":"delta","\\mu":"mu","\\rho":"rho","\\nabla":"del","\\ell":"ell","\\ldots":"dots","\\hat":"hat","\\acute":"acute"},s={prime:"prime",degree:"degrees",circle:"degrees",2:"squared",3:"cubed"},i={"|":"open vertical bar",".":""},l={"|":"close vertical bar",".":""},c={"+":"plus","-":"minus","\\pm":"plus minus","\\cdot":"dot","*":"times","/":"divided by","\\times":"times","\\div":"divided by","\\circ":"circle","\\bullet":"bullet"},u={"=":"equals","\\approx":"approximately equals","\u2260":"does not equal","\\geq":"is greater than or equal to","\\ge":"is greater than or equal to","\\leq":"is less than or equal to","\\le":"is less than or equal to",">":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},p={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},d=function(e,r,t){var a;e&&(/^\d+$/.test(a="open"===r?e in i?i[e]:n[e]||e:"close"===r?e in l?l[e]:n[e]||e:"bin"===r?c[e]||e:"rel"===r?u[e]||e:n[e]||e)&&t.length>0&&/^\d+$/.test(t[t.length-1])?t[t.length-1]+=a:a&&t.push(a))},b=function(e,r){var t=[];e.push(t),r(t)},h=function(e,r,t){switch(e.type){case"accent":b(r,function(r){f(e.base,r,t),r.push("with"),d(e.label,"normal",r),r.push("on top")});break;case"accentUnder":b(r,function(r){f(e.base,r,t),r.push("with"),d(p[e.label],"normal",r),r.push("underneath")});break;case"accent-token":break;case"atom":var a=e.text;switch(e.family){case"bin":d(a,"bin",r);break;case"close":d(a,"close",r);break;case"inner":d(e.text,"inner",r);break;case"open":d(a,"open",r);break;case"punct":d(a,"punct",r);break;case"rel":d(a,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break;case"color":var o=e.color.replace(/katex-/,"");b(r,function(r){r.push("start color "+o),f(e.body,r,t),r.push("end color "+o)});break;case"color-token":break;case"delimsizing":e.delim&&"."!==e.delim&&d(e.delim,"normal",r);break;case"genfrac":b(r,function(r){var a=e.leftDelim,o=e.rightDelim;e.hasBarLine?(r.push("start fraction"),a&&d(a,"open",r),f(e.numer,r,t),r.push("divided by"),f(e.denom,r,t),o&&d(o,"close",r),r.push("end fraction")):(r.push("start binomial"),a&&d(a,"open",r),f(e.numer,r,t),r.push("over"),f(e.denom,r,t),o&&d(o,"close",r),r.push("end binomial"))});break;case"kern":break;case"leftright":b(r,function(r){d(e.left,"open",r),f(e.body,r,t),d(e.right,"close",r)});break;case"leftright-right":break;case"lap":f(e.body,r,t);break;case"mathord":d(e.text,"normal",r);break;case"op":var n=e.body,i=e.name;n?f(n,r,t):i&&d(i,"normal",r);break;case"op-token":d(e.text,t,r);break;case"ordgroup":f(e.body,r,t);break;case"overline":b(r,function(r){r.push("start overline"),f(e.body,r,t),r.push("end overline")});break;case"phantom":r.push("empty space");break;case"raisebox":f(e.body,r,t);break;case"rule":r.push("rectangle");break;case"sizing":f(e.body,r,t);break;case"spacing":r.push("space");break;case"styling":f(e.body,r,t);break;case"sqrt":b(r,function(r){var a=e.body,o=e.index;if(o)return"3"===m(f(o,[],t)).join(",")?(r.push("cube root of"),f(a,r,t),void r.push("end cube root")):(r.push("root"),r.push("start index"),f(o,r,t),void r.push("end index"));r.push("square root of"),f(a,r,t),r.push("end square root")});break;case"supsub":var l=e.base,c=e.sub,u=e.sup,h=!1;if(l&&(f(l,r,t),h="op"===l.type&&"\\log"===l.name),c){var y=h?"base":"subscript";b(r,function(e){e.push("start "+y),f(c,e,t),e.push("end "+y)})}u&&b(r,function(e){var r=m(f(u,[],t)).join(",");r in s?e.push(s[r]):(e.push("start superscript"),f(u,e,t),e.push("end superscript"))});break;case"text":if("\\textbf"===e.font){b(r,function(r){r.push("start bold text"),f(e.body,r,t),r.push("end bold text")});break}b(r,function(r){r.push("start text"),f(e.body,r,t),r.push("end text")});break;case"textord":d(e.text,t,r);break;case"smash":f(e.body,r,t);break;case"enclose":if(/cancel/.test(e.label)){b(r,function(r){r.push("start cancel"),f(e.body,r,t),r.push("end cancel")});break}if(/box/.test(e.label)){b(r,function(r){r.push("start box"),f(e.body,r,t),r.push("end box")});break}if(/sout/.test(e.label)){b(r,function(r){r.push("start strikeout"),f(e.body,r,t),r.push("end strikeout")});break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"hphantom":throw new Error("KaTeX-a11y: hphantom not implemented yet");case"operatorname":f(e.body,r,t);break;case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"size":break;case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":d("start verbatim","normal",r),d(e.body,"normal",r),d("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":d("start "+e.label.slice(1),"normal",r),f(e.base,r,t),d("end "+e.label.slice(1),"normal",r);break;case"infix":break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"font":f(e.body,r,t);break;case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":b(r,function(r){r.push("start underline"),f(e.body,r,t),r.push("end underline")});break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"mclass":var g=e.mclass.slice(1);f(e.body,r,g);break;case"mathchoice":f(e.text,r,t);break;case"htmlmathml":f(e.mathml,r,t);break;case"middle":d(e.delim,t,r);break;default:throw e.type,new Error("KaTeX a11y un-recognized type: "+e.type)}},f=function e(r,t,a){if(void 0===t&&(t=[]),r instanceof Array)for(var o=0;o":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},u={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},p=(e,r,a)=>{if(!e)return;let o;o="open"===r?e in s?s[e]:t[e]||e:"close"===r?e in l?l[e]:t[e]||e:"bin"===r?i[e]||e:"rel"===r?c[e]||e:t[e]||e,/^\d+$/.test(o)&&a.length>0&&/^\d+$/.test(a[a.length-1])?a[a.length-1]+=o:o&&a.push(o)},d=(e,r)=>{const t=[];e.push(t),r(t)},h=function(e,r,t){if(void 0===r&&(r=[]),e instanceof Array)for(let a=0;a{switch(e.type){case"accent":d(r,(r=>{h(e.base,r,t),r.push("with"),p(e.label,"normal",r),r.push("on top")}));break;case"accentUnder":d(r,(r=>{h(e.base,r,t),r.push("with"),p(u[e.label],"normal",r),r.push("underneath")}));break;case"accent-token":case"color-token":case"kern":case"leftright-right":case"size":case"infix":case"internal":break;case"atom":{const{text:t}=e;switch(e.family){case"bin":p(t,"bin",r);break;case"close":p(t,"close",r);break;case"inner":p(e.text,"inner",r);break;case"open":p(t,"open",r);break;case"punct":p(t,"punct",r);break;case"rel":p(t,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break}case"color":{const a=e.color.replace(/katex-/,"");d(r,(r=>{r.push("start color "+a),h(e.body,r,t),r.push("end color "+a)}));break}case"delimsizing":e.delim&&"."!==e.delim&&p(e.delim,"normal",r);break;case"genfrac":d(r,(r=>{const{leftDelim:a,rightDelim:o}=e;e.hasBarLine?(r.push("start fraction"),a&&p(a,"open",r),h(e.numer,r,t),r.push("divided by"),h(e.denom,r,t),o&&p(o,"close",r),r.push("end fraction")):(r.push("start binomial"),a&&p(a,"open",r),h(e.numer,r,t),r.push("over"),h(e.denom,r,t),o&&p(o,"close",r),r.push("end binomial"))}));break;case"hbox":case"lap":case"ordgroup":case"raisebox":case"sizing":case"styling":case"smash":case"vcenter":case"operatorname":case"font":case"html":h(e.body,r,t);break;case"leftright":d(r,(r=>{p(e.left,"open",r),h(e.body,r,t),p(e.right,"close",r)}));break;case"mathord":p(e.text,"normal",r);break;case"op":{const{body:a,name:o}=e;a?h(a,r,t):o&&p(o,"normal",r);break}case"op-token":case"textord":p(e.text,t,r);break;case"overline":d(r,(function(r){r.push("start overline"),h(e.body,r,t),r.push("end overline")}));break;case"pmb":r.push("bold");break;case"phantom":r.push("empty space");break;case"rule":r.push("rectangle");break;case"spacing":r.push("space");break;case"sqrt":d(r,(r=>{const{body:a,index:o}=e;if(o)return"3"===b(h(o,[],t)).join(",")?(r.push("cube root of"),h(a,r,t),void r.push("end cube root")):(r.push("root"),r.push("start index"),h(o,r,t),void r.push("end index"));r.push("square root of"),h(a,r,t),r.push("end square root")}));break;case"supsub":{const{base:a,sub:o,sup:s}=e;let l=!1;if(a&&(h(a,r,t),l="op"===a.type&&"\\log"===a.name),o){const e=l?"base":"subscript";d(r,(function(r){r.push("start "+e),h(o,r,t),r.push("end "+e)}))}s&&d(r,(function(e){const r=b(h(s,[],t)).join(",");r in n?e.push(n[r]):(e.push("start superscript"),h(s,e,t),e.push("end superscript"))}));break}case"text":if("\\textbf"===e.font){d(r,(function(r){r.push("start bold text"),h(e.body,r,t),r.push("end bold text")}));break}d(r,(function(r){r.push("start text"),h(e.body,r,t),r.push("end text")}));break;case"enclose":if(/cancel/.test(e.label)){d(r,(function(r){r.push("start cancel"),h(e.body,r,t),r.push("end cancel")}));break}if(/box/.test(e.label)){d(r,(function(r){r.push("start box"),h(e.body,r,t),r.push("end box")}));break}if(/sout/.test(e.label)){d(r,(function(r){r.push("start strikeout"),h(e.body,r,t),r.push("end strikeout")}));break}if(/phase/.test(e.label)){d(r,(function(r){r.push("start phase angle"),h(e.body,r,t),r.push("end phase angle")}));break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"hphantom":throw new Error("KaTeX-a11y: hphantom not implemented yet");case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":p("start verbatim","normal",r),p(e.body,"normal",r),p("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":p("start "+e.label.slice(1),"normal",r),h(e.base,r,t),p("end "+e.label.slice(1),"normal",r);break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":d(r,(function(r){r.push("start underline"),h(e.body,r,t),r.push("end underline")}));break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"cdlabel":throw new Error("KaTeX-a11y: cdlabel not implemented yet");case"cdlabelparent":throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");case"mclass":{const t=e.mclass.slice(1);h(e.body,r,t);break}case"mathchoice":h(e.text,r,t);break;case"htmlmathml":h(e.mathml,r,t);break;case"middle":p(e.delim,t,r);break;default:throw e.type,new Error("KaTeX a11y un-recognized type: "+e.type)}})(e,r,t);return r},b=function(e){let r=[];return e.forEach((function(e){e instanceof Array?r=r.concat(b(e)):r.push(e)})),r};o.default=function(e,t){const a=r().__parse(e,t),o=h(a,[],"normal");return b(o).join(", ")}}(),o=o.default}()})); \ No newline at end of file diff --git a/katex/contrib/render-a11y-string.mjs b/katex/contrib/render-a11y-string.mjs index fc63bfc051..d23d20a3cf 100644 --- a/katex/contrib/render-a11y-string.mjs +++ b/katex/contrib/render-a11y-string.mjs @@ -15,7 +15,7 @@ import katex from '../katex.mjs'; * The commas in the string aim to increase ease of understanding * when read by a screenreader. */ -const stringMap = { +var stringMap = { "(": "left parenthesis", ")": "right parenthesis", "[": "open bracket", @@ -88,22 +88,22 @@ const stringMap = { "\\hat": "hat", "\\acute": "acute" }; -const powerMap = { +var powerMap = { "prime": "prime", "degree": "degrees", "circle": "degrees", "2": "squared", "3": "cubed" }; -const openMap = { +var openMap = { "|": "open vertical bar", ".": "" }; -const closeMap = { +var closeMap = { "|": "close vertical bar", ".": "" }; -const binMap = { +var binMap = { "+": "plus", "-": "minus", "\\pm": "plus minus", @@ -115,7 +115,7 @@ const binMap = { "\\circ": "circle", "\\bullet": "bullet" }; -const relMap = { +var relMap = { "=": "equals", "\\approx": "approximately equals", "≠": "does not equal", @@ -131,7 +131,7 @@ const relMap = { "\\Rightarrow": "right arrow", ":": "colon" }; -const accentUnderMap = { +var accentUnderMap = { "\\underleftarrow": "left arrow", "\\underrightarrow": "right arrow", "\\underleftrightarrow": "left-right arrow", @@ -140,12 +140,12 @@ const accentUnderMap = { "\\utilde": "tilde" }; -const buildString = (str, type, a11yStrings) => { +var buildString = (str, type, a11yStrings) => { if (!str) { return; } - let ret; + var ret; if (type === "open") { ret = str in openMap ? openMap[str] : stringMap[str] || str; @@ -164,7 +164,8 @@ const buildString = (str, type, a11yStrings) => { if (/^\d+$/.test(ret) && a11yStrings.length > 0 && // TODO(kevinb): check that the last item in a11yStrings is a string // I think we might be able to drop the nested arrays, which would make - // this easier to type - $FlowFixMe + // this easier to type + // $FlowFixMe /^\d+$/.test(a11yStrings[a11yStrings.length - 1])) { a11yStrings[a11yStrings.length - 1] += ret; } else if (ret) { @@ -172,13 +173,13 @@ const buildString = (str, type, a11yStrings) => { } }; -const buildRegion = (a11yStrings, callback) => { - const regionStrings = []; +var buildRegion = (a11yStrings, callback) => { + var regionStrings = []; a11yStrings.push(regionStrings); callback(regionStrings); }; -const handleObject = (tree, a11yStrings, atomType) => { +var handleObject = (tree, a11yStrings, atomType) => { // Everything else is assumed to be an object... switch (tree.type) { case "accent": @@ -211,7 +212,9 @@ const handleObject = (tree, a11yStrings, atomType) => { case "atom": { - const text = tree.text; + var { + text + } = tree; switch (tree.family) { case "bin": @@ -254,7 +257,7 @@ const handleObject = (tree, a11yStrings, atomType) => { default: { tree.family; - throw new Error(`"${tree.family}" is not a valid atom type`); + throw new Error("\"" + tree.family + "\" is not a valid atom type"); } } @@ -263,7 +266,7 @@ const handleObject = (tree, a11yStrings, atomType) => { case "color": { - const color = tree.color.replace(/katex-/, ""); + var color = tree.color.replace(/katex-/, ""); buildRegion(a11yStrings, regionStrings => { regionStrings.push("start color " + color); buildA11yStrings(tree.body, regionStrings, atomType); @@ -292,8 +295,10 @@ const handleObject = (tree, a11yStrings, atomType) => { { buildRegion(a11yStrings, regionStrings => { // genfrac can have unbalanced delimiters - const leftDelim = tree.leftDelim, - rightDelim = tree.rightDelim; // NOTE: Not sure if this is a safe assumption + var { + leftDelim, + rightDelim + } = tree; // NOTE: Not sure if this is a safe assumption // hasBarLine true -> fraction, false -> binomial if (tree.hasBarLine) { @@ -317,6 +322,12 @@ const handleObject = (tree, a11yStrings, atomType) => { break; } + case "hbox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": { // No op: we don't attempt to present kerning information @@ -354,8 +365,10 @@ const handleObject = (tree, a11yStrings, atomType) => { case "op": { - const body = tree.body, - name = tree.name; + var { + body, + name + } = tree; if (body) { buildA11yStrings(body, a11yStrings, atomType); @@ -389,6 +402,12 @@ const handleObject = (tree, a11yStrings, atomType) => { break; } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": { a11yStrings.push("empty space"); @@ -429,11 +448,13 @@ const handleObject = (tree, a11yStrings, atomType) => { case "sqrt": { buildRegion(a11yStrings, regionStrings => { - const body = tree.body, - index = tree.index; + var { + body, + index + } = tree; if (index) { - const indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); + var indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); if (indexString === "3") { regionStrings.push("cube root of"); @@ -458,10 +479,12 @@ const handleObject = (tree, a11yStrings, atomType) => { case "supsub": { - const base = tree.base, - sub = tree.sub, - sup = tree.sup; - let isLog = false; + var { + base, + sub, + sup + } = tree; + var isLog = false; if (base) { buildA11yStrings(base, a11yStrings, atomType); @@ -469,17 +492,17 @@ const handleObject = (tree, a11yStrings, atomType) => { } if (sub) { - const regionName = isLog ? "base" : "subscript"; + var regionName = isLog ? "base" : "subscript"; buildRegion(a11yStrings, function (regionStrings) { - regionStrings.push(`start ${regionName}`); + regionStrings.push("start " + regionName); buildA11yStrings(sub, regionStrings, atomType); - regionStrings.push(`end ${regionName}`); + regionStrings.push("end " + regionName); }); } if (sup) { buildRegion(a11yStrings, function (regionStrings) { - const supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); + var supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); if (supString in powerMap) { regionStrings.push(powerMap[supString]); @@ -553,9 +576,22 @@ const handleObject = (tree, a11yStrings, atomType) => { regionStrings.push("end strikeout"); }); break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; } - throw new Error(`KaTeX-a11y: enclose node with ${tree.label} not supported yet`); + throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); + } + + case "vcenter": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; } case "vphantom": @@ -603,9 +639,9 @@ const handleObject = (tree, a11yStrings, atomType) => { case "verb": { - buildString(`start verbatim`, "normal", a11yStrings); + buildString("start verbatim", "normal", a11yStrings); buildString(tree.body, "normal", a11yStrings); - buildString(`end verbatim`, "normal", a11yStrings); + buildString("end verbatim", "normal", a11yStrings); break; } @@ -616,9 +652,9 @@ const handleObject = (tree, a11yStrings, atomType) => { case "horizBrace": { - buildString(`start ${tree.label.slice(1)}`, "normal", a11yStrings); + buildString("start " + tree.label.slice(1), "normal", a11yStrings); buildA11yStrings(tree.base, a11yStrings, atomType); - buildString(`end ${tree.label.slice(1)}`, "normal", a11yStrings); + buildString("end " + tree.label.slice(1), "normal", a11yStrings); break; } @@ -667,19 +703,30 @@ const handleObject = (tree, a11yStrings, atomType) => { throw new Error("KaTeX-a11y: xArrow not implemented yet"); } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": { // \neq and \ne are macros so we let "htmlmathml" render the mathmal // side of things and extract the text from that. - const atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass + var _atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass - buildA11yStrings(tree.body, a11yStrings, atomType); + + buildA11yStrings(tree.body, a11yStrings, _atomType); break; } case "mathchoice": { - // TODO: track which which style we're using, e.g. dispaly, text, etc. + // TODO: track which style we're using, e.g. display, text, etc. // default to text style if even that may not be the correct style buildA11yStrings(tree.text, a11yStrings, atomType); break; @@ -697,19 +744,31 @@ const handleObject = (tree, a11yStrings, atomType) => { break; } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + + case "html": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: tree.type; throw new Error("KaTeX a11y un-recognized type: " + tree.type); } }; -const buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { +var buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { if (a11yStrings === void 0) { a11yStrings = []; } if (tree instanceof Array) { - for (let i = 0; i < tree.length; i++) { + for (var i = 0; i < tree.length; i++) { buildA11yStrings(tree[i], a11yStrings, atomType); } } else { @@ -719,8 +778,8 @@ const buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) return a11yStrings; }; -const flatten = function flatten(array) { - let result = []; +var flatten = function flatten(array) { + var result = []; array.forEach(function (item) { if (item instanceof Array) { result = result.concat(flatten(item)); @@ -731,11 +790,11 @@ const flatten = function flatten(array) { return result; }; -const renderA11yString = function renderA11yString(text, settings) { - const tree = katex.__parse(text, settings); +var renderA11yString = function renderA11yString(text, settings) { + var tree = katex.__parse(text, settings); - const a11yStrings = buildA11yStrings(tree, [], "normal"); + var a11yStrings = buildA11yStrings(tree, [], "normal"); return flatten(a11yStrings).join(", "); }; -export default renderA11yString; +export { renderA11yString as default }; diff --git a/katex/fonts/KaTeX_AMS-Regular.ttf b/katex/fonts/KaTeX_AMS-Regular.ttf index afcd2eb4d1..c6f9a5e7c0 100644 Binary files a/katex/fonts/KaTeX_AMS-Regular.ttf and b/katex/fonts/KaTeX_AMS-Regular.ttf differ diff --git a/katex/fonts/KaTeX_AMS-Regular.woff b/katex/fonts/KaTeX_AMS-Regular.woff index 4f575152f2..b804d7b33a 100644 Binary files a/katex/fonts/KaTeX_AMS-Regular.woff and b/katex/fonts/KaTeX_AMS-Regular.woff differ diff --git a/katex/fonts/KaTeX_AMS-Regular.woff2 b/katex/fonts/KaTeX_AMS-Regular.woff2 index b982d6eaf8..0acaaff03d 100644 Binary files a/katex/fonts/KaTeX_AMS-Regular.woff2 and b/katex/fonts/KaTeX_AMS-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Caligraphic-Bold.ttf b/katex/fonts/KaTeX_Caligraphic-Bold.ttf index f84148db58..9ff4a5e044 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Bold.ttf and b/katex/fonts/KaTeX_Caligraphic-Bold.ttf differ diff --git a/katex/fonts/KaTeX_Caligraphic-Bold.woff b/katex/fonts/KaTeX_Caligraphic-Bold.woff index ab56ab7fa7..9759710d1d 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Bold.woff and b/katex/fonts/KaTeX_Caligraphic-Bold.woff differ diff --git a/katex/fonts/KaTeX_Caligraphic-Bold.woff2 b/katex/fonts/KaTeX_Caligraphic-Bold.woff2 index 710c26179c..f390922ece 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Bold.woff2 and b/katex/fonts/KaTeX_Caligraphic-Bold.woff2 differ diff --git a/katex/fonts/KaTeX_Caligraphic-Regular.ttf b/katex/fonts/KaTeX_Caligraphic-Regular.ttf index 97814db7e2..f522294ff0 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Regular.ttf and b/katex/fonts/KaTeX_Caligraphic-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Caligraphic-Regular.woff b/katex/fonts/KaTeX_Caligraphic-Regular.woff index aec8a33389..9bdd534fd2 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Regular.woff and b/katex/fonts/KaTeX_Caligraphic-Regular.woff differ diff --git a/katex/fonts/KaTeX_Caligraphic-Regular.woff2 b/katex/fonts/KaTeX_Caligraphic-Regular.woff2 index ee5193d7c8..75344a1f98 100644 Binary files a/katex/fonts/KaTeX_Caligraphic-Regular.woff2 and b/katex/fonts/KaTeX_Caligraphic-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Fraktur-Bold.ttf b/katex/fonts/KaTeX_Fraktur-Bold.ttf index 483a7cdd4e..4e98259c3b 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Bold.ttf and b/katex/fonts/KaTeX_Fraktur-Bold.ttf differ diff --git a/katex/fonts/KaTeX_Fraktur-Bold.woff b/katex/fonts/KaTeX_Fraktur-Bold.woff index 189fea5e4f..e7730f6627 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Bold.woff and b/katex/fonts/KaTeX_Fraktur-Bold.woff differ diff --git a/katex/fonts/KaTeX_Fraktur-Bold.woff2 b/katex/fonts/KaTeX_Fraktur-Bold.woff2 index dc3bd4c040..395f28beac 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Bold.woff2 and b/katex/fonts/KaTeX_Fraktur-Bold.woff2 differ diff --git a/katex/fonts/KaTeX_Fraktur-Regular.ttf b/katex/fonts/KaTeX_Fraktur-Regular.ttf index 9aa5f674da..b8461b275f 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Regular.ttf and b/katex/fonts/KaTeX_Fraktur-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Fraktur-Regular.woff b/katex/fonts/KaTeX_Fraktur-Regular.woff index d01450e918..acab069f90 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Regular.woff and b/katex/fonts/KaTeX_Fraktur-Regular.woff differ diff --git a/katex/fonts/KaTeX_Fraktur-Regular.woff2 b/katex/fonts/KaTeX_Fraktur-Regular.woff2 index 7eeba37793..735f6948d6 100644 Binary files a/katex/fonts/KaTeX_Fraktur-Regular.woff2 and b/katex/fonts/KaTeX_Fraktur-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Main-Bold.ttf b/katex/fonts/KaTeX_Main-Bold.ttf index dc0185a122..4060e627dc 100644 Binary files a/katex/fonts/KaTeX_Main-Bold.ttf and b/katex/fonts/KaTeX_Main-Bold.ttf differ diff --git a/katex/fonts/KaTeX_Main-Bold.woff b/katex/fonts/KaTeX_Main-Bold.woff index acf48e6689..f38136ac1c 100644 Binary files a/katex/fonts/KaTeX_Main-Bold.woff and b/katex/fonts/KaTeX_Main-Bold.woff differ diff --git a/katex/fonts/KaTeX_Main-Bold.woff2 b/katex/fonts/KaTeX_Main-Bold.woff2 index cf5ababf46..ab2ad21da6 100644 Binary files a/katex/fonts/KaTeX_Main-Bold.woff2 and b/katex/fonts/KaTeX_Main-Bold.woff2 differ diff --git a/katex/fonts/KaTeX_Main-BoldItalic.ttf b/katex/fonts/KaTeX_Main-BoldItalic.ttf index 4346f173ce..dc007977ee 100644 Binary files a/katex/fonts/KaTeX_Main-BoldItalic.ttf and b/katex/fonts/KaTeX_Main-BoldItalic.ttf differ diff --git a/katex/fonts/KaTeX_Main-BoldItalic.woff b/katex/fonts/KaTeX_Main-BoldItalic.woff index d2cfe4e319..67807b0bd4 100644 Binary files a/katex/fonts/KaTeX_Main-BoldItalic.woff and b/katex/fonts/KaTeX_Main-BoldItalic.woff differ diff --git a/katex/fonts/KaTeX_Main-BoldItalic.woff2 b/katex/fonts/KaTeX_Main-BoldItalic.woff2 index d0178f4215..5931794de4 100644 Binary files a/katex/fonts/KaTeX_Main-BoldItalic.woff2 and b/katex/fonts/KaTeX_Main-BoldItalic.woff2 differ diff --git a/katex/fonts/KaTeX_Main-Italic.ttf b/katex/fonts/KaTeX_Main-Italic.ttf index f2c3ebaec0..0e9b0f354a 100644 Binary files a/katex/fonts/KaTeX_Main-Italic.ttf and b/katex/fonts/KaTeX_Main-Italic.ttf differ diff --git a/katex/fonts/KaTeX_Main-Italic.woff b/katex/fonts/KaTeX_Main-Italic.woff index 1184295def..6f43b594b6 100644 Binary files a/katex/fonts/KaTeX_Main-Italic.woff and b/katex/fonts/KaTeX_Main-Italic.woff differ diff --git a/katex/fonts/KaTeX_Main-Italic.woff2 b/katex/fonts/KaTeX_Main-Italic.woff2 index aa05e142c4..b50920e138 100644 Binary files a/katex/fonts/KaTeX_Main-Italic.woff2 and b/katex/fonts/KaTeX_Main-Italic.woff2 differ diff --git a/katex/fonts/KaTeX_Main-Regular.ttf b/katex/fonts/KaTeX_Main-Regular.ttf index 8acb365453..dd45e1ed2e 100644 Binary files a/katex/fonts/KaTeX_Main-Regular.ttf and b/katex/fonts/KaTeX_Main-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Main-Regular.woff b/katex/fonts/KaTeX_Main-Regular.woff index 9f8228fc38..21f5812968 100644 Binary files a/katex/fonts/KaTeX_Main-Regular.woff and b/katex/fonts/KaTeX_Main-Regular.woff differ diff --git a/katex/fonts/KaTeX_Main-Regular.woff2 b/katex/fonts/KaTeX_Main-Regular.woff2 index e3f71eb7e9..eb24a7ba28 100644 Binary files a/katex/fonts/KaTeX_Main-Regular.woff2 and b/katex/fonts/KaTeX_Main-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Math-BoldItalic.ttf b/katex/fonts/KaTeX_Math-BoldItalic.ttf index a645df64e5..728ce7a1e2 100644 Binary files a/katex/fonts/KaTeX_Math-BoldItalic.ttf and b/katex/fonts/KaTeX_Math-BoldItalic.ttf differ diff --git a/katex/fonts/KaTeX_Math-BoldItalic.woff b/katex/fonts/KaTeX_Math-BoldItalic.woff index 87d4f223ea..0ae390d74c 100644 Binary files a/katex/fonts/KaTeX_Math-BoldItalic.woff and b/katex/fonts/KaTeX_Math-BoldItalic.woff differ diff --git a/katex/fonts/KaTeX_Math-BoldItalic.woff2 b/katex/fonts/KaTeX_Math-BoldItalic.woff2 index 83b49962aa..29657023ad 100644 Binary files a/katex/fonts/KaTeX_Math-BoldItalic.woff2 and b/katex/fonts/KaTeX_Math-BoldItalic.woff2 differ diff --git a/katex/fonts/KaTeX_Math-Italic.ttf b/katex/fonts/KaTeX_Math-Italic.ttf index 9c38359cca..70d559b4e9 100644 Binary files a/katex/fonts/KaTeX_Math-Italic.ttf and b/katex/fonts/KaTeX_Math-Italic.ttf differ diff --git a/katex/fonts/KaTeX_Math-Italic.woff b/katex/fonts/KaTeX_Math-Italic.woff index 959746ef56..eb5159d4c1 100644 Binary files a/katex/fonts/KaTeX_Math-Italic.woff and b/katex/fonts/KaTeX_Math-Italic.woff differ diff --git a/katex/fonts/KaTeX_Math-Italic.woff2 b/katex/fonts/KaTeX_Math-Italic.woff2 index e3ea522a6a..215c143fd7 100644 Binary files a/katex/fonts/KaTeX_Math-Italic.woff2 and b/katex/fonts/KaTeX_Math-Italic.woff2 differ diff --git a/katex/fonts/KaTeX_SansSerif-Bold.ttf b/katex/fonts/KaTeX_SansSerif-Bold.ttf index ff10851245..2f65a8a3a6 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Bold.ttf and b/katex/fonts/KaTeX_SansSerif-Bold.ttf differ diff --git a/katex/fonts/KaTeX_SansSerif-Bold.woff b/katex/fonts/KaTeX_SansSerif-Bold.woff index f0d6ea739b..8d47c02d94 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Bold.woff and b/katex/fonts/KaTeX_SansSerif-Bold.woff differ diff --git a/katex/fonts/KaTeX_SansSerif-Bold.woff2 b/katex/fonts/KaTeX_SansSerif-Bold.woff2 index 4cf8f14696..cfaa3bda59 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Bold.woff2 and b/katex/fonts/KaTeX_SansSerif-Bold.woff2 differ diff --git a/katex/fonts/KaTeX_SansSerif-Italic.ttf b/katex/fonts/KaTeX_SansSerif-Italic.ttf index 3dd767131a..d5850df98e 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Italic.ttf and b/katex/fonts/KaTeX_SansSerif-Italic.ttf differ diff --git a/katex/fonts/KaTeX_SansSerif-Italic.woff b/katex/fonts/KaTeX_SansSerif-Italic.woff index 9da0dfe396..7e02df9636 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Italic.woff and b/katex/fonts/KaTeX_SansSerif-Italic.woff differ diff --git a/katex/fonts/KaTeX_SansSerif-Italic.woff2 b/katex/fonts/KaTeX_SansSerif-Italic.woff2 index ce19ae03d5..349c06dc60 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Italic.woff2 and b/katex/fonts/KaTeX_SansSerif-Italic.woff2 differ diff --git a/katex/fonts/KaTeX_SansSerif-Regular.ttf b/katex/fonts/KaTeX_SansSerif-Regular.ttf index f117cd619e..537279f6bd 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Regular.ttf and b/katex/fonts/KaTeX_SansSerif-Regular.ttf differ diff --git a/katex/fonts/KaTeX_SansSerif-Regular.woff b/katex/fonts/KaTeX_SansSerif-Regular.woff index 6ed98780a7..31b84829b4 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Regular.woff and b/katex/fonts/KaTeX_SansSerif-Regular.woff differ diff --git a/katex/fonts/KaTeX_SansSerif-Regular.woff2 b/katex/fonts/KaTeX_SansSerif-Regular.woff2 index 27611491a1..a90eea85f6 100644 Binary files a/katex/fonts/KaTeX_SansSerif-Regular.woff2 and b/katex/fonts/KaTeX_SansSerif-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Script-Regular.ttf b/katex/fonts/KaTeX_Script-Regular.ttf index e6f34542e2..fd679bf374 100644 Binary files a/katex/fonts/KaTeX_Script-Regular.ttf and b/katex/fonts/KaTeX_Script-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Script-Regular.woff b/katex/fonts/KaTeX_Script-Regular.woff index 4a48e65f0d..0e7da821ee 100644 Binary files a/katex/fonts/KaTeX_Script-Regular.woff and b/katex/fonts/KaTeX_Script-Regular.woff differ diff --git a/katex/fonts/KaTeX_Script-Regular.woff2 b/katex/fonts/KaTeX_Script-Regular.woff2 index b0aed195ca..b3048fc115 100644 Binary files a/katex/fonts/KaTeX_Script-Regular.woff2 and b/katex/fonts/KaTeX_Script-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Size1-Regular.ttf b/katex/fonts/KaTeX_Size1-Regular.ttf index 37faa0f9fe..871fd7d19d 100644 Binary files a/katex/fonts/KaTeX_Size1-Regular.ttf and b/katex/fonts/KaTeX_Size1-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Size1-Regular.woff b/katex/fonts/KaTeX_Size1-Regular.woff index 0832f7a468..7f292d9118 100644 Binary files a/katex/fonts/KaTeX_Size1-Regular.woff and b/katex/fonts/KaTeX_Size1-Regular.woff differ diff --git a/katex/fonts/KaTeX_Size1-Regular.woff2 b/katex/fonts/KaTeX_Size1-Regular.woff2 index 483e7b66e0..c5a8462fbf 100644 Binary files a/katex/fonts/KaTeX_Size1-Regular.woff2 and b/katex/fonts/KaTeX_Size1-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Size2-Regular.ttf b/katex/fonts/KaTeX_Size2-Regular.ttf index cf326236c0..7a212caf91 100644 Binary files a/katex/fonts/KaTeX_Size2-Regular.ttf and b/katex/fonts/KaTeX_Size2-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Size2-Regular.woff b/katex/fonts/KaTeX_Size2-Regular.woff index 14f6485abb..d241d9be2d 100644 Binary files a/katex/fonts/KaTeX_Size2-Regular.woff and b/katex/fonts/KaTeX_Size2-Regular.woff differ diff --git a/katex/fonts/KaTeX_Size2-Regular.woff2 b/katex/fonts/KaTeX_Size2-Regular.woff2 index 5ff7060676..e1bccfe240 100644 Binary files a/katex/fonts/KaTeX_Size2-Regular.woff2 and b/katex/fonts/KaTeX_Size2-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Size3-Regular.ttf b/katex/fonts/KaTeX_Size3-Regular.ttf index ff7e2b9010..00bff3495f 100644 Binary files a/katex/fonts/KaTeX_Size3-Regular.ttf and b/katex/fonts/KaTeX_Size3-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Size3-Regular.woff b/katex/fonts/KaTeX_Size3-Regular.woff index d3626cef39..e6e9b658dc 100644 Binary files a/katex/fonts/KaTeX_Size3-Regular.woff and b/katex/fonts/KaTeX_Size3-Regular.woff differ diff --git a/katex/fonts/KaTeX_Size3-Regular.woff2 b/katex/fonts/KaTeX_Size3-Regular.woff2 index e45ca49db8..249a286622 100644 Binary files a/katex/fonts/KaTeX_Size3-Regular.woff2 and b/katex/fonts/KaTeX_Size3-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Size4-Regular.ttf b/katex/fonts/KaTeX_Size4-Regular.ttf index 3034091cdb..74f08921f0 100644 Binary files a/katex/fonts/KaTeX_Size4-Regular.ttf and b/katex/fonts/KaTeX_Size4-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Size4-Regular.woff b/katex/fonts/KaTeX_Size4-Regular.woff index 93c57a6f97..e1ec545766 100644 Binary files a/katex/fonts/KaTeX_Size4-Regular.woff and b/katex/fonts/KaTeX_Size4-Regular.woff differ diff --git a/katex/fonts/KaTeX_Size4-Regular.woff2 b/katex/fonts/KaTeX_Size4-Regular.woff2 index 53b65afcff..680c130850 100644 Binary files a/katex/fonts/KaTeX_Size4-Regular.woff2 and b/katex/fonts/KaTeX_Size4-Regular.woff2 differ diff --git a/katex/fonts/KaTeX_Typewriter-Regular.ttf b/katex/fonts/KaTeX_Typewriter-Regular.ttf index 2fd85294ab..c83252c571 100644 Binary files a/katex/fonts/KaTeX_Typewriter-Regular.ttf and b/katex/fonts/KaTeX_Typewriter-Regular.ttf differ diff --git a/katex/fonts/KaTeX_Typewriter-Regular.woff b/katex/fonts/KaTeX_Typewriter-Regular.woff index e90fa2bc7f..2432419f28 100644 Binary files a/katex/fonts/KaTeX_Typewriter-Regular.woff and b/katex/fonts/KaTeX_Typewriter-Regular.woff differ diff --git a/katex/fonts/KaTeX_Typewriter-Regular.woff2 b/katex/fonts/KaTeX_Typewriter-Regular.woff2 index e40ab15161..771f1af705 100644 Binary files a/katex/fonts/KaTeX_Typewriter-Regular.woff2 and b/katex/fonts/KaTeX_Typewriter-Regular.woff2 differ diff --git a/katex/katex.css b/katex/katex.css index 7c97e926d2..4b1bb686c8 100644 --- a/katex/katex.css +++ b/katex/katex.css @@ -128,10 +128,15 @@ .katex * { -ms-high-contrast-adjust: none !important; } +.katex * { + border-color: currentColor; +} .katex .katex-version::after { - content: "0.11.1"; + content: "0.16.10"; } .katex .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ position: absolute; clip: rect(1px, 1px, 1px, 1px); padding: 0; @@ -150,6 +155,8 @@ position: relative; display: inline-block; white-space: nowrap; + width: -webkit-min-content; + width: -moz-min-content; width: min-content; } .katex .strut { @@ -170,7 +177,7 @@ .katex .texttt { font-family: KaTeX_Typewriter; } -.katex .mathdefault { +.katex .mathnormal { font-family: KaTeX_Math; font-style: italic; } @@ -204,6 +211,11 @@ .katex .textfrak { font-family: KaTeX_Fraktur; } +.katex .mathboldfrak, +.katex .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; +} .katex .mathtt { font-family: KaTeX_Typewriter; } @@ -232,6 +244,7 @@ .katex .vlist-t { display: inline-table; table-layout: fixed; + border-collapse: collapse; } .katex .vlist-r { display: table-row; @@ -263,6 +276,22 @@ width: 2px; min-width: 2px; } +.katex .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; +} +.katex .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; +} +.katex .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; +} .katex .msupsub { text-align: left; } @@ -330,6 +359,8 @@ border-bottom-style: dashed; } .katex .sqrt > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ margin-left: 0.27777778em; margin-right: -0.55555556em; } @@ -960,13 +991,16 @@ .katex .x-arrow-pad { padding: 0 0.5em; } +.katex .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; +} .katex .x-arrow, .katex .mover, .katex .munder { text-align: center; } .katex .boxpad { - padding: 0 0.3em 0 0.3em; + padding: 0 0.3em; } .katex .fbox, .katex .fcolorbox { @@ -974,7 +1008,7 @@ border: 0.04em solid; } .katex .cancel-pad { - padding: 0 0.2em 0 0.2em; + padding: 0 0.2em; } .katex .cancel-lap { margin-left: -0.2em; @@ -984,6 +1018,42 @@ border-bottom-style: solid; border-bottom-width: 0.08em; } +.katex .angl { + box-sizing: border-box; + border-top: 0.049em solid; + border-right: 0.049em solid; + margin-right: 0.03889em; +} +.katex .anglpad { + padding: 0 0.03889em; +} +.katex .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; +} +.katex .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; +} +.katex .mtr-glue { + width: 50%; +} +.katex .cd-vert-arrow { + display: inline-block; + position: relative; +} +.katex .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; +} +.katex .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; +} .katex-display { display: block; margin: 1em 0; @@ -1008,5 +1078,9 @@ } .katex-display.fleqn > .katex { text-align: left; + padding-left: 2em; +} +body { + counter-reset: katexEqnNo mmlEqnNo; } diff --git a/katex/katex.js b/katex/katex.js index 7326227174..50760c4cbe 100644 --- a/katex/katex.js +++ b/katex/katex.js @@ -8,199 +8,38 @@ else root["katex"] = factory(); })((typeof self !== 'undefined' ? self : this), function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ // The require scope +/******/ var __webpack_require__ = {}; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } /******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ /************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -// extracted by mini-css-extract-plugin - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); - -// EXTERNAL MODULE: ./src/katex.less -var katex = __webpack_require__(0); - -// CONCATENATED MODULE: ./src/SourceLocation.js -/** - * Lexing or parsing positional information for error reporting. - * This object is immutable. - */ -var SourceLocation = -/*#__PURE__*/ -function () { - // The + prefix indicates that these fields aren't writeable - // Lexer holding the input string. - // Start offset, zero-based inclusive. - // End offset, zero-based exclusive. - function SourceLocation(lexer, start, end) { - this.lexer = void 0; - this.start = void 0; - this.end = void 0; - this.lexer = lexer; - this.start = start; - this.end = end; - } - /** - * Merges two `SourceLocation`s from location providers, given they are - * provided in order of appearance. - * - Returns the first one's location if only the first is provided. - * - Returns a merged range of the first and the last if both are provided - * and their lexers match. - * - Otherwise, returns null. - */ - - - SourceLocation.range = function range(first, second) { - if (!second) { - return first && first.loc; - } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { - return null; - } else { - return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); - } - }; - - return SourceLocation; -}(); - - -// CONCATENATED MODULE: ./src/Token.js - -/** - * Interface required to break circular dependency between Token, Lexer, and - * ParseError. - */ - -/** - * The resulting token returned from `lex`. - * - * It consists of the token text plus some position information. - * The position information is essentially a range in an input string, - * but instead of referencing the bare input string, we refer to the lexer. - * That way it is possible to attach extra metadata to the input string, - * like for example a file name or similar. - * - * The position information is optional, so it is OK to construct synthetic - * tokens if appropriate. Not providing available position information may - * lead to degraded error reporting, though. - */ -var Token_Token = -/*#__PURE__*/ -function () { - function Token(text, // the text of this token - loc) { - this.text = void 0; - this.loc = void 0; - this.text = text; - this.loc = loc; - } - /** - * Given a pair of tokens (this and endToken), compute a `Token` encompassing - * the whole input range enclosed by these two. - */ - +var __webpack_exports__ = {}; - var _proto = Token.prototype; - - _proto.range = function range(endToken, // last token of the range, inclusive - text) // the text of the newly constructed token - { - return new Token(text, SourceLocation.range(this, endToken)); - }; +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ katex_webpack; } +}); - return Token; -}(); -// CONCATENATED MODULE: ./src/ParseError.js +;// CONCATENATED MODULE: ./src/ParseError.js /** @@ -211,66 +50,81 @@ function () { * If possible, a caller should provide a Token or ParseNode with information * about where in the source string the problem occurred. */ -var ParseError = // Error position based on passed-in Token or ParseNode. -function ParseError(message, // The error message -token) // An object providing position information -{ - this.position = void 0; - var error = "KaTeX parse error: " + message; - var start; - var loc = token && token.loc; - - if (loc && loc.start <= loc.end) { - // If we have the input and a position, make the error a bit fancier - // Get the input - var input = loc.lexer.input; // Prepend some information - - start = loc.start; - var end = loc.end; - - if (start === input.length) { - error += " at end of input: "; - } else { - error += " at position " + (start + 1) + ": "; - } // Underline token in question using combining underscores +class ParseError { + // Error start position based on passed-in Token or ParseNode. + // Length of affected text based on passed-in Token or ParseNode. + // The underlying error message without any context added. + constructor(message, // The error message + token // An object providing position information + ) { + this.name = void 0; + this.position = void 0; + this.length = void 0; + this.rawMessage = void 0; + let error = "KaTeX parse error: " + message; + let start; + let end; + const loc = token && token.loc; + + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + // Get the input + const input = loc.lexer.input; // Prepend some information + + start = loc.start; + end = loc.end; + + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } // Underline token in question using combining underscores - var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error + const underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error - var left; + let left; - if (start > 15) { - left = "…" + input.slice(start - 15, start); - } else { - left = input.slice(0, start); - } + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } - var right; + let right; - if (end + 15 < input.length) { - right = input.slice(end, end + 15) + "…"; - } else { - right = input.slice(end); - } + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + + error += left + underlined + right; + } // Some hackery to make ParseError a prototype of Error + // See http://stackoverflow.com/a/8460753 + // $FlowFixMe - error += left + underlined + right; - } // Some hackery to make ParseError a prototype of Error - // See http://stackoverflow.com/a/8460753 + const self = new Error(error); + self.name = "ParseError"; // $FlowFixMe - var self = new Error(error); - self.name = "ParseError"; // $FlowFixMe + self.__proto__ = ParseError.prototype; + self.position = start; - self.__proto__ = ParseError.prototype; // $FlowFixMe + if (start != null && end != null) { + self.length = end - start; + } + + self.rawMessage = message; + return self; + } - self.position = start; - return self; -}; // $FlowFixMe More hackery +} // $FlowFixMe More hackery ParseError.prototype.__proto__ = Error.prototype; /* harmony default export */ var src_ParseError = (ParseError); -// CONCATENATED MODULE: ./src/utils.js +;// CONCATENATED MODULE: ./src/utils.js /** * This file contains a list of utility functions which are useful in other * files. @@ -279,7 +133,7 @@ ParseError.prototype.__proto__ = Error.prototype; /** * Return whether an element is contained in a list */ -var contains = function contains(list, elem) { +const contains = function (list, elem) { return list.indexOf(elem) !== -1; }; /** @@ -288,33 +142,31 @@ var contains = function contains(list, elem) { */ -var deflt = function deflt(setting, defaultIfUndefined) { +const deflt = function (setting, defaultIfUndefined) { return setting === undefined ? defaultIfUndefined : setting; }; // hyphenate and escape adapted from Facebook's React under Apache 2 license -var uppercase = /([A-Z])/g; +const uppercase = /([A-Z])/g; -var hyphenate = function hyphenate(str) { +const hyphenate = function (str) { return str.replace(uppercase, "-$1").toLowerCase(); }; -var ESCAPE_LOOKUP = { +const ESCAPE_LOOKUP = { "&": "&", ">": ">", "<": "<", "\"": """, "'": "'" }; -var ESCAPE_REGEX = /[&><"']/g; +const ESCAPE_REGEX = /[&><"']/g; /** * Escapes text to prevent scripting attacks. */ function utils_escape(text) { - return String(text).replace(ESCAPE_REGEX, function (match) { - return ESCAPE_LOOKUP[match]; - }); + return String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); } /** * Sometimes we want to pull out the innermost element of a group. In most @@ -323,7 +175,7 @@ function utils_escape(text) { */ -var getBaseElem = function getBaseElem(group) { +const getBaseElem = function (group) { if (group.type === "ordgroup") { if (group.body.length === 1) { return getBaseElem(group.body[0]); @@ -349,13 +201,13 @@ var getBaseElem = function getBaseElem(group) { */ -var utils_isCharacterBox = function isCharacterBox(group) { - var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters +const isCharacterBox = function (group) { + const baseElem = getBaseElem(group); // These are all they types of groups which hold single characters return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom"; }; -var assert = function assert(value) { +const assert = function (value) { if (!value) { throw new Error('Expected non-null, but got ' + String(value)); } @@ -364,23 +216,45 @@ var assert = function assert(value) { }; /** * Return the protocol of a URL, or "_relative" if the URL does not specify a - * protocol (and thus is relative). + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). */ -var protocolFromUrl = function protocolFromUrl(url) { - var protocol = /^\s*([^\\/#]*?)(?::|�*58|�*3a)/i.exec(url); - return protocol != null ? protocol[1] : "_relative"; +const protocolFromUrl = function (url) { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + // eslint-disable-next-line no-control-regex + const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + + if (!protocol) { + return "_relative"; + } // Reject weird colons + + + if (protocol[2] !== ":") { + return null; + } // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + + + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } // Lowercase the protocol + + + return protocol[1].toLowerCase(); }; /* harmony default export */ var utils = ({ - contains: contains, - deflt: deflt, + contains, + deflt, escape: utils_escape, - hyphenate: hyphenate, - getBaseElem: getBaseElem, - isCharacterBox: utils_isCharacterBox, - protocolFromUrl: protocolFromUrl + hyphenate, + getBaseElem, + isCharacterBox, + protocolFromUrl }); -// CONCATENATED MODULE: ./src/Settings.js +;// CONCATENATED MODULE: ./src/Settings.js /* eslint no-console:0 */ /** @@ -390,7 +264,126 @@ var protocolFromUrl = function protocolFromUrl(url) { +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +const SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; + +function getDefaultValue(schema) { + if (schema.default) { + return schema.default; + } + + const type = schema.type; + const defaultType = Array.isArray(type) ? type[0] : type; + + if (typeof defaultType !== 'string') { + return defaultType.enum[0]; + } + + switch (defaultType) { + case 'boolean': + return false; + + case 'string': + return ''; + + case 'number': + return 0; + case 'object': + return {}; + } +} /** * The main Settings object * @@ -401,10 +394,10 @@ var protocolFromUrl = function protocolFromUrl(url) { * math (true), meaning that the math starts in \displaystyle * and is placed in a block with vertical margin. */ -var Settings_Settings = -/*#__PURE__*/ -function () { - function Settings(options) { + + +class Settings { + constructor(options) { this.displayMode = void 0; this.output = void 0; this.leqno = void 0; @@ -418,21 +411,19 @@ function () { this.trust = void 0; this.maxSize = void 0; this.maxExpand = void 0; + this.globalGroup = void 0; // allow null options options = options || {}; - this.displayMode = utils.deflt(options.displayMode, false); - this.output = utils.deflt(options.output, "htmlAndMathml"); - this.leqno = utils.deflt(options.leqno, false); - this.fleqn = utils.deflt(options.fleqn, false); - this.throwOnError = utils.deflt(options.throwOnError, true); - this.errorColor = utils.deflt(options.errorColor, "#cc0000"); - this.macros = options.macros || {}; - this.minRuleThickness = Math.max(0, utils.deflt(options.minRuleThickness, 0)); - this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); - this.strict = utils.deflt(options.strict, "warn"); - this.trust = utils.deflt(options.trust, false); - this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity)); - this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000)); + + for (const prop in SETTINGS_SCHEMA) { + if (SETTINGS_SCHEMA.hasOwnProperty(prop)) { + // $FlowFixMe + const schema = SETTINGS_SCHEMA[prop]; // TODO: validate options + // $FlowFixMe + + this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema); + } + } } /** * Report nonstrict (non-LaTeX-compatible) input. @@ -440,10 +431,8 @@ function () { */ - var _proto = Settings.prototype; - - _proto.reportNonstrict = function reportNonstrict(errorCode, errorMsg, token) { - var strict = this.strict; + reportNonstrict(errorCode, errorMsg, token) { + let strict = this.strict; if (typeof strict === "function") { // Allow return value of strict function to be boolean or string @@ -470,10 +459,10 @@ function () { * "warn" prints a warning and returns `false`. * This is for the second category of `errorCode`s listed in the README. */ - ; - _proto.useStrictBehavior = function useStrictBehavior(errorCode, errorMsg, token) { - var strict = this.strict; + + useStrictBehavior(errorCode, errorMsg, token) { + let strict = this.strict; if (typeof strict === "function") { // Allow return value of strict function to be boolean or string @@ -508,22 +497,25 @@ function () { * If `context` has a `url` field, a `protocol` field will automatically * get added by this function (changing the specified object). */ - ; - _proto.isTrusted = function isTrusted(context) { + + isTrusted(context) { if (context.url && !context.protocol) { - context.protocol = utils.protocolFromUrl(context.url); - } + const protocol = utils.protocolFromUrl(context.url); - var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; - return Boolean(trust); - }; + if (protocol == null) { + return false; + } - return Settings; -}(); + context.protocol = protocol; + } + const trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } -// CONCATENATED MODULE: ./src/Style.js +} +;// CONCATENATED MODULE: ./src/Style.js /** * This file contains information and classes for the various kinds of styles * used in TeX. It provides a generic `Style` class, which holds information @@ -536,10 +528,8 @@ function () { * The main style class. Contains a unique id for the style, a size (which is * the same for cramped and uncramped version of a style), and a cramped flag. */ -var Style = -/*#__PURE__*/ -function () { - function Style(id, size, cramped) { +class Style { + constructor(id, size, cramped) { this.id = void 0; this.size = void 0; this.cramped = void 0; @@ -552,94 +542,91 @@ function () { */ - var _proto = Style.prototype; - - _proto.sup = function sup() { - return Style_styles[_sup[this.id]]; + sup() { + return styles[sup[this.id]]; } /** * Get the style of a subscript given a base in the current style. */ - ; - _proto.sub = function sub() { - return Style_styles[_sub[this.id]]; + + sub() { + return styles[sub[this.id]]; } /** * Get the style of a fraction numerator given the fraction in the current * style. */ - ; - _proto.fracNum = function fracNum() { - return Style_styles[_fracNum[this.id]]; + + fracNum() { + return styles[fracNum[this.id]]; } /** * Get the style of a fraction denominator given the fraction in the current * style. */ - ; - _proto.fracDen = function fracDen() { - return Style_styles[_fracDen[this.id]]; + + fracDen() { + return styles[fracDen[this.id]]; } /** * Get the cramped version of a style (in particular, cramping a cramped style * doesn't change the style). */ - ; - _proto.cramp = function cramp() { - return Style_styles[_cramp[this.id]]; + + cramp() { + return styles[cramp[this.id]]; } /** * Get a text or display version of this style. */ - ; - _proto.text = function text() { - return Style_styles[_text[this.id]]; + + text() { + return styles[Style_text[this.id]]; } /** * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) */ - ; - _proto.isTight = function isTight() { + + isTight() { return this.size >= 2; - }; + } - return Style; -}(); // Export an interface for type checking, but don't expose the implementation. +} // Export an interface for type checking, but don't expose the implementation. // This way, no more styles can be generated. // IDs of the different styles -var D = 0; -var Dc = 1; -var T = 2; -var Tc = 3; -var S = 4; -var Sc = 5; -var SS = 6; -var SSc = 7; // Instances of the different styles - -var Style_styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another - -var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; -var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; -var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; -var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; -var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; -var _text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. +const D = 0; +const Dc = 1; +const T = 2; +const Tc = 3; +const S = 4; +const Sc = 5; +const SS = 6; +const SSc = 7; // Instances of the different styles + +const styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another + +const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +const Style_text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. /* harmony default export */ var src_Style = ({ - DISPLAY: Style_styles[D], - TEXT: Style_styles[T], - SCRIPT: Style_styles[S], - SCRIPTSCRIPT: Style_styles[SS] + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] }); -// CONCATENATED MODULE: ./src/unicodeScripts.js +;// CONCATENATED MODULE: ./src/unicodeScripts.js /* * This file defines the Unicode scripts and script families that we * support. To add new scripts or families, just add a new entry to the @@ -657,18 +644,23 @@ var _text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. * Unicode block data for the families of scripts we support in \text{}. * Scripts only need to appear here if they do not have font metrics. */ -var scriptData = [{ +const scriptData = [{ // Latin characters beyond the Latin-1 characters we have metrics for. // Needed for Czech, Hungarian and Turkish text, for example. name: 'latin', blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B - [0x0300, 0x036f]] + [0x0300, 0x036f] // Combining Diacritical marks + ] }, { // The Cyrillic script used by Russian and related languages. // A Cyrillic subset used to be supported as explicitly defined // symbols in symbols.js name: 'cyrillic', blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] }, { // The Brahmic scripts of South and Southeast Asia // Devanagari (0900–097F) @@ -696,7 +688,9 @@ var scriptData = [{ name: "cjk", blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana [0x4E00, 0x9FAF], // CJK ideograms - [0xFF00, 0xFF60]] + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] }, { // Korean name: 'hangul', @@ -708,11 +702,11 @@ var scriptData = [{ */ function scriptFromCodepoint(codepoint) { - for (var i = 0; i < scriptData.length; i++) { - var script = scriptData[i]; + for (let i = 0; i < scriptData.length; i++) { + const script = scriptData[i]; - for (var _i = 0; _i < script.blocks.length; _i++) { - var block = script.blocks[_i]; + for (let i = 0; i < script.blocks.length; i++) { + const block = script.blocks[i]; if (codepoint >= block[0] && codepoint <= block[1]) { return script.name; @@ -727,12 +721,8 @@ function scriptFromCodepoint(codepoint) { * This is an optimization to make supportedCodepoint() fast. */ -var allBlocks = []; -scriptData.forEach(function (s) { - return s.blocks.forEach(function (b) { - return allBlocks.push.apply(allBlocks, b); - }); -}); +const allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); /** * Given a codepoint, return true if it falls within one of the * scripts or script families defined above and false otherwise. @@ -743,7 +733,7 @@ scriptData.forEach(function (s) { */ function supportedCodepoint(codepoint) { - for (var i = 0; i < allBlocks.length; i += 2) { + for (let i = 0; i < allBlocks.length; i += 2) { if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { return true; } @@ -751,99 +741,139 @@ function supportedCodepoint(codepoint) { return false; } -// CONCATENATED MODULE: ./src/svgGeometry.js +;// CONCATENATED MODULE: ./src/svgGeometry.js /** * This file provides support to domTree.js and delimiter.js. * It's a storehouse of path geometry for SVG images. */ // In all paths below, the viewBox-to-em scale is 1000:1. -var hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping. -// The viniculum of a \sqrt can be made thicker by a KaTeX rendering option. -// Think of variable extraViniculum as two detours in the SVG path. -// The detour begins at the lower left of the area labeled extraViniculum below. -// The detour proceeds one extraViniculum distance up and slightly to the right, -// displacing the radiused corner between surd and viniculum. The radius is +const hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is // traversed as usual, then the detour resumes. It goes right, to the end of -// the very long viniculumn, then down one extraViniculum distance, +// the very long vinculum, then down one extraVinculum distance, // after which it resumes regular path geometry for the radical. -/* viniculum +/* vinculum / - /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraViniculum - / █████████████████████←0.04em (40 unit) std viniculum thickness + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness / / / / / /\ / / surd */ -var sqrtMain = function sqrtMain(extraViniculum, hLinePad) { +const sqrtMain = function (extraVinculum, hLinePad) { // sqrtMain path geometry is from glyph U221A in the font KaTeX Main - return "M95," + (622 + extraViniculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraViniculum / 2.075 + " -" + extraViniculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraViniculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z"; + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -var sqrtSize1 = function sqrtSize1(extraViniculum, hLinePad) { +const sqrtSize1 = function (extraVinculum, hLinePad) { // size1 is from glyph U221A in the font KaTeX_Size1-Regular - return "M263," + (601 + extraViniculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraViniculum / 2.084 + " -" + extraViniculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraViniculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z"; + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -var sqrtSize2 = function sqrtSize2(extraViniculum, hLinePad) { +const sqrtSize2 = function (extraVinculum, hLinePad) { // size2 is from glyph U221A in the font KaTeX_Size2-Regular - return "M983 " + (10 + extraViniculum + hLinePad) + "\nl" + extraViniculum / 3.13 + " -" + extraViniculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraViniculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z"; + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -var sqrtSize3 = function sqrtSize3(extraViniculum, hLinePad) { +const sqrtSize3 = function (extraVinculum, hLinePad) { // size3 is from glyph U221A in the font KaTeX_Size3-Regular - return "M424," + (2398 + extraViniculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraViniculum / 4.223 + " -" + extraViniculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraViniculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraViniculum) + " " + hLinePad + "\nh400000v" + (40 + extraViniculum) + "h-400000z"; + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; }; -var sqrtSize4 = function sqrtSize4(extraViniculum, hLinePad) { +const sqrtSize4 = function (extraVinculum, hLinePad) { // size4 is from glyph U221A in the font KaTeX_Size4-Regular - return "M473," + (2713 + extraViniculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraViniculum / 5.298 + " -" + extraViniculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraViniculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "H1017.7z"; + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; }; -var sqrtTall = function sqrtTall(extraViniculum, hLinePad, viewBoxHeight) { +const phasePath = function (y) { + const x = y / 2; // x coordinate at top of angle + + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; + +const sqrtTall = function (extraVinculum, hLinePad, viewBoxHeight) { // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular - // One path edge has a variable length. It runs vertically from the viniculumn - // to a point near (14 units) the bottom of the surd. The viniculum + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum // is normally 40 units thick. So the length of the line in question is: - var vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum; - return "M702 " + (extraViniculum + hLinePad) + "H400000" + (40 + extraViniculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraViniculum) + "H742z"; + const vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; }; -var sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) { - extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox. +const sqrtPath = function (size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. - var path = ""; + let path = ""; switch (size) { case "sqrtMain": - path = sqrtMain(extraViniculum, hLinePad); + path = sqrtMain(extraVinculum, hLinePad); break; case "sqrtSize1": - path = sqrtSize1(extraViniculum, hLinePad); + path = sqrtSize1(extraVinculum, hLinePad); break; case "sqrtSize2": - path = sqrtSize2(extraViniculum, hLinePad); + path = sqrtSize2(extraVinculum, hLinePad); break; case "sqrtSize3": - path = sqrtSize3(extraViniculum, hLinePad); + path = sqrtSize3(extraVinculum, hLinePad); break; case "sqrtSize4": - path = sqrtSize4(extraViniculum, hLinePad); + path = sqrtSize4(extraVinculum, hLinePad); break; case "sqrtTall": - path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight); + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); } return path; }; -var svgGeometry_path = { +const innerPath = function (name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z"; + + case "\u2223": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z"; + + case "\u2225": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z"); + + case "\u239f": + return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z"; + + case "\u23a2": + return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z"; + + case "\u23a5": + return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z"; + + case "\u23aa": + return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z"; + + case "\u23d0": + return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z"; + + case "\u2016": + return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z"); + + default: + return ""; + } +}; +const path = { // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", // doublerightarrow is from glyph U+21D2 in font KaTeX Main @@ -910,7 +940,7 @@ var svgGeometry_path = { widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", // The next ten paths support reaction arrows from the mhchem package. // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX - // baraboveleftarrow is mostly from from glyph U+2190 in font KaTeX Main + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", @@ -921,7 +951,44 @@ var svgGeometry_path = { shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" }; -// CONCATENATED MODULE: ./src/tree.js +const tallDelim = function (label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z"; + + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; +;// CONCATENATED MODULE: ./src/tree.js /** @@ -929,12 +996,10 @@ var svgGeometry_path = { * placed into the DOM doesn't have any representation itself. It only contains * children and doesn't have any DOM node properties. */ -var tree_DocumentFragment = -/*#__PURE__*/ -function () { +class DocumentFragment { // HtmlDomNode // Never used; needed for satisfying interface. - function DocumentFragment(children) { + constructor(children) { this.children = void 0; this.classes = void 0; this.height = void 0; @@ -949,30 +1014,28 @@ function () { this.style = {}; } - var _proto = DocumentFragment.prototype; - - _proto.hasClass = function hasClass(className) { + hasClass(className) { return utils.contains(this.classes, className); } /** Convert the fragment into a node. */ - ; - _proto.toNode = function toNode() { - var frag = document.createDocumentFragment(); - for (var i = 0; i < this.children.length; i++) { + toNode() { + const frag = document.createDocumentFragment(); + + for (let i = 0; i < this.children.length; i++) { frag.appendChild(this.children[i].toNode()); } return frag; } /** Convert the fragment into HTML markup. */ - ; - _proto.toMarkup = function toMarkup() { - var markup = ""; // Simply concatenate the markup for the children together. - for (var i = 0; i < this.children.length; i++) { + toMarkup() { + let markup = ""; // Simply concatenate the markup for the children together. + + for (let i = 0; i < this.children.length; i++) { markup += this.children[i].toMarkup(); } @@ -982,592 +1045,23 @@ function () { * Converts the math node into a string, similar to innerText. Applies to * MathDomNode's only. */ - ; - _proto.toText = function toText() { + + toText() { // To avoid this, we would subclass documentFragment separately for // MathML, but polyfills for subclassing is expensive per PR 1469. // $FlowFixMe: Only works for ChildType = MathDomNode. - var toText = function toText(child) { - return child.toText(); - }; + const toText = child => child.toText(); return this.children.map(toText).join(""); - }; - - return DocumentFragment; -}(); -// CONCATENATED MODULE: ./src/domTree.js -/** - * These objects store the data about the DOM nodes we create, as well as some - * extra data. They can then be transformed into real DOM nodes with the - * `toNode` function or HTML markup using `toMarkup`. They are useful for both - * storing extra properties on the nodes, as well as providing a way to easily - * work with the DOM. - * - * Similar functions for working with MathML nodes exist in mathMLTree.js. - * - * TODO: refactor `span` and `anchor` into common superclass when - * target environments support class inheritance - */ - - - - - -/** - * Create an HTML className based on a list of classes. In addition to joining - * with spaces, we also remove empty classes. - */ -var createClass = function createClass(classes) { - return classes.filter(function (cls) { - return cls; - }).join(" "); -}; - -var initNode = function initNode(classes, options, style) { - this.classes = classes || []; - this.attributes = {}; - this.height = 0; - this.depth = 0; - this.maxFontSize = 0; - this.style = style || {}; - - if (options) { - if (options.style.isTight()) { - this.classes.push("mtight"); - } - - var color = options.getColor(); - - if (color) { - this.style.color = color; - } } -}; -/** - * Convert into an HTML node - */ - - -var _toNode = function toNode(tagName) { - var node = document.createElement(tagName); // Apply the class - node.className = createClass(this.classes); // Apply inline styles - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe Flow doesn't seem to understand span.style's type. - node.style[style] = this.style[style]; - } - } // Apply attributes - - - for (var attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } // Append the children, also as HTML nodes - - - for (var i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; -}; -/** - * Convert into an HTML markup string - */ - - -var _toMarkup = function toMarkup(tagName) { - var markup = "<" + tagName; // Add the class - - if (this.classes.length) { - markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; - } - - var styles = ""; // Add the styles, after hyphenation - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; - } - } - - if (styles) { - markup += " style=\"" + utils.escape(styles) + "\""; - } // Add the attributes - - - for (var attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; - } - } - - markup += ">"; // Add the markup of the children, also as markup - - for (var i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); - } - - markup += ""; - return markup; -}; // Making the type below exact with all optional fields doesn't work due to -// - https://github.com/facebook/flow/issues/4582 -// - https://github.com/facebook/flow/issues/5688 -// However, since *all* fields are optional, $Shape<> works as suggested in 5688 -// above. -// This type does not include all CSS properties. Additional properties should -// be added as needed. - - -/** - * This node represents a span node, with a className, a list of children, and - * an inline style. It also contains information about its height, depth, and - * maxFontSize. - * - * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan - * otherwise. This typesafety is important when HTML builders access a span's - * children. - */ -var domTree_Span = -/*#__PURE__*/ -function () { - function Span(classes, children, options, style) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.width = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options, style); - this.children = children || []; - } - /** - * Sets an arbitrary attribute on the span. Warning: use this wisely. Not - * all browsers support attributes the same, and having too many custom - * attributes is probably bad. - */ - - - var _proto = Span.prototype; - - _proto.setAttribute = function setAttribute(attribute, value) { - this.attributes[attribute] = value; - }; - - _proto.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto.toNode = function toNode() { - return _toNode.call(this, "span"); - }; - - _proto.toMarkup = function toMarkup() { - return _toMarkup.call(this, "span"); - }; - - return Span; -}(); -/** - * This node represents an anchor () element with a hyperlink. See `span` - * for further details. - */ - -var domTree_Anchor = -/*#__PURE__*/ -function () { - function Anchor(href, classes, children, options) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options); - this.children = children || []; - this.setAttribute('href', href); - } - - var _proto2 = Anchor.prototype; - - _proto2.setAttribute = function setAttribute(attribute, value) { - this.attributes[attribute] = value; - }; - - _proto2.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto2.toNode = function toNode() { - return _toNode.call(this, "a"); - }; - - _proto2.toMarkup = function toMarkup() { - return _toMarkup.call(this, "a"); - }; - - return Anchor; -}(); -/** - * This node represents an image embed () element. - */ - -var domTree_Img = -/*#__PURE__*/ -function () { - function Img(src, alt, style) { - this.src = void 0; - this.alt = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - this.alt = alt; - this.src = src; - this.classes = ["mord"]; - this.style = style; - } - - var _proto3 = Img.prototype; - - _proto3.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto3.toNode = function toNode() { - var node = document.createElement("img"); - node.src = this.src; - node.alt = this.alt; - node.className = "mord"; // Apply inline styles - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe - node.style[style] = this.style[style]; - } - } - - return node; - }; - - _proto3.toMarkup = function toMarkup() { - var markup = "" + this.alt + " 0) { - span = document.createElement("span"); - span.style.marginRight = this.italic + "em"; - } - - if (this.classes.length > 0) { - span = span || document.createElement("span"); - span.className = createClass(this.classes); - } - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. - - span.style[style] = this.style[style]; - } - } - - if (span) { - span.appendChild(node); - return span; - } else { - return node; - } - } - /** - * Creates markup for a symbol node. - */ - ; - - _proto4.toMarkup = function toMarkup() { - // TODO(alpert): More duplication than I'd like from - // span.prototype.toMarkup and symbolNode.prototype.toNode... - var needsSpan = false; - var markup = " 0) { - styles += "margin-right:" + this.italic + "em;"; - } - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; - } - } - - if (styles) { - needsSpan = true; - markup += " style=\"" + utils.escape(styles) + "\""; - } - - var escaped = utils.escape(this.text); - - if (needsSpan) { - markup += ">"; - markup += escaped; - markup += ""; - return markup; - } else { - return escaped; - } - }; - - return SymbolNode; -}(); -/** - * SVG nodes are used to render stretchy wide elements. - */ - -var SvgNode = -/*#__PURE__*/ -function () { - function SvgNode(children, attributes) { - this.children = void 0; - this.attributes = void 0; - this.children = children || []; - this.attributes = attributes || {}; - } - - var _proto5 = SvgNode.prototype; - - _proto5.toNode = function toNode() { - var svgNS = "http://www.w3.org/2000/svg"; - var node = document.createElementNS(svgNS, "svg"); // Apply attributes - - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - for (var i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; - }; - - _proto5.toMarkup = function toMarkup() { - var markup = ""; - } else { - return ""; - } - }; - - return PathNode; -}(); -var LineNode = -/*#__PURE__*/ -function () { - function LineNode(attributes) { - this.attributes = void 0; - this.attributes = attributes || {}; - } - - var _proto7 = LineNode.prototype; - - _proto7.toNode = function toNode() { - var svgNS = "http://www.w3.org/2000/svg"; - var node = document.createElementNS(svgNS, "line"); // Apply attributes - - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - return node; - }; - - _proto7.toMarkup = function toMarkup() { - var markup = " but got " + String(group) + "."); - } -} -// CONCATENATED MODULE: ./submodules/katex-fonts/fontMetricsData.js +;// CONCATENATED MODULE: ./src/fontMetricsData.js // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. /* harmony default export */ var fontMetricsData = ({ "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.68889, 0, 0, 0.72222], "66": [0, 0.68889, 0, 0, 0.66667], "67": [0, 0.68889, 0, 0, 0.72222], @@ -1595,6 +1089,7 @@ function assertSpan(group) { "89": [0, 0.68889, 0, 0, 0.72222], "90": [0, 0.68889, 0, 0, 0.66667], "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], "165": [0, 0.675, 0.025, 0, 0.75], "174": [0.15559, 0.69224, 0, 0, 0.94666], "240": [0, 0.68889, 0, 0, 0.55556], @@ -1825,16 +1320,7 @@ function assertSpan(group) { "57371": [0.13597, 0.63597, 0, 0, 0.77778] }, "Caligraphic-Regular": { - "48": [0, 0.43056, 0, 0, 0.5], - "49": [0, 0.43056, 0, 0, 0.5], - "50": [0, 0.43056, 0, 0, 0.5], - "51": [0.19444, 0.43056, 0, 0, 0.5], - "52": [0.19444, 0.43056, 0, 0, 0.5], - "53": [0.19444, 0.43056, 0, 0, 0.5], - "54": [0, 0.64444, 0, 0, 0.5], - "55": [0.19444, 0.43056, 0, 0, 0.5], - "56": [0, 0.64444, 0, 0, 0.5], - "57": [0.19444, 0.43056, 0, 0, 0.5], + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.68333, 0, 0.19445, 0.79847], "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], @@ -1860,9 +1346,11 @@ function assertSpan(group) { "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], - "90": [0, 0.68333, 0.07944, 0.13889, 0.72473] + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] }, "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69141, 0, 0, 0.29574], "34": [0, 0.69141, 0, 0, 0.21471], "38": [0, 0.69141, 0, 0, 0.73786], @@ -1944,6 +1432,7 @@ function assertSpan(group) { "120": [0.18906, 0.47534, 0, 0, 0.38865], "121": [0.18906, 0.47534, 0, 0, 0.49884], "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], "8216": [0, 0.69141, 0, 0, 0.21471], "8217": [0, 0.69141, 0, 0, 0.21471], "58112": [0, 0.62119, 0, 0, 0.49749], @@ -1956,6 +1445,7 @@ function assertSpan(group) { "58119": [0, 0.47534, 0, 0, 0.50073] }, "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.35], "34": [0, 0.69444, 0, 0, 0.60278], "35": [0.19444, 0.69444, 0, 0, 0.95833], @@ -2049,6 +1539,8 @@ function assertSpan(group) { "124": [0.25, 0.75, 0, 0, 0.31944], "125": [0.25, 0.75, 0, 0, 0.575], "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], "168": [0, 0.69444, 0, 0, 0.575], "172": [0, 0.44444, 0, 0, 0.76666], "176": [0, 0.69444, 0, 0, 0.86944], @@ -2150,6 +1642,7 @@ function assertSpan(group) { "8764": [-0.10889, 0.39111, 0, 0, 0.89444], "8768": [0.19444, 0.69444, 0, 0, 0.31944], "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], "8776": [0.02444, 0.52444, 0, 0, 0.89444], "8781": [0.00222, 0.50222, 0, 0, 0.89444], "8801": [0.00222, 0.50222, 0, 0, 0.89444], @@ -2206,6 +1699,7 @@ function assertSpan(group) { "57376": [0.19444, 0.69444, 0, 0, 0] }, "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.11417, 0, 0.38611], "34": [0, 0.69444, 0.07939, 0, 0.62055], "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], @@ -2292,7 +1786,7 @@ function assertSpan(group) { "121": [0.19444, 0.44444, 0.105, 0, 0.56166], "122": [0, 0.44444, 0.13889, 0, 0.49055], "126": [0.35, 0.34444, 0.11472, 0, 0.59111], - "163": [0, 0.69444, 0, 0, 0.86853], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.69444, 0.11473, 0, 0.59111], "176": [0, 0.69444, 0, 0, 0.94888], "184": [0.17014, 0, 0, 0, 0.53222], @@ -2334,6 +1828,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0.07939, 0, 0.62055] }, "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.12417, 0, 0.30667], "34": [0, 0.69444, 0.06961, 0, 0.51444], "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], @@ -2420,7 +1915,7 @@ function assertSpan(group) { "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], "122": [0, 0.43056, 0.12292, 0, 0.40889], "126": [0.35, 0.31786, 0.11585, 0, 0.51111], - "163": [0, 0.69444, 0, 0, 0.76909], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.66786, 0.10474, 0, 0.51111], "176": [0, 0.69444, 0, 0, 0.83129], "184": [0.17014, 0, 0, 0, 0.46], @@ -2429,10 +1924,8 @@ function assertSpan(group) { "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], "230": [0, 0.43056, 0.07514, 0, 0.71555], "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], - "305": [0, 0.43056, 0, 0.02778, 0.32246], "338": [0, 0.68333, 0.12028, 0, 0.98499], "339": [0, 0.43056, 0.07514, 0, 0.71555], - "567": [0.19444, 0.43056, 0, 0.08334, 0.38403], "710": [0, 0.69444, 0.06646, 0, 0.51111], "711": [0, 0.62847, 0.08295, 0, 0.51111], "713": [0, 0.56167, 0.10333, 0, 0.51111], @@ -2558,6 +2051,7 @@ function assertSpan(group) { "125": [0.25, 0.75, 0, 0, 0.5], "126": [0.35, 0.31786, 0, 0, 0.5], "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], "167": [0.19444, 0.69444, 0, 0, 0.44445], "168": [0, 0.66786, 0, 0, 0.5], "172": [0, 0.43056, 0, 0, 0.66667], @@ -2605,7 +2099,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0, 0, 0.5], "8224": [0.19444, 0.69444, 0, 0, 0.44445], "8225": [0.19444, 0.69444, 0, 0, 0.44445], - "8230": [0, 0.12, 0, 0, 1.172], + "8230": [0, 0.123, 0, 0, 1.172], "8242": [0, 0.55556, 0, 0, 0.275], "8407": [0, 0.71444, 0.15382, 0, 0.5], "8463": [0, 0.68889, 0, 0, 0.54028], @@ -2666,10 +2160,10 @@ function assertSpan(group) { "8764": [-0.13313, 0.36687, 0, 0, 0.77778], "8768": [0.19444, 0.69444, 0, 0, 0.27778], "8771": [-0.03625, 0.46375, 0, 0, 0.77778], - "8773": [-0.022, 0.589, 0, 0, 1.0], + "8773": [-0.022, 0.589, 0, 0, 0.778], "8776": [-0.01688, 0.48312, 0, 0, 0.77778], "8781": [-0.03625, 0.46375, 0, 0, 0.77778], - "8784": [-0.133, 0.67, 0, 0, 0.778], + "8784": [-0.133, 0.673, 0, 0, 0.778], "8801": [-0.03625, 0.46375, 0, 0, 0.77778], "8804": [0.13597, 0.63597, 0, 0, 0.77778], "8805": [0.13597, 0.63597, 0, 0, 0.77778], @@ -2700,9 +2194,9 @@ function assertSpan(group) { "8901": [-0.05555, 0.44445, 0, 0, 0.27778], "8902": [-0.03472, 0.46528, 0, 0, 0.5], "8904": [0.005, 0.505, 0, 0, 0.9], - "8942": [0.03, 0.9, 0, 0, 0.278], - "8943": [-0.19, 0.31, 0, 0, 1.172], - "8945": [-0.1, 0.82, 0, 0, 1.282], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], "8968": [0.25, 0.75, 0, 0, 0.44445], "8969": [0.25, 0.75, 0, 0, 0.44445], "8970": [0.25, 0.75, 0, 0, 0.44445], @@ -2710,7 +2204,7 @@ function assertSpan(group) { "8994": [-0.14236, 0.35764, 0, 0, 1.0], "8995": [-0.14236, 0.35764, 0, 0, 1.0], "9136": [0.244, 0.744, 0, 0, 0.412], - "9137": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], "9651": [0.19444, 0.69444, 0, 0, 0.88889], "9657": [-0.03472, 0.46528, 0, 0, 0.5], "9661": [0.19444, 0.69444, 0, 0, 0.88889], @@ -2726,7 +2220,7 @@ function assertSpan(group) { "10216": [0.25, 0.75, 0, 0, 0.38889], "10217": [0.25, 0.75, 0, 0, 0.38889], "10222": [0.244, 0.744, 0, 0, 0.412], - "10223": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], "10229": [0.011, 0.511, 0, 0, 1.609], "10230": [0.011, 0.511, 0, 0, 1.638], "10231": [0.011, 0.511, 0, 0, 1.859], @@ -2740,6 +2234,17 @@ function assertSpan(group) { "57376": [0.19444, 0.69444, 0, 0, 0] }, "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], "65": [0, 0.68611, 0, 0, 0.86944], "66": [0, 0.68611, 0.04835, 0, 0.8664], "67": [0, 0.68611, 0.06979, 0, 0.81694], @@ -2792,6 +2297,7 @@ function assertSpan(group) { "120": [0, 0.44444, 0, 0, 0.65903], "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], "915": [0, 0.68611, 0.15972, 0, 0.65694], "916": [0, 0.68611, 0, 0, 0.95833], "920": [0, 0.68611, 0.03194, 0, 0.86722], @@ -2832,9 +2338,22 @@ function assertSpan(group) { "981": [0.19444, 0.69444, 0, 0, 0.7125], "982": [0, 0.44444, 0.03194, 0, 0.975], "1009": [0.19444, 0.44444, 0, 0, 0.6118], - "1013": [0, 0.44444, 0, 0, 0.48333] + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] }, "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], "65": [0, 0.68333, 0, 0.13889, 0.75], "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], @@ -2887,6 +2406,7 @@ function assertSpan(group) { "120": [0, 0.43056, 0, 0.02778, 0.57153], "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], "916": [0, 0.68333, 0, 0.16667, 0.83334], "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], @@ -2927,104 +2447,12 @@ function assertSpan(group) { "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], "982": [0, 0.43056, 0.02778, 0, 0.82813], "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "1013": [0, 0.43056, 0, 0.05556, 0.4059] - }, - "Math-Regular": { - "65": [0, 0.68333, 0, 0.13889, 0.75], - "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], - "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], - "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], - "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], - "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], - "71": [0, 0.68333, 0, 0.08334, 0.78625], - "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], - "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], - "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], - "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], - "76": [0, 0.68333, 0, 0.02778, 0.68056], - "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], - "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], - "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], - "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], - "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], - "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], - "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], - "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], - "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], - "86": [0, 0.68333, 0.22222, 0, 0.58333], - "87": [0, 0.68333, 0.13889, 0, 0.94445], - "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], - "89": [0, 0.68333, 0.22222, 0, 0.58056], - "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], - "97": [0, 0.43056, 0, 0, 0.52859], - "98": [0, 0.69444, 0, 0, 0.42917], - "99": [0, 0.43056, 0, 0.05556, 0.43276], - "100": [0, 0.69444, 0, 0.16667, 0.52049], - "101": [0, 0.43056, 0, 0.05556, 0.46563], - "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], - "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], - "104": [0, 0.69444, 0, 0, 0.57616], - "105": [0, 0.65952, 0, 0, 0.34451], - "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], - "107": [0, 0.69444, 0.03148, 0, 0.5206], - "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], - "109": [0, 0.43056, 0, 0, 0.87801], - "110": [0, 0.43056, 0, 0, 0.60023], - "111": [0, 0.43056, 0, 0.05556, 0.48472], - "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], - "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], - "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], - "115": [0, 0.43056, 0, 0.05556, 0.46875], - "116": [0, 0.61508, 0, 0.08334, 0.36111], - "117": [0, 0.43056, 0, 0.02778, 0.57246], - "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], - "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], - "120": [0, 0.43056, 0, 0.02778, 0.57153], - "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], - "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], - "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], - "916": [0, 0.68333, 0, 0.16667, 0.83334], - "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], - "923": [0, 0.68333, 0, 0.16667, 0.69445], - "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], - "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], - "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], - "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], - "934": [0, 0.68333, 0, 0.08334, 0.66667], - "936": [0, 0.68333, 0.11, 0.05556, 0.61222], - "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], - "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], - "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], - "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], - "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], - "949": [0, 0.43056, 0, 0.08334, 0.46632], - "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], - "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], - "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], - "953": [0, 0.43056, 0, 0.05556, 0.35394], - "954": [0, 0.43056, 0, 0, 0.57616], - "955": [0, 0.69444, 0, 0, 0.58334], - "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], - "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], - "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], - "959": [0, 0.43056, 0, 0.05556, 0.48472], - "960": [0, 0.43056, 0.03588, 0, 0.57003], - "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], - "963": [0, 0.43056, 0.03588, 0, 0.57141], - "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], - "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], - "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], - "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], - "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], - "969": [0, 0.43056, 0.03588, 0, 0.62245], - "977": [0, 0.69444, 0, 0.08334, 0.59144], - "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], - "982": [0, 0.43056, 0.02778, 0, 0.82813], - "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "1013": [0, 0.43056, 0, 0.05556, 0.4059] + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] }, "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.36667], "34": [0, 0.69444, 0, 0, 0.55834], "35": [0.19444, 0.69444, 0, 0, 0.91667], @@ -3112,6 +2540,7 @@ function assertSpan(group) { "121": [0.19444, 0.45833, 0.01528, 0, 0.5], "122": [0, 0.45833, 0, 0, 0.47639], "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.69444, 0, 0, 0.55], "176": [0, 0.69444, 0, 0, 0.73334], "180": [0, 0.69444, 0, 0, 0.55], @@ -3145,6 +2574,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0, 0, 0.55834] }, "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.05733, 0, 0.31945], "34": [0, 0.69444, 0.00316, 0, 0.5], "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], @@ -3232,6 +2662,7 @@ function assertSpan(group) { "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], "122": [0, 0.44444, 0.08752, 0, 0.43472], "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.67937, 0.06385, 0, 0.5], "176": [0, 0.69444, 0, 0, 0.73752], "184": [0.17014, 0, 0, 0, 0.44445], @@ -3266,6 +2697,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0.00316, 0, 0.5] }, "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.31945], "34": [0, 0.69444, 0, 0, 0.5], "35": [0.19444, 0.69444, 0, 0, 0.83334], @@ -3353,6 +2785,7 @@ function assertSpan(group) { "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], "122": [0, 0.44444, 0, 0, 0.43472], "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.67937, 0, 0, 0.5], "176": [0, 0.69444, 0, 0, 0.66667], "184": [0.17014, 0, 0, 0, 0.44445], @@ -3387,6 +2820,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0, 0, 0.5] }, "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.7, 0.22925, 0, 0.80253], "66": [0, 0.7, 0.04087, 0, 0.90757], "67": [0, 0.7, 0.1689, 0, 0.66619], @@ -3412,9 +2846,11 @@ function assertSpan(group) { "87": [0, 0.7, 0.27523, 0, 0.80532], "88": [0, 0.7, 0.26006, 0, 0.94445], "89": [0, 0.7, 0.2939, 0, 0.70961], - "90": [0, 0.7, 0.24037, 0, 0.8212] + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] }, "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.35001, 0.85, 0, 0, 0.45834], "41": [0.35001, 0.85, 0, 0, 0.45834], "47": [0.35001, 0.85, 0, 0, 0.57778], @@ -3423,6 +2859,7 @@ function assertSpan(group) { "93": [0.35001, 0.85, 0, 0, 0.41667], "123": [0.35001, 0.85, 0, 0, 0.58334], "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.72222, 0, 0, 0.55556], "732": [0, 0.72222, 0, 0, 0.55556], "770": [0, 0.72222, 0, 0, 0.55556], @@ -3460,6 +2897,7 @@ function assertSpan(group) { "10758": [0.25001, 0.75, 0, 0, 0.83334] }, "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.65002, 1.15, 0, 0, 0.59722], "41": [0.65002, 1.15, 0, 0, 0.59722], "47": [0.65002, 1.15, 0, 0, 0.81111], @@ -3468,6 +2906,7 @@ function assertSpan(group) { "93": [0.65002, 1.15, 0, 0, 0.47222], "123": [0.65002, 1.15, 0, 0, 0.66667], "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.75, 0, 0, 1.0], "732": [0, 0.75, 0, 0, 1.0], "770": [0, 0.75, 0, 0, 1.0], @@ -3497,6 +2936,7 @@ function assertSpan(group) { "10758": [0.55001, 1.05, 0, 0, 1.11111] }, "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.95003, 1.45, 0, 0, 0.73611], "41": [0.95003, 1.45, 0, 0, 0.73611], "47": [0.95003, 1.45, 0, 0, 1.04445], @@ -3505,6 +2945,7 @@ function assertSpan(group) { "93": [0.95003, 1.45, 0, 0, 0.52778], "123": [0.95003, 1.45, 0, 0, 0.75], "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.75, 0, 0, 1.44445], "732": [0, 0.75, 0, 0, 1.44445], "770": [0, 0.75, 0, 0, 1.44445], @@ -3518,6 +2959,7 @@ function assertSpan(group) { "10217": [0.95003, 1.45, 0, 0, 0.75] }, "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [1.25003, 1.75, 0, 0, 0.79167], "41": [1.25003, 1.75, 0, 0, 0.79167], "47": [1.25003, 1.75, 0, 0, 1.27778], @@ -3526,6 +2968,7 @@ function assertSpan(group) { "93": [1.25003, 1.75, 0, 0, 0.58334], "123": [1.25003, 1.75, 0, 0, 0.80556], "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.825, 0, 0, 1.8889], "732": [0, 0.825, 0, 0, 1.8889], "770": [0, 0.825, 0, 0, 1.8889], @@ -3691,293 +3134,1255 @@ function assertSpan(group) { "8242": [0, 0.61111, 0, 0, 0.525], "9251": [0.11111, 0.21944, 0, 0, 0.525] } -}); -// CONCATENATED MODULE: ./src/fontMetrics.js +}); +;// CONCATENATED MODULE: ./src/fontMetrics.js + + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +const sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm + +}; // This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. + + // These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. + +const extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ + +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + + let ch = character.charCodeAt(0); + let metrics = fontMetricsData[font][ch]; + + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +const fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ + +function getGlobalMetrics(size) { + let sizeIndex; + + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + + if (!fontMetricsBySizeIndex[sizeIndex]) { + const metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + + for (const key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + + return fontMetricsBySizeIndex[sizeIndex]; +} +;// CONCATENATED MODULE: ./src/Options.js +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + +const sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +const sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +const sizeAtStyle = function (size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; // In these types, "" (empty string) means "no change". + + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + + /** + * The base size index. + */ + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ''; + this.fontShape = data.fontShape || ''; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + + + extend(extension) { + const data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + + for (const key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + + + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + + + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + + + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + + + havingBaseStyle(style) { + style = style || this.style.text(); + const wantSize = sizeAtStyle(Options.BASESIZE, style); + + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + + + havingBaseSizing() { + let size; + + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + + break; + + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + + break; + + default: + size = 6; + // normalsize in textstyle or displaystyle + } + + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + + + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + + + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + + + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + + + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + + + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + + + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + + + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + + + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } + +} + +Options.BASESIZE = 6; +/* harmony default export */ var src_Options = (Options); +;// CONCATENATED MODULE: ./src/units.js +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ + + // This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + +const ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX + +}; // Dictionary of relative units, for fast validity testing. + +const relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +const validUnit = function (unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ + +const calculateSize = function (sizeValue, options) { + let scale; + + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + let unitOptions; + + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + + + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ + +const makeEm = function (n) { + return +n.toFixed(4) + "em"; +}; +;// CONCATENATED MODULE: ./src/domTree.js +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + + + + + + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +const createClass = function (classes) { + return classes.filter(cls => cls).join(" "); +}; + +const initNode = function (classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + + const color = options.getColor(); + + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ + + +const toNode = function (tagName) { + const node = document.createElement(tagName); // Apply the class + + node.className = createClass(this.classes); // Apply inline styles + + for (const style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + node.style[style] = this.style[style]; + } + } // Apply attributes + + + for (const attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } // Append the children, also as HTML nodes + + + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; +/** + * Convert into an HTML markup string + */ + + +const toMarkup = function (tagName) { + let markup = "<" + tagName; // Add the class + + if (this.classes.length) { + markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; + } + + let styles = ""; // Add the styles, after hyphenation + + for (const style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + utils.escape(styles) + "\""; + } // Add the attributes + + + for (const attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; // Add the markup of the children, also as markup + + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. /** - * This file contains metrics regarding fonts and individual symbols. The sigma - * and xi variables, as well as the metricMap map contain data extracted from - * TeX, TeX font metrics, and the TTF files. These data are then exposed via the - * `metrics` variable and the getCharacterMetrics function. + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. */ -// In TeX, there are actually three sets of dimensions, one for each of -// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: -// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are -// provided in the arrays below, in that order. -// -// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively. -// This was determined by running the following script: -// -// latex -interaction=nonstopmode \ -// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ -// '$a$ \expandafter\show\the\textfont2' \ -// '\expandafter\show\the\scriptfont2' \ -// '\expandafter\show\the\scriptscriptfont2' \ -// '\stop' -// -// The metrics themselves were retreived using the following commands: -// -// tftopl cmsy10 -// tftopl cmsy7 -// tftopl cmsy5 -// -// The output of each of these commands is quite lengthy. The only part we -// care about is the FONTDIMEN section. Each value is measured in EMs. -var sigmasAndXis = { - slant: [0.250, 0.250, 0.250], - // sigma1 - space: [0.000, 0.000, 0.000], - // sigma2 - stretch: [0.000, 0.000, 0.000], - // sigma3 - shrink: [0.000, 0.000, 0.000], - // sigma4 - xHeight: [0.431, 0.431, 0.431], - // sigma5 - quad: [1.000, 1.171, 1.472], - // sigma6 - extraSpace: [0.000, 0.000, 0.000], - // sigma7 - num1: [0.677, 0.732, 0.925], - // sigma8 - num2: [0.394, 0.384, 0.387], - // sigma9 - num3: [0.444, 0.471, 0.504], - // sigma10 - denom1: [0.686, 0.752, 1.025], - // sigma11 - denom2: [0.345, 0.344, 0.532], - // sigma12 - sup1: [0.413, 0.503, 0.504], - // sigma13 - sup2: [0.363, 0.431, 0.404], - // sigma14 - sup3: [0.289, 0.286, 0.294], - // sigma15 - sub1: [0.150, 0.143, 0.200], - // sigma16 - sub2: [0.247, 0.286, 0.400], - // sigma17 - supDrop: [0.386, 0.353, 0.494], - // sigma18 - subDrop: [0.050, 0.071, 0.100], - // sigma19 - delim1: [2.390, 1.700, 1.980], - // sigma20 - delim2: [1.010, 1.157, 1.420], - // sigma21 - axisHeight: [0.250, 0.250, 0.250], - // sigma22 - // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; - // they correspond to the font parameters of the extension fonts (family 3). - // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to - // match cmex7, we'd use cmex7.tfm values for script and scriptscript - // values. - defaultRuleThickness: [0.04, 0.049, 0.049], - // xi8; cmex7: 0.049 - bigOpSpacing1: [0.111, 0.111, 0.111], - // xi9 - bigOpSpacing2: [0.166, 0.166, 0.166], - // xi10 - bigOpSpacing3: [0.2, 0.2, 0.2], - // xi11 - bigOpSpacing4: [0.6, 0.611, 0.611], - // xi12; cmex7: 0.611 - bigOpSpacing5: [0.1, 0.143, 0.143], - // xi13; cmex7: 0.143 - // The \sqrt rule width is taken from the height of the surd character. - // Since we use the same font at all sizes, this thickness doesn't scale. - sqrtRuleThickness: [0.04, 0.04, 0.04], - // This value determines how large a pt is, for metrics which are defined - // in terms of pts. - // This value is also used in katex.less; if you change it make sure the - // values match. - ptPerEm: [10.0, 10.0, 10.0], - // The space between adjacent `|` columns in an array definition. From - // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. - doubleRuleSep: [0.2, 0.2, 0.2], - // The width of separator lines in {array} environments. From - // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. - arrayRuleWidth: [0.04, 0.04, 0.04], - // Two values from LaTeX source2e: - fboxsep: [0.3, 0.3, 0.3], - // 3 pt / ptPerEm - fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "span"); + } + + toMarkup() { + return toMarkup.call(this, "span"); + } + +} +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ + +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "a"); + } + + toMarkup() { + return toMarkup.call(this, "a"); + } + +} +/** + * This node represents an image embed () element. + */ + +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.style = style; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + const node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; // Apply inline styles + + for (const style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe + node.style[style] = this.style[style]; + } + } + + return node; + } + + toMarkup() { + let markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (const style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. + + span.style[style] = this.style[style]; + } + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + + + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + let needsSpan = false; + let markup = " 0) { + styles += "margin-right:" + this.italic + "em;"; + } + + for (const style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + utils.escape(styles) + "\""; + } + + const escaped = utils.escape(this.text); + + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } -/** - * This function adds new font metrics to default metricMap - * It can also override existing metrics - */ -function setFontMetrics(fontName, metrics) { - fontMetricsData[fontName] = metrics; } /** - * This function is a convenience function for looking up information in the - * metricMap table. It takes a character as a string, and a font. - * - * Note: the `width` property may be undefined if fontMetricsData.js wasn't - * built using `Make extended_metrics`. + * SVG nodes are used to render stretchy wide elements. */ -function getCharacterMetrics(character, font, mode) { - if (!fontMetricsData[font]) { - throw new Error("Font metrics not found for font: " + font + "."); +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; } - var ch = character.charCodeAt(0); - var metrics = fontMetricsData[font][ch]; + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "svg"); // Apply attributes - if (!metrics && character[0] in extraCharacterMap) { - ch = extraCharacterMap[character[0]].charCodeAt(0); - metrics = fontMetricsData[font][ch]; + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; } - if (!metrics && mode === 'text') { - // We don't typically have font metrics for Asian scripts. - // But since we support them in text mode, we need to return - // some sort of metrics. - // So if the character is in a script we support but we - // don't have metrics for it, just use the metrics for - // the Latin capital letter M. This is close enough because - // we (currently) only care about the height of the glpyh - // not its width. - if (supportedCodepoint(ch)) { - metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + toMarkup() { + let markup = ""; + } else { + return ""; } } - if (metrics) { - return { - depth: metrics[0], - height: metrics[1], - italic: metrics[2], - skew: metrics[3], - width: metrics[4] - }; - } } -var fontMetricsBySizeIndex = {}; -/** - * Get the font metrics for a given size. - */ +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } -function getGlobalMetrics(size) { - var sizeIndex; + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "line"); // Apply attributes - if (size >= 5) { - sizeIndex = 0; - } else if (size >= 3) { - sizeIndex = 1; - } else { - sizeIndex = 2; + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + return node; } - if (!fontMetricsBySizeIndex[sizeIndex]) { - var metrics = fontMetricsBySizeIndex[sizeIndex] = { - cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 - }; + toMarkup() { + let markup = " but got " + String(group) + "."); + } +} +;// CONCATENATED MODULE: ./src/symbols.js /** * This file holds a list of all no-argument functions and single-character * symbols (like 'a' or ';'). @@ -3999,7 +4404,7 @@ function getGlobalMetrics(size) { // types for raw text tokens, and we want to avoid conflicts with higher-level // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by // looking up the `symbols` map. -var ATOMS = { +const ATOMS = { "bin": 1, "close": 1, "inner": 1, @@ -4007,14 +4412,14 @@ var ATOMS = { "punct": 1, "rel": 1 }; -var NON_ATOMS = { +const NON_ATOMS = { "accent-token": 1, "mathord": 1, "op-token": 1, "spacing": 1, "textord": 1 }; -var symbols = { +const symbols = { "math": {}, "text": {} }; @@ -4023,9 +4428,9 @@ var symbols = { function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { symbols[mode][name] = { - font: font, - group: group, - replace: replace + font, + group, + replace }; if (acceptUnicodeChar && replace) { @@ -4035,1346 +4440,910 @@ function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { // This helps minify the code, and also spotting typos using jshint. // modes: -var symbols_math = "math"; -var symbols_text = "text"; // fonts: - -var main = "main"; -var ams = "ams"; // groups: - -var symbols_accent = "accent-token"; -var bin = "bin"; -var symbols_close = "close"; -var symbols_inner = "inner"; -var mathord = "mathord"; -var op = "op-token"; -var symbols_open = "open"; -var punct = "punct"; -var rel = "rel"; -var symbols_spacing = "spacing"; -var symbols_textord = "textord"; // Now comes the symbol table +const math = "math"; +const symbols_text = "text"; // fonts: + +const main = "main"; +const ams = "ams"; // groups: + +const accent = "accent-token"; +const bin = "bin"; +const symbols_close = "close"; +const inner = "inner"; +const mathord = "mathord"; +const op = "op-token"; +const symbols_open = "open"; +const punct = "punct"; +const rel = "rel"; +const spacing = "spacing"; +const textord = "textord"; // Now comes the symbol table // Relation Symbols -defineSymbol(symbols_math, main, rel, "\u2261", "\\equiv", true); -defineSymbol(symbols_math, main, rel, "\u227A", "\\prec", true); -defineSymbol(symbols_math, main, rel, "\u227B", "\\succ", true); -defineSymbol(symbols_math, main, rel, "\u223C", "\\sim", true); -defineSymbol(symbols_math, main, rel, "\u22A5", "\\perp"); -defineSymbol(symbols_math, main, rel, "\u2AAF", "\\preceq", true); -defineSymbol(symbols_math, main, rel, "\u2AB0", "\\succeq", true); -defineSymbol(symbols_math, main, rel, "\u2243", "\\simeq", true); -defineSymbol(symbols_math, main, rel, "\u2223", "\\mid", true); -defineSymbol(symbols_math, main, rel, "\u226A", "\\ll", true); -defineSymbol(symbols_math, main, rel, "\u226B", "\\gg", true); -defineSymbol(symbols_math, main, rel, "\u224D", "\\asymp", true); -defineSymbol(symbols_math, main, rel, "\u2225", "\\parallel"); -defineSymbol(symbols_math, main, rel, "\u22C8", "\\bowtie", true); -defineSymbol(symbols_math, main, rel, "\u2323", "\\smile", true); -defineSymbol(symbols_math, main, rel, "\u2291", "\\sqsubseteq", true); -defineSymbol(symbols_math, main, rel, "\u2292", "\\sqsupseteq", true); -defineSymbol(symbols_math, main, rel, "\u2250", "\\doteq", true); -defineSymbol(symbols_math, main, rel, "\u2322", "\\frown", true); -defineSymbol(symbols_math, main, rel, "\u220B", "\\ni", true); -defineSymbol(symbols_math, main, rel, "\u221D", "\\propto", true); -defineSymbol(symbols_math, main, rel, "\u22A2", "\\vdash", true); -defineSymbol(symbols_math, main, rel, "\u22A3", "\\dashv", true); -defineSymbol(symbols_math, main, rel, "\u220B", "\\owns"); // Punctuation - -defineSymbol(symbols_math, main, punct, ".", "\\ldotp"); -defineSymbol(symbols_math, main, punct, "\u22C5", "\\cdotp"); // Misc Symbols - -defineSymbol(symbols_math, main, symbols_textord, "#", "\\#"); -defineSymbol(symbols_text, main, symbols_textord, "#", "\\#"); -defineSymbol(symbols_math, main, symbols_textord, "&", "\\&"); -defineSymbol(symbols_text, main, symbols_textord, "&", "\\&"); -defineSymbol(symbols_math, main, symbols_textord, "\u2135", "\\aleph", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2200", "\\forall", true); -defineSymbol(symbols_math, main, symbols_textord, "\u210F", "\\hbar", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2203", "\\exists", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2207", "\\nabla", true); -defineSymbol(symbols_math, main, symbols_textord, "\u266D", "\\flat", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2113", "\\ell", true); -defineSymbol(symbols_math, main, symbols_textord, "\u266E", "\\natural", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2663", "\\clubsuit", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2118", "\\wp", true); -defineSymbol(symbols_math, main, symbols_textord, "\u266F", "\\sharp", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2662", "\\diamondsuit", true); -defineSymbol(symbols_math, main, symbols_textord, "\u211C", "\\Re", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2661", "\\heartsuit", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2111", "\\Im", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2660", "\\spadesuit", true); -defineSymbol(symbols_text, main, symbols_textord, "\xA7", "\\S", true); -defineSymbol(symbols_text, main, symbols_textord, "\xB6", "\\P", true); // Math and Text - -defineSymbol(symbols_math, main, symbols_textord, "\u2020", "\\dag"); -defineSymbol(symbols_text, main, symbols_textord, "\u2020", "\\dag"); -defineSymbol(symbols_text, main, symbols_textord, "\u2020", "\\textdagger"); -defineSymbol(symbols_math, main, symbols_textord, "\u2021", "\\ddag"); -defineSymbol(symbols_text, main, symbols_textord, "\u2021", "\\ddag"); -defineSymbol(symbols_text, main, symbols_textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters - -defineSymbol(symbols_math, main, symbols_close, "\u23B1", "\\rmoustache", true); -defineSymbol(symbols_math, main, symbols_open, "\u23B0", "\\lmoustache", true); -defineSymbol(symbols_math, main, symbols_close, "\u27EF", "\\rgroup", true); -defineSymbol(symbols_math, main, symbols_open, "\u27EE", "\\lgroup", true); // Binary Operators - -defineSymbol(symbols_math, main, bin, "\u2213", "\\mp", true); -defineSymbol(symbols_math, main, bin, "\u2296", "\\ominus", true); -defineSymbol(symbols_math, main, bin, "\u228E", "\\uplus", true); -defineSymbol(symbols_math, main, bin, "\u2293", "\\sqcap", true); -defineSymbol(symbols_math, main, bin, "\u2217", "\\ast"); -defineSymbol(symbols_math, main, bin, "\u2294", "\\sqcup", true); -defineSymbol(symbols_math, main, bin, "\u25EF", "\\bigcirc"); -defineSymbol(symbols_math, main, bin, "\u2219", "\\bullet"); -defineSymbol(symbols_math, main, bin, "\u2021", "\\ddagger"); -defineSymbol(symbols_math, main, bin, "\u2240", "\\wr", true); -defineSymbol(symbols_math, main, bin, "\u2A3F", "\\amalg"); -defineSymbol(symbols_math, main, bin, "&", "\\And"); // from amsmath +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); // Punctuation + +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols + +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(symbols_text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(symbols_text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(symbols_text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(symbols_text, main, textord, "\u00b6", "\\P"); // Math and Text + +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters + +defineSymbol(math, main, symbols_close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, symbols_open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, symbols_close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, symbols_open, "\u27ee", "\\lgroup", true); // Binary Operators + +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath // Arrow Symbols -defineSymbol(symbols_math, main, rel, "\u27F5", "\\longleftarrow", true); -defineSymbol(symbols_math, main, rel, "\u21D0", "\\Leftarrow", true); -defineSymbol(symbols_math, main, rel, "\u27F8", "\\Longleftarrow", true); -defineSymbol(symbols_math, main, rel, "\u27F6", "\\longrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u21D2", "\\Rightarrow", true); -defineSymbol(symbols_math, main, rel, "\u27F9", "\\Longrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u2194", "\\leftrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u27F7", "\\longleftrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u21D4", "\\Leftrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u27FA", "\\Longleftrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u21A6", "\\mapsto", true); -defineSymbol(symbols_math, main, rel, "\u27FC", "\\longmapsto", true); -defineSymbol(symbols_math, main, rel, "\u2197", "\\nearrow", true); -defineSymbol(symbols_math, main, rel, "\u21A9", "\\hookleftarrow", true); -defineSymbol(symbols_math, main, rel, "\u21AA", "\\hookrightarrow", true); -defineSymbol(symbols_math, main, rel, "\u2198", "\\searrow", true); -defineSymbol(symbols_math, main, rel, "\u21BC", "\\leftharpoonup", true); -defineSymbol(symbols_math, main, rel, "\u21C0", "\\rightharpoonup", true); -defineSymbol(symbols_math, main, rel, "\u2199", "\\swarrow", true); -defineSymbol(symbols_math, main, rel, "\u21BD", "\\leftharpoondown", true); -defineSymbol(symbols_math, main, rel, "\u21C1", "\\rightharpoondown", true); -defineSymbol(symbols_math, main, rel, "\u2196", "\\nwarrow", true); -defineSymbol(symbols_math, main, rel, "\u21CC", "\\rightleftharpoons", true); // AMS Negated Binary Relations - -defineSymbol(symbols_math, ams, rel, "\u226E", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro. - -defineSymbol(symbols_math, ams, rel, "\uE010", "\\@nleqslant"); -defineSymbol(symbols_math, ams, rel, "\uE011", "\\@nleqq"); -defineSymbol(symbols_math, ams, rel, "\u2A87", "\\lneq", true); -defineSymbol(symbols_math, ams, rel, "\u2268", "\\lneqq", true); -defineSymbol(symbols_math, ams, rel, "\uE00C", "\\@lvertneqq"); -defineSymbol(symbols_math, ams, rel, "\u22E6", "\\lnsim", true); -defineSymbol(symbols_math, ams, rel, "\u2A89", "\\lnapprox", true); -defineSymbol(symbols_math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u22E0", "\\npreceq", true); -defineSymbol(symbols_math, ams, rel, "\u22E8", "\\precnsim", true); -defineSymbol(symbols_math, ams, rel, "\u2AB9", "\\precnapprox", true); -defineSymbol(symbols_math, ams, rel, "\u2241", "\\nsim", true); -defineSymbol(symbols_math, ams, rel, "\uE006", "\\@nshortmid"); -defineSymbol(symbols_math, ams, rel, "\u2224", "\\nmid", true); -defineSymbol(symbols_math, ams, rel, "\u22AC", "\\nvdash", true); -defineSymbol(symbols_math, ams, rel, "\u22AD", "\\nvDash", true); -defineSymbol(symbols_math, ams, rel, "\u22EA", "\\ntriangleleft"); -defineSymbol(symbols_math, ams, rel, "\u22EC", "\\ntrianglelefteq", true); -defineSymbol(symbols_math, ams, rel, "\u228A", "\\subsetneq", true); -defineSymbol(symbols_math, ams, rel, "\uE01A", "\\@varsubsetneq"); -defineSymbol(symbols_math, ams, rel, "\u2ACB", "\\subsetneqq", true); -defineSymbol(symbols_math, ams, rel, "\uE017", "\\@varsubsetneqq"); -defineSymbol(symbols_math, ams, rel, "\u226F", "\\ngtr", true); -defineSymbol(symbols_math, ams, rel, "\uE00F", "\\@ngeqslant"); -defineSymbol(symbols_math, ams, rel, "\uE00E", "\\@ngeqq"); -defineSymbol(symbols_math, ams, rel, "\u2A88", "\\gneq", true); -defineSymbol(symbols_math, ams, rel, "\u2269", "\\gneqq", true); -defineSymbol(symbols_math, ams, rel, "\uE00D", "\\@gvertneqq"); -defineSymbol(symbols_math, ams, rel, "\u22E7", "\\gnsim", true); -defineSymbol(symbols_math, ams, rel, "\u2A8A", "\\gnapprox", true); -defineSymbol(symbols_math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u22E1", "\\nsucceq", true); -defineSymbol(symbols_math, ams, rel, "\u22E9", "\\succnsim", true); -defineSymbol(symbols_math, ams, rel, "\u2ABA", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u2246", "\\ncong", true); -defineSymbol(symbols_math, ams, rel, "\uE007", "\\@nshortparallel"); -defineSymbol(symbols_math, ams, rel, "\u2226", "\\nparallel", true); -defineSymbol(symbols_math, ams, rel, "\u22AF", "\\nVDash", true); -defineSymbol(symbols_math, ams, rel, "\u22EB", "\\ntriangleright"); -defineSymbol(symbols_math, ams, rel, "\u22ED", "\\ntrianglerighteq", true); -defineSymbol(symbols_math, ams, rel, "\uE018", "\\@nsupseteqq"); -defineSymbol(symbols_math, ams, rel, "\u228B", "\\supsetneq", true); -defineSymbol(symbols_math, ams, rel, "\uE01B", "\\@varsupsetneq"); -defineSymbol(symbols_math, ams, rel, "\u2ACC", "\\supsetneqq", true); -defineSymbol(symbols_math, ams, rel, "\uE019", "\\@varsupsetneqq"); -defineSymbol(symbols_math, ams, rel, "\u22AE", "\\nVdash", true); -defineSymbol(symbols_math, ams, rel, "\u2AB5", "\\precneqq", true); -defineSymbol(symbols_math, ams, rel, "\u2AB6", "\\succneqq", true); -defineSymbol(symbols_math, ams, rel, "\uE016", "\\@nsubseteqq"); -defineSymbol(symbols_math, ams, bin, "\u22B4", "\\unlhd"); -defineSymbol(symbols_math, ams, bin, "\u22B5", "\\unrhd"); // AMS Negated Arrows - -defineSymbol(symbols_math, ams, rel, "\u219A", "\\nleftarrow", true); -defineSymbol(symbols_math, ams, rel, "\u219B", "\\nrightarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21CD", "\\nLeftarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21CF", "\\nRightarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21AE", "\\nleftrightarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21CE", "\\nLeftrightarrow", true); // AMS Misc - -defineSymbol(symbols_math, ams, rel, "\u25B3", "\\vartriangle"); -defineSymbol(symbols_math, ams, symbols_textord, "\u210F", "\\hslash"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25BD", "\\triangledown"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25CA", "\\lozenge"); -defineSymbol(symbols_math, ams, symbols_textord, "\u24C8", "\\circledS"); -defineSymbol(symbols_math, ams, symbols_textord, "\xAE", "\\circledR"); -defineSymbol(symbols_text, ams, symbols_textord, "\xAE", "\\circledR"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2221", "\\measuredangle", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2204", "\\nexists"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2127", "\\mho"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2132", "\\Finv", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2141", "\\Game", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2035", "\\backprime"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25B2", "\\blacktriangle"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25BC", "\\blacktriangledown"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25A0", "\\blacksquare"); -defineSymbol(symbols_math, ams, symbols_textord, "\u29EB", "\\blacklozenge"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2605", "\\bigstar"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2222", "\\sphericalangle", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 (ð) to \matheth. We map to AMS function \eth - -defineSymbol(symbols_math, ams, symbols_textord, "\xF0", "\\eth", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2571", "\\diagup"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2572", "\\diagdown"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25A1", "\\square"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25A1", "\\Box"); -defineSymbol(symbols_math, ams, symbols_textord, "\u25CA", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen - -defineSymbol(symbols_math, ams, symbols_textord, "\xA5", "\\yen", true); -defineSymbol(symbols_text, ams, symbols_textord, "\xA5", "\\yen", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2713", "\\checkmark", true); -defineSymbol(symbols_text, ams, symbols_textord, "\u2713", "\\checkmark"); // AMS Hebrew - -defineSymbol(symbols_math, ams, symbols_textord, "\u2136", "\\beth", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2138", "\\daleth", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2137", "\\gimel", true); // AMS Greek - -defineSymbol(symbols_math, ams, symbols_textord, "\u03DD", "\\digamma", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u03F0", "\\varkappa"); // AMS Delimiters - -defineSymbol(symbols_math, ams, symbols_open, "\u250C", "\\ulcorner", true); -defineSymbol(symbols_math, ams, symbols_close, "\u2510", "\\urcorner", true); -defineSymbol(symbols_math, ams, symbols_open, "\u2514", "\\llcorner", true); -defineSymbol(symbols_math, ams, symbols_close, "\u2518", "\\lrcorner", true); // AMS Binary Relations - -defineSymbol(symbols_math, ams, rel, "\u2266", "\\leqq", true); -defineSymbol(symbols_math, ams, rel, "\u2A7D", "\\leqslant", true); -defineSymbol(symbols_math, ams, rel, "\u2A95", "\\eqslantless", true); -defineSymbol(symbols_math, ams, rel, "\u2272", "\\lesssim", true); -defineSymbol(symbols_math, ams, rel, "\u2A85", "\\lessapprox", true); -defineSymbol(symbols_math, ams, rel, "\u224A", "\\approxeq", true); -defineSymbol(symbols_math, ams, bin, "\u22D6", "\\lessdot"); -defineSymbol(symbols_math, ams, rel, "\u22D8", "\\lll", true); -defineSymbol(symbols_math, ams, rel, "\u2276", "\\lessgtr", true); -defineSymbol(symbols_math, ams, rel, "\u22DA", "\\lesseqgtr", true); -defineSymbol(symbols_math, ams, rel, "\u2A8B", "\\lesseqqgtr", true); -defineSymbol(symbols_math, ams, rel, "\u2251", "\\doteqdot"); -defineSymbol(symbols_math, ams, rel, "\u2253", "\\risingdotseq", true); -defineSymbol(symbols_math, ams, rel, "\u2252", "\\fallingdotseq", true); -defineSymbol(symbols_math, ams, rel, "\u223D", "\\backsim", true); -defineSymbol(symbols_math, ams, rel, "\u22CD", "\\backsimeq", true); -defineSymbol(symbols_math, ams, rel, "\u2AC5", "\\subseteqq", true); -defineSymbol(symbols_math, ams, rel, "\u22D0", "\\Subset", true); -defineSymbol(symbols_math, ams, rel, "\u228F", "\\sqsubset", true); -defineSymbol(symbols_math, ams, rel, "\u227C", "\\preccurlyeq", true); -defineSymbol(symbols_math, ams, rel, "\u22DE", "\\curlyeqprec", true); -defineSymbol(symbols_math, ams, rel, "\u227E", "\\precsim", true); -defineSymbol(symbols_math, ams, rel, "\u2AB7", "\\precapprox", true); -defineSymbol(symbols_math, ams, rel, "\u22B2", "\\vartriangleleft"); -defineSymbol(symbols_math, ams, rel, "\u22B4", "\\trianglelefteq"); -defineSymbol(symbols_math, ams, rel, "\u22A8", "\\vDash", true); -defineSymbol(symbols_math, ams, rel, "\u22AA", "\\Vvdash", true); -defineSymbol(symbols_math, ams, rel, "\u2323", "\\smallsmile"); -defineSymbol(symbols_math, ams, rel, "\u2322", "\\smallfrown"); -defineSymbol(symbols_math, ams, rel, "\u224F", "\\bumpeq", true); -defineSymbol(symbols_math, ams, rel, "\u224E", "\\Bumpeq", true); -defineSymbol(symbols_math, ams, rel, "\u2267", "\\geqq", true); -defineSymbol(symbols_math, ams, rel, "\u2A7E", "\\geqslant", true); -defineSymbol(symbols_math, ams, rel, "\u2A96", "\\eqslantgtr", true); -defineSymbol(symbols_math, ams, rel, "\u2273", "\\gtrsim", true); -defineSymbol(symbols_math, ams, rel, "\u2A86", "\\gtrapprox", true); -defineSymbol(symbols_math, ams, bin, "\u22D7", "\\gtrdot"); -defineSymbol(symbols_math, ams, rel, "\u22D9", "\\ggg", true); -defineSymbol(symbols_math, ams, rel, "\u2277", "\\gtrless", true); -defineSymbol(symbols_math, ams, rel, "\u22DB", "\\gtreqless", true); -defineSymbol(symbols_math, ams, rel, "\u2A8C", "\\gtreqqless", true); -defineSymbol(symbols_math, ams, rel, "\u2256", "\\eqcirc", true); -defineSymbol(symbols_math, ams, rel, "\u2257", "\\circeq", true); -defineSymbol(symbols_math, ams, rel, "\u225C", "\\triangleq", true); -defineSymbol(symbols_math, ams, rel, "\u223C", "\\thicksim"); -defineSymbol(symbols_math, ams, rel, "\u2248", "\\thickapprox"); -defineSymbol(symbols_math, ams, rel, "\u2AC6", "\\supseteqq", true); -defineSymbol(symbols_math, ams, rel, "\u22D1", "\\Supset", true); -defineSymbol(symbols_math, ams, rel, "\u2290", "\\sqsupset", true); -defineSymbol(symbols_math, ams, rel, "\u227D", "\\succcurlyeq", true); -defineSymbol(symbols_math, ams, rel, "\u22DF", "\\curlyeqsucc", true); -defineSymbol(symbols_math, ams, rel, "\u227F", "\\succsim", true); -defineSymbol(symbols_math, ams, rel, "\u2AB8", "\\succapprox", true); -defineSymbol(symbols_math, ams, rel, "\u22B3", "\\vartriangleright"); -defineSymbol(symbols_math, ams, rel, "\u22B5", "\\trianglerighteq"); -defineSymbol(symbols_math, ams, rel, "\u22A9", "\\Vdash", true); -defineSymbol(symbols_math, ams, rel, "\u2223", "\\shortmid"); -defineSymbol(symbols_math, ams, rel, "\u2225", "\\shortparallel"); -defineSymbol(symbols_math, ams, rel, "\u226C", "\\between", true); -defineSymbol(symbols_math, ams, rel, "\u22D4", "\\pitchfork", true); -defineSymbol(symbols_math, ams, rel, "\u221D", "\\varpropto"); -defineSymbol(symbols_math, ams, rel, "\u25C0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom. +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations + +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceded by "@" each have a corresponding macro. + +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); // AMS Negated Arrows + +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); // AMS Misc + +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(symbols_text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth + +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(symbols_text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen + +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(symbols_text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(symbols_text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew + +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek + +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters + +defineSymbol(math, ams, symbols_open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, symbols_close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, symbols_open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, symbols_close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations + +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom. // We kept the amssymb atom type, which is rel. -defineSymbol(symbols_math, ams, rel, "\u2234", "\\therefore", true); -defineSymbol(symbols_math, ams, rel, "\u220D", "\\backepsilon"); -defineSymbol(symbols_math, ams, rel, "\u25B6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom. // We kept the amssymb atom type, which is rel. -defineSymbol(symbols_math, ams, rel, "\u2235", "\\because", true); -defineSymbol(symbols_math, ams, rel, "\u22D8", "\\llless"); -defineSymbol(symbols_math, ams, rel, "\u22D9", "\\gggtr"); -defineSymbol(symbols_math, ams, bin, "\u22B2", "\\lhd"); -defineSymbol(symbols_math, ams, bin, "\u22B3", "\\rhd"); -defineSymbol(symbols_math, ams, rel, "\u2242", "\\eqsim", true); -defineSymbol(symbols_math, main, rel, "\u22C8", "\\Join"); -defineSymbol(symbols_math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators - -defineSymbol(symbols_math, ams, bin, "\u2214", "\\dotplus", true); -defineSymbol(symbols_math, ams, bin, "\u2216", "\\smallsetminus"); -defineSymbol(symbols_math, ams, bin, "\u22D2", "\\Cap", true); -defineSymbol(symbols_math, ams, bin, "\u22D3", "\\Cup", true); -defineSymbol(symbols_math, ams, bin, "\u2A5E", "\\doublebarwedge", true); -defineSymbol(symbols_math, ams, bin, "\u229F", "\\boxminus", true); -defineSymbol(symbols_math, ams, bin, "\u229E", "\\boxplus", true); -defineSymbol(symbols_math, ams, bin, "\u22C7", "\\divideontimes", true); -defineSymbol(symbols_math, ams, bin, "\u22C9", "\\ltimes", true); -defineSymbol(symbols_math, ams, bin, "\u22CA", "\\rtimes", true); -defineSymbol(symbols_math, ams, bin, "\u22CB", "\\leftthreetimes", true); -defineSymbol(symbols_math, ams, bin, "\u22CC", "\\rightthreetimes", true); -defineSymbol(symbols_math, ams, bin, "\u22CF", "\\curlywedge", true); -defineSymbol(symbols_math, ams, bin, "\u22CE", "\\curlyvee", true); -defineSymbol(symbols_math, ams, bin, "\u229D", "\\circleddash", true); -defineSymbol(symbols_math, ams, bin, "\u229B", "\\circledast", true); -defineSymbol(symbols_math, ams, bin, "\u22C5", "\\centerdot"); -defineSymbol(symbols_math, ams, bin, "\u22BA", "\\intercal", true); -defineSymbol(symbols_math, ams, bin, "\u22D2", "\\doublecap"); -defineSymbol(symbols_math, ams, bin, "\u22D3", "\\doublecup"); -defineSymbol(symbols_math, ams, bin, "\u22A0", "\\boxtimes", true); // AMS Arrows +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators + +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); // AMS Arrows // Note: unicode-math maps \u21e2 to their own function \rightdasharrow. // We'll map it to AMS function \dashrightarrow. It produces the same atom. -defineSymbol(symbols_math, ams, rel, "\u21E2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u21E0", "\\dashleftarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21C7", "\\leftleftarrows", true); -defineSymbol(symbols_math, ams, rel, "\u21C6", "\\leftrightarrows", true); -defineSymbol(symbols_math, ams, rel, "\u21DA", "\\Lleftarrow", true); -defineSymbol(symbols_math, ams, rel, "\u219E", "\\twoheadleftarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21A2", "\\leftarrowtail", true); -defineSymbol(symbols_math, ams, rel, "\u21AB", "\\looparrowleft", true); -defineSymbol(symbols_math, ams, rel, "\u21CB", "\\leftrightharpoons", true); -defineSymbol(symbols_math, ams, rel, "\u21B6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u21BA", "\\circlearrowleft", true); -defineSymbol(symbols_math, ams, rel, "\u21B0", "\\Lsh", true); -defineSymbol(symbols_math, ams, rel, "\u21C8", "\\upuparrows", true); -defineSymbol(symbols_math, ams, rel, "\u21BF", "\\upharpoonleft", true); -defineSymbol(symbols_math, ams, rel, "\u21C3", "\\downharpoonleft", true); -defineSymbol(symbols_math, ams, rel, "\u22B8", "\\multimap", true); -defineSymbol(symbols_math, ams, rel, "\u21AD", "\\leftrightsquigarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21C9", "\\rightrightarrows", true); -defineSymbol(symbols_math, ams, rel, "\u21C4", "\\rightleftarrows", true); -defineSymbol(symbols_math, ams, rel, "\u21A0", "\\twoheadrightarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21A3", "\\rightarrowtail", true); -defineSymbol(symbols_math, ams, rel, "\u21AC", "\\looparrowright", true); -defineSymbol(symbols_math, ams, rel, "\u21B7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. - -defineSymbol(symbols_math, ams, rel, "\u21BB", "\\circlearrowright", true); -defineSymbol(symbols_math, ams, rel, "\u21B1", "\\Rsh", true); -defineSymbol(symbols_math, ams, rel, "\u21CA", "\\downdownarrows", true); -defineSymbol(symbols_math, ams, rel, "\u21BE", "\\upharpoonright", true); -defineSymbol(symbols_math, ams, rel, "\u21C2", "\\downharpoonright", true); -defineSymbol(symbols_math, ams, rel, "\u21DD", "\\rightsquigarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21DD", "\\leadsto"); -defineSymbol(symbols_math, ams, rel, "\u21DB", "\\Rrightarrow", true); -defineSymbol(symbols_math, ams, rel, "\u21BE", "\\restriction"); -defineSymbol(symbols_math, main, symbols_textord, "\u2018", "`"); -defineSymbol(symbols_math, main, symbols_textord, "$", "\\$"); -defineSymbol(symbols_text, main, symbols_textord, "$", "\\$"); -defineSymbol(symbols_text, main, symbols_textord, "$", "\\textdollar"); -defineSymbol(symbols_math, main, symbols_textord, "%", "\\%"); -defineSymbol(symbols_text, main, symbols_textord, "%", "\\%"); -defineSymbol(symbols_math, main, symbols_textord, "_", "\\_"); -defineSymbol(symbols_text, main, symbols_textord, "_", "\\_"); -defineSymbol(symbols_text, main, symbols_textord, "_", "\\textunderscore"); -defineSymbol(symbols_math, main, symbols_textord, "\u2220", "\\angle", true); -defineSymbol(symbols_math, main, symbols_textord, "\u221E", "\\infty", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2032", "\\prime"); -defineSymbol(symbols_math, main, symbols_textord, "\u25B3", "\\triangle"); -defineSymbol(symbols_math, main, symbols_textord, "\u0393", "\\Gamma", true); -defineSymbol(symbols_math, main, symbols_textord, "\u0394", "\\Delta", true); -defineSymbol(symbols_math, main, symbols_textord, "\u0398", "\\Theta", true); -defineSymbol(symbols_math, main, symbols_textord, "\u039B", "\\Lambda", true); -defineSymbol(symbols_math, main, symbols_textord, "\u039E", "\\Xi", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A0", "\\Pi", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A3", "\\Sigma", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A5", "\\Upsilon", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A6", "\\Phi", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A8", "\\Psi", true); -defineSymbol(symbols_math, main, symbols_textord, "\u03A9", "\\Omega", true); -defineSymbol(symbols_math, main, symbols_textord, "A", "\u0391"); -defineSymbol(symbols_math, main, symbols_textord, "B", "\u0392"); -defineSymbol(symbols_math, main, symbols_textord, "E", "\u0395"); -defineSymbol(symbols_math, main, symbols_textord, "Z", "\u0396"); -defineSymbol(symbols_math, main, symbols_textord, "H", "\u0397"); -defineSymbol(symbols_math, main, symbols_textord, "I", "\u0399"); -defineSymbol(symbols_math, main, symbols_textord, "K", "\u039A"); -defineSymbol(symbols_math, main, symbols_textord, "M", "\u039C"); -defineSymbol(symbols_math, main, symbols_textord, "N", "\u039D"); -defineSymbol(symbols_math, main, symbols_textord, "O", "\u039F"); -defineSymbol(symbols_math, main, symbols_textord, "P", "\u03A1"); -defineSymbol(symbols_math, main, symbols_textord, "T", "\u03A4"); -defineSymbol(symbols_math, main, symbols_textord, "X", "\u03A7"); -defineSymbol(symbols_math, main, symbols_textord, "\xAC", "\\neg", true); -defineSymbol(symbols_math, main, symbols_textord, "\xAC", "\\lnot"); -defineSymbol(symbols_math, main, symbols_textord, "\u22A4", "\\top"); -defineSymbol(symbols_math, main, symbols_textord, "\u22A5", "\\bot"); -defineSymbol(symbols_math, main, symbols_textord, "\u2205", "\\emptyset"); -defineSymbol(symbols_math, ams, symbols_textord, "\u2205", "\\varnothing"); -defineSymbol(symbols_math, main, mathord, "\u03B1", "\\alpha", true); -defineSymbol(symbols_math, main, mathord, "\u03B2", "\\beta", true); -defineSymbol(symbols_math, main, mathord, "\u03B3", "\\gamma", true); -defineSymbol(symbols_math, main, mathord, "\u03B4", "\\delta", true); -defineSymbol(symbols_math, main, mathord, "\u03F5", "\\epsilon", true); -defineSymbol(symbols_math, main, mathord, "\u03B6", "\\zeta", true); -defineSymbol(symbols_math, main, mathord, "\u03B7", "\\eta", true); -defineSymbol(symbols_math, main, mathord, "\u03B8", "\\theta", true); -defineSymbol(symbols_math, main, mathord, "\u03B9", "\\iota", true); -defineSymbol(symbols_math, main, mathord, "\u03BA", "\\kappa", true); -defineSymbol(symbols_math, main, mathord, "\u03BB", "\\lambda", true); -defineSymbol(symbols_math, main, mathord, "\u03BC", "\\mu", true); -defineSymbol(symbols_math, main, mathord, "\u03BD", "\\nu", true); -defineSymbol(symbols_math, main, mathord, "\u03BE", "\\xi", true); -defineSymbol(symbols_math, main, mathord, "\u03BF", "\\omicron", true); -defineSymbol(symbols_math, main, mathord, "\u03C0", "\\pi", true); -defineSymbol(symbols_math, main, mathord, "\u03C1", "\\rho", true); -defineSymbol(symbols_math, main, mathord, "\u03C3", "\\sigma", true); -defineSymbol(symbols_math, main, mathord, "\u03C4", "\\tau", true); -defineSymbol(symbols_math, main, mathord, "\u03C5", "\\upsilon", true); -defineSymbol(symbols_math, main, mathord, "\u03D5", "\\phi", true); -defineSymbol(symbols_math, main, mathord, "\u03C7", "\\chi", true); -defineSymbol(symbols_math, main, mathord, "\u03C8", "\\psi", true); -defineSymbol(symbols_math, main, mathord, "\u03C9", "\\omega", true); -defineSymbol(symbols_math, main, mathord, "\u03B5", "\\varepsilon", true); -defineSymbol(symbols_math, main, mathord, "\u03D1", "\\vartheta", true); -defineSymbol(symbols_math, main, mathord, "\u03D6", "\\varpi", true); -defineSymbol(symbols_math, main, mathord, "\u03F1", "\\varrho", true); -defineSymbol(symbols_math, main, mathord, "\u03C2", "\\varsigma", true); -defineSymbol(symbols_math, main, mathord, "\u03C6", "\\varphi", true); -defineSymbol(symbols_math, main, bin, "\u2217", "*"); -defineSymbol(symbols_math, main, bin, "+", "+"); -defineSymbol(symbols_math, main, bin, "\u2212", "-"); -defineSymbol(symbols_math, main, bin, "\u22C5", "\\cdot", true); -defineSymbol(symbols_math, main, bin, "\u2218", "\\circ"); -defineSymbol(symbols_math, main, bin, "\xF7", "\\div", true); -defineSymbol(symbols_math, main, bin, "\xB1", "\\pm", true); -defineSymbol(symbols_math, main, bin, "\xD7", "\\times", true); -defineSymbol(symbols_math, main, bin, "\u2229", "\\cap", true); -defineSymbol(symbols_math, main, bin, "\u222A", "\\cup", true); -defineSymbol(symbols_math, main, bin, "\u2216", "\\setminus"); -defineSymbol(symbols_math, main, bin, "\u2227", "\\land"); -defineSymbol(symbols_math, main, bin, "\u2228", "\\lor"); -defineSymbol(symbols_math, main, bin, "\u2227", "\\wedge", true); -defineSymbol(symbols_math, main, bin, "\u2228", "\\vee", true); -defineSymbol(symbols_math, main, symbols_textord, "\u221A", "\\surd"); -defineSymbol(symbols_math, main, symbols_open, "(", "("); -defineSymbol(symbols_math, main, symbols_open, "[", "["); -defineSymbol(symbols_math, main, symbols_open, "\u27E8", "\\langle", true); -defineSymbol(symbols_math, main, symbols_open, "\u2223", "\\lvert"); -defineSymbol(symbols_math, main, symbols_open, "\u2225", "\\lVert"); -defineSymbol(symbols_math, main, symbols_close, ")", ")"); -defineSymbol(symbols_math, main, symbols_close, "]", "]"); -defineSymbol(symbols_math, main, symbols_close, "?", "?"); -defineSymbol(symbols_math, main, symbols_close, "!", "!"); -defineSymbol(symbols_math, main, symbols_close, "\u27E9", "\\rangle", true); -defineSymbol(symbols_math, main, symbols_close, "\u2223", "\\rvert"); -defineSymbol(symbols_math, main, symbols_close, "\u2225", "\\rVert"); -defineSymbol(symbols_math, main, rel, "=", "="); -defineSymbol(symbols_math, main, rel, "<", "<"); -defineSymbol(symbols_math, main, rel, ">", ">"); -defineSymbol(symbols_math, main, rel, ":", ":"); -defineSymbol(symbols_math, main, rel, "\u2248", "\\approx", true); -defineSymbol(symbols_math, main, rel, "\u2245", "\\cong", true); -defineSymbol(symbols_math, main, rel, "\u2265", "\\ge"); -defineSymbol(symbols_math, main, rel, "\u2265", "\\geq", true); -defineSymbol(symbols_math, main, rel, "\u2190", "\\gets"); -defineSymbol(symbols_math, main, rel, ">", "\\gt"); -defineSymbol(symbols_math, main, rel, "\u2208", "\\in", true); -defineSymbol(symbols_math, main, rel, "\uE020", "\\@not"); -defineSymbol(symbols_math, main, rel, "\u2282", "\\subset", true); -defineSymbol(symbols_math, main, rel, "\u2283", "\\supset", true); -defineSymbol(symbols_math, main, rel, "\u2286", "\\subseteq", true); -defineSymbol(symbols_math, main, rel, "\u2287", "\\supseteq", true); -defineSymbol(symbols_math, ams, rel, "\u2288", "\\nsubseteq", true); -defineSymbol(symbols_math, ams, rel, "\u2289", "\\nsupseteq", true); -defineSymbol(symbols_math, main, rel, "\u22A8", "\\models"); -defineSymbol(symbols_math, main, rel, "\u2190", "\\leftarrow", true); -defineSymbol(symbols_math, main, rel, "\u2264", "\\le"); -defineSymbol(symbols_math, main, rel, "\u2264", "\\leq", true); -defineSymbol(symbols_math, main, rel, "<", "\\lt"); -defineSymbol(symbols_math, main, rel, "\u2192", "\\rightarrow", true); -defineSymbol(symbols_math, main, rel, "\u2192", "\\to"); -defineSymbol(symbols_math, ams, rel, "\u2271", "\\ngeq", true); -defineSymbol(symbols_math, ams, rel, "\u2270", "\\nleq", true); -defineSymbol(symbols_math, main, symbols_spacing, "\xA0", "\\ "); -defineSymbol(symbols_math, main, symbols_spacing, "\xA0", "~"); -defineSymbol(symbols_math, main, symbols_spacing, "\xA0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% - -defineSymbol(symbols_math, main, symbols_spacing, "\xA0", "\\nobreakspace"); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "\\ "); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "~"); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "\\space"); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "\\nobreakspace"); -defineSymbol(symbols_math, main, symbols_spacing, null, "\\nobreak"); -defineSymbol(symbols_math, main, symbols_spacing, null, "\\allowbreak"); -defineSymbol(symbols_math, main, punct, ",", ","); -defineSymbol(symbols_math, main, punct, ";", ";"); -defineSymbol(symbols_math, ams, bin, "\u22BC", "\\barwedge", true); -defineSymbol(symbols_math, ams, bin, "\u22BB", "\\veebar", true); -defineSymbol(symbols_math, main, bin, "\u2299", "\\odot", true); -defineSymbol(symbols_math, main, bin, "\u2295", "\\oplus", true); -defineSymbol(symbols_math, main, bin, "\u2297", "\\otimes", true); -defineSymbol(symbols_math, main, symbols_textord, "\u2202", "\\partial", true); -defineSymbol(symbols_math, main, bin, "\u2298", "\\oslash", true); -defineSymbol(symbols_math, ams, bin, "\u229A", "\\circledcirc", true); -defineSymbol(symbols_math, ams, bin, "\u22A1", "\\boxdot", true); -defineSymbol(symbols_math, main, bin, "\u25B3", "\\bigtriangleup"); -defineSymbol(symbols_math, main, bin, "\u25BD", "\\bigtriangledown"); -defineSymbol(symbols_math, main, bin, "\u2020", "\\dagger"); -defineSymbol(symbols_math, main, bin, "\u22C4", "\\diamond"); -defineSymbol(symbols_math, main, bin, "\u22C6", "\\star"); -defineSymbol(symbols_math, main, bin, "\u25C3", "\\triangleleft"); -defineSymbol(symbols_math, main, bin, "\u25B9", "\\triangleright"); -defineSymbol(symbols_math, main, symbols_open, "{", "\\{"); -defineSymbol(symbols_text, main, symbols_textord, "{", "\\{"); -defineSymbol(symbols_text, main, symbols_textord, "{", "\\textbraceleft"); -defineSymbol(symbols_math, main, symbols_close, "}", "\\}"); -defineSymbol(symbols_text, main, symbols_textord, "}", "\\}"); -defineSymbol(symbols_text, main, symbols_textord, "}", "\\textbraceright"); -defineSymbol(symbols_math, main, symbols_open, "{", "\\lbrace"); -defineSymbol(symbols_math, main, symbols_close, "}", "\\rbrace"); -defineSymbol(symbols_math, main, symbols_open, "[", "\\lbrack"); -defineSymbol(symbols_text, main, symbols_textord, "[", "\\lbrack"); -defineSymbol(symbols_math, main, symbols_close, "]", "\\rbrack"); -defineSymbol(symbols_text, main, symbols_textord, "]", "\\rbrack"); -defineSymbol(symbols_math, main, symbols_open, "(", "\\lparen"); -defineSymbol(symbols_math, main, symbols_close, ")", "\\rparen"); -defineSymbol(symbols_text, main, symbols_textord, "<", "\\textless"); // in T1 fontenc - -defineSymbol(symbols_text, main, symbols_textord, ">", "\\textgreater"); // in T1 fontenc - -defineSymbol(symbols_math, main, symbols_open, "\u230A", "\\lfloor", true); -defineSymbol(symbols_math, main, symbols_close, "\u230B", "\\rfloor", true); -defineSymbol(symbols_math, main, symbols_open, "\u2308", "\\lceil", true); -defineSymbol(symbols_math, main, symbols_close, "\u2309", "\\rceil", true); -defineSymbol(symbols_math, main, symbols_textord, "\\", "\\backslash"); -defineSymbol(symbols_math, main, symbols_textord, "\u2223", "|"); -defineSymbol(symbols_math, main, symbols_textord, "\u2223", "\\vert"); -defineSymbol(symbols_text, main, symbols_textord, "|", "\\textbar"); // in T1 fontenc - -defineSymbol(symbols_math, main, symbols_textord, "\u2225", "\\|"); -defineSymbol(symbols_math, main, symbols_textord, "\u2225", "\\Vert"); -defineSymbol(symbols_text, main, symbols_textord, "\u2225", "\\textbardbl"); -defineSymbol(symbols_text, main, symbols_textord, "~", "\\textasciitilde"); -defineSymbol(symbols_text, main, symbols_textord, "\\", "\\textbackslash"); -defineSymbol(symbols_text, main, symbols_textord, "^", "\\textasciicircum"); -defineSymbol(symbols_math, main, rel, "\u2191", "\\uparrow", true); -defineSymbol(symbols_math, main, rel, "\u21D1", "\\Uparrow", true); -defineSymbol(symbols_math, main, rel, "\u2193", "\\downarrow", true); -defineSymbol(symbols_math, main, rel, "\u21D3", "\\Downarrow", true); -defineSymbol(symbols_math, main, rel, "\u2195", "\\updownarrow", true); -defineSymbol(symbols_math, main, rel, "\u21D5", "\\Updownarrow", true); -defineSymbol(symbols_math, main, op, "\u2210", "\\coprod"); -defineSymbol(symbols_math, main, op, "\u22C1", "\\bigvee"); -defineSymbol(symbols_math, main, op, "\u22C0", "\\bigwedge"); -defineSymbol(symbols_math, main, op, "\u2A04", "\\biguplus"); -defineSymbol(symbols_math, main, op, "\u22C2", "\\bigcap"); -defineSymbol(symbols_math, main, op, "\u22C3", "\\bigcup"); -defineSymbol(symbols_math, main, op, "\u222B", "\\int"); -defineSymbol(symbols_math, main, op, "\u222B", "\\intop"); -defineSymbol(symbols_math, main, op, "\u222C", "\\iint"); -defineSymbol(symbols_math, main, op, "\u222D", "\\iiint"); -defineSymbol(symbols_math, main, op, "\u220F", "\\prod"); -defineSymbol(symbols_math, main, op, "\u2211", "\\sum"); -defineSymbol(symbols_math, main, op, "\u2A02", "\\bigotimes"); -defineSymbol(symbols_math, main, op, "\u2A01", "\\bigoplus"); -defineSymbol(symbols_math, main, op, "\u2A00", "\\bigodot"); -defineSymbol(symbols_math, main, op, "\u222E", "\\oint"); -defineSymbol(symbols_math, main, op, "\u222F", "\\oiint"); -defineSymbol(symbols_math, main, op, "\u2230", "\\oiiint"); -defineSymbol(symbols_math, main, op, "\u2A06", "\\bigsqcup"); -defineSymbol(symbols_math, main, op, "\u222B", "\\smallint"); -defineSymbol(symbols_text, main, symbols_inner, "\u2026", "\\textellipsis"); -defineSymbol(symbols_math, main, symbols_inner, "\u2026", "\\mathellipsis"); -defineSymbol(symbols_text, main, symbols_inner, "\u2026", "\\ldots", true); -defineSymbol(symbols_math, main, symbols_inner, "\u2026", "\\ldots", true); -defineSymbol(symbols_math, main, symbols_inner, "\u22EF", "\\@cdots", true); -defineSymbol(symbols_math, main, symbols_inner, "\u22F1", "\\ddots", true); -defineSymbol(symbols_math, main, symbols_textord, "\u22EE", "\\varvdots"); // \vdots is a macro - -defineSymbol(symbols_math, main, symbols_accent, "\u02CA", "\\acute"); -defineSymbol(symbols_math, main, symbols_accent, "\u02CB", "\\grave"); -defineSymbol(symbols_math, main, symbols_accent, "\xA8", "\\ddot"); -defineSymbol(symbols_math, main, symbols_accent, "~", "\\tilde"); -defineSymbol(symbols_math, main, symbols_accent, "\u02C9", "\\bar"); -defineSymbol(symbols_math, main, symbols_accent, "\u02D8", "\\breve"); -defineSymbol(symbols_math, main, symbols_accent, "\u02C7", "\\check"); -defineSymbol(symbols_math, main, symbols_accent, "^", "\\hat"); -defineSymbol(symbols_math, main, symbols_accent, "\u20D7", "\\vec"); -defineSymbol(symbols_math, main, symbols_accent, "\u02D9", "\\dot"); -defineSymbol(symbols_math, main, symbols_accent, "\u02DA", "\\mathring"); -defineSymbol(symbols_math, main, mathord, "\u0131", "\\imath", true); -defineSymbol(symbols_math, main, mathord, "\u0237", "\\jmath", true); -defineSymbol(symbols_text, main, symbols_textord, "\u0131", "\\i", true); -defineSymbol(symbols_text, main, symbols_textord, "\u0237", "\\j", true); -defineSymbol(symbols_text, main, symbols_textord, "\xDF", "\\ss", true); -defineSymbol(symbols_text, main, symbols_textord, "\xE6", "\\ae", true); -defineSymbol(symbols_text, main, symbols_textord, "\xE6", "\\ae", true); -defineSymbol(symbols_text, main, symbols_textord, "\u0153", "\\oe", true); -defineSymbol(symbols_text, main, symbols_textord, "\xF8", "\\o", true); -defineSymbol(symbols_text, main, symbols_textord, "\xC6", "\\AE", true); -defineSymbol(symbols_text, main, symbols_textord, "\u0152", "\\OE", true); -defineSymbol(symbols_text, main, symbols_textord, "\xD8", "\\O", true); -defineSymbol(symbols_text, main, symbols_accent, "\u02CA", "\\'"); // acute - -defineSymbol(symbols_text, main, symbols_accent, "\u02CB", "\\`"); // grave - -defineSymbol(symbols_text, main, symbols_accent, "\u02C6", "\\^"); // circumflex - -defineSymbol(symbols_text, main, symbols_accent, "\u02DC", "\\~"); // tilde - -defineSymbol(symbols_text, main, symbols_accent, "\u02C9", "\\="); // macron - -defineSymbol(symbols_text, main, symbols_accent, "\u02D8", "\\u"); // breve - -defineSymbol(symbols_text, main, symbols_accent, "\u02D9", "\\."); // dot above - -defineSymbol(symbols_text, main, symbols_accent, "\u02DA", "\\r"); // ring above - -defineSymbol(symbols_text, main, symbols_accent, "\u02C7", "\\v"); // caron - -defineSymbol(symbols_text, main, symbols_accent, "\xA8", '\\"'); // diaresis - -defineSymbol(symbols_text, main, symbols_accent, "\u02DD", "\\H"); // double acute - -defineSymbol(symbols_text, main, symbols_accent, "\u25EF", "\\textcircled"); // \bigcirc glyph +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font + +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font + +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(symbols_text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, symbols_open, "\u27e8", "\\langle", true); +defineSymbol(math, main, symbols_open, "\u2223", "\\lvert"); +defineSymbol(math, main, symbols_open, "\u2225", "\\lVert"); +defineSymbol(math, main, symbols_close, "?", "?"); +defineSymbol(math, main, symbols_close, "!", "!"); +defineSymbol(math, main, symbols_close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, symbols_close, "\u2223", "\\rvert"); +defineSymbol(math, main, symbols_close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% + +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\ "); +defineSymbol(symbols_text, main, spacing, "\u00a0", " "); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\space"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, null, "\\nobreak"); +defineSymbol(math, main, spacing, null, "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, symbols_open, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, symbols_close, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, symbols_open, "{", "\\lbrace"); +defineSymbol(math, main, symbols_close, "}", "\\rbrace"); +defineSymbol(math, main, symbols_open, "[", "\\lbrack", true); +defineSymbol(symbols_text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, symbols_close, "]", "\\rbrack", true); +defineSymbol(symbols_text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, symbols_open, "(", "\\lparen", true); +defineSymbol(math, main, symbols_close, ")", "\\rparen", true); +defineSymbol(symbols_text, main, textord, "<", "\\textless", true); // in T1 fontenc + +defineSymbol(symbols_text, main, textord, ">", "\\textgreater", true); // in T1 fontenc + +defineSymbol(math, main, symbols_open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, symbols_close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, symbols_open, "\u2308", "\\lceil", true); +defineSymbol(math, main, symbols_close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(symbols_text, main, textord, "|", "\\textbar", true); // in T1 fontenc + +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(symbols_text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(symbols_text, main, textord, "~", "\\textasciitilde"); +defineSymbol(symbols_text, main, textord, "\\", "\\textbackslash"); +defineSymbol(symbols_text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); // \vdots is a macro + +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA + +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true); +defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true); +defineSymbol(symbols_text, main, textord, "\u00df", "\\ss", true); +defineSymbol(symbols_text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true); +defineSymbol(symbols_text, main, textord, "\u00f8", "\\o", true); +defineSymbol(symbols_text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true); +defineSymbol(symbols_text, main, textord, "\u00d8", "\\O", true); +defineSymbol(symbols_text, main, accent, "\u02ca", "\\'"); // acute + +defineSymbol(symbols_text, main, accent, "\u02cb", "\\`"); // grave + +defineSymbol(symbols_text, main, accent, "\u02c6", "\\^"); // circumflex + +defineSymbol(symbols_text, main, accent, "\u02dc", "\\~"); // tilde + +defineSymbol(symbols_text, main, accent, "\u02c9", "\\="); // macron + +defineSymbol(symbols_text, main, accent, "\u02d8", "\\u"); // breve + +defineSymbol(symbols_text, main, accent, "\u02d9", "\\."); // dot above + +defineSymbol(symbols_text, main, accent, "\u00b8", "\\c"); // cedilla + +defineSymbol(symbols_text, main, accent, "\u02da", "\\r"); // ring above + +defineSymbol(symbols_text, main, accent, "\u02c7", "\\v"); // caron + +defineSymbol(symbols_text, main, accent, "\u00a8", '\\"'); // diaresis + +defineSymbol(symbols_text, main, accent, "\u02dd", "\\H"); // double acute + +defineSymbol(symbols_text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph // These ligatures are detected and created in Parser.js's `formLigatures`. -var ligatures = { - "--": true, - "---": true, - "``": true, - "''": true -}; -defineSymbol(symbols_text, main, symbols_textord, "\u2013", "--"); -defineSymbol(symbols_text, main, symbols_textord, "\u2013", "\\textendash"); -defineSymbol(symbols_text, main, symbols_textord, "\u2014", "---"); -defineSymbol(symbols_text, main, symbols_textord, "\u2014", "\\textemdash"); -defineSymbol(symbols_text, main, symbols_textord, "\u2018", "`"); -defineSymbol(symbols_text, main, symbols_textord, "\u2018", "\\textquoteleft"); -defineSymbol(symbols_text, main, symbols_textord, "\u2019", "'"); -defineSymbol(symbols_text, main, symbols_textord, "\u2019", "\\textquoteright"); -defineSymbol(symbols_text, main, symbols_textord, "\u201C", "``"); -defineSymbol(symbols_text, main, symbols_textord, "\u201C", "\\textquotedblleft"); -defineSymbol(symbols_text, main, symbols_textord, "\u201D", "''"); -defineSymbol(symbols_text, main, symbols_textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package - -defineSymbol(symbols_math, main, symbols_textord, "\xB0", "\\degree", true); -defineSymbol(symbols_text, main, symbols_textord, "\xB0", "\\degree"); // \textdegree from inputenc package - -defineSymbol(symbols_text, main, symbols_textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math -// mode, but among our fonts, only Main-Italic defines this character "163". - -defineSymbol(symbols_math, main, mathord, "\xA3", "\\pounds"); -defineSymbol(symbols_math, main, mathord, "\xA3", "\\mathsterling", true); -defineSymbol(symbols_text, main, mathord, "\xA3", "\\pounds"); -defineSymbol(symbols_text, main, mathord, "\xA3", "\\textsterling", true); -defineSymbol(symbols_math, ams, symbols_textord, "\u2720", "\\maltese"); -defineSymbol(symbols_text, ams, symbols_textord, "\u2720", "\\maltese"); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "\\ "); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", " "); -defineSymbol(symbols_text, main, symbols_spacing, "\xA0", "~"); // There are lots of symbols which are the same, so we add them in afterwards. -// All of these are textords in math mode - -var mathTextSymbols = "0123456789/@.\""; - -for (var symbols_i = 0; symbols_i < mathTextSymbols.length; symbols_i++) { - var symbols_ch = mathTextSymbols.charAt(symbols_i); - defineSymbol(symbols_math, main, symbols_textord, symbols_ch, symbols_ch); -} // All of these are textords in text mode - - -var textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,"; - -for (var src_symbols_i = 0; src_symbols_i < textSymbols.length; src_symbols_i++) { - var _ch = textSymbols.charAt(src_symbols_i); - - defineSymbol(symbols_text, main, symbols_textord, _ch, _ch); -} // All of these are textords in text mode, and mathords in math mode - - -var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -for (var symbols_i2 = 0; symbols_i2 < letters.length; symbols_i2++) { - var _ch2 = letters.charAt(symbols_i2); - - defineSymbol(symbols_math, main, mathord, _ch2, _ch2); - defineSymbol(symbols_text, main, symbols_textord, _ch2, _ch2); -} // Blackboard bold and script letters in Unicode range - - -defineSymbol(symbols_math, ams, symbols_textord, "C", "\u2102"); // blackboard bold - -defineSymbol(symbols_text, ams, symbols_textord, "C", "\u2102"); -defineSymbol(symbols_math, ams, symbols_textord, "H", "\u210D"); -defineSymbol(symbols_text, ams, symbols_textord, "H", "\u210D"); -defineSymbol(symbols_math, ams, symbols_textord, "N", "\u2115"); -defineSymbol(symbols_text, ams, symbols_textord, "N", "\u2115"); -defineSymbol(symbols_math, ams, symbols_textord, "P", "\u2119"); -defineSymbol(symbols_text, ams, symbols_textord, "P", "\u2119"); -defineSymbol(symbols_math, ams, symbols_textord, "Q", "\u211A"); -defineSymbol(symbols_text, ams, symbols_textord, "Q", "\u211A"); -defineSymbol(symbols_math, ams, symbols_textord, "R", "\u211D"); -defineSymbol(symbols_text, ams, symbols_textord, "R", "\u211D"); -defineSymbol(symbols_math, ams, symbols_textord, "Z", "\u2124"); -defineSymbol(symbols_text, ams, symbols_textord, "Z", "\u2124"); -defineSymbol(symbols_math, main, mathord, "h", "\u210E"); // italic h, Planck constant - -defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. -// We support some letters in the Unicode range U+1D400 to U+1D7FF, -// Mathematical Alphanumeric Symbols. -// Some editors do not deal well with wide characters. So don't write the -// string into this file. Instead, create the string from the surrogate pair. - -var symbols_wideChar = ""; - -for (var symbols_i3 = 0; symbols_i3 < letters.length; symbols_i3++) { - var _ch3 = letters.charAt(symbols_i3); // The hex numbers in the next line are a surrogate pair. - // 0xD835 is the high surrogate for all letters in the range we support. - // 0xDC00 is the low surrogate for bold A. - - - symbols_wideChar = String.fromCharCode(0xD835, 0xDC00 + symbols_i3); // A-Z a-z bold - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDC34 + symbols_i3); // A-Z a-z italic - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDC68 + symbols_i3); // A-Z a-z bold italic - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDD04 + symbols_i3); // A-Z a-z Fractur - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDDA0 + symbols_i3); // A-Z a-z sans-serif - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDDD4 + symbols_i3); // A-Z a-z sans bold - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDE08 + symbols_i3); // A-Z a-z sans italic - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDE70 + symbols_i3); // A-Z a-z monospace - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - - if (symbols_i3 < 26) { - // KaTeX fonts have only capital letters for blackboard bold and script. - // See exception for k below. - symbols_wideChar = String.fromCharCode(0xD835, 0xDD38 + symbols_i3); // A-Z double struck - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDC9C + symbols_i3); // A-Z script - - defineSymbol(symbols_math, main, mathord, _ch3, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch3, symbols_wideChar); - } // TODO: Add bold script when it is supported by a KaTeX font. - -} // "k" is the only double struck lower case letter in the KaTeX fonts. - - -symbols_wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - -defineSymbol(symbols_math, main, mathord, "k", symbols_wideChar); -defineSymbol(symbols_text, main, symbols_textord, "k", symbols_wideChar); // Next, some wide character numerals - -for (var symbols_i4 = 0; symbols_i4 < 10; symbols_i4++) { - var _ch4 = symbols_i4.toString(); - - symbols_wideChar = String.fromCharCode(0xD835, 0xDFCE + symbols_i4); // 0-9 bold - - defineSymbol(symbols_math, main, mathord, _ch4, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch4, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDFE2 + symbols_i4); // 0-9 sans serif - - defineSymbol(symbols_math, main, mathord, _ch4, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch4, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDFEC + symbols_i4); // 0-9 bold sans - - defineSymbol(symbols_math, main, mathord, _ch4, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch4, symbols_wideChar); - symbols_wideChar = String.fromCharCode(0xD835, 0xDFF6 + symbols_i4); // 0-9 monospace - - defineSymbol(symbols_math, main, mathord, _ch4, symbols_wideChar); - defineSymbol(symbols_text, main, symbols_textord, _ch4, symbols_wideChar); -} // We add these Latin-1 letters as symbols for backwards-compatibility, -// but they are not actually in the font, nor are they supported by the -// Unicode accent mechanism, so they fall back to Times font and look ugly. -// TODO(edemaine): Fix this. - - -var extraLatin = "ÇÐÞçþ"; - -for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { - var _ch5 = extraLatin.charAt(_i5); - - defineSymbol(symbols_math, main, mathord, _ch5, _ch5); - defineSymbol(symbols_text, main, symbols_textord, _ch5, _ch5); -} - -defineSymbol(symbols_text, main, symbols_textord, "ð", "ð"); // Unicode versions of existing characters - -defineSymbol(symbols_text, main, symbols_textord, "\u2013", "–"); -defineSymbol(symbols_text, main, symbols_textord, "\u2014", "—"); -defineSymbol(symbols_text, main, symbols_textord, "\u2018", "‘"); -defineSymbol(symbols_text, main, symbols_textord, "\u2019", "’"); -defineSymbol(symbols_text, main, symbols_textord, "\u201C", "“"); -defineSymbol(symbols_text, main, symbols_textord, "\u201D", "”"); -// CONCATENATED MODULE: ./src/wide-character.js -/** - * This file provides support for Unicode range U+1D400 to U+1D7FF, - * Mathematical Alphanumeric Symbols. - * - * Function wideCharacterFont takes a wide character as input and returns - * the font information necessary to render it properly. - */ - -/** - * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf - * That document sorts characters into groups by font type, say bold or italic. - * - * In the arrays below, each subarray consists three elements: - * * The CSS class of that group when in math mode. - * * The CSS class of that group when in text mode. - * * The font name, so that KaTeX can get font metrics. - */ - -var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright -["mathbf", "textbf", "Main-Bold"], // a-z bold upright -["mathdefault", "textit", "Math-Italic"], // A-Z italic -["mathdefault", "textit", "Math-Italic"], // a-z italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic -// Map fancy A-Z letters to script, not calligraphic. -// This aligns with unicode-math and math fonts (except Cambria Math). -["mathscr", "textscr", "Script-Regular"], // A-Z script -["", "", ""], // a-z script. No font -["", "", ""], // A-Z bold script. No font -["", "", ""], // a-z bold script. No font -["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur -["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur -["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck -["mathbb", "textbb", "AMS-Regular"], // k double-struck -["", "", ""], // A-Z bold Fraktur No font metrics -["", "", ""], // a-z bold Fraktur. No font. -["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif -["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif -["", "", ""], // A-Z bold italic sans. No font -["", "", ""], // a-z bold italic sans. No font -["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace -["mathtt", "texttt", "Typewriter-Regular"]]; -var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold -["", "", ""], // 0-9 double-struck. No KaTeX font. -["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif -["mathtt", "texttt", "Typewriter-Regular"]]; -var wide_character_wideCharacterFont = function wideCharacterFont(wideChar, mode) { - // IE doesn't support codePointAt(). So work with the surrogate pair. - var H = wideChar.charCodeAt(0); // high surrogate - - var L = wideChar.charCodeAt(1); // low surrogate - - var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; - var j = mode === "math" ? 0 : 1; // column index for CSS class. - - if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { - // wideLatinLetterData contains exactly 26 chars on each row. - // So we can calculate the relevant row. No traverse necessary. - var i = Math.floor((codePoint - 0x1D400) / 26); - return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; - } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { - // Numerals, ten per row. - var _i = Math.floor((codePoint - 0x1D7CE) / 10); - - return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; - } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { - // dotless i or j - return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; - } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { - // Greek letters. Not supported, yet. - return ["", ""]; - } else { - // We don't support any wide characters outside 1D400–1D7FF. - throw new src_ParseError("Unsupported character: " + wideChar); - } -}; -// CONCATENATED MODULE: ./src/Options.js -/** - * This file contains information about the options that the Parser carries - * around with it while parsing. Data is held in an `Options` object, and when - * recursing, a new `Options` object can be created with the `.with*` and - * `.reset` functions. - */ - -var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. -// The size mappings are taken from TeX with \normalsize=10pt. -[1, 1, 1], // size1: [5, 5, 5] \tiny -[2, 1, 1], // size2: [6, 5, 5] -[3, 1, 1], // size3: [7, 5, 5] \scriptsize -[4, 2, 1], // size4: [8, 6, 5] \footnotesize -[5, 2, 1], // size5: [9, 6, 5] \small -[6, 3, 1], // size6: [10, 7, 5] \normalsize -[7, 4, 2], // size7: [12, 8, 6] \large -[8, 6, 3], // size8: [14.4, 10, 7] \Large -[9, 7, 6], // size9: [17.28, 12, 10] \LARGE -[10, 8, 7], // size10: [20.74, 14.4, 12] \huge -[11, 10, 9]]; -var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if -// you change size indexes, change that function. -0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; - -var sizeAtStyle = function sizeAtStyle(size, style) { - return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; -}; // In these types, "" (empty string) means "no change". - - -/** - * This is the main options class. It contains the current style, size, color, - * and font. - * - * Options objects should not be modified. To create a new Options with - * different properties, call a `.having*` method. - */ -var Options_Options = -/*#__PURE__*/ -function () { - // A font family applies to a group of fonts (i.e. SansSerif), while a font - // represents a specific font (i.e. SansSerif Bold). - // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm - - /** - * The base size index. - */ - function Options(data) { - this.style = void 0; - this.color = void 0; - this.size = void 0; - this.textSize = void 0; - this.phantom = void 0; - this.font = void 0; - this.fontFamily = void 0; - this.fontWeight = void 0; - this.fontShape = void 0; - this.sizeMultiplier = void 0; - this.maxSize = void 0; - this.minRuleThickness = void 0; - this._fontMetrics = void 0; - this.style = data.style; - this.color = data.color; - this.size = data.size || Options.BASESIZE; - this.textSize = data.textSize || this.size; - this.phantom = !!data.phantom; - this.font = data.font || ""; - this.fontFamily = data.fontFamily || ""; - this.fontWeight = data.fontWeight || ''; - this.fontShape = data.fontShape || ''; - this.sizeMultiplier = sizeMultipliers[this.size - 1]; - this.maxSize = data.maxSize; - this.minRuleThickness = data.minRuleThickness; - this._fontMetrics = undefined; - } - /** - * Returns a new options object with the same properties as "this". Properties - * from "extension" will be copied to the new options object. - */ +const ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(symbols_text, main, textord, "\u2013", "--", true); +defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash"); +defineSymbol(symbols_text, main, textord, "\u2014", "---", true); +defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(symbols_text, main, textord, "\u2018", "`", true); +defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(symbols_text, main, textord, "\u2019", "'", true); +defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(symbols_text, main, textord, "\u201c", "``", true); +defineSymbol(symbols_text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(symbols_text, main, textord, "\u201d", "''", true); +defineSymbol(symbols_text, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package + +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(symbols_text, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package + +defineSymbol(symbols_text, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". + +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +const mathTextSymbols = "0123456789/@.\""; - var _proto = Options.prototype; +for (let i = 0; i < mathTextSymbols.length; i++) { + const ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} // All of these are textords in text mode - _proto.extend = function extend(extension) { - var data = { - style: this.style, - size: this.size, - textSize: this.textSize, - color: this.color, - phantom: this.phantom, - font: this.font, - fontFamily: this.fontFamily, - fontWeight: this.fontWeight, - fontShape: this.fontShape, - maxSize: this.maxSize, - minRuleThickness: this.minRuleThickness - }; - for (var key in extension) { - if (extension.hasOwnProperty(key)) { - data[key] = extension[key]; - } - } +const textSymbols = "0123456789!@*()-=+\";:?/.,"; - return new Options(data); - } - /** - * Return an options object with the given style. If `this.style === style`, - * returns `this`. - */ - ; +for (let i = 0; i < textSymbols.length; i++) { + const ch = textSymbols.charAt(i); + defineSymbol(symbols_text, main, textord, ch, ch); +} // All of these are textords in text mode, and mathords in math mode - _proto.havingStyle = function havingStyle(style) { - if (this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: sizeAtStyle(this.textSize, style) - }); - } - } - /** - * Return an options object with a cramped version of the current style. If - * the current style is cramped, returns `this`. - */ - ; - _proto.havingCrampedStyle = function havingCrampedStyle() { - return this.havingStyle(this.style.cramp()); - } - /** - * Return an options object with the given size and in at least `\textstyle`. - * Returns `this` if appropriate. - */ - ; +const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - _proto.havingSize = function havingSize(size) { - if (this.size === size && this.textSize === size) { - return this; - } else { - return this.extend({ - style: this.style.text(), - size: size, - textSize: size, - sizeMultiplier: sizeMultipliers[size - 1] - }); - } - } - /** - * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, - * changes to at least `\textstyle`. - */ - ; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} // Blackboard bold and script letters in Unicode range - _proto.havingBaseStyle = function havingBaseStyle(style) { - style = style || this.style.text(); - var wantSize = sizeAtStyle(Options.BASESIZE, style); - if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: wantSize - }); - } - } - /** - * Remove the effect of sizing changes such as \Huge. - * Keep the effect of the current style, such as \scriptstyle. - */ - ; +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold - _proto.havingBaseSizing = function havingBaseSizing() { - var size; +defineSymbol(symbols_text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(symbols_text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(symbols_text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(symbols_text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(symbols_text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(symbols_text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(symbols_text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant - switch (this.style.id) { - case 4: - case 5: - size = 3; // normalsize in scriptstyle +defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. - break; +let wideChar = ""; - case 6: - case 7: - size = 1; // normalsize in scriptscriptstyle +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. - break; + wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold - default: - size = 6; - // normalsize in textstyle or displaystyle - } + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic - return this.extend({ - style: this.style.text(), - size: size - }); - } - /** - * Create a new options object with the given color. - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic - _proto.withColor = function withColor(color) { - return this.extend({ - color: color - }); - } - /** - * Create a new options object with "phantom" set to true. - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fractur - _proto.withPhantom = function withPhantom() { - return this.extend({ - phantom: true - }); - } - /** - * Creates a new options object with the given math font or old text font. - * @type {[type]} - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fractur - _proto.withFont = function withFont(font) { - return this.extend({ - font: font - }); - } - /** - * Create a new options objects with the given fontFamily. - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif - _proto.withTextFontFamily = function withTextFontFamily(fontFamily) { - return this.extend({ - fontFamily: fontFamily, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold - _proto.withTextFontWeight = function withTextFontWeight(fontWeight) { - return this.extend({ - fontWeight: fontWeight, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic - _proto.withTextFontShape = function withTextFontShape(fontShape) { - return this.extend({ - fontShape: fontShape, - font: "" - }); - } - /** - * Return the CSS sizing classes required to switch from enclosing options - * `oldOptions` to `this`. Returns an array of classes. - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace - _proto.sizingClasses = function sizingClasses(oldOptions) { - if (oldOptions.size !== this.size) { - return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; - } else { - return []; - } - } - /** - * Return the CSS sizing classes required to switch to the base size. Like - * `this.havingSize(BASESIZE).sizingClasses(this)`. - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); - _proto.baseSizingClasses = function baseSizingClasses() { - if (this.size !== Options.BASESIZE) { - return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; - } else { - return []; - } - } - /** - * Return the font metrics for this size. - */ - ; + if (i < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck - _proto.fontMetrics = function fontMetrics() { - if (!this._fontMetrics) { - this._fontMetrics = getGlobalMetrics(this.size); - } + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script - return this._fontMetrics; - } - /** - * Gets the CSS color of the current options object - */ - ; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + } // TODO: Add bold script when it is supported by a KaTeX font. - _proto.getColor = function getColor() { - if (this.phantom) { - return "transparent"; - } else { - return this.color; - } - }; +} // "k" is the only double struck lower case letter in the KaTeX fonts. - return Options; -}(); -Options_Options.BASESIZE = 6; -/* harmony default export */ var src_Options = (Options_Options); -// CONCATENATED MODULE: ./src/units.js -/** - * This file does conversion between units. In particular, it provides - * calculateSize to convert other units into ems. - */ +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - // This table gives the number of TeX pts in one of each *absolute* TeX unit. -// Thus, multiplying a length by this number converts the length from units -// into pts. Dividing the result by ptPerEm gives the number of ems -// *assuming* a font size of ptPerEm (normal size, normal style). +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals -var ptPerUnit = { - // https://en.wikibooks.org/wiki/LaTeX/Lengths and - // https://tex.stackexchange.com/a/8263 - "pt": 1, - // TeX point - "mm": 7227 / 2540, - // millimeter - "cm": 7227 / 254, - // centimeter - "in": 72.27, - // inch - "bp": 803 / 800, - // big (PostScript) points - "pc": 12, - // pica - "dd": 1238 / 1157, - // didot - "cc": 14856 / 1157, - // cicero (12 didot) - "nd": 685 / 642, - // new didot - "nc": 1370 / 107, - // new cicero (12 new didot) - "sp": 1 / 65536, - // scaled point (TeX's internal smallest unit) - // https://tex.stackexchange.com/a/41371 - "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +for (let i = 0; i < 10; i++) { + const ch = i.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold -}; // Dictionary of relative units, for fast validity testing. + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif -var relativeUnit = { - "ex": true, - "em": true, - "mu": true -}; + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans + + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace + + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); +} // We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. + +const extraLatin = "\u00d0\u00de\u00fe"; + +for (let i = 0; i < extraLatin.length; i++) { + const ch = extraLatin.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} +;// CONCATENATED MODULE: ./src/wide-character.js /** - * Determine whether the specified unit (either a string defining the unit - * or a "size" parse node containing a unit field) is valid. + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. */ -var validUnit = function validUnit(unit) { - if (typeof unit !== "string") { - unit = unit.unit; - } - return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; -}; -/* - * Convert a "size" parse node (with numeric "number" and string "unit" fields, - * as parsed by functions.js argType "size") into a CSS em value for the - * current style/scale. `options` gives the current options. +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each subarray consists three elements: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. */ -var units_calculateSize = function calculateSize(sizeValue, options) { - var scale; - - if (sizeValue.unit in ptPerUnit) { - // Absolute units - scale = ptPerUnit[sizeValue.unit] // Convert unit to pt - / options.fontMetrics().ptPerEm // Convert pt to CSS em - / options.sizeMultiplier; // Unscale to make absolute units - } else if (sizeValue.unit === "mu") { - // `mu` units scale with scriptstyle/scriptscriptstyle. - scale = options.fontMetrics().cssEmPerMu; - } else { - // Other relative units always refer to the *textstyle* font - // in the current size. - var unitOptions; - - if (options.style.isTight()) { - // isTight() means current style is script/scriptscript. - unitOptions = options.havingStyle(options.style.text()); - } else { - unitOptions = options; - } // TODO: In TeX these units are relative to the quad of the current - // *text* font, e.g. cmr10. KaTeX instead uses values from the - // comparably-sized *Computer Modern symbol* font. At 10pt, these - // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; - // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. - // TeX \showlists shows a kern of 1.13889 * fontsize; - // KaTeX shows a kern of 1.171 * fontsize. +const wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright +["mathbf", "textbf", "Main-Bold"], // a-z bold upright +["mathnormal", "textit", "Math-Italic"], // A-Z italic +["mathnormal", "textit", "Math-Italic"], // a-z italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +["mathscr", "textscr", "Script-Regular"], // A-Z script +["", "", ""], // a-z script. No font +["", "", ""], // A-Z bold script. No font +["", "", ""], // a-z bold script. No font +["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur +["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur +["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck +["mathbb", "textbb", "AMS-Regular"], // k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur +["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif +["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif +["", "", ""], // A-Z bold italic sans. No font +["", "", ""], // a-z bold italic sans. No font +["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace +["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace +]; +const wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold +["", "", ""], // 0-9 double-struck. No KaTeX font. +["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif +["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace +]; +const wideCharacterFont = function (wideChar, mode) { + // IE doesn't support codePointAt(). So work with the surrogate pair. + const H = wideChar.charCodeAt(0); // high surrogate + const L = wideChar.charCodeAt(1); // low surrogate - if (sizeValue.unit === "ex") { - scale = unitOptions.fontMetrics().xHeight; - } else if (sizeValue.unit === "em") { - scale = unitOptions.fontMetrics().quad; - } else { - throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); - } + const codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + const j = mode === "math" ? 0 : 1; // column index for CSS class. - if (unitOptions !== options) { - scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; - } + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + const i = Math.floor((codePoint - 0x1D400) / 26); + return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + const i = Math.floor((codePoint - 0x1D7CE) / 10); + return [wideNumeralData[i][2], wideNumeralData[i][j]]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return ["", ""]; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new src_ParseError("Unsupported character: " + wideChar); } - - return Math.min(sizeValue.number * scale, options.maxSize); }; -// CONCATENATED MODULE: ./src/buildCommon.js +;// CONCATENATED MODULE: ./src/buildCommon.js /* eslint no-console:0 */ /** @@ -5388,16 +5357,11 @@ var units_calculateSize = function calculateSize(sizeValue, options) { -// The following have to be loaded from Main-Italic font, using class mathit -var mathitLetters = ["\\imath", "ı", // dotless i -"\\jmath", "ȷ", // dotless j -"\\pounds", "\\mathsterling", "\\textsterling", "£"]; /** * Looks up the given symbol in fontMetrics, after applying any symbol * replacements defined in symbol.js */ - -var buildCommon_lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this. +const lookupSymbol = function (value, // TODO(#963): Use a union type for this. fontName, mode) { // Replace the value with its replaced value from symbol.js if (src_symbols[mode][value] && src_symbols[mode][value].replace) { @@ -5421,24 +5385,24 @@ fontName, mode) { */ -var buildCommon_makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { - var lookup = buildCommon_lookupSymbol(value, fontName, mode); - var metrics = lookup.metrics; +const makeSymbol = function (value, fontName, mode, options, classes) { + const lookup = lookupSymbol(value, fontName, mode); + const metrics = lookup.metrics; value = lookup.value; - var symbolNode; + let symbolNode; if (metrics) { - var italic = metrics.italic; + let italic = metrics.italic; if (mode === "text" || options && options.font === "mathit") { italic = 0; } - symbolNode = new domTree_SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); } else { // TODO(emily): Figure out a good way to only print this in development typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); - symbolNode = new domTree_SymbolNode(value, 0, 0, 0, 0, 0, classes); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); } if (options) { @@ -5448,7 +5412,7 @@ var buildCommon_makeSymbol = function makeSymbol(value, fontName, mode, options, symbolNode.classes.push("mtight"); } - var color = options.getColor(); + const color = options.getColor(); if (color) { symbolNode.style.color = color; @@ -5463,7 +5427,7 @@ var buildCommon_makeSymbol = function makeSymbol(value, fontName, mode, options, */ -var buildCommon_mathsym = function mathsym(value, mode, options, classes) { +const mathsym = function (value, mode, options, classes) { if (classes === void 0) { classes = []; } @@ -5475,60 +5439,12 @@ var buildCommon_mathsym = function mathsym(value, mode, options, classes) { // text ordinal and is therefore not present as a symbol in the symbols // table for text, as well as a special case for boldsymbol because it // can be used for bold + and - - if (options.font === "boldsymbol" && buildCommon_lookupSymbol(value, "Main-Bold", mode).metrics) { - return buildCommon_makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); } else if (value === "\\" || src_symbols[mode][value].font === "main") { - return buildCommon_makeSymbol(value, "Main-Regular", mode, options, classes); - } else { - return buildCommon_makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); - } -}; -/** - * Determines which of the two font names (Main-Italic and Math-Italic) and - * corresponding style tags (maindefault or mathit) to use for default math font, - * depending on the symbol. - */ - - -var buildCommon_mathdefault = function mathdefault(value, mode, options, classes) { - if (/[0-9]/.test(value.charAt(0)) || // glyphs for \imath and \jmath do not exist in Math-Italic so we - // need to use Main-Italic instead - utils.contains(mathitLetters, value)) { - return { - fontName: "Main-Italic", - fontClass: "mathit" - }; - } else { - return { - fontName: "Math-Italic", - fontClass: "mathdefault" - }; - } -}; -/** - * Determines which of the font names (Main-Italic, Math-Italic, and Caligraphic) - * and corresponding style tags (mathit, mathdefault, or mathcal) to use for font - * "mathnormal", depending on the symbol. Use this function instead of fontMap for - * font "mathnormal". - */ - - -var buildCommon_mathnormal = function mathnormal(value, mode, options, classes) { - if (utils.contains(mathitLetters, value)) { - return { - fontName: "Main-Italic", - fontClass: "mathit" - }; - } else if (/[0-9]/.test(value.charAt(0))) { - return { - fontName: "Caligraphic-Regular", - fontClass: "mathcal" - }; + return makeSymbol(value, "Main-Regular", mode, options, classes); } else { - return { - fontName: "Math-Italic", - fontClass: "mathdefault" - }; + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); } }; /** @@ -5539,8 +5455,8 @@ var buildCommon_mathnormal = function mathnormal(value, mode, options, classes) */ -var boldsymbol = function boldsymbol(value, mode, options, classes) { - if (buildCommon_lookupSymbol(value, "Math-BoldItalic", mode).metrics) { +const boldsymbol = function (value, mode, options, classes, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { return { fontName: "Math-BoldItalic", fontClass: "boldsymbol" @@ -5559,32 +5475,31 @@ var boldsymbol = function boldsymbol(value, mode, options, classes) { */ -var buildCommon_makeOrd = function makeOrd(group, options, type) { - var mode = group.mode; - var text = group.text; - var classes = ["mord"]; // Math mode or Old font (i.e. \rm) +const makeOrd = function (group, options, type) { + const mode = group.mode; + const text = group.text; + const classes = ["mord"]; // Math mode or Old font (i.e. \rm) - var isFont = mode === "math" || mode === "text" && options.font; - var fontOrFamily = isFont ? options.font : options.fontFamily; + const isFont = mode === "math" || mode === "text" && options.font; + const fontOrFamily = isFont ? options.font : options.fontFamily; + let wideFontName = ""; + let wideFontClass = ""; if (text.charCodeAt(0) === 0xD835) { - // surrogate pairs get special treatment - var _wideCharacterFont = wide_character_wideCharacterFont(text, mode), - wideFontName = _wideCharacterFont[0], - wideFontClass = _wideCharacterFont[1]; + [wideFontName, wideFontClass] = wideCharacterFont(text, mode); + } - return buildCommon_makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + if (wideFontName.length > 0) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); } else if (fontOrFamily) { - var fontName; - var fontClasses; + let fontName; + let fontClasses; - if (fontOrFamily === "boldsymbol" || fontOrFamily === "mathnormal") { - var fontData = fontOrFamily === "boldsymbol" ? boldsymbol(text, mode, options, classes) : buildCommon_mathnormal(text, mode, options, classes); + if (fontOrFamily === "boldsymbol") { + const fontData = boldsymbol(text, mode, options, classes, type); fontName = fontData.fontName; fontClasses = [fontData.fontClass]; - } else if (utils.contains(mathitLetters, text)) { - fontName = "Main-Italic"; - fontClasses = ["mathit"]; } else if (isFont) { fontName = fontMap[fontOrFamily].fontName; fontClasses = [fontOrFamily]; @@ -5593,41 +5508,37 @@ var buildCommon_makeOrd = function makeOrd(group, options, type) { fontClasses = [fontOrFamily, options.fontWeight, options.fontShape]; } - if (buildCommon_lookupSymbol(text, fontName, mode).metrics) { - return buildCommon_makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); - } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") { + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { // Deconstruct ligatures in monospace fonts (\texttt, \tt). - var parts = []; + const parts = []; - for (var i = 0; i < text.length; i++) { - parts.push(buildCommon_makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); } - return buildCommon_makeFragment(parts); + return makeFragment(parts); } } // Makes a symbol in the default font for mathords and textords. if (type === "mathord") { - var fontLookup = buildCommon_mathdefault(text, mode, options, classes); - return buildCommon_makeSymbol(text, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass])); + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); } else if (type === "textord") { - var font = src_symbols[mode][text] && src_symbols[mode][text].font; + const font = src_symbols[mode][text] && src_symbols[mode][text].font; if (font === "ams") { - var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); - - return buildCommon_makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); + const fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); } else if (font === "main" || !font) { - var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); - - return buildCommon_makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape)); + const fontName = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat(options.fontWeight, options.fontShape)); } else { // fonts added by plugins - var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class - + const fontName = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class - return buildCommon_makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape)); + return makeSymbol(text, fontName, mode, options, classes.concat(fontName, options.fontWeight, options.fontShape)); } } else { throw new Error("unexpected type: " + type + " in makeOrd"); @@ -5639,19 +5550,29 @@ var buildCommon_makeOrd = function makeOrd(group, options, type) { */ -var buildCommon_canCombine = function canCombine(prev, next) { +const canCombine = (prev, next) => { if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) { return false; + } // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + + + if (prev.classes.length === 1) { + const cls = prev.classes[0]; + + if (cls === "mbin" || cls === "mord") { + return false; + } } - for (var style in prev.style) { + for (const style in prev.style) { if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { return false; } } - for (var _style in next.style) { - if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) { + for (const style in next.style) { + if (next.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { return false; } } @@ -5659,17 +5580,17 @@ var buildCommon_canCombine = function canCombine(prev, next) { return true; }; /** - * Combine consequetive domTree.symbolNodes into a single symbolNode. + * Combine consecutive domTree.symbolNodes into a single symbolNode. * Note: this function mutates the argument. */ -var buildCommon_tryCombineChars = function tryCombineChars(chars) { - for (var i = 0; i < chars.length - 1; i++) { - var prev = chars[i]; - var next = chars[i + 1]; +const tryCombineChars = chars => { + for (let i = 0; i < chars.length - 1; i++) { + const prev = chars[i]; + const next = chars[i + 1]; - if (prev instanceof domTree_SymbolNode && next instanceof domTree_SymbolNode && buildCommon_canCombine(prev, next)) { + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { prev.text += next.text; prev.height = Math.max(prev.height, next.height); prev.depth = Math.max(prev.depth, next.depth); // Use the last character's italic correction since we use @@ -5690,13 +5611,13 @@ var buildCommon_tryCombineChars = function tryCombineChars(chars) { */ -var sizeElementFromChildren = function sizeElementFromChildren(elem) { - var height = 0; - var depth = 0; - var maxFontSize = 0; +const sizeElementFromChildren = function (elem) { + let height = 0; + let depth = 0; + let maxFontSize = 0; - for (var i = 0; i < elem.children.length; i++) { - var child = elem.children[i]; + for (let i = 0; i < elem.children.length; i++) { + const child = elem.children[i]; if (child.height > height) { height = child.height; @@ -5725,22 +5646,20 @@ var sizeElementFromChildren = function sizeElementFromChildren(elem) { */ -var buildCommon_makeSpan = function makeSpan(classes, children, options, style) { - var span = new domTree_Span(classes, children, options, style); +const makeSpan = function (classes, children, options, style) { + const span = new Span(classes, children, options, style); sizeElementFromChildren(span); return span; }; // SVG one is simpler -- doesn't require height, depth, max-font setting. // This is also a separate method for typesafety. -var buildCommon_makeSvgSpan = function makeSvgSpan(classes, children, options, style) { - return new domTree_Span(classes, children, options, style); -}; +const makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); -var makeLineSpan = function makeLineSpan(className, options, thickness) { - var line = buildCommon_makeSpan([className], [], options); +const makeLineSpan = function (className, options, thickness) { + const line = makeSpan([className], [], options); line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); - line.style.borderBottomWidth = line.height + "em"; + line.style.borderBottomWidth = makeEm(line.height); line.maxFontSize = 1.0; return line; }; @@ -5750,8 +5669,8 @@ var makeLineSpan = function makeLineSpan(className, options, thickness) { */ -var buildCommon_makeAnchor = function makeAnchor(href, classes, children, options) { - var anchor = new domTree_Anchor(href, classes, children, options); +const makeAnchor = function (href, classes, children, options) { + const anchor = new Anchor(href, classes, children, options); sizeElementFromChildren(anchor); return anchor; }; @@ -5760,8 +5679,8 @@ var buildCommon_makeAnchor = function makeAnchor(href, classes, children, option */ -var buildCommon_makeFragment = function makeFragment(children) { - var fragment = new tree_DocumentFragment(children); +const makeFragment = function (children) { + const fragment = new DocumentFragment(children); sizeElementFromChildren(fragment); return fragment; }; @@ -5771,9 +5690,9 @@ var buildCommon_makeFragment = function makeFragment(children) { */ -var buildCommon_wrapFragment = function wrapFragment(group, options) { - if (group instanceof tree_DocumentFragment) { - return buildCommon_makeSpan([], [group], options); +const wrapFragment = function (group, options) { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); } return group; @@ -5784,42 +5703,41 @@ var buildCommon_wrapFragment = function wrapFragment(group, options) { // // This helper function for makeVList makes it easier to enforce type safety by // allowing early exits (returns) in the logic. -var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { +const getVListChildrenAndDepth = function (params) { if (params.positionType === "individualShift") { - var oldChildren = params.children; - var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be + const oldChildren = params.children; + const children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be // shifted to the correct specified shift - var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + let currPos = depth; - var currPos = _depth; - - for (var i = 1; i < oldChildren.length; i++) { - var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; - var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + for (let i = 1; i < oldChildren.length; i++) { + const diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + const size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); currPos = currPos + diff; children.push({ type: "kern", - size: size + size }); children.push(oldChildren[i]); } return { - children: children, - depth: _depth + children, + depth }; } - var depth; + let depth; if (params.positionType === "top") { // We always start at the bottom, so calculate the bottom by adding up // all the sizes - var bottom = params.positionData; + let bottom = params.positionData; - for (var _i = 0; _i < params.children.length; _i++) { - var child = params.children[_i]; + for (let i = 0; i < params.children.length; i++) { + const child = params.children[i]; bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; } @@ -5827,7 +5745,7 @@ var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { } else if (params.positionType === "bottom") { depth = -params.positionData; } else { - var firstChild = params.children[0]; + const firstChild = params.children[0]; if (firstChild.type !== "elem") { throw new Error('First child must have type "elem".'); @@ -5844,7 +5762,7 @@ var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { return { children: params.children, - depth: depth + depth }; }; /** @@ -5855,10 +5773,11 @@ var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { */ -var buildCommon_makeVList = function makeVList(params, options) { - var _getVListChildrenAndD = getVListChildrenAndDepth(params), - children = _getVListChildrenAndD.children, - depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to +const makeVList = function (params, options) { + const { + children, + depth + } = getVListChildrenAndDepth(params); // Create a strut that is taller than any list item. The strut is added to // each item, where it will determine the item's baseline. Since it has // `overflow:hidden`, the strut's top edge will sit on the item's line box's // top edge and the strut's bottom edge will sit on the item's baseline, @@ -5866,49 +5785,48 @@ var buildCommon_makeVList = function makeVList(params, options) { // be positioned precisely without worrying about font ascent and // line-height. + let pstrutSize = 0; - var pstrutSize = 0; - - for (var i = 0; i < children.length; i++) { - var child = children[i]; + for (let i = 0; i < children.length; i++) { + const child = children[i]; if (child.type === "elem") { - var elem = child.elem; + const elem = child.elem; pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); } } pstrutSize += 2; - var pstrut = buildCommon_makeSpan(["pstrut"], []); - pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets + const pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets - var realChildren = []; - var minPos = depth; - var maxPos = depth; - var currPos = depth; + const realChildren = []; + let minPos = depth; + let maxPos = depth; + let currPos = depth; - for (var _i2 = 0; _i2 < children.length; _i2++) { - var _child = children[_i2]; + for (let i = 0; i < children.length; i++) { + const child = children[i]; - if (_child.type === "kern") { - currPos += _child.size; + if (child.type === "kern") { + currPos += child.size; } else { - var _elem = _child.elem; - var classes = _child.wrapperClasses || []; - var style = _child.wrapperStyle || {}; - var childWrap = buildCommon_makeSpan(classes, [pstrut, _elem], undefined, style); - childWrap.style.top = -pstrutSize - currPos - _elem.depth + "em"; - - if (_child.marginLeft) { - childWrap.style.marginLeft = _child.marginLeft; + const elem = child.elem; + const classes = child.wrapperClasses || []; + const style = child.wrapperStyle || {}; + const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth); + + if (child.marginLeft) { + childWrap.style.marginLeft = child.marginLeft; } - if (_child.marginRight) { - childWrap.style.marginRight = _child.marginRight; + if (child.marginRight) { + childWrap.style.marginRight = child.marginRight; } realChildren.push(childWrap); - currPos += _elem.height + _elem.depth; + currPos += elem.height + elem.depth; } minPos = Math.min(minPos, currPos); @@ -5918,10 +5836,10 @@ var buildCommon_makeVList = function makeVList(params, options) { // without overly expanding the containing line-box. - var vlist = buildCommon_makeSpan(["vlist"], realChildren); - vlist.style.height = maxPos + "em"; // A second row is used if necessary to represent the vlist's depth. + const vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth. - var rows; + let rows; if (minPos < 0) { // We will define depth in an empty span with display: table-cell. @@ -5929,18 +5847,18 @@ var buildCommon_makeVList = function makeVList(params, options) { // contenteditable mode only, treats that span as if it contains some // text content. And that min-height over-rides our desired height. // So we put another empty span inside the depth strut span. - var emptySpan = buildCommon_makeSpan([], []); - var depthStrut = buildCommon_makeSpan(["vlist"], [emptySpan]); - depthStrut.style.height = -minPos + "em"; // Safari wants the first row to have inline content; otherwise it + const emptySpan = makeSpan([], []); + const depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it // puts the bottom of the *second* row on the baseline. - var topStrut = buildCommon_makeSpan(["vlist-s"], [new domTree_SymbolNode("\u200B")]); - rows = [buildCommon_makeSpan(["vlist-r"], [vlist, topStrut]), buildCommon_makeSpan(["vlist-r"], [depthStrut])]; + const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; } else { - rows = [buildCommon_makeSpan(["vlist-r"], [vlist])]; + rows = [makeSpan(["vlist-r"], [vlist])]; } - var vtable = buildCommon_makeSpan(["vlist-t"], rows); + const vtable = makeSpan(["vlist-t"], rows); if (rows.length === 2) { vtable.classes.push("vlist-t2"); @@ -5954,17 +5872,17 @@ var buildCommon_makeVList = function makeVList(params, options) { // static space between elements in a horizontal layout. -var buildCommon_makeGlue = function makeGlue(measurement, options) { +const makeGlue = (measurement, options) => { // Make an empty span for the space - var rule = buildCommon_makeSpan(["mspace"], [], options); - var size = units_calculateSize(measurement, options); - rule.style.marginRight = size + "em"; + const rule = makeSpan(["mspace"], [], options); + const size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); return rule; }; // Takes font options, and returns the appropriate fontLookup name -var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) { - var baseFontName = ""; +const retrieveTextFontName = function (fontFamily, fontWeight, fontShape) { + let baseFontName = ""; switch (fontFamily) { case "amsrm": @@ -5988,7 +5906,7 @@ var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, // use fonts added by a plugin } - var fontStylesName; + let fontStylesName; if (fontWeight === "textbf" && fontShape === "textit") { fontStylesName = "BoldItalic"; @@ -6010,7 +5928,7 @@ var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, // A map between tex font commands an MathML mathvariant attribute values -var fontMap = { +const fontMap = { // styles "mathbf": { variant: "bold", @@ -6028,12 +5946,13 @@ var fontMap = { variant: "italic", fontName: "Main-Italic" }, - // Default math font, "mathnormal" and "boldsymbol" are missing because they - // require the use of several fonts: Main-Italic and Math-Italic for default - // math font, Main-Italic, Math-Italic, Caligraphic for "mathnormal", and - // Math-BoldItalic and Main-Bold for "boldsymbol". This is handled by a - // special case in makeOrd which ends up calling mathdefault, mathnormal, - // and boldsymbol. + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. // families "mathbb": { variant: "double-struck", @@ -6060,7 +5979,7 @@ var fontMap = { fontName: "Typewriter-Regular" } }; -var svgData = { +const svgData = { // path, width, height vec: ["vec", 0.471, 0.714], // values from the font glyph @@ -6071,140 +5990,55 @@ var svgData = { oiiintSize2: ["oiiintSize2", 1.98, 0.659] }; -var buildCommon_staticSvg = function staticSvg(value, options) { +const staticSvg = function (value, options) { // Create a span with inline SVG for the element. - var _svgData$value = svgData[value], - pathName = _svgData$value[0], - width = _svgData$value[1], - height = _svgData$value[2]; - var path = new domTree_PathNode(pathName); - var svgNode = new SvgNode([path], { - "width": width + "em", - "height": height + "em", + const [pathName, width, height] = svgData[value]; + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), // Override CSS rule `.katex svg { width: 100% }` - "style": "width:" + width + "em", + "style": "width:" + makeEm(width), "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, "preserveAspectRatio": "xMinYMin" }); - var span = buildCommon_makeSvgSpan(["overlay"], [svgNode], options); + const span = makeSvgSpan(["overlay"], [svgNode], options); span.height = height; - span.style.height = height + "em"; - span.style.width = width + "em"; + span.style.height = makeEm(height); + span.style.width = makeEm(width); return span; }; /* harmony default export */ var buildCommon = ({ - fontMap: fontMap, - makeSymbol: buildCommon_makeSymbol, - mathsym: buildCommon_mathsym, - makeSpan: buildCommon_makeSpan, - makeSvgSpan: buildCommon_makeSvgSpan, - makeLineSpan: makeLineSpan, - makeAnchor: buildCommon_makeAnchor, - makeFragment: buildCommon_makeFragment, - wrapFragment: buildCommon_wrapFragment, - makeVList: buildCommon_makeVList, - makeOrd: buildCommon_makeOrd, - makeGlue: buildCommon_makeGlue, - staticSvg: buildCommon_staticSvg, - svgData: svgData, - tryCombineChars: buildCommon_tryCombineChars + fontMap, + makeSymbol, + mathsym, + makeSpan, + makeSvgSpan, + makeLineSpan, + makeAnchor, + makeFragment, + wrapFragment, + makeVList, + makeOrd, + makeGlue, + staticSvg, + svgData, + tryCombineChars }); -// CONCATENATED MODULE: ./src/parseNode.js - - -/** - * Asserts that the node is of the given type and returns it with stricter - * typing. Throws if the node's type does not match. - */ -function assertNodeType(node, type) { - var typedNode = checkNodeType(node, type); - - if (!typedNode) { - throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); - } // $FlowFixMe: Unsure why. - - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkNodeType(node, type) { - if (node && node.type === type) { - // The definition of ParseNode doesn't communicate to flow that - // `type: TYPE` (as that's not explicitly mentioned anywhere), though that - // happens to be true for all our value types. - // $FlowFixMe - return node; - } - - return null; -} -/** - * Asserts that the node is of the given type and returns it with stricter - * typing. Throws if the node's type does not match. - */ - -function assertAtomFamily(node, family) { - var typedNode = checkAtomFamily(node, family); - - if (!typedNode) { - throw new Error("Expected node of type \"atom\" and family \"" + family + "\", but got " + (node ? node.type === "atom" ? "atom of family " + node.family : "node of type " + node.type : String(node))); - } - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkAtomFamily(node, family) { - return node && node.type === "atom" && node.family === family ? node : null; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function assertSymbolNodeType(node) { - var typedNode = checkSymbolNodeType(node); - - if (!typedNode) { - throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); - } - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkSymbolNodeType(node) { - if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { - // $FlowFixMe - return node; - } - - return null; -} -// CONCATENATED MODULE: ./src/spacingData.js +;// CONCATENATED MODULE: ./src/spacingData.js /** * Describes spaces between different classes of atoms. */ -var thinspace = { +const thinspace = { number: 3, unit: "mu" }; -var mediumspace = { +const mediumspace = { number: 4, unit: "mu" }; -var thickspace = { +const thickspace = { number: 5, unit: "mu" }; // Making the type below exact with all optional fields doesn't work due to @@ -6214,7 +6048,7 @@ var thickspace = { // above. // Spacing relationships for display and text styles -var spacings = { +const spacings = { mord: { mop: thinspace, mbin: mediumspace, @@ -6266,7 +6100,7 @@ var spacings = { } }; // Spacing relationships for script and scriptscript styles -var tightSpacings = { +const tightSpacings = { mord: { mop: thinspace }, @@ -6285,48 +6119,64 @@ var tightSpacings = { mop: thinspace } }; -// CONCATENATED MODULE: ./src/defineFunction.js +;// CONCATENATED MODULE: ./src/defineFunction.js +/** Context provided to function handlers for error messages. */ +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ /** * All registered functions. * `functions.js` just exports this same dictionary again and makes it public. * `Parser.js` requires this dictionary. */ -var _functions = {}; +const _functions = {}; /** * All HTML builders. Should be only used in the `define*` and the `build*ML` * functions. */ -var _htmlGroupBuilders = {}; +const _htmlGroupBuilders = {}; /** * All MathML builders. Should be only used in the `define*` and the `build*ML` * functions. */ -var _mathmlGroupBuilders = {}; +const _mathmlGroupBuilders = {}; function defineFunction(_ref) { - var type = _ref.type, - names = _ref.names, - props = _ref.props, - handler = _ref.handler, - htmlBuilder = _ref.htmlBuilder, - mathmlBuilder = _ref.mathmlBuilder; + let { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; // Set default values of functions - var data = { - type: type, + const data = { + type, numArgs: props.numArgs, argTypes: props.argTypes, - greediness: props.greediness === undefined ? 1 : props.greediness, + allowedInArgument: !!props.allowedInArgument, allowedInText: !!props.allowedInText, allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, numOptionalArgs: props.numOptionalArgs || 0, infix: !!props.infix, + primitive: !!props.primitive, handler: handler }; - for (var i = 0; i < names.length; ++i) { + for (let i = 0; i < names.length; ++i) { _functions[names[i]] = data; } @@ -6347,29 +6197,35 @@ function defineFunction(_ref) { */ function defineFunctionBuilders(_ref2) { - var type = _ref2.type, - htmlBuilder = _ref2.htmlBuilder, - mathmlBuilder = _ref2.mathmlBuilder; + let { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; defineFunction({ - type: type, + type, names: [], props: { numArgs: 0 }, - handler: function handler() { + + handler() { throw new Error('Should never be called.'); }, - htmlBuilder: htmlBuilder, - mathmlBuilder: mathmlBuilder + + htmlBuilder, + mathmlBuilder }); -} // Since the corresponding buildHTML/buildMathML function expects a +} +const normalizeArgument = function (arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; // Since the corresponding buildHTML/buildMathML function expects a // list of elements, we normalize for different kinds of arguments -var defineFunction_ordargument = function ordargument(arg) { - var node = checkNodeType(arg, "ordgroup"); - return node ? node.body : [arg]; +const ordargument = function (arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; }; -// CONCATENATED MODULE: ./src/buildHTML.js +;// CONCATENATED MODULE: ./src/buildHTML.js /** * This file does the main work of building a domTree structure from a parse * tree. The entry point is the `buildHTML` function, which takes a parse tree. @@ -6385,19 +6241,19 @@ var defineFunction_ordargument = function ordargument(arg) { -var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +const buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, // and the text before Rule 19. -var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; -var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; -var styleMap = { +const binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; +const binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; +const styleMap = { "display": src_Style.DISPLAY, "text": src_Style.TEXT, "script": src_Style.SCRIPT, "scriptscript": src_Style.SCRIPTSCRIPT }; -var DomEnum = { +const DomEnum = { mord: "mord", mop: "mop", mbin: "mbin", @@ -6416,38 +6272,39 @@ var DomEnum = { * a partial group (e.g. one created by \color). `surrounding` is an array * consisting type of nodes that will be added to the left and right. */ -var buildHTML_buildExpression = function buildExpression(expression, options, isRealGroup, surrounding) { +const buildExpression = function (expression, options, isRealGroup, surrounding) { if (surrounding === void 0) { surrounding = [null, null]; } // Parse expressions into `groups`. - var groups = []; + const groups = []; - for (var i = 0; i < expression.length; i++) { - var output = buildHTML_buildGroup(expression[i], options); + for (let i = 0; i < expression.length; i++) { + const output = buildGroup(expression[i], options); - if (output instanceof tree_DocumentFragment) { - var children = output.children; - groups.push.apply(groups, children); + if (output instanceof DocumentFragment) { + const children = output.children; + groups.push(...children); } else { groups.push(output); } - } // If `expression` is a partial group, let the parent handle spacings - // to avoid processing groups multiple times. + } // Combine consecutive domTree.symbolNodes into a single symbolNode. + buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { return groups; } - var glueOptions = options; + let glueOptions = options; if (expression.length === 1) { - var node = checkNodeType(expression[0], "sizing") || checkNodeType(expression[0], "styling"); + const node = expression[0]; - if (!node) {// No match. - } else if (node.type === "sizing") { + if (node.type === "sizing") { glueOptions = options.havingSize(node.size); } else if (node.type === "styling") { glueOptions = options.havingStyle(styleMap[node.style]); @@ -6457,16 +6314,17 @@ var buildHTML_buildExpression = function buildExpression(expression, options, is // or "rightmost", respectively, is used to indicate it. - var dummyPrev = buildHTML_makeSpan([surrounding[0] || "leftmost"], [], options); - var dummyNext = buildHTML_makeSpan([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element + const dummyPrev = buildHTML_makeSpan([surrounding[0] || "leftmost"], [], options); + const dummyNext = buildHTML_makeSpan([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element // of its `classes` array. A later cleanup should ensure this, for // instance by changing the signature of `makeSpan`. // Before determining what spaces to insert, perform bin cancellation. // Binary operators change to ordinary symbols in some contexts. - traverseNonSpaceNodes(groups, function (node, prev) { - var prevType = prev.classes[0]; - var type = node.classes[0]; + const isRoot = isRealGroup === "root"; + traverseNonSpaceNodes(groups, (node, prev) => { + const prevType = prev.classes[0]; + const type = node.classes[0]; if (prevType === "mbin" && utils.contains(binRightCanceller, type)) { prev.classes[0] = "mord"; @@ -6475,12 +6333,12 @@ var buildHTML_buildExpression = function buildExpression(expression, options, is } }, { node: dummyPrev - }, dummyNext); - traverseNonSpaceNodes(groups, function (node, prev) { - var prevType = getTypeOfDomTree(prev); - var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. + }, dummyNext, isRoot); + traverseNonSpaceNodes(groups, (node, prev) => { + const prevType = getTypeOfDomTree(prev); + const type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. - var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; + const space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; if (space) { // Insert glue (spacing) after the `prev`. @@ -6488,7 +6346,7 @@ var buildHTML_buildExpression = function buildExpression(expression, options, is } }, { node: dummyPrev - }, dummyNext); + }, dummyNext, isRoot); return groups; }; // Depth-first traverse non-space `nodes`, calling `callback` with the current and // previous node as arguments, optionally returning a node to insert after the @@ -6496,51 +6354,53 @@ var buildHTML_buildExpression = function buildExpression(expression, options, is // function to insert after it. `next` is a node that will be added to the right. // Used for bin cancellation and inserting spacings. -var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next) { +const traverseNonSpaceNodes = function (nodes, callback, prev, next, isRoot) { if (next) { // temporarily append the right node, if exists nodes.push(next); } - var i = 0; + let i = 0; for (; i < nodes.length; i++) { - var node = nodes[i]; - var partialGroup = buildHTML_checkPartialGroup(node); + const node = nodes[i]; + const partialGroup = checkPartialGroup(node); if (partialGroup) { // Recursive DFS // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array - traverseNonSpaceNodes(partialGroup.children, callback, prev); + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); continue; } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit // spacing should go between atoms of different classes - if (node.classes[0] === "mspace") { - continue; - } + const nonspace = !node.hasClass("mspace"); - var result = callback(node, prev.node); + if (nonspace) { + const result = callback(node, prev.node); - if (result) { - if (prev.insertAfter) { - prev.insertAfter(result); - } else { - // insert at front - nodes.unshift(result); - i++; + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } } } - prev.node = node; + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = buildHTML_makeSpan(["leftmost"]); // treat like beginning of line + } - prev.insertAfter = function (index) { - return function (n) { - nodes.splice(index + 1, 0, n); - i++; - }; - }(i); + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); } if (next) { @@ -6549,8 +6409,8 @@ var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev }; // Check if given node is a partial group, i.e., does not affect spacing around. -var buildHTML_checkPartialGroup = function checkPartialGroup(node) { - if (node instanceof tree_DocumentFragment || node instanceof domTree_Anchor) { +const checkPartialGroup = function (node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { return node; } @@ -6558,11 +6418,11 @@ var buildHTML_checkPartialGroup = function checkPartialGroup(node) { }; // Return the outermost node of a domTree. -var getOutermostNode = function getOutermostNode(node, side) { - var partialGroup = buildHTML_checkPartialGroup(node); +const getOutermostNode = function (node, side) { + const partialGroup = checkPartialGroup(node); if (partialGroup) { - var children = partialGroup.children; + const children = partialGroup.children; if (children.length) { if (side === "right") { @@ -6578,7 +6438,7 @@ var getOutermostNode = function getOutermostNode(node, side) { // If `side` is given, it will get the type of the outermost node at given side. -var getTypeOfDomTree = function getTypeOfDomTree(node, side) { +const getTypeOfDomTree = function (node, side) { if (!node) { return null; } @@ -6591,8 +6451,8 @@ var getTypeOfDomTree = function getTypeOfDomTree(node, side) { return DomEnum[node.classes[0]] || null; }; -var makeNullDelimiter = function makeNullDelimiter(options, classes) { - var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); +const makeNullDelimiter = function (options, classes) { + const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); return buildHTML_makeSpan(classes.concat(moreClasses)); }; /** @@ -6601,19 +6461,20 @@ var makeNullDelimiter = function makeNullDelimiter(options, classes) { * between parents and children. */ -var buildHTML_buildGroup = function buildGroup(group, options, baseOptions) { +const buildGroup = function (group, options, baseOptions) { if (!group) { return buildHTML_makeSpan(); } if (_htmlGroupBuilders[group.type]) { // Call the groupBuilders function - var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account + // $FlowFixMe + let groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account // for that size difference. if (baseOptions && options.size !== baseOptions.size) { groupNode = buildHTML_makeSpan(options.sizingClasses(baseOptions), [groupNode], options); - var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; groupNode.height *= multiplier; groupNode.depth *= multiplier; } @@ -6632,17 +6493,17 @@ var buildHTML_buildGroup = function buildGroup(group, options, baseOptions) { function buildHTMLUnbreakable(children, options) { // Compute height and depth of this chunk. - var body = buildHTML_makeSpan(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at + const body = buildHTML_makeSpan(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at // the height of the expression, and the bottom of the HTML element // falls at the depth of the expression. - // We used to have separate top and bottom struts, where the bottom strut - // would like to use `vertical-align: top`, but in IE 9 this lowers the - // baseline of the box to the bottom of this strut (instead of staying in - // the normal place) so we use an absolute value for vertical-align instead. - - var strut = buildHTML_makeSpan(["strut"]); - strut.style.height = body.height + body.depth + "em"; - strut.style.verticalAlign = -body.depth + "em"; + + const strut = buildHTML_makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); return body; } @@ -6654,7 +6515,7 @@ function buildHTMLUnbreakable(children, options) { function buildHTML(tree, options) { // Strip off outer tag wrapper for processing below. - var tag = null; + let tag = null; if (tree.length === 1 && tree[0].type === "tag") { tag = tree[0].tag; @@ -6662,23 +6523,30 @@ function buildHTML(tree, options) { } // Build the expression contained in the tree - var expression = buildHTML_buildExpression(tree, options, true); - var children = []; // Create one base node for each chunk between potential line breaks. + const expression = buildExpression(tree, options, "root"); + let eqnNum; + + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + const children = []; // Create one base node for each chunk between potential line breaks. // The TeXBook [p.173] says "A formula will be broken only after a // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary // operation symbol like $+$ or $-$ or $\times$, where the relation or // binary operation is on the ``outer level'' of the formula (i.e., not // enclosed in {...} and not part of an \over construction)." - var parts = []; + let parts = []; - for (var i = 0; i < expression.length; i++) { + for (let i = 0; i < expression.length; i++) { parts.push(expression[i]); if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { // Put any post-operator glue on same line as operator. // Watch for \nobreak along the way, and stop at \newline. - var nobreak = false; + let nobreak = false; while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { i++; @@ -6713,40 +6581,47 @@ function buildHTML(tree, options) { } // Now, if there was a tag, build it too and append it as a final child. - var tagChild; + let tagChild; if (tag) { - tagChild = buildHTMLUnbreakable(buildHTML_buildExpression(tag, options, true)); + tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true)); tagChild.classes = ["tag"]; children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); } - var htmlNode = buildHTML_makeSpan(["katex-html"], children); + const htmlNode = buildHTML_makeSpan(["katex-html"], children); htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children // (the height of the enclosing htmlNode) for proper vertical alignment. if (tagChild) { - var strut = tagChild.children[0]; - strut.style.height = htmlNode.height + htmlNode.depth + "em"; - strut.style.verticalAlign = -htmlNode.depth + "em"; + const strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } } return htmlNode; } -// CONCATENATED MODULE: ./src/mathMLTree.js +;// CONCATENATED MODULE: ./src/mathMLTree.js /** * These objects store data about MathML nodes. This is the MathML equivalent * of the types in domTree.js. Since MathML handles its own rendering, and * since we're mainly using MathML to improve accessibility, we don't manage * any of the styling state that the plain DOM nodes do. * - * The `toNode` and `toMarkup` functions work simlarly to how they do in + * The `toNode` and `toMarkup` functions work similarly to how they do in * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. */ + + function newDocumentFragment(children) { - return new tree_DocumentFragment(children); + return new DocumentFragment(children); } /** * This node represents a general purpose MathML node of any type. The @@ -6754,16 +6629,16 @@ function newDocumentFragment(children) { * `"mspace"`, corresponding to `` and `` tags). */ -var mathMLTree_MathNode = -/*#__PURE__*/ -function () { - function MathNode(type, children) { +class MathNode { + constructor(type, children, classes) { this.type = void 0; this.attributes = void 0; this.children = void 0; + this.classes = void 0; this.type = type; this.attributes = {}; this.children = children || []; + this.classes = classes || []; } /** * Sets an attribute on a MathML node. MathML depends on attributes to convey a @@ -6771,34 +6646,36 @@ function () { */ - var _proto = MathNode.prototype; - - _proto.setAttribute = function setAttribute(name, value) { + setAttribute(name, value) { this.attributes[name] = value; } /** * Gets an attribute on a MathML node. */ - ; - _proto.getAttribute = function getAttribute(name) { + + getAttribute(name) { return this.attributes[name]; } /** * Converts the math node into a MathML-namespaced DOM element. */ - ; - _proto.toNode = function toNode() { - var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); - for (var attr in this.attributes) { + toNode() { + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + + for (const attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { node.setAttribute(attr, this.attributes[attr]); } } - for (var i = 0; i < this.children.length; i++) { + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (let i = 0; i < this.children.length; i++) { node.appendChild(this.children[i].toNode()); } @@ -6807,12 +6684,12 @@ function () { /** * Converts the math node into an HTML markup string. */ - ; - _proto.toMarkup = function toMarkup() { - var markup = "<" + this.type; // Add the attributes - for (var attr in this.attributes) { + toMarkup() { + let markup = "<" + this.type; // Add the attributes + + for (const attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { markup += " " + attr + "=\""; markup += utils.escape(this.attributes[attr]); @@ -6820,9 +6697,13 @@ function () { } } + if (this.classes.length > 0) { + markup += " class =\"" + utils.escape(createClass(this.classes)) + "\""; + } + markup += ">"; - for (var i = 0; i < this.children.length; i++) { + for (let i = 0; i < this.children.length; i++) { markup += this.children[i].toMarkup(); } @@ -6832,24 +6713,19 @@ function () { /** * Converts the math node into a string, similar to innerText, but escaped. */ - ; - _proto.toText = function toText() { - return this.children.map(function (child) { - return child.toText(); - }).join(""); - }; - return MathNode; -}(); + toText() { + return this.children.map(child => child.toText()).join(""); + } + +} /** * This node represents a piece of text. */ -var mathMLTree_TextNode = -/*#__PURE__*/ -function () { - function TextNode(text) { +class TextNode { + constructor(text) { this.text = void 0; this.text = text; } @@ -6858,44 +6734,39 @@ function () { */ - var _proto2 = TextNode.prototype; - - _proto2.toNode = function toNode() { + toNode() { return document.createTextNode(this.text); } /** * Converts the text node into escaped HTML markup * (representing the text itself). */ - ; - _proto2.toMarkup = function toMarkup() { + + toMarkup() { return utils.escape(this.toText()); } /** * Converts the text node into a string - * (representing the text iteself). + * (representing the text itself). */ - ; - _proto2.toText = function toText() { + + toText() { return this.text; - }; + } - return TextNode; -}(); +} /** * This node represents a space, but may render as or as text, * depending on the width. */ -var SpaceNode = -/*#__PURE__*/ -function () { +class SpaceNode { /** * Create a Space node with width given in CSS ems. */ - function SpaceNode(width) { + constructor(width) { this.width = void 0; this.character = void 0; this.width = width; // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html @@ -6904,19 +6775,19 @@ function () { // make the latter via document.createTextNode. if (width >= 0.05555 && width <= 0.05556) { - this.character = "\u200A"; //   + this.character = "\u200a"; //   } else if (width >= 0.1666 && width <= 0.1667) { this.character = "\u2009"; //   } else if (width >= 0.2222 && width <= 0.2223) { this.character = "\u2005"; //   } else if (width >= 0.2777 && width <= 0.2778) { - this.character = "\u2005\u200A"; //    + this.character = "\u2005\u200a"; //    } else if (width >= -0.05556 && width <= -0.05555) { - this.character = "\u200A\u2063"; // ​ + this.character = "\u200a\u2063"; // ​ } else if (width >= -0.1667 && width <= -0.1666) { this.character = "\u2009\u2063"; // ​ } else if (width >= -0.2223 && width <= -0.2222) { - this.character = "\u205F\u2063"; // ​ + this.character = "\u205f\u2063"; // ​ } else if (width >= -0.2778 && width <= -0.2777) { this.character = "\u2005\u2063"; // ​ } else { @@ -6928,54 +6799,51 @@ function () { */ - var _proto3 = SpaceNode.prototype; - - _proto3.toNode = function toNode() { + toNode() { if (this.character) { return document.createTextNode(this.character); } else { - var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); - node.setAttribute("width", this.width + "em"); + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); return node; } } /** * Converts the math node into an HTML markup string. */ - ; - _proto3.toMarkup = function toMarkup() { + + toMarkup() { if (this.character) { return "" + this.character + ""; } else { - return ""; + return ""; } } /** * Converts the math node into a string, similar to innerText. */ - ; - _proto3.toText = function toText() { + + toText() { if (this.character) { return this.character; } else { return " "; } - }; + } - return SpaceNode; -}(); +} /* harmony default export */ var mathMLTree = ({ - MathNode: mathMLTree_MathNode, - TextNode: mathMLTree_TextNode, - SpaceNode: SpaceNode, - newDocumentFragment: newDocumentFragment + MathNode, + TextNode, + SpaceNode, + newDocumentFragment }); -// CONCATENATED MODULE: ./src/buildMathML.js +;// CONCATENATED MODULE: ./src/buildMathML.js /** - * This file converts a parse tree into a cooresponding MathML tree. The main + * This file converts a parse tree into a corresponding MathML tree. The main * entry point is the `buildMathML` function, which takes a parse tree from the * parser. */ @@ -6992,8 +6860,8 @@ function () { * Takes a symbol and converts it into a MathML text node after performing * optional replacement from symbols.js. */ -var buildMathML_makeText = function makeText(text, mode, options) { - if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.substr(4, 2) === "tt" || options.font && options.font.substr(4, 2) === "tt"))) { +const makeText = function (text, mode, options) { + if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { text = src_symbols[mode][text].replace; } @@ -7004,7 +6872,7 @@ var buildMathML_makeText = function makeText(text, mode, options) { * unless the array has length 1. Always returns a single node. */ -var buildMathML_makeRow = function makeRow(body) { +const makeRow = function (body) { if (body.length === 1) { return body[0]; } else { @@ -7015,7 +6883,7 @@ var buildMathML_makeRow = function makeRow(body) { * Returns the math variant as a string or null if none is required. */ -var buildMathML_getVariant = function getVariant(group, options) { +const getVariant = function (group, options) { // Handle \text... font specifiers as best we can. // MathML has a limited list of allowable mathvariant specifiers; see // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt @@ -7039,18 +6907,18 @@ var buildMathML_getVariant = function getVariant(group, options) { return "bold"; } - var font = options.font; + const font = options.font; if (!font || font === "mathnormal") { return null; } - var mode = group.mode; + const mode = group.mode; if (font === "mathit") { return "italic"; } else if (font === "boldsymbol") { - return "bold-italic"; + return group.type === "textord" ? "bold" : "bold-italic"; } else if (font === "mathbf") { return "bold"; } else if (font === "mathbb") { @@ -7058,7 +6926,7 @@ var buildMathML_getVariant = function getVariant(group, options) { } else if (font === "mathfrak") { return "fraktur"; } else if (font === "mathscr" || font === "mathcal") { - // MathML makes no distinction between script and caligrahpic + // MathML makes no distinction between script and calligraphic return "script"; } else if (font === "mathsf") { return "sans-serif"; @@ -7066,7 +6934,7 @@ var buildMathML_getVariant = function getVariant(group, options) { return "monospace"; } - var text = group.text; + let text = group.text; if (utils.contains(["\\imath", "\\jmath"], text)) { return null; @@ -7076,7 +6944,7 @@ var buildMathML_getVariant = function getVariant(group, options) { text = src_symbols[mode][text].replace; } - var fontName = buildCommon.fontMap[font].fontName; + const fontName = buildCommon.fontMap[font].fontName; if (getCharacterMetrics(text, fontName, mode)) { return buildCommon.fontMap[font].variant; @@ -7090,11 +6958,11 @@ var buildMathML_getVariant = function getVariant(group, options) { * tag. */ -var buildMathML_buildExpression = function buildExpression(expression, options, isOrdgroup) { +const buildMathML_buildExpression = function (expression, options, isOrdgroup) { if (expression.length === 1) { - var group = buildMathML_buildGroup(expression[0], options); + const group = buildMathML_buildGroup(expression[0], options); - if (isOrdgroup && group instanceof mathMLTree_MathNode && group.type === "mo") { + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { // When TeX writers want to suppress spacing on an operator, // they often put the operator by itself inside braces. group.setAttribute("lspace", "0em"); @@ -7104,53 +6972,44 @@ var buildMathML_buildExpression = function buildExpression(expression, options, return [group]; } - var groups = []; - var lastGroup; + const groups = []; + let lastGroup; - for (var i = 0; i < expression.length; i++) { - var _group = buildMathML_buildGroup(expression[i], options); + for (let i = 0; i < expression.length; i++) { + const group = buildMathML_buildGroup(expression[i], options); - if (_group instanceof mathMLTree_MathNode && lastGroup instanceof mathMLTree_MathNode) { + if (group instanceof MathNode && lastGroup instanceof MathNode) { // Concatenate adjacent s - if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { - var _lastGroup$children; - - (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, _group.children); - + if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(...group.children); continue; // Concatenate adjacent s - } else if (_group.type === 'mn' && lastGroup.type === 'mn') { - var _lastGroup$children2; - - (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, _group.children); - + } else if (group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); continue; // Concatenate ... followed by . - } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') { - var child = _group.children[0]; - - if (child instanceof mathMLTree_TextNode && child.text === '.') { - var _lastGroup$children3; - - (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, _group.children); + } else if (group.type === 'mi' && group.children.length === 1 && lastGroup.type === 'mn') { + const child = group.children[0]; + if (child instanceof TextNode && child.text === '.') { + lastGroup.children.push(...group.children); continue; } } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { - var lastChild = lastGroup.children[0]; + const lastChild = lastGroup.children[0]; - if (lastChild instanceof mathMLTree_TextNode && lastChild.text === "\u0338" && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { - var _child = _group.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (group.type === 'mo' || group.type === 'mi' || group.type === 'mn')) { + const child = group.children[0]; - if (_child instanceof mathMLTree_TextNode && _child.text.length > 0) { + if (child instanceof TextNode && child.text.length > 0) { // Overlay with combining character long solidus - _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1); + child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); groups.pop(); } } } } - groups.push(_group); - lastGroup = _group; + groups.push(group); + lastGroup = group; } return groups; @@ -7160,22 +7019,24 @@ var buildMathML_buildExpression = function buildExpression(expression, options, * if there's more than one. Returns a single node instead of an array. */ -var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { - return buildMathML_makeRow(buildMathML_buildExpression(expression, options, isOrdgroup)); +const buildExpressionRow = function (expression, options, isOrdgroup) { + return makeRow(buildMathML_buildExpression(expression, options, isOrdgroup)); }; /** * Takes a group from the parser and calls the appropriate groupBuilders function * on it to produce a MathML node. */ -var buildMathML_buildGroup = function buildGroup(group, options) { +const buildMathML_buildGroup = function (group, options) { if (!group) { return new mathMLTree.MathNode("mrow"); } if (_mathmlGroupBuilders[group.type]) { // Call the groupBuilders function - var result = _mathmlGroupBuilders[group.type](group, options); + // $FlowFixMe + const result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe + return result; } else { throw new src_ParseError("Got group of unknown type: '" + group.type + "'"); @@ -7190,33 +7051,42 @@ var buildMathML_buildGroup = function buildGroup(group, options) { * we can do appropriate styling. */ -function buildMathML(tree, texExpression, options, forMathmlOnly) { - var expression = buildMathML_buildExpression(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + const expression = buildMathML_buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics // tag correctly, unless it's a single or . - var wrapper; + let wrapper; - if (expression.length === 1 && expression[0] instanceof mathMLTree_MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) { + if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) { wrapper = expression[0]; } else { wrapper = new mathMLTree.MathNode("mrow", expression); } // Build a TeX annotation of the source - var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); + const annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); annotation.setAttribute("encoding", "application/x-tex"); - var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); - var math = new mathMLTree.MathNode("math", [semantics]); - math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); // You can't style nodes, so we wrap the node in a span. + const semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); + const math = new mathMLTree.MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + + if (isDisplayMode) { + math.setAttribute("display", "block"); + } // You can't style nodes, so we wrap the node in a span. // NOTE: The span class is not typed to have nodes as children, and // we don't want to make the children type more generic since the children // of span are expected to have more fields in `buildHtml` contexts. - var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe + + const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe return buildCommon.makeSpan([wrapperClass], [math]); } -// CONCATENATED MODULE: ./src/buildTree.js +;// CONCATENATED MODULE: ./src/buildTree.js @@ -7224,7 +7094,7 @@ function buildMathML(tree, texExpression, options, forMathmlOnly) { -var buildTree_optionsFromSettings = function optionsFromSettings(settings) { +const optionsFromSettings = function (settings) { return new src_Options({ style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT, maxSize: settings.maxSize, @@ -7232,9 +7102,9 @@ var buildTree_optionsFromSettings = function optionsFromSettings(settings) { }); }; -var buildTree_displayWrap = function displayWrap(node, settings) { +const displayWrap = function (node, settings) { if (settings.displayMode) { - var classes = ["katex-display"]; + const classes = ["katex-display"]; if (settings.leqno) { classes.push("leqno"); @@ -7250,33 +7120,31 @@ var buildTree_displayWrap = function displayWrap(node, settings) { return node; }; -var buildTree_buildTree = function buildTree(tree, expression, settings) { - var options = buildTree_optionsFromSettings(settings); - var katexNode; +const buildTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + let katexNode; if (settings.output === "mathml") { - return buildMathML(tree, expression, options, true); + return buildMathML(tree, expression, options, settings.displayMode, true); } else if (settings.output === "html") { - var htmlNode = buildHTML(tree, options); + const htmlNode = buildHTML(tree, options); katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); } else { - var mathMLNode = buildMathML(tree, expression, options, false); - - var _htmlNode = buildHTML(tree, options); - - katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]); + const mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + const htmlNode = buildHTML(tree, options); + katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, htmlNode]); } - return buildTree_displayWrap(katexNode, settings); + return displayWrap(katexNode, settings); }; -var buildTree_buildHTMLTree = function buildHTMLTree(tree, expression, settings) { - var options = buildTree_optionsFromSettings(settings); - var htmlNode = buildHTML(tree, options); - var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); - return buildTree_displayWrap(katexNode, settings); +const buildHTMLTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + const htmlNode = buildHTML(tree, options); + const katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); }; -/* harmony default export */ var src_buildTree = (buildTree_buildTree); -// CONCATENATED MODULE: ./src/stretchy.js +/* harmony default export */ var src_buildTree = ((/* unused pure expression or super */ null && (buildTree))); +;// CONCATENATED MODULE: ./src/stretchy.js /** * This file provides support to buildMathML.js and buildHTML.js * for stretchy wide elements rendered from SVG files @@ -7286,7 +7154,8 @@ var buildTree_buildHTMLTree = function buildHTMLTree(tree, expression, settings) -var stretchyCodePoint = { + +const stretchyCodePoint = { widehat: "^", widecheck: "ˇ", widetilde: "~", @@ -7297,41 +7166,44 @@ var stretchyCodePoint = { overrightarrow: "\u2192", underrightarrow: "\u2192", xrightarrow: "\u2192", - underbrace: "\u23DF", - overbrace: "\u23DE", - overgroup: "\u23E0", - undergroup: "\u23E1", + underbrace: "\u23df", + overbrace: "\u23de", + overgroup: "\u23e0", + undergroup: "\u23e1", overleftrightarrow: "\u2194", underleftrightarrow: "\u2194", xleftrightarrow: "\u2194", - Overrightarrow: "\u21D2", - xRightarrow: "\u21D2", - overleftharpoon: "\u21BC", - xleftharpoonup: "\u21BC", - overrightharpoon: "\u21C0", - xrightharpoonup: "\u21C0", - xLeftarrow: "\u21D0", - xLeftrightarrow: "\u21D4", - xhookleftarrow: "\u21A9", - xhookrightarrow: "\u21AA", - xmapsto: "\u21A6", - xrightharpoondown: "\u21C1", - xleftharpoondown: "\u21BD", - xrightleftharpoons: "\u21CC", - xleftrightharpoons: "\u21CB", - xtwoheadleftarrow: "\u219E", - xtwoheadrightarrow: "\u21A0", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", xlongequal: "=", - xtofrom: "\u21C4", - xrightleftarrows: "\u21C4", - xrightequilibrium: "\u21CC", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", // Not a perfect match. - xleftequilibrium: "\u21CB" // None better available. - + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" }; -var stretchy_mathMLnode = function mathMLnode(label) { - var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.substr(1)])]); +const mathMLnode = function (label) { + const node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); node.setAttribute("stretchy", "true"); return node; }; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. @@ -7372,14 +7244,17 @@ var stretchy_mathMLnode = function mathMLnode(label) { // corresponds to 0.522 em inside the document. -var katexImagesData = { +const katexImagesData = { // path(s), minWidth, height, align overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], @@ -7390,6 +7265,7 @@ var katexImagesData = { xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], @@ -7417,493 +7293,910 @@ var katexImagesData = { xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] }; -var groupLength = function groupLength(arg) { - if (arg.type === "ordgroup") { - return arg.body.length; - } else { - return 1; - } -}; +const groupLength = function (arg) { + if (arg.type === "ordgroup") { + return arg.body.length; + } else { + return 1; + } +}; + +const svgSpan = function (group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + let viewBoxWidth = 400000; // default + + const label = group.label.slice(1); + + if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { + // Each type in the `if` statement corresponds to one of the ParseNode + // types below. This narrowing is required to access `grp.base`. + // $FlowFixMe + const grp = group; // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + + const numChars = groupLength(grp.base); + let viewBoxHeight; + let pathName; + let height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + height = 0.34; + pathName = "tilde4"; + } + } else { + const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: buildCommon.makeSvgSpan([], [svgNode], options), + minWidth: 0, + height + }; + } else { + const spans = []; + const data = katexImagesData[label]; + const [paths, minWidth, viewBoxHeight] = data; + const height = viewBoxHeight / 1000; + const numSvgChildren = paths.length; + let widthClasses; + let aligns; + + if (numSvgChildren === 1) { + // $FlowFixMe: All these cases must be of the 4-tuple type. + const align1 = data[3]; + widthClasses = ["hide-tail"]; + aligns = [align1]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + + for (let i = 0; i < numSvgChildren; i++) { + const path = new PathNode(paths[i]); + const svgNode = new SvgNode([path], { + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + const span = buildCommon.makeSvgSpan([widthClasses[i]], [svgNode], options); + + if (numSvgChildren === 1) { + return { + span, + minWidth, + height + }; + } else { + span.style.height = makeEm(height); + spans.push(span); + } + } + + return { + span: buildCommon.makeSpan(["stretchy"], spans, options), + minWidth, + height + }; + } + } // buildSvgSpan_() + + + const { + span, + minWidth, + height + } = buildSvgSpan_(); // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + + span.height = height; + span.style.height = makeEm(height); + + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +const encloseSpan = function (inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + let img; + const totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = buildCommon.makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + const color = options.color && options.getColor(); + + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + const lines = []; + + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + + const svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = buildCommon.makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +/* harmony default export */ var stretchy = ({ + encloseSpan, + mathMLnode, + svgSpan +}); +;// CONCATENATED MODULE: ./src/parseNode.js + + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } // $FlowFixMe, >=0.125 + + + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function assertSymbolNodeType(node) { + const typedNode = checkSymbolNodeType(node); + + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + + return typedNode; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + // $FlowFixMe + return node; + } + + return null; +} +;// CONCATENATED MODULE: ./src/functions/accent.js + + + + + + + + + + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +const htmlBuilder = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + let base; + let group; + let supSubGroup; + + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group + + base = group.base; // Stick the character box into the base of the supsub group + + grp.base = base; // Rerender the supsub group with its new base, and store that + // result. + + supSubGroup = assertSpan(buildGroup(grp, options)); // reset original base + + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } // Build the base group + + + const body = buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + + const mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + + let skew = 0; + + if (mustShift) { + // If the base is a character box, then we want the skew of the + // innermost character. To do that, we find the innermost character: + const baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it + + const baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. + + skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we + // removed with getBaseElem might contain things like \color which + // we can't get rid of. + // TODO(emily): Find a better way to get the skew + } + + const accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent + + let clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent + + let accentBody; + + if (!group.isStretchy) { + let accent; + let width; + + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = buildCommon.staticSvg("vec", options); + width = buildCommon.svgData.vec[1]; + } else { + accent = buildCommon.makeOrd({ + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + + accent.italic = 0; + width = accent.width; + + if (accentBelow) { + clearance += accent.depth; + } + } -var stretchy_svgSpan = function svgSpan(group, options) { - // Create a span with inline SVG for the element. - function buildSvgSpan_() { - var viewBoxWidth = 400000; // default + accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. - var label = group.label.substr(1); + const accentFull = group.label === "\\textcircled"; - if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { - // Each type in the `if` statement corresponds to one of the ParseNode - // types below. This narrowing is required to access `grp.base`. - var grp = group; // There are four SVG images available for each function. - // Choose a taller image when there are more characters. + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } // Shift the accent over by the skew. - var numChars = groupLength(grp.base); - var viewBoxHeight; - var pathName; - var _height; + let left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. - if (numChars > 5) { - if (label === "widehat" || label === "widecheck") { - viewBoxHeight = 420; - viewBoxWidth = 2364; - _height = 0.42; - pathName = label + "4"; - } else { - viewBoxHeight = 312; - viewBoxWidth = 2340; - _height = 0.34; - pathName = "tilde4"; - } - } else { - var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (!accentFull) { + left -= width / 2; + } - if (label === "widehat" || label === "widecheck") { - viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; - viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; - _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; - pathName = label + imgIndex; - } else { - viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; - viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; - _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; - pathName = "tilde" + imgIndex; - } - } + accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. - var path = new domTree_PathNode(pathName); - var svgNode = new SvgNode([path], { - "width": "100%", - "height": _height + "em", - "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, - "preserveAspectRatio": "none" - }); - return { - span: buildCommon.makeSvgSpan([], [svgNode], options), - minWidth: 0, - height: _height - }; - } else { - var spans = []; - var data = katexImagesData[label]; - var paths = data[0], - _minWidth = data[1], - _viewBoxHeight = data[2]; + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } - var _height2 = _viewBoxHeight / 1000; + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchy.svgSpan(group, options); + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } - var numSvgChildren = paths.length; - var widthClasses; - var aligns; + const accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); - if (numSvgChildren === 1) { - // $FlowFixMe: All these cases must be of the 4-tuple type. - var align1 = data[3]; - widthClasses = ["hide-tail"]; - aligns = [align1]; - } else if (numSvgChildren === 2) { - widthClasses = ["halfarrow-left", "halfarrow-right"]; - aligns = ["xMinYMin", "xMaxYMin"]; - } else if (numSvgChildren === 3) { - widthClasses = ["brace-left", "brace-center", "brace-right"]; - aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; - } else { - throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); - } + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. - for (var i = 0; i < numSvgChildren; i++) { - var _path = new domTree_PathNode(paths[i]); + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. - var _svgNode = new SvgNode([_path], { - "width": "400em", - "height": _height2 + "em", - "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, - "preserveAspectRatio": aligns[i] + " slice" - }); + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; - var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options); +const mathmlBuilder = (group, options) => { + const accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]); + const node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; - if (numSvgChildren === 1) { - return { - span: _span, - minWidth: _minWidth, - height: _height2 - }; - } else { - _span.style.height = _height2 + "em"; - spans.push(_span); - } - } +const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); // Accents - return { - span: buildCommon.makeSpan(["stretchy"], spans, options), - minWidth: _minWidth, - height: _height2 - }; +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + const base = normalizeArgument(args[0]); + const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + const isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder, + mathmlBuilder +}); // Text-mode accents + +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + const base = args[0]; + let mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; } - } // buildSvgSpan_() + + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder, + mathmlBuilder +}); +;// CONCATENATED MODULE: ./src/functions/accentunder.js +// Horizontal overlap functions - var _buildSvgSpan_ = buildSvgSpan_(), - span = _buildSvgSpan_.span, - minWidth = _buildSvgSpan_.minWidth, - height = _buildSvgSpan_.height; // Note that we are returning span.depth = 0. - // Any adjustments relative to the baseline must be done in buildHTML. - span.height = height; - span.style.height = height + "em"; - if (minWidth > 0) { - span.style.minWidth = minWidth + "em"; + +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + const innerGroup = buildGroup(group.base, options); + const accentBody = stretchy.svgSpan(group, options); + const kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns + + const vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + const accentNode = stretchy.mathMLnode(group.label); + const node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; } +}); +;// CONCATENATED MODULE: ./src/functions/arrow.js - return span; -}; -var stretchy_encloseSpan = function encloseSpan(inner, label, pad, options) { - // Return an image span for \cancel, \bcancel, \xcancel, or \fbox - var img; - var totalHeight = inner.height + inner.depth + 2 * pad; - if (/fbox|color/.test(label)) { - img = buildCommon.makeSpan(["stretchy", label], [], options); - if (label === "fbox") { - var color = options.color && options.getColor(); - if (color) { - img.style.borderColor = color; - } - } - } else { - // \cancel, \bcancel, or \xcancel - // Since \cancel's SVG is inline and it omits the viewBox attribute, - // its stroke-width will not vary with span area. - var lines = []; - if (/^[bx]cancel$/.test(label)) { - lines.push(new LineNode({ - "x1": "0", - "y1": "0", - "x2": "100%", - "y2": "100%", - "stroke-width": "0.046em" - })); - } - if (/^x?cancel$/.test(label)) { - lines.push(new LineNode({ - "x1": "0", - "y1": "100%", - "x2": "100%", - "y2": "0", - "stroke-width": "0.046em" - })); - } +// Helper function +const paddedNode = group => { + const node = new mathMLTree.MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; // Stretchy arrows with an optional argument - var svgNode = new SvgNode(lines, { - "width": "100%", - "height": totalHeight + "em" - }); - img = buildCommon.makeSvgSpan([], [svgNode], options); - } - img.height = totalHeight; - img.style.height = totalHeight + "em"; - return img; -}; +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, -/* harmony default export */ var stretchy = ({ - encloseSpan: stretchy_encloseSpan, - mathMLnode: stretchy_mathMLnode, - svgSpan: stretchy_svgSpan -}); -// CONCATENATED MODULE: ./src/functions/accent.js + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + // Flow is unable to correctly infer the type of `group`, even though it's + // unambiguously determined from the passed-in `type` above. + htmlBuilder(group, options) { + const style = options.style; // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + let newOptions = options.havingStyle(style.sup()); + const upperGroup = buildCommon.wrapFragment(buildGroup(group.body, newOptions, options), options); + const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + let lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = buildCommon.wrapFragment(buildGroup(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + const arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + const arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + let upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } // Generate the vlist -// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but -var accent_htmlBuilder = function htmlBuilder(grp, options) { - // Accents are handled in the TeXbook pg. 443, rule 12. - var base; - var group; - var supSub = checkNodeType(grp, "supsub"); - var supSubGroup; + let vlist; - if (supSub) { - // If our base is a character box, and we have superscripts and - // subscripts, the supsub will defer to us. In particular, we want - // to attach the superscripts and subscripts to the inner body (so - // that the position of the superscripts and subscripts won't be - // affected by the height of the accent). We accomplish this by - // sticking the base of the accent into the base of the supsub, and - // rendering that, while keeping track of where the accent is. - // The real accent group is the base of the supsub group - group = assertNodeType(supSub.base, "accent"); // The character box is the base of the accent group + if (lowerGroup) { + const lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }] + }, options); + } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. - base = group.base; // Stick the character box into the base of the supsub group - supSub.base = base; // Rerender the supsub group with its new base, and store that - // result. + vlist.children[0].children[0].children[1].classes.push("svg-align"); + return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); + }, - supSubGroup = assertSpan(buildHTML_buildGroup(supSub, options)); // reset original base + mathmlBuilder(group, options) { + const arrowNode = stretchy.mathMLnode(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + let node; - supSub.base = group; - } else { - group = assertNodeType(grp, "accent"); - base = group.base; - } // Build the base group + if (group.body) { + const upperNode = paddedNode(buildMathML_buildGroup(group.body, options)); + if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new mathMLTree.MathNode("mover", [arrowNode, node]); + } - var body = buildHTML_buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + return node; + } - var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the - // nucleus is not a single character, let s = 0; otherwise set s to the - // kern amount for the nucleus followed by the \skewchar of its font." - // Note that our skew metrics are just the kern between each character - // and the skewchar. +}); +;// CONCATENATED MODULE: ./src/functions/mclass.js - var skew = 0; - if (mustShift) { - // If the base is a character box, then we want the skew of the - // innermost character. To do that, we find the innermost character: - var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it - var baseGroup = buildHTML_buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. - skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we - // removed with getBaseElem might contain things like \color which - // we can't get rid of. - // TODO(emily): Find a better way to get the skew - } // calculate the amount of space between the body and the accent - var clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent +const mclass_makeSpan = buildCommon.makeSpan; - var accentBody; +function mclass_htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + return mclass_makeSpan([group.mclass], elements, options); +} - if (!group.isStretchy) { - var accent; - var width; +function mclass_mathmlBuilder(group, options) { + let node; + const inner = buildMathML_buildExpression(group.body, options); - if (group.label === "\\vec") { - // Before version 0.9, \vec used the combining font glyph U+20D7. - // But browsers, especially Safari, are not consistent in how they - // render combining characters when not preceded by a character. - // So now we use an SVG. - // If Safari reforms, we should consider reverting to the glyph. - accent = buildCommon.staticSvg("vec", options); - width = buildCommon.svgData.vec[1]; + if (group.mclass === "minner") { + node = new mathMLTree.MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; } else { - accent = buildCommon.makeOrd({ - mode: group.mode, - text: group.label - }, options, "textord"); - accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to - // shift the accent over to a place we don't want. - - accent.italic = 0; - width = accent.width; + node = new mathMLTree.MathNode("mi", inner); } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new mathMLTree.MathNode("mo", inner); + } // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. - accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be - // at least the width of the accent, and overlap directly onto the - // character without any vertical offset. - - var accentFull = group.label === "\\textcircled"; - - if (accentFull) { - accentBody.classes.push('accent-full'); - clearance = body.height; - } // Shift the accent over by the skew. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space - var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` - // so that the accent doesn't contribute to the bounding box. - // We need to shift the character by its width (effectively half - // its width) to compensate. + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option - if (!accentFull) { - left -= width / 2; - } + node.attributes.width = "+0.1111em"; + } // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo - accentBody.style.left = left + "em"; // \textcircled uses the \bigcirc glyph, so it needs some - // vertical adjustment to match LaTeX. + } - if (group.label === "\\textcircled") { - accentBody.style.top = ".2em"; - } + return node; +} // Math class commands except \mathop - accentBody = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: body - }, { - type: "kern", - size: -clearance - }, { - type: "elem", - elem: accentBody - }] - }, options); - } else { - accentBody = stretchy.svgSpan(group, options); - accentBody = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: body - }, { - type: "elem", - elem: accentBody, - wrapperClasses: ["svg-align"], - wrapperStyle: skew > 0 ? { - width: "calc(100% - " + 2 * skew + "em)", - marginLeft: 2 * skew + "em" - } : undefined - }] - }, options); - } - var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, - if (supSubGroup) { - // Here, we replace the "base" child of the supsub with our newly - // generated accent. - supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the - // accent, we manually recalculate height. + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: utils.isCharacterBox(body) + }; + }, - supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. + htmlBuilder: mclass_htmlBuilder, + mathmlBuilder: mclass_mathmlBuilder +}); +const binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + const atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; - supSubGroup.classes[0] = "mord"; - return supSubGroup; + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; } else { - return accentWrap; + return "mord"; } -}; - -var accent_mathmlBuilder = function mathmlBuilder(group, options) { - var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [buildMathML_makeText(group.label, group.mode)]); - var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]); - node.setAttribute("accent", "true"); - return node; -}; - -var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(function (accent) { - return "\\" + accent; -}).join("|")); // Accents +}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. defineFunction({ - type: "accent", - names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + type: "mclass", + names: ["\\@binrel"], props: { - numArgs: 1 + numArgs: 2 }, - handler: function handler(context, args) { - var base = args[0]; - var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); - var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + + handler(_ref2, args) { + let { + parser + } = _ref2; return { - type: "accent", - mode: context.parser.mode, - label: context.funcName, - isStretchy: isStretchy, - isShifty: isShifty, - base: base + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: utils.isCharacterBox(args[1]) }; - }, - htmlBuilder: accent_htmlBuilder, - mathmlBuilder: accent_mathmlBuilder -}); // Text-mode accents + } + +}); // Build a relation or stacked op by placing one symbol on top of another defineFunction({ - type: "accent", - names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v", "\\textcircled"], + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], props: { - numArgs: 1, - allowedInText: true, - allowedInMath: false + numArgs: 2 }, - handler: function handler(context, args) { - var base = args[0]; + + handler(_ref3, args) { + let { + parser, + funcName + } = _ref3; + const baseArg = args[1]; + const shiftedArg = args[0]; + let mclass; + + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + const baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + const supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; return { - type: "accent", - mode: context.parser.mode, - label: context.funcName, - isStretchy: false, - isShifty: true, - base: base + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: utils.isCharacterBox(supsub) }; }, - htmlBuilder: accent_htmlBuilder, - mathmlBuilder: accent_mathmlBuilder + + htmlBuilder: mclass_htmlBuilder, + mathmlBuilder: mclass_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/accentunder.js -// Horizontal overlap functions +;// CONCATENATED MODULE: ./src/functions/pmb.js +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. defineFunction({ - type: "accentUnder", - names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + type: "pmb", + names: ["\\pmb"], props: { - numArgs: 1 + numArgs: 1, + allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var base = args[0]; + + handler(_ref, args) { + let { + parser + } = _ref; return { - type: "accentUnder", + type: "pmb", mode: parser.mode, - label: funcName, - base: base + mclass: binrelClass(args[0]), + body: ordargument(args[0]) }; }, - htmlBuilder: function htmlBuilder(group, options) { - // Treat under accents much like underlines. - var innerGroup = buildHTML_buildGroup(group.base, options); - var accentBody = stretchy.svgSpan(group, options); - var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns - var vlist = buildCommon.makeVList({ - positionType: "bottom", - positionData: accentBody.height + kern, - children: [{ - type: "elem", - elem: accentBody, - wrapperClasses: ["svg-align"] - }, { - type: "kern", - size: kern - }, { - type: "elem", - elem: innerGroup - }] - }, options); - return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + const node = buildCommon.makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; }, - mathmlBuilder: function mathmlBuilder(group, options) { - var accentNode = stretchy.mathMLnode(group.label); - var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]); - node.setAttribute("accentunder", "true"); + + mathmlBuilder(group, style) { + const inner = buildMathML_buildExpression(group.body, style); // Wrap with an element. + + const node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); return node; } + }); -// CONCATENATED MODULE: ./src/functions/arrow.js +;// CONCATENATED MODULE: ./src/environments/cd.js @@ -7911,134 +8204,333 @@ defineFunction({ -// Helper function -var arrow_paddedNode = function paddedNode(group) { - var node = new mathMLTree.MathNode("mpadded", group ? [group] : []); - node.setAttribute("width", "+0.6em"); - node.setAttribute("lspace", "0.3em"); - return node; -}; // Stretchy arrows with an optional argument +const cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; -defineFunction({ - type: "xArrow", - names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. - // Direct use of these functions is discouraged and may break someday. - "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium"], - props: { - numArgs: 1, - numOptionalArgs: 1 - }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser, - funcName = _ref.funcName; - return { - type: "xArrow", - mode: parser.mode, - label: funcName, - body: args[0], - below: optArgs[0] - }; - }, - // Flow is unable to correctly infer the type of `group`, even though it's - // unamibiguously determined from the passed-in `type` above. - htmlBuilder: function htmlBuilder(group, options) { - var style = options.style; // Build the argument groups in the appropriate style. - // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% - // Some groups can return document fragments. Handle those by wrapping - // them in a span. +const newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + // So these values are fixed and flow can do implicit typing. + return { + type: "styling", + body: [], + mode: "math", + style: "display" + }; +}; - var newOptions = options.havingStyle(style.sup()); - var upperGroup = buildCommon.wrapFragment(buildHTML_buildGroup(group.body, newOptions, options), options); - upperGroup.classes.push("x-arrow-pad"); - var lowerGroup; +const isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; - if (group.below) { - // Build the lower group - newOptions = options.havingStyle(style.sub()); - lowerGroup = buildCommon.wrapFragment(buildHTML_buildGroup(group.below, newOptions, options), options); - lowerGroup.classes.push("x-arrow-pad"); - } +const isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; - var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. - // The point we want on the math axis is at 0.5 * arrowBody.height. +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + const funcName = cdArrowFunctionName[arrowChar]; - var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); - var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + case "\\uparrow": + case "\\downarrow": + { + const leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + const bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + const sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + const rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + const arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } - if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { - upperShift -= upperGroup.depth; // shift up if depth encroaches - } // Generate the vlist + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + + case "\\Vert": + { + const arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + const parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); - var vlist; + while (true) { + // eslint-disable-line no-constant-condition + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + const next = parser.fetch().text; - if (lowerGroup) { - var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; - vlist = buildCommon.makeVList({ - positionType: "individualShift", - children: [{ - type: "elem", - elem: upperGroup, - shift: upperShift - }, { - type: "elem", - elem: arrowBody, - shift: arrowShift - }, { - type: "elem", - elem: lowerGroup, - shift: lowerShift - }] - }, options); + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + + break; } else { - vlist = buildCommon.makeVList({ - positionType: "individualShift", - children: [{ - type: "elem", - elem: upperGroup, - shift: upperShift - }, { - type: "elem", - elem: arrowBody, - shift: arrowShift - }] - }, options); - } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + throw new src_ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + let row = []; + const body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows. - vlist.children[0].children[0].children[1].classes.push("svg-align"); - return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); - }, - mathmlBuilder: function mathmlBuilder(group, options) { - var arrowNode = stretchy.mathMLnode(group.label); - var node; + for (let i = 0; i < parsedRows.length; i++) { + // Start a new row. + const rowNodes = parsedRows[i]; // Create the first cell. - if (group.body) { - var upperNode = arrow_paddedNode(buildMathML_buildGroup(group.body, options)); + let cell = newCell(); - if (group.below) { - var lowerNode = arrow_paddedNode(buildMathML_buildGroup(group.below, options)); - node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + for (let j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); } else { - node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + + j += 1; + const arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them. + + const labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; // Process the arrow. + + if ("=|.".indexOf(arrowChar) > -1) {// Three "arrows", ``@=`, `@|`, and `@.`, do not take labels. + // Do nothing here. + } else if ("<>AV".indexOf(arrowChar) > -1) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (let labelNum = 0; labelNum < 2; labelNum++) { + let inLabel = true; + + for (let k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + + if (isStartOfArrow(rowNodes[k])) { + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } + + if (inLabel) { + // isLabelEnd never returned a true. + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new src_ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } // Now join the arrow to its labels. + + + const arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + + const wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display" // CD is always displaystyle. + + }; + row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + + cell = newCell(); } - } else if (group.below) { - var _lowerNode = arrow_paddedNode(buildMathML_buildGroup(group.below, options)); + } - node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]); + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); } else { - // This should never happen. - // Parser.js throws an error if there is no argument. - node = arrow_paddedNode(); - node = new mathMLTree.MathNode("mover", [arrowNode, node]); + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); } - return node; + row = []; + body.push(row); + } // End row group + + + parser.gullet.endGroup(); // End array group defining \\ + + parser.gullet.endGroup(); // define column separation. + + const cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} // The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + + htmlBuilder(group, options) { + const newOptions = options.havingStyle(options.style.sup()); + const label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + + label.height = 0; + label.depth = 0; + return label; + }, + + mathmlBuilder(group, options) { + let label = new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.label, options)]); + label = new mathMLTree.MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + + + label.setAttribute("voffset", "0.7em"); + label = new mathMLTree.MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } + +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + + handler(_ref2, args) { + let { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + const parent = buildCommon.wrapFragment(buildGroup(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.fragment, options)]); } + }); -// CONCATENATED MODULE: ./src/functions/char.js +;// CONCATENATED MODULE: ./src/functions/char.js // \@char is an internal function that takes a grouped decimal argument like @@ -8052,31 +8544,45 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var arg = assertNodeType(args[0], "ordgroup"); - var group = arg.body; - var number = ""; - - for (var i = 0; i < group.length; i++) { - var node = assertNodeType(group[i], "textord"); + + handler(_ref, args) { + let { + parser + } = _ref; + const arg = assertNodeType(args[0], "ordgroup"); + const group = arg.body; + let number = ""; + + for (let i = 0; i < group.length; i++) { + const node = assertNodeType(group[i], "textord"); number += node.text; } - var code = parseInt(number); + let code = parseInt(number); + let text; if (isNaN(code)) { - throw new src_ParseError("\\@char has non-numeric argument " + number); + throw new src_ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new src_ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); } return { type: "textord", mode: parser.mode, - text: String.fromCharCode(code) + text: text }; } + }); -// CONCATENATED MODULE: ./src/functions/color.js +;// CONCATENATED MODULE: ./src/functions/color.js @@ -8084,8 +8590,8 @@ defineFunction({ -var color_htmlBuilder = function htmlBuilder(group, options) { - var elements = buildHTML_buildExpression(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. +const color_htmlBuilder = (group, options) => { + const elements = buildExpression(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. // To accomplish this, we wrap the results in a fragment, so the inner // elements will be able to directly interact with their neighbors. For // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` @@ -8093,9 +8599,9 @@ var color_htmlBuilder = function htmlBuilder(group, options) { return buildCommon.makeFragment(elements); }; -var color_mathmlBuilder = function mathmlBuilder(group, options) { - var inner = buildMathML_buildExpression(group.body, options.withColor(group.color)); - var node = new mathMLTree.MathNode("mstyle", inner); +const color_mathmlBuilder = (group, options) => { + const inner = buildMathML_buildExpression(group.body, options.withColor(group.color)); + const node = new mathMLTree.MathNode("mstyle", inner); node.setAttribute("mathcolor", group.color); return node; }; @@ -8106,20 +8612,23 @@ defineFunction({ props: { numArgs: 2, allowedInText: true, - greediness: 3, argTypes: ["color", "original"] }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var color = assertNodeType(args[0], "color-token").color; - var body = args[1]; + + handler(_ref, args) { + let { + parser + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; return { type: "color", mode: parser.mode, - color: color, - body: defineFunction_ordargument(body) + color, + body: ordargument(body) }; }, + htmlBuilder: color_htmlBuilder, mathmlBuilder: color_mathmlBuilder }); @@ -8129,108 +8638,340 @@ defineFunction({ props: { numArgs: 1, allowedInText: true, - greediness: 3, argTypes: ["color"] }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser, - breakOnTokenText = _ref2.breakOnTokenText; - var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current + + handler(_ref2, args) { + let { + parser, + breakOnTokenText + } = _ref2; + const color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current // color, mimicking the behavior of color.sty. // This is currently used just to correctly color a \right // that follows a \color command. parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored. - var body = parser.parseExpression(true, breakOnTokenText); + const body = parser.parseExpression(true, breakOnTokenText); return { type: "color", mode: parser.mode, - color: color, - body: body + color, + body }; }, + htmlBuilder: color_htmlBuilder, mathmlBuilder: color_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/cr.js +;// CONCATENATED MODULE: ./src/functions/cr.js // Row breaks within tabular environments, and line breaks at top level - - // \\ is a macro mapping to either \cr or \newline. Because they have the -// same signature, we implement them as one megafunction, with newRow -// indicating whether we're in the \cr case, and newLine indicating whether -// to break the line in the \newline case. + // \DeclareRobustCommand\\{...\@xnewline} defineFunction({ type: "cr", - names: ["\\cr", "\\newline"], + names: ["\\\\"], props: { numArgs: 0, - numOptionalArgs: 1, - argTypes: ["size"], + numOptionalArgs: 0, allowedInText: true }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser, - funcName = _ref.funcName; - var size = optArgs[0]; - var newRow = funcName === "\\cr"; - var newLine = false; - - if (!newRow) { - if (parser.settings.displayMode && parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode")) { - newLine = false; - } else { - newLine = true; - } - } + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + const newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); return { type: "cr", mode: parser.mode, - newLine: newLine, - newRow: newRow, + newLine, size: size && assertNodeType(size, "size").value }; }, + // The following builders are called only at the top level, // not within tabular/array environments. - htmlBuilder: function htmlBuilder(group, options) { - if (group.newRow) { - throw new src_ParseError("\\cr valid only within a tabular/array environment"); - } - - var span = buildCommon.makeSpan(["mspace"], [], options); + htmlBuilder(group, options) { + const span = buildCommon.makeSpan(["mspace"], [], options); if (group.newLine) { span.classes.push("newline"); if (group.size) { - span.style.marginTop = units_calculateSize(group.size, options) + "em"; + span.style.marginTop = makeEm(calculateSize(group.size, options)); } } return span; }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mspace"); + + mathmlBuilder(group, options) { + const node = new mathMLTree.MathNode("mspace"); if (group.newLine) { node.setAttribute("linebreak", "newline"); if (group.size) { - node.setAttribute("height", units_calculateSize(group.size, options) + "em"); + node.setAttribute("height", makeEm(calculateSize(group.size, options))); } } return node; } + +}); +;// CONCATENATED MODULE: ./src/functions/def.js + + + +const globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; + +const checkControlSequence = tok => { + const name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + + return name; +}; + +const getRHS = parser => { + let tok = parser.gullet.popToken(); + + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + + return tok; +}; + +const letCommand = (parser, name, tok, global) => { + let macro = parser.gullet.macros.get(tok.text); + + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + + parser.gullet.macros.set(name, macro, global); +}; // -> | +// -> |\global +// -> | +// -> \global|\long|\outer + + +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + let { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + const token = parser.fetch(); + + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + + return assertNodeType(parser.parseFunction(), "internal"); + } + + throw new src_ParseError("Invalid token after macro prefix", token); + } + +}); // Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> + +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref2) { + let { + parser, + funcName + } = _ref2; + let tok = parser.gullet.popToken(); + const name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + + let numArgs = 0; + let insert; + const delimiters = [[]]; // contains no braces + + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + + + tok = parser.gullet.popToken(); + + if (!/^[1-9]$/.test(tok.text)) { + throw new src_ParseError("Invalid argument number \"" + tok.text + "\""); + } + + if (parseInt(tok.text) !== numArgs + 1) { + throw new src_ParseError("Argument number \"" + tok.text + "\" out of order"); + } + + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new src_ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } // replacement text, enclosed in '{' and '}' and properly nested + + + let { + tokens + } = parser.gullet.consumeArg(); + + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } // Final arg is the expansion of the macro + + + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // -> +// -> \futurelet +// | \let +// -> |= + +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref3) { + let { + parser, + funcName + } = _ref3; + const name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + const tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf + +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref4) { + let { + parser, + funcName + } = _ref4; + const name = checkControlSequence(parser.gullet.popToken()); + const middle = parser.gullet.popToken(); + const tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } + }); -// CONCATENATED MODULE: ./src/delimiter.js +;// CONCATENATED MODULE: ./src/delimiter.js /** * This file deals with creating delimiters of various sizes. The TeXbook * discusses these routines on page 441-442, in the "Another subroutine sets box @@ -8261,13 +9002,15 @@ defineFunction({ + + /** * Get the metrics for a given symbol and font, after transformation (i.e. * after following replacement from symbols.js) */ -var delimiter_getMetrics = function getMetrics(symbol, font, mode) { - var replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace; - var metrics = getCharacterMetrics(replace || symbol, font, mode); +const getMetrics = function (symbol, font, mode) { + const replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace; + const metrics = getCharacterMetrics(replace || symbol, font, mode); if (!metrics) { throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); @@ -8281,21 +9024,21 @@ var delimiter_getMetrics = function getMetrics(symbol, font, mode) { */ -var delimiter_styleWrap = function styleWrap(delim, toStyle, options, classes) { - var newOptions = options.havingBaseStyle(toStyle); - var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); - var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; +const styleWrap = function (delim, toStyle, options, classes) { + const newOptions = options.havingBaseStyle(toStyle); + const span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + const delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; span.height *= delimSizeMultiplier; span.depth *= delimSizeMultiplier; span.maxFontSize = newOptions.sizeMultiplier; return span; }; -var centerSpan = function centerSpan(span, options, style) { - var newOptions = options.havingBaseStyle(style); - var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; +const centerSpan = function (span, options, style) { + const newOptions = options.havingBaseStyle(style); + const shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; span.classes.push("delimcenter"); - span.style.top = shift + "em"; + span.style.top = makeEm(shift); span.height -= shift; span.depth += shift; }; @@ -8306,9 +9049,9 @@ var centerSpan = function centerSpan(span, options, style) { */ -var delimiter_makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { - var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); - var span = delimiter_styleWrap(text, style, options, classes); +const makeSmallDelim = function (delim, style, center, options, mode, classes) { + const text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); + const span = styleWrap(text, style, options, classes); if (center) { centerSpan(span, options, style); @@ -8321,7 +9064,7 @@ var delimiter_makeSmallDelim = function makeSmallDelim(delim, style, center, opt */ -var delimiter_mathrmSize = function mathrmSize(value, size, mode, options) { +const mathrmSize = function (value, size, mode, options) { return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options); }; /** @@ -8330,9 +9073,9 @@ var delimiter_mathrmSize = function mathrmSize(value, size, mode, options) { */ -var delimiter_makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { - var inner = delimiter_mathrmSize(delim, size, mode, options); - var span = delimiter_styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes); +const makeLargeDelim = function (delim, size, center, options, mode, classes) { + const inner = mathrmSize(delim, size, mode, options); + const span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes); if (center) { centerSpan(span, options, src_Style.TEXT); @@ -8341,13 +9084,13 @@ var delimiter_makeLargeDelim = function makeLargeDelim(delim, size, center, opti return span; }; /** - * Make an inner span with the given offset and in the given font. This is used - * in `makeStackedDelim` to make the stacking pieces for the delimiter. + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. */ -var delimiter_makeInner = function makeInner(symbol, font, mode) { - var sizeClass; // Apply the correct CSS class to choose the right font. +const makeGlyphSpan = function (symbol, font, mode) { + let sizeClass; // Apply the correct CSS class to choose the right font. if (font === "Size1-Regular") { sizeClass = "delim-size1"; @@ -8357,238 +9100,288 @@ var delimiter_makeInner = function makeInner(symbol, font, mode) { sizeClass = "delim-size4"; } - var inner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element + const corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element // in the appropriate tag that VList uses. return { type: "elem", - elem: inner + elem: corner + }; +}; + +const makeInner = function (ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + const width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4]; + const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + const span = buildCommon.makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span }; -}; // Helper for makeStackedDelim +}; // Helpers for makeStackedDelim -var lap = { +const lapInEms = 0.008; +const lap = { type: "kern", - size: -0.005 + size: -1 * lapInEms }; +const verts = ["|", "\\lvert", "\\rvert", "\\vert"]; +const doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"]; /** * Make a stacked delimiter out of a given delimiter, with the total height at * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. */ -var delimiter_makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { +const makeStackedDelim = function (delim, heightTotal, center, options, mode, classes) { // There are four parts, the top, an optional middle, a repeated part, and a // bottom. - var top; - var middle; - var repeat; - var bottom; + let top; + let middle; + let repeat; + let bottom; + let svgLabel = ""; + let viewBoxWidth = 0; top = repeat = bottom = delim; middle = null; // Also keep track of what font the delimiters are in - var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use + let font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the // repeats of the arrows if (delim === "\\uparrow") { - repeat = bottom = "\u23D0"; + repeat = bottom = "\u23d0"; } else if (delim === "\\Uparrow") { repeat = bottom = "\u2016"; } else if (delim === "\\downarrow") { - top = repeat = "\u23D0"; + top = repeat = "\u23d0"; } else if (delim === "\\Downarrow") { top = repeat = "\u2016"; } else if (delim === "\\updownarrow") { top = "\\uparrow"; - repeat = "\u23D0"; + repeat = "\u23d0"; bottom = "\\downarrow"; } else if (delim === "\\Updownarrow") { top = "\\Uparrow"; repeat = "\u2016"; bottom = "\\Downarrow"; + } else if (utils.contains(verts, delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (utils.contains(doubleVerts, delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; } else if (delim === "[" || delim === "\\lbrack") { - top = "\u23A1"; - repeat = "\u23A2"; - bottom = "\u23A3"; + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; } else if (delim === "]" || delim === "\\rbrack") { - top = "\u23A4"; - repeat = "\u23A5"; - bottom = "\u23A6"; + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; font = "Size4-Regular"; - } else if (delim === "\\lfloor" || delim === "\u230A") { - repeat = top = "\u23A2"; - bottom = "\u23A3"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; } else if (delim === "\\lceil" || delim === "\u2308") { - top = "\u23A1"; - repeat = bottom = "\u23A2"; + top = "\u23a1"; + repeat = bottom = "\u23a2"; font = "Size4-Regular"; - } else if (delim === "\\rfloor" || delim === "\u230B") { - repeat = top = "\u23A5"; - bottom = "\u23A6"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; } else if (delim === "\\rceil" || delim === "\u2309") { - top = "\u23A4"; - repeat = bottom = "\u23A5"; + top = "\u23a4"; + repeat = bottom = "\u23a5"; font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; } else if (delim === "(" || delim === "\\lparen") { - top = "\u239B"; - repeat = "\u239C"; - bottom = "\u239D"; + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; } else if (delim === ")" || delim === "\\rparen") { - top = "\u239E"; - repeat = "\u239F"; - bottom = "\u23A0"; + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; } else if (delim === "\\{" || delim === "\\lbrace") { - top = "\u23A7"; - middle = "\u23A8"; - bottom = "\u23A9"; - repeat = "\u23AA"; + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; font = "Size4-Regular"; } else if (delim === "\\}" || delim === "\\rbrace") { - top = "\u23AB"; - middle = "\u23AC"; - bottom = "\u23AD"; - repeat = "\u23AA"; + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; font = "Size4-Regular"; - } else if (delim === "\\lgroup" || delim === "\u27EE") { - top = "\u23A7"; - bottom = "\u23A9"; - repeat = "\u23AA"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; font = "Size4-Regular"; - } else if (delim === "\\rgroup" || delim === "\u27EF") { - top = "\u23AB"; - bottom = "\u23AD"; - repeat = "\u23AA"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; font = "Size4-Regular"; - } else if (delim === "\\lmoustache" || delim === "\u23B0") { - top = "\u23A7"; - bottom = "\u23AD"; - repeat = "\u23AA"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; font = "Size4-Regular"; - } else if (delim === "\\rmoustache" || delim === "\u23B1") { - top = "\u23AB"; - bottom = "\u23A9"; - repeat = "\u23AA"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; font = "Size4-Regular"; } // Get the metrics of the four sections - var topMetrics = delimiter_getMetrics(top, font, mode); - var topHeightTotal = topMetrics.height + topMetrics.depth; - var repeatMetrics = delimiter_getMetrics(repeat, font, mode); - var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; - var bottomMetrics = delimiter_getMetrics(bottom, font, mode); - var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; - var middleHeightTotal = 0; - var middleFactor = 1; + const topMetrics = getMetrics(top, font, mode); + const topHeightTotal = topMetrics.height + topMetrics.depth; + const repeatMetrics = getMetrics(repeat, font, mode); + const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + const bottomMetrics = getMetrics(bottom, font, mode); + const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + let middleHeightTotal = 0; + let middleFactor = 1; if (middle !== null) { - var middleMetrics = delimiter_getMetrics(middle, font, mode); + const middleMetrics = getMetrics(middle, font, mode); middleHeightTotal = middleMetrics.height + middleMetrics.depth; middleFactor = 2; // repeat symmetrically above and below middle - } // Calcuate the minimal height that the delimiter can have. + } // Calculate the minimal height that the delimiter can have. // It is at least the size of the top, bottom, and optional middle combined. - var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need + const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need - var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols + const repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols - var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note + const realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note // that in this context, "center" means that the delimiter should be // centered around the axis in the current style, while normally it is // centered around the axis in textstyle. - var axisHeight = options.fontMetrics().axisHeight; + let axisHeight = options.fontMetrics().axisHeight; if (center) { axisHeight *= options.sizeMultiplier; } // Calculate the depth - var depth = realHeightTotal / 2 - axisHeight; // This function differs from the TeX procedure in one way. - // We shift each repeat element downwards by 0.005em, to prevent a gap - // due to browser floating point rounding error. - // Then, at the last element-to element joint, we add one extra repeat - // element to cover the gap created by the shifts. - // Find the shift needed to align the upper end of the extra element at a point - // 0.005em above the lower end of the top element. - - var shiftOfExtraElement = (repeatCount + 1) * 0.005 - repeatHeightTotal; // Now, we start building the pieces that will go into the vlist - // Keep a list of the inner pieces - - var inners = []; // Add the bottom symbol - - inners.push(delimiter_makeInner(bottom, font, mode)); - - if (middle === null) { - // Add that many symbols - for (var i = 0; i < repeatCount; i++) { - inners.push(lap); // overlap - - inners.push(delimiter_makeInner(repeat, font, mode)); - } - } else { - // When there is a middle bit, we need the middle part and two repeated - // sections - for (var _i = 0; _i < repeatCount; _i++) { - inners.push(lap); - inners.push(delimiter_makeInner(repeat, font, mode)); - } // Insert one extra repeat element. - - - inners.push({ - type: "kern", - size: shiftOfExtraElement + const depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + + const stack = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + const viewBoxHeight = Math.round(realHeightTotal * 1000); + const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + const path = new PathNode(svgLabel, pathStr); + const width = (viewBoxWidth / 1000).toFixed(3) + "em"; + const height = (viewBoxHeight / 1000).toFixed(3) + "em"; + const svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight }); - inners.push(delimiter_makeInner(repeat, font, mode)); - inners.push(lap); // Now insert the middle of the brace. - - inners.push(delimiter_makeInner(middle, font, mode)); + const wrapper = buildCommon.makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + const innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); // Now insert the middle of the brace. - for (var _i2 = 0; _i2 < repeatCount; _i2++) { - inners.push(lap); - inners.push(delimiter_makeInner(repeat, font, mode)); - } - } // To cover the gap create by the overlaps, insert one more repeat element, - // at a position that juts 0.005 above the bottom of the top element. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, innerHeight, options)); + } // Add the top symbol - inners.push({ - type: "kern", - size: shiftOfExtraElement - }); - inners.push(delimiter_makeInner(repeat, font, mode)); - inners.push(lap); // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } // Finally, build the vlist - inners.push(delimiter_makeInner(top, font, mode)); // Finally, build the vlist - var newOptions = options.havingBaseStyle(src_Style.TEXT); - var inner = buildCommon.makeVList({ + const newOptions = options.havingBaseStyle(src_Style.TEXT); + const inner = buildCommon.makeVList({ positionType: "bottom", positionData: depth, - children: inners + children: stack }, newOptions); - return delimiter_styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes); -}; // All surds have 0.08em padding above the viniculum inside the SVG. + return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes); +}; // All surds have 0.08em padding above the vinculum inside the SVG. // That keeps browser span height rounding error from pinching the line. -var vbPad = 80; // padding above the surd, measured inside the viewBox. +const vbPad = 80; // padding above the surd, measured inside the viewBox. -var emPad = 0.08; // padding, in ems, measured in the document. +const emPad = 0.08; // padding, in ems, measured in the document. -var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) { - var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight); - var pathNode = new domTree_PathNode(sqrtName, path); - var svg = new SvgNode([pathNode], { +const sqrtSvg = function (sqrtName, height, viewBoxHeight, extraVinculum, options) { + const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + const pathNode = new PathNode(sqrtName, path); + const svg = new SvgNode([pathNode], { // Note: 1000:1 ratio of viewBox to document em width. "width": "400em", - "height": height + "em", + "height": makeEm(height), "viewBox": "0 0 400000 " + viewBoxHeight, "preserveAspectRatio": "xMinYMin slice" }); @@ -8599,32 +9392,32 @@ var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraV */ -var makeSqrtImage = function makeSqrtImage(height, options) { +const makeSqrtImage = function (height, options) { // Define a newOptions that removes the effect of size changes such as \Huge. // We don't pick different a height surd for \Huge. For it, we scale up. - var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. + const newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. - var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); - var sizeMultiplier = newOptions.sizeMultiplier; // default - // The standard sqrt SVGs each have a 0.04em thick viniculum. - // If Settings.minRuleThickness is larger than that, we add extraViniculum. + const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + let sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. - var extraViniculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. + const extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. - var span; - var spanHeight = 0; - var texHeight = 0; - var viewBoxHeight = 0; - var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. + let span; + let spanHeight = 0; + let texHeight = 0; + let viewBoxHeight = 0; + let advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. // Then browser rounding error on the parent span height will not - // encroach on the ink of the viniculum. But that padding is not + // encroach on the ink of the vinculum. But that padding is not // included in the TeX-like `height` used for calculation of // vertical alignment. So texHeight = span.height < span.style.height. if (delim.type === "small") { // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. // 1000 unit normal glyph height. - viewBoxHeight = 1000 + 1000 * extraViniculum + vbPad; + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; if (height < 1.0) { sizeMultiplier = 1.0; // mimic a \textfont radical @@ -8632,71 +9425,71 @@ var makeSqrtImage = function makeSqrtImage(height, options) { sizeMultiplier = 0.7; // mimic a \scriptfont radical } - spanHeight = (1.0 + extraViniculum + emPad) / sizeMultiplier; - texHeight = (1.00 + extraViniculum) / sizeMultiplier; - span = delimiter_sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraViniculum, options); + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "0.853em"; advanceWidth = 0.833 / sizeMultiplier; // from the font. } else if (delim.type === "large") { // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; - texHeight = (sizeToMaxHeight[delim.size] + extraViniculum) / sizeMultiplier; - spanHeight = (sizeToMaxHeight[delim.size] + extraViniculum + emPad) / sizeMultiplier; - span = delimiter_sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraViniculum, options); + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "1.02em"; advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. } else { // Tall sqrt. In TeX, this would be stacked using multiple glyphs. // We'll use a single SVG to accomplish the same thing. - spanHeight = height + extraViniculum + emPad; - texHeight = height + extraViniculum; - viewBoxHeight = Math.floor(1000 * height + extraViniculum) + vbPad; - span = delimiter_sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraViniculum, options); + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "0.742em"; advanceWidth = 1.056; } span.height = texHeight; - span.style.height = spanHeight + "em"; + span.style.height = makeEm(spanHeight); return { - span: span, - advanceWidth: advanceWidth, + span, + advanceWidth, // Calculate the actual line width. // This actually should depend on the chosen font -- e.g. \boldmath // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and // have thicker rules. - ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraViniculum) * sizeMultiplier + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier }; }; // There are three kinds of delimiters, delimiters that stack when they become // too large -var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack +const stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack -var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1"]; // and delimiters that never stack +const stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]; // and delimiters that never stack -var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of +const stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ // Used to create stacked delimiters of appropriate sizes in makeSizedDelim. -var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; /** * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. */ -var delimiter_makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { +const makeSizedDelim = function (delim, size, options, mode, classes) { // < and > turn into \langle and \rangle in delimiters - if (delim === "<" || delim === "\\lt" || delim === "\u27E8") { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { delim = "\\langle"; - } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") { + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { delim = "\\rangle"; } // Sized delimiters are never centered. if (utils.contains(stackLargeDelimiters, delim) || utils.contains(stackNeverDelimiters, delim)) { - return delimiter_makeLargeDelim(delim, size, false, options, mode, classes); + return makeLargeDelim(delim, size, false, options, mode, classes); } else if (utils.contains(stackAlwaysDelimiters, delim)) { - return delimiter_makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); } else { throw new src_ParseError("Illegal delimiter: '" + delim + "'"); } @@ -8715,7 +9508,7 @@ var delimiter_makeSizedDelim = function makeSizedDelim(delim, size, options, mod // Delimiters that never stack try small delimiters and large delimiters only -var stackNeverDelimiterSequence = [{ +const stackNeverDelimiterSequence = [{ type: "small", style: src_Style.SCRIPTSCRIPT }, { @@ -8738,7 +9531,7 @@ var stackNeverDelimiterSequence = [{ size: 4 }]; // Delimiters that always stack try the small delimiters first, then stack -var stackAlwaysDelimiterSequence = [{ +const stackAlwaysDelimiterSequence = [{ type: "small", style: src_Style.SCRIPTSCRIPT }, { @@ -8752,7 +9545,7 @@ var stackAlwaysDelimiterSequence = [{ }]; // Delimiters that stack when large try the small and then large delimiters, and // stack afterwards -var stackLargeDelimiterSequence = [{ +const stackLargeDelimiterSequence = [{ type: "small", style: src_Style.SCRIPTSCRIPT }, { @@ -8781,7 +9574,7 @@ var stackLargeDelimiterSequence = [{ * TODO(#963) Use more specific font family return type once that is introduced. */ -var delimTypeToFont = function delimTypeToFont(type) { +const delimTypeToFont = function (type) { if (type.type === "small") { return "Main-Regular"; } else if (type.type === "large") { @@ -8798,25 +9591,25 @@ var delimTypeToFont = function delimTypeToFont(type) { */ -var traverseSequence = function traverseSequence(delim, height, sequence, options) { +const traverseSequence = function (delim, height, sequence, options) { // Here, we choose the index we should start at in the sequences. In smaller // sizes (which correspond to larger numbers in style.size) we start earlier // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 - var start = Math.min(2, 3 - options.style.size); + const start = Math.min(2, 3 - options.style.size); - for (var i = start; i < sequence.length; i++) { + for (let i = start; i < sequence.length; i++) { if (sequence[i].type === "stack") { // This is always the last delimiter, so we just break the loop now. break; } - var metrics = delimiter_getMetrics(delim, delimTypeToFont(sequence[i]), "math"); - var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we + const metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math"); + let heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we // account for the style change size. if (sequence[i].type === "small") { - var newOptions = options.havingBaseStyle(sequence[i].style); + const newOptions = options.havingBaseStyle(sequence[i].style); heightDepth *= newOptions.sizeMultiplier; } // Check if the delimiter at this size works for the given height. @@ -8835,15 +9628,15 @@ var traverseSequence = function traverseSequence(delim, height, sequence, option */ -var delimiter_makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { - if (delim === "<" || delim === "\\lt" || delim === "\u27E8") { +const makeCustomSizedDelim = function (delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { delim = "\\langle"; - } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") { + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { delim = "\\rangle"; } // Decide what sequence to use - var sequence; + let sequence; if (utils.contains(stackNeverDelimiters, delim)) { sequence = stackNeverDelimiterSequence; @@ -8854,18 +9647,18 @@ var delimiter_makeCustomSizedDelim = function makeCustomSizedDelim(delim, height } // Look through the sequence - var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. + const delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. // Depending on the sequence element we decided on, call the // appropriate function. if (delimType.type === "small") { - return delimiter_makeSmallDelim(delim, delimType.style, center, options, mode, classes); + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); } else if (delimType.type === "large") { - return delimiter_makeLargeDelim(delim, delimType.size, center, options, mode, classes); + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); } else /* if (delimType.type === "stack") */ { - return delimiter_makeStackedDelim(delim, height, center, options, mode, classes); + return makeStackedDelim(delim, height, center, options, mode, classes); } }; /** @@ -8874,14 +9667,14 @@ var delimiter_makeCustomSizedDelim = function makeCustomSizedDelim(delim, height */ -var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { +const makeLeftRightDelim = function (delim, height, depth, options, mode, classes) { // We always center \left/\right delimiters, so the axis is always shifted - var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right + const axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right - var delimiterFactor = 901; - var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; - var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); - var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are + const delimiterFactor = 901; + const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + const totalHeight = Math.max( // In real TeX, calculations are done using integral values which are // 65536 per pt, or 655360 per em. So, the division here truncates in // TeX but doesn't here, producing different results. If we wanted to // exactly match TeX's calculation, we could do @@ -8893,16 +9686,18 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total // height - return delimiter_makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); }; /* harmony default export */ var delimiter = ({ sqrtImage: makeSqrtImage, - sizedDelim: delimiter_makeSizedDelim, - customSizedDelim: delimiter_makeCustomSizedDelim, + sizedDelim: makeSizedDelim, + sizeToMaxHeight: sizeToMaxHeight, + customSizedDelim: makeCustomSizedDelim, leftRightDelim: makeLeftRightDelim }); -// CONCATENATED MODULE: ./src/functions/delimsizing.js +;// CONCATENATED MODULE: ./src/functions/delimsizing.js + @@ -8913,7 +9708,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio // Extra data needed for the delimiter handler down below -var delimiterSizes = { +const delimiterSizes = { "\\bigl": { mclass: "mopen", size: 1 @@ -8979,16 +9774,18 @@ var delimiterSizes = { size: 4 } }; -var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27E8", "\\rangle", "\u27E9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; +const delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; // Delimiter functions function checkDelimiter(delim, context) { - var symDelim = checkSymbolNodeType(delim); + const symDelim = checkSymbolNodeType(delim); if (symDelim && utils.contains(delimiters, symDelim.text)) { return symDelim; + } else if (symDelim) { + throw new src_ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); } else { - throw new src_ParseError("Invalid delimiter: '" + (symDelim ? symDelim.text : JSON.stringify(delim)) + "' after '" + context.funcName + "'", delim); + throw new src_ParseError("Invalid delimiter type '" + delim.type + "'", delim); } } @@ -8996,10 +9793,11 @@ defineFunction({ type: "delimsizing", names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], props: { - numArgs: 1 + numArgs: 1, + argTypes: ["primitive"] }, - handler: function handler(context, args) { - var delim = checkDelimiter(args[0], context); + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); return { type: "delimsizing", mode: context.parser.mode, @@ -9008,7 +9806,7 @@ defineFunction({ delim: delim.text }; }, - htmlBuilder: function htmlBuilder(group, options) { + htmlBuilder: (group, options) => { if (group.delim === ".") { // Empty delimiters still count as elements, even though they don't // show anything. @@ -9018,14 +9816,14 @@ defineFunction({ return delimiter.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); }, - mathmlBuilder: function mathmlBuilder(group) { - var children = []; + mathmlBuilder: group => { + const children = []; if (group.delim !== ".") { - children.push(buildMathML_makeText(group.delim, group.mode)); + children.push(makeText(group.delim, group.mode)); } - var node = new mathMLTree.MathNode("mo", children); + const node = new mathMLTree.MathNode("mo", children); if (group.mclass === "mopen" || group.mclass === "mclose") { // Only some of the delimsizing functions act as fences, and they @@ -9037,6 +9835,10 @@ defineFunction({ node.setAttribute("fence", "false"); } + node.setAttribute("stretchy", "true"); + const size = makeEm(delimiter.sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); return node; } }); @@ -9051,13 +9853,14 @@ defineFunction({ type: "leftright-right", names: ["\\right"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, - handler: function handler(context, args) { + handler: (context, args) => { // \left case below triggers parsing of \right in // `const right = parser.parseFunction();` // uses this return value. - var color = context.parser.gullet.macros.get("\\current@color"); + const color = context.parser.gullet.macros.get("\\current@color"); if (color && typeof color !== "string") { throw new src_ParseError("\\current@color set to non-string in \\right"); @@ -9067,7 +9870,7 @@ defineFunction({ type: "leftright-right", mode: context.parser.mode, delim: checkDelimiter(args[0], context).text, - color: color // undefined if not set via \color + color // undefined if not set via \color }; } @@ -9076,37 +9879,38 @@ defineFunction({ type: "leftright", names: ["\\left"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, - handler: function handler(context, args) { - var delim = checkDelimiter(args[0], context); - var parser = context.parser; // Parse out the implicit body + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + const parser = context.parser; // Parse out the implicit body ++parser.leftrightDepth; // parseExpression stops before '\\right' - var body = parser.parseExpression(false); + const body = parser.parseExpression(false); --parser.leftrightDepth; // Check the next token parser.expect("\\right", false); - var right = assertNodeType(parser.parseFunction(), "leftright-right"); + const right = assertNodeType(parser.parseFunction(), "leftright-right"); return { type: "leftright", mode: parser.mode, - body: body, + body, left: delim.text, right: right.delim, rightColor: right.color }; }, - htmlBuilder: function htmlBuilder(group, options) { + htmlBuilder: (group, options) => { assertParsed(group); // Build the inner expression - var inner = buildHTML_buildExpression(group.body, options, true, ["mopen", "mclose"]); - var innerHeight = 0; - var innerDepth = 0; - var hadMiddle = false; // Calculate its height and depth + const inner = buildExpression(group.body, options, true, ["mopen", "mclose"]); + let innerHeight = 0; + let innerDepth = 0; + let hadMiddle = false; // Calculate its height and depth - for (var i = 0; i < inner.length; i++) { + for (let i = 0; i < inner.length; i++) { // Property `isMiddle` not defined on `span`. See comment in // "middle"'s htmlBuilder. // $FlowFixMe @@ -9123,7 +9927,7 @@ defineFunction({ innerHeight *= options.sizeMultiplier; innerDepth *= options.sizeMultiplier; - var leftDelim; + let leftDelim; if (group.left === ".") { // Empty delimiters in \left and \right make null delimiter spaces. @@ -9138,26 +9942,26 @@ defineFunction({ inner.unshift(leftDelim); // Handle middle delimiters if (hadMiddle) { - for (var _i = 1; _i < inner.length; _i++) { - var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in + for (let i = 1; i < inner.length; i++) { + const middleDelim = inner[i]; // Property `isMiddle` not defined on `span`. See comment in // "middle"'s htmlBuilder. // $FlowFixMe - var isMiddle = middleDelim.isMiddle; + const isMiddle = middleDelim.isMiddle; if (isMiddle) { // Apply the options that were active when \middle was called - inner[_i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + inner[i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); } } } - var rightDelim; // Same for the right delimiter, but using color specified by \color + let rightDelim; // Same for the right delimiter, but using color specified by \color if (group.right === ".") { rightDelim = makeNullDelimiter(options, ["mclose"]); } else { - var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + const colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); } // Add it to the end of the expression. @@ -9165,18 +9969,18 @@ defineFunction({ inner.push(rightDelim); return buildCommon.makeSpan(["minner"], inner, options); }, - mathmlBuilder: function mathmlBuilder(group, options) { + mathmlBuilder: (group, options) => { assertParsed(group); - var inner = buildMathML_buildExpression(group.body, options); + const inner = buildMathML_buildExpression(group.body, options); if (group.left !== ".") { - var leftNode = new mathMLTree.MathNode("mo", [buildMathML_makeText(group.left, group.mode)]); + const leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]); leftNode.setAttribute("fence", "true"); inner.unshift(leftNode); } if (group.right !== ".") { - var rightNode = new mathMLTree.MathNode("mo", [buildMathML_makeText(group.right, group.mode)]); + const rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]); rightNode.setAttribute("fence", "true"); if (group.rightColor) { @@ -9186,17 +9990,18 @@ defineFunction({ inner.push(rightNode); } - return buildMathML_makeRow(inner); + return makeRow(inner); } }); defineFunction({ type: "middle", names: ["\\middle"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, - handler: function handler(context, args) { - var delim = checkDelimiter(args[0], context); + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); if (!context.parser.leftrightDepth) { throw new src_ParseError("\\middle without preceding \\left", delim); @@ -9208,16 +10013,16 @@ defineFunction({ delim: delim.text }; }, - htmlBuilder: function htmlBuilder(group, options) { - var middleDelim; + htmlBuilder: (group, options) => { + let middleDelim; if (group.delim === ".") { middleDelim = makeNullDelimiter(options, []); } else { middleDelim = delimiter.sizedDelim(group.delim, 1, options, group.mode, []); - var isMiddle = { + const isMiddle = { delim: group.delim, - options: options + options }; // Property `isMiddle` not defined on `span`. It is only used in // this file above. // TODO: Fix this violation of the `span` type and possibly rename @@ -9229,13 +10034,13 @@ defineFunction({ return middleDelim; }, - mathmlBuilder: function mathmlBuilder(group, options) { - // A Firefox \middle will strech a character vertically only if it + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it // is in the fence part of the operator dictionary at: // https://www.w3.org/TR/MathML3/appendixc.html. // So we need to avoid U+2223 and use plain "|" instead. - var textNode = group.delim === "\\vert" || group.delim === "|" ? buildMathML_makeText("|", "text") : buildMathML_makeText(group.delim, group.mode); - var middleNode = new mathMLTree.MathNode("mo", [textNode]); + const textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + const middleNode = new mathMLTree.MathNode("mo", [textNode]); middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each element. // \middle should get delimiter spacing instead. @@ -9244,7 +10049,10 @@ defineFunction({ return middleNode; } }); -// CONCATENATED MODULE: ./src/functions/enclose.js +;// CONCATENATED MODULE: ./src/functions/enclose.js + + + @@ -9254,57 +10062,99 @@ defineFunction({ -var enclose_htmlBuilder = function htmlBuilder(group, options) { - // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox +const enclose_htmlBuilder = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase // Some groups can return document fragments. Handle those by wrapping // them in a span. - var inner = buildCommon.wrapFragment(buildHTML_buildGroup(group.body, options), options); - var label = group.label.substr(1); - var scale = options.sizeMultiplier; - var img; - var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different + const inner = buildCommon.wrapFragment(buildGroup(group.body, options), options); + const label = group.label.slice(1); + let scale = options.sizeMultiplier; + let img; + let imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different // depending on whether the subject is wider than it is tall, or vice versa. // We don't know the width of a group, so as a proxy, we test if // the subject is a single character. This captures most of the // subjects that should get the "tall" treatment. - var isSingleChar = utils.isCharacterBox(group.body); + const isSingleChar = utils.isCharacterBox(group.body); if (label === "sout") { img = buildCommon.makeSpan(["stretchy", "sout"]); img.height = options.fontMetrics().defaultRuleThickness / scale; imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + const lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + const clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); // Prevent size changes like \Huge from affecting line thickness + + const newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + const angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle. + + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG + + const viewBoxHeight = Math.floor(1000 * angleHeight * scale); + const path = phasePath(viewBoxHeight); + const svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); // Wrap it in a span with overflow: hidden. + + img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; } else { // Add horizontal padding if (/cancel/.test(label)) { if (!isSingleChar) { inner.classes.push("cancel-pad"); } + } else if (label === "angl") { + inner.classes.push("anglpad"); } else { inner.classes.push("boxpad"); } // Add vertical padding - var vertPad = 0; - var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" + let topPad = 0; + let bottomPad = 0; + let ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" if (/box/.test(label)) { ruleThickness = Math.max(options.fontMetrics().fboxrule, // default options.minRuleThickness // User override. ); - vertPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + + bottomPad = Math.max(0, 0.25 - inner.depth); } else { - vertPad = isSingleChar ? 0.2 : 0; + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; } - img = stretchy.encloseSpan(inner, label, vertPad, options); + img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options); if (/fbox|boxed|fcolorbox/.test(label)) { img.style.borderStyle = "solid"; - img.style.borderWidth = ruleThickness + "em"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); } - imgShift = inner.depth + vertPad; + imgShift = inner.depth + bottomPad; if (group.backgroundColor) { img.style.backgroundColor = group.backgroundColor; @@ -9315,7 +10165,7 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { } } - var vlist; + let vlist; if (group.backgroundColor) { vlist = buildCommon.makeVList({ @@ -9332,6 +10182,7 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { }] }, options); } else { + const classes = /cancel|phase/.test(label) ? ["svg-align"] : []; vlist = buildCommon.makeVList({ positionType: "individualShift", children: [// Write the \cancel stroke on top of inner. @@ -9343,7 +10194,7 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { type: "elem", elem: img, shift: imgShift, - wrapperClasses: /cancel/.test(label) ? ["svg-align"] : [] + wrapperClasses: classes }] }, options); } @@ -9363,9 +10214,9 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { } }; -var enclose_mathmlBuilder = function mathmlBuilder(group, options) { - var fboxsep = 0; - var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]); +const enclose_mathmlBuilder = (group, options) => { + let fboxsep = 0; + const node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]); switch (group.label) { case "\\cancel": @@ -9376,6 +10227,10 @@ var enclose_mathmlBuilder = function mathmlBuilder(group, options) { node.setAttribute("notation", "downdiagonalstrike"); break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": node.setAttribute("notation", "horizontalstrike"); break; @@ -9384,6 +10239,10 @@ var enclose_mathmlBuilder = function mathmlBuilder(group, options) { node.setAttribute("notation", "box"); break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": case "\\colorbox": // doesn't have a good notation option. So use @@ -9396,7 +10255,7 @@ var enclose_mathmlBuilder = function mathmlBuilder(group, options) { node.setAttribute("voffset", fboxsep + "pt"); if (group.label === "\\fcolorbox") { - var thk = Math.max(options.fontMetrics().fboxrule, // default + const thk = Math.max(options.fontMetrics().fboxrule, // default options.minRuleThickness // user override ); node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor)); @@ -9422,22 +10281,25 @@ defineFunction({ props: { numArgs: 2, allowedInText: true, - greediness: 3, argTypes: ["color", "text"] }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser, - funcName = _ref.funcName; - var color = assertNodeType(args[0], "color-token").color; - var body = args[1]; + + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; return { type: "enclose", mode: parser.mode, label: funcName, backgroundColor: color, - body: body + body }; }, + htmlBuilder: enclose_htmlBuilder, mathmlBuilder: enclose_mathmlBuilder }); @@ -9447,24 +10309,27 @@ defineFunction({ props: { numArgs: 3, allowedInText: true, - greediness: 3, argTypes: ["color", "color", "text"] }, - handler: function handler(_ref2, args, optArgs) { - var parser = _ref2.parser, - funcName = _ref2.funcName; - var borderColor = assertNodeType(args[0], "color-token").color; - var backgroundColor = assertNodeType(args[1], "color-token").color; - var body = args[2]; + + handler(_ref2, args, optArgs) { + let { + parser, + funcName + } = _ref2; + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; + const body = args[2]; return { type: "enclose", mode: parser.mode, label: funcName, - backgroundColor: backgroundColor, - borderColor: borderColor, - body: body + backgroundColor, + borderColor, + body }; }, + htmlBuilder: enclose_htmlBuilder, mathmlBuilder: enclose_mathmlBuilder }); @@ -9476,8 +10341,11 @@ defineFunction({ argTypes: ["hbox"], allowedInText: true }, - handler: function handler(_ref3, args) { - var parser = _ref3.parser; + + handler(_ref3, args) { + let { + parser + } = _ref3; return { type: "enclose", mode: parser.mode, @@ -9485,28 +10353,55 @@ defineFunction({ body: args[0] }; } + }); defineFunction({ type: "enclose", - names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout"], + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"], props: { numArgs: 1 }, - handler: function handler(_ref4, args, optArgs) { - var parser = _ref4.parser, - funcName = _ref4.funcName; - var body = args[0]; + + handler(_ref4, args) { + let { + parser, + funcName + } = _ref4; + const body = args[0]; return { type: "enclose", mode: parser.mode, label: funcName, - body: body + body }; }, + htmlBuilder: enclose_htmlBuilder, mathmlBuilder: enclose_mathmlBuilder }); -// CONCATENATED MODULE: ./src/defineEnvironment.js +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + + handler(_ref5, args) { + let { + parser + } = _ref5; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } + +}); +;// CONCATENATED MODULE: ./src/defineEnvironment.js /** @@ -9514,29 +10409,29 @@ defineFunction({ * `environments.js` exports this same dictionary again and makes it public. * `Parser.js` requires this dictionary via `environments.js`. */ -var _environments = {}; +const _environments = {}; function defineEnvironment(_ref) { - var type = _ref.type, - names = _ref.names, - props = _ref.props, - handler = _ref.handler, - htmlBuilder = _ref.htmlBuilder, - mathmlBuilder = _ref.mathmlBuilder; + let { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; // Set default values of environments. - var data = { - type: type, + const data = { + type, numArgs: props.numArgs || 0, - greediness: 1, allowedInText: false, numOptionalArgs: 0, - handler: handler + handler }; - for (var i = 0; i < names.length; ++i) { + for (let i = 0; i < names.length; ++i) { // TODO: The value type of _environments should be a type union of all // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is // an existential type. - // $FlowFixMe _environments[names[i]] = data; } @@ -9548,7 +10443,107 @@ function defineEnvironment(_ref) { _mathmlGroupBuilders[type] = mathmlBuilder; } } -// CONCATENATED MODULE: ./src/environments/array.js +;// CONCATENATED MODULE: ./src/defineMacro.js + + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +const _macros = {}; // This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + _macros[name] = body; +} +;// CONCATENATED MODULE: ./src/SourceLocation.js +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // The + prefix indicates that these fields aren't writeable + // Lexer holding the input string. + // Start offset, zero-based inclusive. + // End offset, zero-based exclusive. + constructor(lexer, start, end) { + this.lexer = void 0; + this.start = void 0; + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + + + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } + +} +;// CONCATENATED MODULE: ./src/Token.js + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // don't expand the token + // used in \noexpand + constructor(text, // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + + + range(endToken, // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + } + +} +;// CONCATENATED MODULE: ./src/environments/array.js + + + @@ -9562,12 +10557,20 @@ function defineEnvironment(_ref) { +// Helper functions function getHLines(parser) { // Return an array. The array length = number of hlines. // Each element in the array tells if the line is dashed. - var hlineInfo = []; + const hlineInfo = []; parser.consumeSpaces(); - var nxt = parser.fetch().text; + let nxt = parser.fetch().text; + + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } while (nxt === "\\hline" || nxt === "\\hdashline") { parser.consume(); @@ -9578,6 +10581,26 @@ function getHLines(parser) { return hlineInfo; } + +const validateAmsEnvironmentContext = context => { + const settings = context.parser.settings; + + if (!settings.displayMode) { + throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; // autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. + + +function getAutoTag(name) { + if (name.indexOf("ed") === -1) { + return name.indexOf("*") === -1; + } // return undefined; + +} /** * Parse the body of the environment, with rows delimited by \\ and * columns delimited by &, and create a nested list in row-major order @@ -9587,17 +10610,29 @@ function getHLines(parser) { function parseArray(parser, _ref, style) { - var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, - addJot = _ref.addJot, - cols = _ref.cols, - arraystretch = _ref.arraystretch, - colSeparationType = _ref.colSeparationType; - // Parse body of array with \\ temporarily mapped to \cr + let { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; parser.gullet.beginGroup(); - parser.gullet.macros.set("\\\\", "\\cr"); // Get current arraystretch if it's not set by the environment + + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } // Get current arraystretch if it's not set by the environment + if (!arraystretch) { - var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); if (stretch == null) { // Default \arraystretch from lttab.dtx @@ -9613,17 +10648,39 @@ function parseArray(parser, _ref, style) { parser.gullet.beginGroup(); - var row = []; - var body = [row]; - var rowGaps = []; - var hLinesBeforeRow = []; // Test for \hline at the top of the array. + let row = []; + const body = [row]; + const rowGaps = []; + const hLinesBeforeRow = []; + const tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + + beginRow(); // Test for \hline at the top of the array. hLinesBeforeRow.push(getHLines(parser)); while (true) { // eslint-disable-line no-constant-condition // Parse each cell in its own group (namespace) - var cell = parser.parseExpression(false, "\\cr"); + let cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); parser.gullet.endGroup(); parser.gullet.beginGroup(); cell = { @@ -9636,21 +10693,33 @@ function parseArray(parser, _ref, style) { cell = { type: "styling", mode: parser.mode, - style: style, + style, body: [cell] }; } row.push(cell); - var next = parser.fetch().text; + const next = parser.fetch().text; if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new src_ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); } else if (next === "\\end") { - // Arrays terminate newlines with `\crcr` which consumes a `\cr` if - // the last line is empty. + endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. // NOTE: Currently, `cell` is the last item added into `row`. - if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0) { + + if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { body.pop(); } @@ -9659,60 +10728,74 @@ function parseArray(parser, _ref, style) { } break; - } else if (next === "\\cr") { - var cr = assertNodeType(parser.parseFunction(), "cr"); - rowGaps.push(cr.size); // check for \hline(s) following the row separator + } else if (next === "\\\\") { + parser.consume(); + let size; // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + + rowGaps.push(size ? size.value : null); + endRow(); // check for \hline(s) following the row separator hLinesBeforeRow.push(getHLines(parser)); row = []; body.push(row); + beginRow(); } else { throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); } } // End cell group - parser.gullet.endGroup(); // End array group defining \\ + parser.gullet.endGroup(); // End array group defining \cr parser.gullet.endGroup(); return { type: "array", mode: parser.mode, - addJot: addJot, - arraystretch: arraystretch, - body: body, - cols: cols, - rowGaps: rowGaps, - hskipBeforeAndAfter: hskipBeforeAndAfter, - hLinesBeforeRow: hLinesBeforeRow, - colSeparationType: colSeparationType + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno }; } // Decides on a style for cells in an array according to whether the given // environment name starts with the letter 'd'. function dCellStyle(envName) { - if (envName.substr(0, 1) === "d") { + if (envName.slice(0, 1) === "d") { return "display"; } else { return "text"; } } -var array_htmlBuilder = function htmlBuilder(group, options) { - var r; - var c; - var nr = group.body.length; - var hLinesBeforeRow = group.hLinesBeforeRow; - var nc = 0; - var body = new Array(nr); - var hlines = []; - var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. +const array_htmlBuilder = function (group, options) { + let r; + let c; + const nr = group.body.length; + const hLinesBeforeRow = group.hLinesBeforeRow; + let nc = 0; + let body = new Array(nr); + const hlines = []; + const ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. ); // Horizontal spacing - var pt = 1 / options.fontMetrics().ptPerEm; - var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + const pt = 1 / options.fontMetrics().ptPerEm; + let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls if (group.colSeparationType && group.colSeparationType === "small") { // We're in a {smallmatrix}. Default column space is \thickspace, @@ -9720,25 +10803,28 @@ var array_htmlBuilder = function htmlBuilder(group, options) { // But that needs adjustment because LaTeX applies \scriptstyle to the // entire array, including the colspace, but this function applies // \scriptstyle only inside each element. - var localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier; + const localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier; arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); } // Vertical spacing - var baselineskip = 12 * pt; // see size10.clo + const baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo // Default \jot from ltmath.dtx // TODO(edemaine): allow overriding \jot via \setlength (#687) - var jot = 3 * pt; - var arrayskip = group.arraystretch * baselineskip; - var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + const jot = 3 * pt; + const arrayskip = group.arraystretch * baselineskip; + const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and - var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx - var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. + let totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. function setHLinePos(hlinesInGap) { - for (var i = 0; i < hlinesInGap.length; ++i) { + for (let i = 0; i < hlinesInGap.length; ++i) { if (i > 0) { totalHeight += 0.25; } @@ -9753,19 +10839,19 @@ var array_htmlBuilder = function htmlBuilder(group, options) { setHLinePos(hLinesBeforeRow[0]); for (r = 0; r < group.body.length; ++r) { - var inrow = group.body[r]; - var height = arstrutHeight; // \@array adds an \@arstrut + const inrow = group.body[r]; + let height = arstrutHeight; // \@array adds an \@arstrut - var depth = arstrutDepth; // to each tow (via the template) + let depth = arstrutDepth; // to each tow (via the template) if (nc < inrow.length) { nc = inrow.length; } - var outrow = new Array(inrow.length); + const outrow = new Array(inrow.length); for (c = 0; c < inrow.length; ++c) { - var elt = buildHTML_buildGroup(inrow[c], options); + const elt = buildGroup(inrow[c], options); if (depth < elt.depth) { depth = elt.depth; @@ -9778,11 +10864,11 @@ var array_htmlBuilder = function htmlBuilder(group, options) { outrow[c] = elt; } - var rowGap = group.rowGaps[r]; - var gap = 0; + const rowGap = group.rowGaps[r]; + let gap = 0; if (rowGap) { - gap = units_calculateSize(rowGap, options); + gap = calculateSize(rowGap, options); if (gap > 0) { // \@argarraycr @@ -9814,35 +10900,71 @@ var array_htmlBuilder = function htmlBuilder(group, options) { setHLinePos(hLinesBeforeRow[r + 1]); } - var offset = totalHeight / 2 + options.fontMetrics().axisHeight; - var colDescriptions = group.cols || []; - var cols = []; - var colSep; - var colDescrNum; + const offset = totalHeight / 2 + options.fontMetrics().axisHeight; + const colDescriptions = group.cols || []; + const cols = []; + let colSep; + let colDescrNum; + const tagSpans = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + const rw = body[r]; + const shift = rw.pos - offset; + const tag = group.tags[r]; + let tagSpan; + + if (tag === true) { + // automatic numbering + tagSpan = buildCommon.makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = buildCommon.makeSpan([], [], options); + } else { + // manual \tag + tagSpan = buildCommon.makeSpan([], buildExpression(tag, options, true), options); + } + + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column // descriptions, so trailing separators don't get lost. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { - var colDescr = colDescriptions[colDescrNum] || {}; - var firstSeparator = true; + let colDescr = colDescriptions[colDescrNum] || {}; + let firstSeparator = true; while (colDescr.type === "separator") { // If there is more than one separator in a row, add a space // between them. if (!firstSeparator) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = options.fontMetrics().doubleRuleSep + "em"; + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); cols.push(colSep); } if (colDescr.separator === "|" || colDescr.separator === ":") { - var lineType = colDescr.separator === "|" ? "solid" : "dashed"; - var separator = buildCommon.makeSpan(["vertical-separator"], [], options); - separator.style.height = totalHeight + "em"; - separator.style.borderRightWidth = ruleThickness + "em"; + const lineType = colDescr.separator === "|" ? "solid" : "dashed"; + const separator = buildCommon.makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); separator.style.borderRightStyle = lineType; - separator.style.margin = "0 -" + ruleThickness / 2 + "em"; - separator.style.verticalAlign = -(totalHeight - offset) + "em"; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + const shift = totalHeight - offset; + + if (shift) { + separator.style.verticalAlign = makeEm(-shift); + } + cols.push(separator); } else { throw new src_ParseError("Invalid separator type: " + colDescr.separator); @@ -9857,29 +10979,29 @@ var array_htmlBuilder = function htmlBuilder(group, options) { continue; } - var sepwidth = void 0; + let sepwidth; if (c > 0 || group.hskipBeforeAndAfter) { sepwidth = utils.deflt(colDescr.pregap, arraycolsep); if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } - var col = []; + let col = []; for (r = 0; r < nr; ++r) { - var row = body[r]; - var elem = row[c]; + const row = body[r]; + const elem = row[c]; if (!elem) { continue; } - var shift = row.pos - offset; + const shift = row.pos - offset; elem.depth = row.depth; elem.height = row.height; col.push({ @@ -9901,7 +11023,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) { if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } @@ -9910,17 +11032,17 @@ var array_htmlBuilder = function htmlBuilder(group, options) { body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any. if (hlines.length > 0) { - var line = buildCommon.makeLineSpan("hline", options, ruleThickness); - var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); - var vListElems = [{ + const line = buildCommon.makeLineSpan("hline", options, ruleThickness); + const dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); + const vListElems = [{ type: "elem", elem: body, shift: 0 }]; while (hlines.length > 0) { - var hline = hlines.pop(); - var lineShift = hline.pos - offset; + const hline = hlines.pop(); + const lineShift = hline.pos - offset; if (hline.isDashed) { vListElems.push({ @@ -9943,21 +11065,52 @@ var array_htmlBuilder = function htmlBuilder(group, options) { }, options); } - return buildCommon.makeSpan(["mord"], [body], options); + if (tagSpans.length === 0) { + return buildCommon.makeSpan(["mord"], [body], options); + } else { + let eqnNumCol = buildCommon.makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options); + return buildCommon.makeFragment([body, eqnNumCol]); + } }; -var alignMap = { +const alignMap = { c: "center ", l: "left ", r: "right " }; -var array_mathmlBuilder = function mathmlBuilder(group, options) { - var table = new mathMLTree.MathNode("mtable", group.body.map(function (row) { - return new mathMLTree.MathNode("mtr", row.map(function (cell) { - return new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(cell, options)]); - })); - })); // Set column alignment, row spacing, column spacing, and +const array_mathmlBuilder = function (group, options) { + const tbl = []; + const glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]); + const tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]); + + for (let i = 0; i < group.body.length; i++) { + const rw = group.body[i]; + const row = []; + + for (let j = 0; j < rw.length; j++) { + row.push(new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(rw[j], options)])); + } + + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + + tbl.push(new mathMLTree.MathNode("mtr", row)); + } + + let table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and // array lines by setting attributes on the table element. // Set the row spacing. In MathML, we specify a gap distance. // We do not use rowGap[] because MathML automatically increases @@ -9965,24 +11118,24 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. // We simulate this by adding (arraystretch - 1)em to the gap. This // does a reasonable job of adjusting arrays containing 1 em tall content. - // The 0.16 and 0.09 values are found emprically. They produce an array - // similar to LaTeX and in which content does not interfere with \hines. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. - var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + const gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); - table.setAttribute("rowspacing", gap + "em"); // MathML table lines go only between cells. + table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells. // To place a line on an edge we'll use , if necessary. - var menclose = ""; - var align = ""; + let menclose = ""; + let align = ""; - if (group.cols) { + if (group.cols && group.cols.length > 0) { // Find column alignment, column spacing, and vertical lines. - var cols = group.cols; - var columnLines = ""; - var prevTypeWasAlign = false; - var iStart = 0; - var iEnd = cols.length; + const cols = group.cols; + let columnLines = ""; + let prevTypeWasAlign = false; + let iStart = 0; + let iEnd = cols.length; if (cols[0].type === "separator") { menclose += "top "; @@ -9994,7 +11147,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { iEnd -= 1; } - for (var i = iStart; i < iEnd; i++) { + for (let i = iStart; i < iEnd; i++) { if (cols[i].type === "align") { align += alignMap[cols[i].align]; @@ -10022,32 +11175,33 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { if (group.colSeparationType === "align") { - var _cols = group.cols || []; + const cols = group.cols || []; + let spacing = ""; - var spacing = ""; - - for (var _i = 1; _i < _cols.length; _i++) { - spacing += _i % 2 ? "0em " : "1em "; + for (let i = 1; i < cols.length; i++) { + spacing += i % 2 ? "0em " : "1em "; } table.setAttribute("columnspacing", spacing.trim()); - } else if (group.colSeparationType === "alignat") { + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { table.setAttribute("columnspacing", "0em"); } else if (group.colSeparationType === "small") { table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); } else { table.setAttribute("columnspacing", "1em"); } // Address \hline and \hdashline - var rowLines = ""; - var hlines = group.hLinesBeforeRow; + let rowLines = ""; + const hlines = group.hLinesBeforeRow; menclose += hlines[0].length > 0 ? "left " : ""; menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; - for (var _i2 = 1; _i2 < hlines.length - 1; _i2++) { - rowLines += hlines[_i2].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. - : hlines[_i2][0] ? "dashed " : "solid "; + for (let i = 1; i < hlines.length - 1; i++) { + rowLines += hlines[i].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. + : hlines[i][0] ? "dashed " : "solid "; } if (/[sd]/.test(rowLines)) { @@ -10066,14 +11220,25 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { } return table; -}; // Convenience function for aligned and alignedat environments. +}; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat. + +const alignedHandler = function (context, args) { + if (context.envName.indexOf("ed") === -1) { + validateAmsEnvironmentContext(context); + } -var array_alignedHandler = function alignedHandler(context, args) { - var cols = []; - var res = parseArray(context.parser, { - cols: cols, - addJot: true + const cols = []; + const separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align"; + const isSplit = context.envName === "split"; + const res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno }, "display"); // Determining number of columns. // 1. If the first argument is given, we use it as a number of columns, // and makes sure that each row doesn't exceed that number. @@ -10084,20 +11249,19 @@ var array_alignedHandler = function alignedHandler(context, args) { // cell in each row (starting with second cell) so that operators become // binary. This behavior is implemented in amsmath's \start@aligned. - var numMaths; - var numCols = 0; - var emptyGroup = { + let numMaths; + let numCols = 0; + const emptyGroup = { type: "ordgroup", mode: context.mode, body: [] }; - var ordgroup = checkNodeType(args[0], "ordgroup"); - if (ordgroup) { - var arg0 = ""; + if (args[0] && args[0].type === "ordgroup") { + let arg0 = ""; - for (var i = 0; i < ordgroup.body.length; i++) { - var textord = assertNodeType(ordgroup.body[i], "textord"); + for (let i = 0; i < args[0].body.length; i++) { + const textord = assertNodeType(args[0].body[i], "textord"); arg0 += textord.text; } @@ -10105,20 +11269,18 @@ var array_alignedHandler = function alignedHandler(context, args) { numCols = numMaths * 2; } - var isAligned = !numCols; + const isAligned = !numCols; res.body.forEach(function (row) { - for (var _i3 = 1; _i3 < row.length; _i3 += 2) { + for (let i = 1; i < row.length; i += 2) { // Modify ordgroup node within styling node - var styling = assertNodeType(row[_i3], "styling"); - - var _ordgroup = assertNodeType(styling.body[0], "ordgroup"); - - _ordgroup.body.unshift(emptyGroup); + const styling = assertNodeType(row[i], "styling"); + const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); } if (!isAligned) { // Case 1 - var curMaths = row.length / 2; + const curMaths = row.length / 2; if (numMaths < curMaths) { throw new src_ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); @@ -10131,18 +11293,18 @@ var array_alignedHandler = function alignedHandler(context, args) { // In aligned mode, we add one \qquad between columns; // otherwise we add nothing. - for (var _i4 = 0; _i4 < numCols; ++_i4) { - var align = "r"; - var pregap = 0; + for (let i = 0; i < numCols; ++i) { + let align = "r"; + let pregap = 0; - if (_i4 % 2 === 1) { + if (i % 2 === 1) { align = "l"; - } else if (_i4 > 0 && isAligned) { + } else if (i > 0 && isAligned) { // "aligned" mode. pregap = 1; // add one \quad } - cols[_i4] = { + cols[i] = { type: "align", align: align, pregap: pregap, @@ -10164,16 +11326,17 @@ defineEnvironment({ props: { numArgs: 1 }, - handler: function handler(context, args) { + + handler(context, args) { // Since no types are specified above, the two possibilities are // - The argument is wrapped in {} or [], in which case Parser's // parseGroup() returns an "ordgroup" wrapping some symbol node. // - The argument is a bare symbol node. - var symNode = checkSymbolNodeType(args[0]); - var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; - var cols = colalign.map(function (nde) { - var node = assertSymbolNodeType(nde); - var ca = node.text; + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; if ("lcr".indexOf(ca) !== -1) { return { @@ -10194,38 +11357,81 @@ defineEnvironment({ throw new src_ParseError("Unknown column alignment: " + ca, nde); }); - var res = { - cols: cols, - hskipBeforeAndAfter: true // \@preamble in lttab.dtx - + const res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length }; return parseArray(context.parser, res, dCellStyle(context.envName)); }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); // The matrix environments of amsmath builds on the array environment // of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. defineEnvironment({ type: "array", - names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"], + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], props: { numArgs: 0 }, - handler: function handler(context) { - var delimiters = { + + handler(context) { + const delimiters = { "matrix": null, "pmatrix": ["(", ")"], "bmatrix": ["[", "]"], "Bmatrix": ["\\{", "\\}"], "vmatrix": ["|", "|"], "Vmatrix": ["\\Vert", "\\Vert"] - }[context.envName]; // \hskip -\arraycolsep in amsmath + }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath - var payload = { - hskipBeforeAndAfter: false + let colAlign = "c"; + const payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] }; - var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + const parser = context.parser; + parser.consumeSpaces(); + + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + + if ("lcr".indexOf(colAlign) === -1) { + throw new src_ParseError("Expected l or c or r", parser.nextToken); + } + + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs. + + const numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); return delimiters ? { type: "leftright", mode: context.mode, @@ -10236,6 +11442,7 @@ defineEnvironment({ } : res; }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); @@ -10245,14 +11452,16 @@ defineEnvironment({ props: { numArgs: 0 }, - handler: function handler(context) { - var payload = { + + handler(context) { + const payload = { arraystretch: 0.5 }; - var res = parseArray(context.parser, payload, "script"); + const res = parseArray(context.parser, payload, "script"); res.colSeparationType = "small"; return res; }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); @@ -10262,13 +11471,14 @@ defineEnvironment({ props: { numArgs: 1 }, - handler: function handler(context, args) { + + handler(context, args) { // Parsing of {subarray} is similar to {array} - var symNode = checkSymbolNodeType(args[0]); - var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; - var cols = colalign.map(function (nde) { - var node = assertSymbolNodeType(nde); - var ca = node.text; // {subarray} only recognizes "l" & "c" + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; // {subarray} only recognizes "l" & "c" if ("lc".indexOf(ca) !== -1) { return { @@ -10284,19 +11494,20 @@ defineEnvironment({ throw new src_ParseError("{subarray} can contain only one column"); } - var res = { - cols: cols, + let res = { + cols, hskipBeforeAndAfter: false, arraystretch: 0.5 }; res = parseArray(context.parser, res, "script"); - if (res.body[0].length > 1) { + if (res.body.length > 0 && res.body[0].length > 1) { throw new src_ParseError("{subarray} can contain only one column"); } return res; }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); // A cases environment (in amsmath.sty) is almost equivalent to @@ -10304,15 +11515,17 @@ defineEnvironment({ // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. // {dcases} is a {cases} environment where cells are set in \displaystyle, // as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. defineEnvironment({ type: "array", - names: ["cases", "dcases"], + names: ["cases", "dcases", "rcases", "drcases"], props: { numArgs: 0 }, - handler: function handler(context) { - var payload = { + + handler(context) { + const payload = { arraystretch: 1.2, cols: [{ type: "align", @@ -10332,30 +11545,33 @@ defineEnvironment({ postgap: 0 }] }; - var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); return { type: "leftright", mode: context.mode, body: [res], - left: "\\{", - right: ".", + left: context.envName.indexOf("r") > -1 ? "." : "\\{", + right: context.envName.indexOf("r") > -1 ? "\\}" : ".", rightColor: undefined }; }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder -}); // An aligned environment is like the align* environment -// except it operates within math mode. +}); // In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. // Note that we assume \nomallineskiplimit to be zero, // so that \strut@ is the same as \strut. defineEnvironment({ type: "array", - names: ["aligned"], + names: ["align", "align*", "aligned", "split"], props: { numArgs: 0 }, - handler: array_alignedHandler, + handler: alignedHandler, htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); // A gathered environment is like an array environment with one centered @@ -10364,20 +11580,30 @@ defineEnvironment({ defineEnvironment({ type: "array", - names: ["gathered"], + names: ["gathered", "gather", "gather*"], props: { numArgs: 0 }, - handler: function handler(context) { - var res = { + + handler(context) { + if (utils.contains(["gather", "gather*"], context.envName)) { + validateAmsEnvironmentContext(context); + } + + const res = { cols: [{ type: "align", align: "c" }], - addJot: true + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno }; return parseArray(context.parser, res, "display"); }, + htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder }); // alignat environment is like an align environment, but one must explicitly @@ -10386,266 +11612,148 @@ defineEnvironment({ defineEnvironment({ type: "array", - names: ["alignedat"], - // One for numbered and for unnumbered; - // but, KaTeX doesn't supports math numbering yet, - // they make no difference for now. + names: ["alignat", "alignat*", "alignedat"], props: { numArgs: 1 }, - handler: array_alignedHandler, + handler: alignedHandler, htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder -}); // Catch \hline outside array environment - -defineFunction({ - type: "text", - // Doesn't matter what this is. - names: ["\\hline", "\\hdashline"], - props: { - numArgs: 0, - allowedInText: true, - allowedInMath: true - }, - handler: function handler(context, args) { - throw new src_ParseError(context.funcName + " valid only within array environment"); - } }); -// CONCATENATED MODULE: ./src/environments.js - -var environments = _environments; -/* harmony default export */ var src_environments = (environments); // All environment definitions should be imported below - - -// CONCATENATED MODULE: ./src/functions/environment.js - - - - // Environment delimiters. HTML/MathML rendering is defined in the corresponding -// defineEnvironment definitions. -// $FlowFixMe, "environment" handler returns an environment ParseNode - -defineFunction({ - type: "environment", - names: ["\\begin", "\\end"], +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], props: { - numArgs: 1, - argTypes: ["text"] + numArgs: 0 }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var nameGroup = args[0]; - - if (nameGroup.type !== "ordgroup") { - throw new src_ParseError("Invalid environment name", nameGroup); - } - - var envName = ""; - - for (var i = 0; i < nameGroup.body.length; ++i) { - envName += assertNodeType(nameGroup.body[i], "textord").text; - } - - if (funcName === "\\begin") { - // begin...end is similar to left...right - if (!src_environments.hasOwnProperty(envName)) { - throw new src_ParseError("No such environment: " + envName, nameGroup); - } // Build the environment object. Arguments and other information will - // be made available to the begin and end methods using properties. - - - var env = src_environments[envName]; - - var _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env), - _args = _parser$parseArgument.args, - optArgs = _parser$parseArgument.optArgs; - - var context = { - mode: parser.mode, - envName: envName, - parser: parser - }; - var result = env.handler(context, _args, optArgs); - parser.expect("\\end", false); - var endNameToken = parser.nextToken; - var end = assertNodeType(parser.parseFunction(), "environment"); - if (end.name !== envName) { - throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); - } - - return result; - } - - return { - type: "environment", - mode: parser.mode, - name: envName, - nameGroup: nameGroup + handler(context) { + validateAmsEnvironmentContext(context); + const res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno }; - } -}); -// CONCATENATED MODULE: ./src/functions/mclass.js - - - - - - -var mclass_makeSpan = buildCommon.makeSpan; - -function mclass_htmlBuilder(group, options) { - var elements = buildHTML_buildExpression(group.body, options, true); - return mclass_makeSpan([group.mclass], elements, options); -} - -function mclass_mathmlBuilder(group, options) { - var node; - var inner = buildMathML_buildExpression(group.body, options); - - if (group.mclass === "minner") { - return mathMLTree.newDocumentFragment(inner); - } else if (group.mclass === "mord") { - if (group.isCharacterBox) { - node = inner[0]; - node.type = "mi"; - } else { - node = new mathMLTree.MathNode("mi", inner); - } - } else { - if (group.isCharacterBox) { - node = inner[0]; - node.type = "mo"; - } else { - node = new mathMLTree.MathNode("mo", inner); - } // Set spacing based on what is the most likely adjacent atom type. - // See TeXbook p170. - - - if (group.mclass === "mbin") { - node.attributes.lspace = "0.22em"; // medium space - - node.attributes.rspace = "0.22em"; - } else if (group.mclass === "mpunct") { - node.attributes.lspace = "0em"; - node.attributes.rspace = "0.17em"; // thinspace - } else if (group.mclass === "mopen" || group.mclass === "mclose") { - node.attributes.lspace = "0em"; - node.attributes.rspace = "0em"; - } // MathML default space is 5/18 em, so needs no action. - // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo - - } - - return node; -} // Math class commands except \mathop - + return parseArray(context.parser, res, "display"); + }, -defineFunction({ - type: "mclass", - names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["CD"], props: { - numArgs: 1 + numArgs: 0 }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var body = args[0]; - return { - type: "mclass", - mode: parser.mode, - mclass: "m" + funcName.substr(5), - // TODO(kevinb): don't prefix with 'm' - body: defineFunction_ordargument(body), - isCharacterBox: utils.isCharacterBox(body) - }; + + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); }, - htmlBuilder: mclass_htmlBuilder, - mathmlBuilder: mclass_mathmlBuilder -}); -var binrelClass = function binrelClass(arg) { - // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. - // (by rendering separately and with {}s before and after, and measuring - // the change in spacing). We'll do roughly the same by detecting the - // atom type directly. - var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; - if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { - return "m" + atom.family; - } else { - return "mord"; - } -}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. -// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment defineFunction({ - type: "mclass", - names: ["\\@binrel"], + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], props: { - numArgs: 2 - }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser; - return { - type: "mclass", - mode: parser.mode, - mclass: binrelClass(args[0]), - body: [args[1]], - isCharacterBox: utils.isCharacterBox(args[1]) - }; + numArgs: 0, + allowedInText: true, + allowedInMath: true + }, + + handler(context, args) { + throw new src_ParseError(context.funcName + " valid only within array environment"); } -}); // Build a relation or stacked op by placing one symbol on top of another + +}); +;// CONCATENATED MODULE: ./src/environments.js + +const environments = _environments; +/* harmony default export */ var src_environments = (environments); // All environment definitions should be imported below + + +;// CONCATENATED MODULE: ./src/functions/environment.js + + + + // Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. defineFunction({ - type: "mclass", - names: ["\\stackrel", "\\overset", "\\underset"], + type: "environment", + names: ["\\begin", "\\end"], props: { - numArgs: 2 + numArgs: 1, + argTypes: ["text"] }, - handler: function handler(_ref3, args) { - var parser = _ref3.parser, - funcName = _ref3.funcName; - var baseArg = args[1]; - var shiftedArg = args[0]; - var mclass; - if (funcName !== "\\stackrel") { - // LaTeX applies \binrel spacing to \overset and \underset. - mclass = binrelClass(baseArg); - } else { - mclass = "mrel"; // for \stackrel + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const nameGroup = args[0]; + + if (nameGroup.type !== "ordgroup") { + throw new src_ParseError("Invalid environment name", nameGroup); + } + + let envName = ""; + + for (let i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!src_environments.hasOwnProperty(envName)) { + throw new src_ParseError("No such environment: " + envName, nameGroup); + } // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + + + const env = src_environments[envName]; + const { + args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + const context = { + mode: parser.mode, + envName, + parser + }; + const result = env.handler(context, args, optArgs); + parser.expect("\\end", false); + const endNameToken = parser.nextToken; + const end = assertNodeType(parser.parseFunction(), "environment"); + + if (end.name !== envName) { + throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } // $FlowFixMe, "environment" handler returns an environment ParseNode + + + return result; } - var baseOp = { - type: "op", - mode: baseArg.mode, - limits: true, - alwaysHandleSupSub: true, - parentIsSupSub: false, - symbol: false, - suppressBaseShift: funcName !== "\\stackrel", - body: defineFunction_ordargument(baseArg) - }; - var supsub = { - type: "supsub", - mode: shiftedArg.mode, - base: baseOp, - sup: funcName === "\\underset" ? null : shiftedArg, - sub: funcName === "\\underset" ? shiftedArg : null - }; return { - type: "mclass", + type: "environment", mode: parser.mode, - mclass: mclass, - body: [supsub], - isCharacterBox: utils.isCharacterBox(supsub) + name: envName, + nameGroup }; - }, - htmlBuilder: mclass_htmlBuilder, - mathmlBuilder: mclass_mathmlBuilder + } + }); -// CONCATENATED MODULE: ./src/functions/font.js +;// CONCATENATED MODULE: ./src/functions/font.js // TODO(kevinb): implement \\sl and \\sc @@ -10653,19 +11761,19 @@ defineFunction({ -var font_htmlBuilder = function htmlBuilder(group, options) { - var font = group.font; - var newOptions = options.withFont(font); - return buildHTML_buildGroup(group.body, newOptions); +const font_htmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); }; -var font_mathmlBuilder = function mathmlBuilder(group, options) { - var font = group.font; - var newOptions = options.withFont(font); +const font_mathmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); return buildMathML_buildGroup(group.body, newOptions); }; -var fontAliases = { +const fontAliases = { "\\Bbb": "\\mathbb", "\\bold": "\\mathbf", "\\frak": "\\mathfrak", @@ -10679,13 +11787,15 @@ defineFunction({ "\\Bbb", "\\bold", "\\frak"], props: { numArgs: 1, - greediness: 2 + allowedInArgument: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var body = args[0]; - var func = funcName; + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = normalizeArgument(args[0]); + let func = funcName; if (func in fontAliases) { func = fontAliases[func]; @@ -10695,7 +11805,7 @@ defineFunction({ type: "font", mode: parser.mode, font: func.slice(1), - body: body + body }; }, htmlBuilder: font_htmlBuilder, @@ -10705,13 +11815,14 @@ defineFunction({ type: "mclass", names: ["\\boldsymbol", "\\bm"], props: { - numArgs: 1, - greediness: 2 + numArgs: 1 }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser; - var body = args[0]; - var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + const isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the // argument's bin|rel|ord status return { @@ -10722,7 +11833,7 @@ defineFunction({ type: "font", mode: parser.mode, font: "boldsymbol", - body: body + body }], isCharacterBox: isCharacterBox }; @@ -10731,18 +11842,22 @@ defineFunction({ defineFunction({ type: "font", - names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it"], + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], props: { numArgs: 0, allowedInText: true }, - handler: function handler(_ref3, args) { - var parser = _ref3.parser, - funcName = _ref3.funcName, - breakOnTokenText = _ref3.breakOnTokenText; - var mode = parser.mode; - var body = parser.parseExpression(true, breakOnTokenText); - var style = "math" + funcName.slice(1); + handler: (_ref3, args) => { + let { + parser, + funcName, + breakOnTokenText + } = _ref3; + const { + mode + } = parser; + const body = parser.parseExpression(true, breakOnTokenText); + const style = "math" + funcName.slice(1); return { type: "font", mode: mode, @@ -10750,14 +11865,14 @@ defineFunction({ body: { type: "ordgroup", mode: parser.mode, - body: body + body } }; }, htmlBuilder: font_htmlBuilder, mathmlBuilder: font_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/genfrac.js +;// CONCATENATED MODULE: ./src/functions/genfrac.js @@ -10769,10 +11884,10 @@ defineFunction({ -var genfrac_adjustStyle = function adjustStyle(size, originalStyle) { +const adjustStyle = (size, originalStyle) => { // Figure out what style this fraction should be in based on the // function used - var style = originalStyle; + let style = originalStyle; if (size === "display") { // Get display style as a default. @@ -10790,33 +11905,33 @@ var genfrac_adjustStyle = function adjustStyle(size, originalStyle) { return style; }; -var genfrac_htmlBuilder = function htmlBuilder(group, options) { +const genfrac_htmlBuilder = (group, options) => { // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). - var style = genfrac_adjustStyle(group.size, options.style); - var nstyle = style.fracNum(); - var dstyle = style.fracDen(); - var newOptions; + const style = adjustStyle(group.size, options.style); + const nstyle = style.fracNum(); + const dstyle = style.fracDen(); + let newOptions; newOptions = options.havingStyle(nstyle); - var numerm = buildHTML_buildGroup(group.numer, newOptions, options); + const numerm = buildGroup(group.numer, newOptions, options); if (group.continued) { // \cfrac inserts a \strut into the numerator. // Get \strut dimensions from TeXbook page 353. - var hStrut = 8.5 / options.fontMetrics().ptPerEm; - var dStrut = 3.5 / options.fontMetrics().ptPerEm; + const hStrut = 8.5 / options.fontMetrics().ptPerEm; + const dStrut = 3.5 / options.fontMetrics().ptPerEm; numerm.height = numerm.height < hStrut ? hStrut : numerm.height; numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; } newOptions = options.havingStyle(dstyle); - var denomm = buildHTML_buildGroup(group.denom, newOptions, options); - var rule; - var ruleWidth; - var ruleSpacing; + const denomm = buildGroup(group.denom, newOptions, options); + let rule; + let ruleWidth; + let ruleSpacing; if (group.hasBarLine) { if (group.barSize) { - ruleWidth = units_calculateSize(group.barSize, options); + ruleWidth = calculateSize(group.barSize, options); rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth); } else { rule = buildCommon.makeLineSpan("frac-line", options); @@ -10831,9 +11946,9 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { } // Rule 15b - var numShift; - var clearance; - var denomShift; + let numShift; + let clearance; + let denomShift; if (style.size === src_Style.DISPLAY.size || group.size === "display") { numShift = options.fontMetrics().num1; @@ -10857,11 +11972,11 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { denomShift = options.fontMetrics().denom2; } - var frac; + let frac; if (!rule) { // Rule 15c - var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + const candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); if (candidateClearance < clearance) { numShift += 0.5 * (clearance - candidateClearance); @@ -10882,7 +11997,7 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { }, options); } else { // Rule 15d - var axisHeight = options.fontMetrics().axisHeight; + const axisHeight = options.fontMetrics().axisHeight; if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); @@ -10892,7 +12007,7 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); } - var midShift = -(axisHeight - 0.5 * ruleWidth); + const midShift = -(axisHeight - 0.5 * ruleWidth); frac = buildCommon.makeVList({ positionType: "individualShift", children: [{ @@ -10917,16 +12032,18 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e - var delimSize; + let delimSize; if (style.size === src_Style.DISPLAY.size) { delimSize = options.fontMetrics().delim1; + } else if (style.size === src_Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2; } else { delimSize = options.fontMetrics().delim2; } - var leftDelim; - var rightDelim; + let leftDelim; + let rightDelim; if (group.leftDelim == null) { leftDelim = makeNullDelimiter(options, ["mopen"]); @@ -10945,30 +12062,30 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options); }; -var genfrac_mathmlBuilder = function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]); +const genfrac_mathmlBuilder = (group, options) => { + let node = new mathMLTree.MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]); if (!group.hasBarLine) { node.setAttribute("linethickness", "0px"); } else if (group.barSize) { - var ruleWidth = units_calculateSize(group.barSize, options); - node.setAttribute("linethickness", ruleWidth + "em"); + const ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); } - var style = genfrac_adjustStyle(group.size, options.style); + const style = adjustStyle(group.size, options.style); if (style.size !== options.style.size) { node = new mathMLTree.MathNode("mstyle", [node]); - var isDisplay = style.size === src_Style.DISPLAY.size ? "true" : "false"; + const isDisplay = style.size === src_Style.DISPLAY.size ? "true" : "false"; node.setAttribute("displaystyle", isDisplay); node.setAttribute("scriptlevel", "0"); } if (group.leftDelim != null || group.rightDelim != null) { - var withDelims = []; + const withDelims = []; if (group.leftDelim != null) { - var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); + const leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); leftOp.setAttribute("fence", "true"); withDelims.push(leftOp); } @@ -10976,12 +12093,12 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) { withDelims.push(node); if (group.rightDelim != null) { - var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); + const rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); rightOp.setAttribute("fence", "true"); withDelims.push(rightOp); } - return buildMathML_makeRow(withDelims); + return makeRow(withDelims); } return node; @@ -10989,24 +12106,26 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) { defineFunction({ type: "genfrac", - names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly - "\\\\bracefrac", "\\\\brackfrac"], + names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], props: { numArgs: 2, - greediness: 2 + allowedInArgument: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var numer = args[0]; - var denom = args[1]; - var hasBarLine; - var leftDelim = null; - var rightDelim = null; - var size = "auto"; + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const numer = args[0]; + const denom = args[1]; + let hasBarLine; + let leftDelim = null; + let rightDelim = null; + let size = "auto"; switch (funcName) { - case "\\cfrac": case "\\dfrac": case "\\frac": case "\\tfrac": @@ -11042,7 +12161,6 @@ defineFunction({ } switch (funcName) { - case "\\cfrac": case "\\dfrac": case "\\dbinom": size = "display"; @@ -11057,18 +12175,45 @@ defineFunction({ return { type: "genfrac", mode: parser.mode, - continued: funcName === "\\cfrac", - numer: numer, - denom: denom, - hasBarLine: hasBarLine, - leftDelim: leftDelim, - rightDelim: rightDelim, - size: size, + continued: false, + numer, + denom, + hasBarLine, + leftDelim, + rightDelim, + size, barSize: null }; }, htmlBuilder: genfrac_htmlBuilder, mathmlBuilder: genfrac_mathmlBuilder +}); +defineFunction({ + type: "genfrac", + names: ["\\cfrac"], + props: { + numArgs: 2 + }, + handler: (_ref2, args) => { + let { + parser, + funcName + } = _ref2; + const numer = args[0]; + const denom = args[1]; + return { + type: "genfrac", + mode: parser.mode, + continued: true, + numer, + denom, + hasBarLine: true, + leftDelim: null, + rightDelim: null, + size: "display", + barSize: null + }; + } }); // Infix generalized fractions -- these are not rendered directly, but replaced // immediately by one of the variants above. @@ -11079,11 +12224,14 @@ defineFunction({ numArgs: 0, infix: true }, - handler: function handler(_ref2) { - var parser = _ref2.parser, - funcName = _ref2.funcName, - token = _ref2.token; - var replaceWith; + + handler(_ref3) { + let { + parser, + funcName, + token + } = _ref3; + let replaceWith; switch (funcName) { case "\\over": @@ -11113,15 +12261,16 @@ defineFunction({ return { type: "infix", mode: parser.mode, - replaceWith: replaceWith, - token: token + replaceWith, + token }; } + }); -var stylArray = ["display", "text", "script", "scriptscript"]; +const stylArray = ["display", "text", "script", "scriptscript"]; -var delimFromValue = function delimFromValue(delimString) { - var delim = null; +const delimFromValue = function (delimString) { + let delim = null; if (delimString.length > 0) { delim = delimString; @@ -11136,31 +12285,24 @@ defineFunction({ names: ["\\genfrac"], props: { numArgs: 6, - greediness: 6, + allowedInArgument: true, argTypes: ["math", "math", "size", "text", "math", "math"] }, - handler: function handler(_ref3, args) { - var parser = _ref3.parser; - var numer = args[4]; - var denom = args[5]; // Look into the parse nodes to get the desired delimiters. - - var leftNode = checkNodeType(args[0], "atom"); - - if (leftNode) { - leftNode = assertAtomFamily(args[0], "open"); - } - - var leftDelim = leftNode ? delimFromValue(leftNode.text) : null; - var rightNode = checkNodeType(args[1], "atom"); - - if (rightNode) { - rightNode = assertAtomFamily(args[1], "close"); - } - var rightDelim = rightNode ? delimFromValue(rightNode.text) : null; - var barNode = assertNodeType(args[2], "size"); - var hasBarLine; - var barSize = null; + handler(_ref4, args) { + let { + parser + } = _ref4; + const numer = args[4]; + const denom = args[5]; // Look into the parse nodes to get the desired delimiters. + + const leftNode = normalizeArgument(args[0]); + const leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + const rightNode = normalizeArgument(args[1]); + const rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + const barNode = assertNodeType(args[2], "size"); + let hasBarLine; + let barSize = null; if (barNode.isBlank) { // \genfrac acts differently than \above. @@ -11173,32 +12315,33 @@ defineFunction({ } // Find out if we want displaystyle, textstyle, etc. - var size = "auto"; - var styl = checkNodeType(args[3], "ordgroup"); + let size = "auto"; + let styl = args[3]; - if (styl) { + if (styl.type === "ordgroup") { if (styl.body.length > 0) { - var textOrd = assertNodeType(styl.body[0], "textord"); + const textOrd = assertNodeType(styl.body[0], "textord"); size = stylArray[Number(textOrd.text)]; } } else { - styl = assertNodeType(args[3], "textord"); + styl = assertNodeType(styl, "textord"); size = stylArray[Number(styl.text)]; } return { type: "genfrac", mode: parser.mode, - numer: numer, - denom: denom, + numer, + denom, continued: false, - hasBarLine: hasBarLine, - barSize: barSize, - leftDelim: leftDelim, - rightDelim: rightDelim, - size: size + hasBarLine, + barSize, + leftDelim, + rightDelim, + size }; }, + htmlBuilder: genfrac_htmlBuilder, mathmlBuilder: genfrac_mathmlBuilder }); // \above is an infix fraction that also defines a fraction bar size. @@ -11211,18 +12354,22 @@ defineFunction({ argTypes: ["size"], infix: true }, - handler: function handler(_ref4, args) { - var parser = _ref4.parser, - funcName = _ref4.funcName, - token = _ref4.token; + + handler(_ref5, args) { + let { + parser, + funcName, + token + } = _ref5; return { type: "infix", mode: parser.mode, replaceWith: "\\\\abovefrac", size: assertNodeType(args[0], "size").value, - token: token + token }; } + }); defineFunction({ type: "genfrac", @@ -11231,21 +12378,23 @@ defineFunction({ numArgs: 3, argTypes: ["math", "size", "math"] }, - handler: function handler(_ref5, args) { - var parser = _ref5.parser, - funcName = _ref5.funcName; - var numer = args[0]; - var barSize = assert(assertNodeType(args[1], "infix").size); - var denom = args[2]; - var hasBarLine = barSize.number > 0; + handler: (_ref6, args) => { + let { + parser, + funcName + } = _ref6; + const numer = args[0]; + const barSize = assert(assertNodeType(args[1], "infix").size); + const denom = args[2]; + const hasBarLine = barSize.number > 0; return { type: "genfrac", mode: parser.mode, - numer: numer, - denom: denom, + numer, + denom, continued: false, - hasBarLine: hasBarLine, - barSize: barSize, + hasBarLine, + barSize, leftDelim: null, rightDelim: null, size: "auto" @@ -11254,7 +12403,7 @@ defineFunction({ htmlBuilder: genfrac_htmlBuilder, mathmlBuilder: genfrac_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/horizBrace.js +;// CONCATENATED MODULE: ./src/functions/horizBrace.js @@ -11264,30 +12413,30 @@ defineFunction({ // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but -var horizBrace_htmlBuilder = function htmlBuilder(grp, options) { - var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. +// also "supsub" since an over/underbrace can affect super/subscripting. +const horizBrace_htmlBuilder = (grp, options) => { + const style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. - var supSubGroup; - var group; - var supSub = checkNodeType(grp, "supsub"); + let supSubGroup; + let group; - if (supSub) { + if (grp.type === "supsub") { // Ref: LaTeX source2e: }}}}\limits} // i.e. LaTeX treats the brace similar to an op and passes it // with \limits, so we need to assign supsub style. - supSubGroup = supSub.sup ? buildHTML_buildGroup(supSub.sup, options.havingStyle(style.sup()), options) : buildHTML_buildGroup(supSub.sub, options.havingStyle(style.sub()), options); - group = assertNodeType(supSub.base, "horizBrace"); + supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); } else { group = assertNodeType(grp, "horizBrace"); } // Build the base group - var body = buildHTML_buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); // Create the stretchy element + const body = buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); // Create the stretchy element - var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + const braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ // This first vlist contains the content and the brace: equation - var vlist; + let vlist; if (group.isOver) { vlist = buildCommon.makeVList({ @@ -11332,7 +12481,7 @@ var horizBrace_htmlBuilder = function htmlBuilder(grp, options) { // note long note long note // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ // equation eqn eqn - var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); + const vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); if (group.isOver) { vlist = buildCommon.makeVList({ @@ -11369,8 +12518,8 @@ var horizBrace_htmlBuilder = function htmlBuilder(grp, options) { return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); }; -var horizBrace_mathmlBuilder = function mathmlBuilder(group, options) { - var accentNode = stretchy.mathMLnode(group.label); +const horizBrace_mathmlBuilder = (group, options) => { + const accentNode = stretchy.mathMLnode(group.label); return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildMathML_buildGroup(group.base, options), accentNode]); }; // Horizontal stretchy braces @@ -11381,9 +12530,12 @@ defineFunction({ props: { numArgs: 1 }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; + + handler(_ref, args) { + let { + parser, + funcName + } = _ref; return { type: "horizBrace", mode: parser.mode, @@ -11392,10 +12544,11 @@ defineFunction({ base: args[0] }; }, + htmlBuilder: horizBrace_htmlBuilder, mathmlBuilder: horizBrace_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/href.js +;// CONCATENATED MODULE: ./src/functions/href.js @@ -11410,10 +12563,12 @@ defineFunction({ argTypes: ["url", "original"], allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var body = args[1]; - var href = assertNodeType(args[0], "url").url; + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[1]; + const href = assertNodeType(args[0], "url").url; if (!parser.settings.isTrusted({ command: "\\href", @@ -11425,19 +12580,19 @@ defineFunction({ return { type: "href", mode: parser.mode, - href: href, - body: defineFunction_ordargument(body) + href, + body: ordargument(body) }; }, - htmlBuilder: function htmlBuilder(group, options) { - var elements = buildHTML_buildExpression(group.body, options, false); + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); return buildCommon.makeAnchor(group.href, [], elements, options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var math = buildExpressionRow(group.body, options); + mathmlBuilder: (group, options) => { + let math = buildExpressionRow(group.body, options); - if (!(math instanceof mathMLTree_MathNode)) { - math = new mathMLTree_MathNode("mrow", [math]); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); } math.setAttribute("href", group.href); @@ -11452,9 +12607,11 @@ defineFunction({ argTypes: ["url"], allowedInText: true }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser; - var href = assertNodeType(args[0], "url").url; + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const href = assertNodeType(args[0], "url").url; if (!parser.settings.isTrusted({ command: "\\url", @@ -11463,10 +12620,10 @@ defineFunction({ return parser.formatUnsupportedCmd("\\url"); } - var chars = []; + const chars = []; - for (var i = 0; i < href.length; i++) { - var c = href[i]; + for (let i = 0; i < href.length; i++) { + let c = href[i]; if (c === "~") { c = "\\textasciitilde"; @@ -11479,7 +12636,7 @@ defineFunction({ }); } - var body = { + const body = { type: "text", mode: parser.mode, font: "\\texttt", @@ -11488,12 +12645,167 @@ defineFunction({ return { type: "href", mode: parser.mode, - href: href, - body: defineFunction_ordargument(body) + href, + body: ordargument(body) + }; + } +}); +;// CONCATENATED MODULE: ./src/functions/hbox.js + + + + + // \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, false); + return buildCommon.makeFragment(elements); + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", buildMathML_buildExpression(group.body, options)); + } + +}); +;// CONCATENATED MODULE: ./src/functions/html.js + + + + + + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser, + funcName, + token + } = _ref; + const value = assertNodeType(args[0], "raw").string; + const body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + + let trustContext; + const attributes = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + + case "\\htmlData": + { + const data = value.split(","); + + for (let i = 0; i < data.length; i++) { + const keyVal = data[i].split("="); + + if (keyVal.length !== 2) { + throw new src_ParseError("Error parsing key-value for \\htmlData"); + } + + attributes["data-" + keyVal[0].trim()] = keyVal[1].trim(); + } + + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); + const classes = ["enclosing"]; + + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + + const span = buildCommon.makeSpan(classes, elements, options); + + for (const attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); } }); -// CONCATENATED MODULE: ./src/functions/htmlmathml.js +;// CONCATENATED MODULE: ./src/functions/htmlmathml.js @@ -11505,24 +12817,26 @@ defineFunction({ numArgs: 2, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; + handler: (_ref, args) => { + let { + parser + } = _ref; return { type: "htmlmathml", mode: parser.mode, - html: defineFunction_ordargument(args[0]), - mathml: defineFunction_ordargument(args[1]) + html: ordargument(args[0]), + mathml: ordargument(args[1]) }; }, - htmlBuilder: function htmlBuilder(group, options) { - var elements = buildHTML_buildExpression(group.html, options, false); + htmlBuilder: (group, options) => { + const elements = buildExpression(group.html, options, false); return buildCommon.makeFragment(elements); }, - mathmlBuilder: function mathmlBuilder(group, options) { + mathmlBuilder: (group, options) => { return buildExpressionRow(group.mathml, options); } }); -// CONCATENATED MODULE: ./src/functions/includegraphics.js +;// CONCATENATED MODULE: ./src/functions/includegraphics.js @@ -11530,7 +12844,7 @@ defineFunction({ -var includegraphics_sizeData = function sizeData(str) { +const sizeData = function (str) { if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { // str is a number with no unit specified. // default unit is bp, per graphix package. @@ -11539,13 +12853,13 @@ var includegraphics_sizeData = function sizeData(str) { unit: "bp" }; } else { - var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); if (!match) { throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics"); } - var data = { + const data = { number: +(match[1] + match[2]), // sign + magnitude, cast to number unit: match[3] @@ -11568,33 +12882,35 @@ defineFunction({ argTypes: ["raw", "url"], allowedInText: false }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser; - var width = { + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let width = { number: 0, unit: "em" }; - var height = { + let height = { number: 0.9, unit: "em" }; // sorta character sized. - var totalheight = { + let totalheight = { number: 0, unit: "em" }; - var alt = ""; + let alt = ""; if (optArgs[0]) { - var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. + const attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. - var attributes = attributeStr.split(","); + const attributes = attributeStr.split(","); - for (var i = 0; i < attributes.length; i++) { - var keyVal = attributes[i].split("="); + for (let i = 0; i < attributes.length; i++) { + const keyVal = attributes[i].split("="); if (keyVal.length === 2) { - var str = keyVal[1].trim(); + const str = keyVal[1].trim(); switch (keyVal[0].trim()) { case "alt": @@ -11602,15 +12918,15 @@ defineFunction({ break; case "width": - width = includegraphics_sizeData(str); + width = sizeData(str); break; case "height": - height = includegraphics_sizeData(str); + height = sizeData(str); break; case "totalheight": - totalheight = includegraphics_sizeData(str); + totalheight = sizeData(str); break; default: @@ -11620,7 +12936,7 @@ defineFunction({ } } - var src = assertNodeType(args[0], "url").url; + const src = assertNodeType(args[0], "url").url; if (alt === "") { // No alt given. Use the file name. Strip away the path. @@ -11646,62 +12962,60 @@ defineFunction({ src: src }; }, - htmlBuilder: function htmlBuilder(group, options) { - var height = units_calculateSize(group.height, options); - var depth = 0; + htmlBuilder: (group, options) => { + const height = calculateSize(group.height, options); + let depth = 0; if (group.totalheight.number > 0) { - depth = units_calculateSize(group.totalheight, options) - height; - depth = Number(depth.toFixed(2)); + depth = calculateSize(group.totalheight, options) - height; } - var width = 0; + let width = 0; if (group.width.number > 0) { - width = units_calculateSize(group.width, options); + width = calculateSize(group.width, options); } - var style = { - height: height + depth + "em" + const style = { + height: makeEm(height + depth) }; if (width > 0) { - style.width = width + "em"; + style.width = makeEm(width); } if (depth > 0) { - style.verticalAlign = -depth + "em"; + style.verticalAlign = makeEm(-depth); } - var node = new domTree_Img(group.src, group.alt, style); + const node = new Img(group.src, group.alt, style); node.height = height; node.depth = depth; return node; }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mglyph", []); + mathmlBuilder: (group, options) => { + const node = new mathMLTree.MathNode("mglyph", []); node.setAttribute("alt", group.alt); - var height = units_calculateSize(group.height, options); - var depth = 0; + const height = calculateSize(group.height, options); + let depth = 0; if (group.totalheight.number > 0) { - depth = units_calculateSize(group.totalheight, options) - height; - depth = depth.toFixed(2); - node.setAttribute("valign", "-" + depth + "em"); + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); } - node.setAttribute("height", height + depth + "em"); + node.setAttribute("height", makeEm(height + depth)); if (group.width.number > 0) { - var width = units_calculateSize(group.width, options); - node.setAttribute("width", width + "em"); + const width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); } node.setAttribute("src", group.src); return node; } }); -// CONCATENATED MODULE: ./src/functions/kern.js +;// CONCATENATED MODULE: ./src/functions/kern.js // Horizontal spacing commands @@ -11715,17 +13029,21 @@ defineFunction({ props: { numArgs: 1, argTypes: ["size"], + primitive: true, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var size = assertNodeType(args[0], "size"); + + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const size = assertNodeType(args[0], "size"); if (parser.settings.strict) { - var mathFunction = funcName[1] === 'm'; // \mkern, \mskip + const mathFunction = funcName[1] === 'm'; // \mkern, \mskip - var muUnit = size.value.unit === 'mu'; + const muUnit = size.value.unit === 'mu'; if (mathFunction) { if (!muUnit) { @@ -11749,21 +13067,25 @@ defineFunction({ dimension: size.value }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { return buildCommon.makeGlue(group.dimension, options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var dimension = units_calculateSize(group.dimension, options); + + mathmlBuilder(group, options) { + const dimension = calculateSize(group.dimension, options); return new mathMLTree.SpaceNode(dimension); } + }); -// CONCATENATED MODULE: ./src/functions/lap.js +;// CONCATENATED MODULE: ./src/functions/lap.js // Horizontal overlap functions + defineFunction({ type: "lap", names: ["\\mathllap", "\\mathrlap", "\\mathclap"], @@ -11771,57 +13093,58 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var body = args[0]; + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; return { type: "lap", mode: parser.mode, alignment: funcName.slice(5), - body: body + body }; }, - htmlBuilder: function htmlBuilder(group, options) { + htmlBuilder: (group, options) => { // mathllap, mathrlap, mathclap - var inner; + let inner; if (group.alignment === "clap") { // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ - inner = buildCommon.makeSpan([], [buildHTML_buildGroup(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span + inner = buildCommon.makeSpan([], [buildGroup(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span inner = buildCommon.makeSpan(["inner"], [inner], options); } else { - inner = buildCommon.makeSpan(["inner"], [buildHTML_buildGroup(group.body, options)]); + inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options)]); } - var fix = buildCommon.makeSpan(["fix"], []); - var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the + const fix = buildCommon.makeSpan(["fix"], []); + let node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the // two items involved in the lap. // Next, use a strut to set the height of the HTML bounding box. // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 - var strut = buildCommon.makeSpan(["strut"]); - strut.style.height = node.height + node.depth + "em"; - strut.style.verticalAlign = -node.depth + "em"; - node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + const strut = buildCommon.makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); - node = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: node - }] - }, options); // Get the horizontal spacing correct relative to adjacent items. + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } - return buildCommon.makeSpan(["mord"], [node], options); + node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + + node = buildCommon.makeSpan(["thinbox"], [node], options); + return buildCommon.makeSpan(["mord", "vbox"], [node], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { + mathmlBuilder: (group, options) => { // mathllap, mathrlap, mathclap - var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + const node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); if (group.alignment !== "rlap") { - var offset = group.alignment === "llap" ? "-1" : "-0.5"; + const offset = group.alignment === "llap" ? "-1" : "-0.5"; node.setAttribute("lspace", offset + "width"); } @@ -11829,7 +13152,7 @@ defineFunction({ return node; } }); -// CONCATENATED MODULE: ./src/functions/math.js +;// CONCATENATED MODULE: ./src/functions/math.js // Switching from text mode back to math mode @@ -11841,22 +13164,26 @@ defineFunction({ allowedInText: true, allowedInMath: false }, - handler: function handler(_ref, args) { - var funcName = _ref.funcName, - parser = _ref.parser; - var outerMode = parser.mode; + + handler(_ref, args) { + let { + funcName, + parser + } = _ref; + const outerMode = parser.mode; parser.switchMode("math"); - var close = funcName === "\\(" ? "\\)" : "$"; - var body = parser.parseExpression(false, close); + const close = funcName === "\\(" ? "\\)" : "$"; + const body = parser.parseExpression(false, close); parser.expect(close); parser.switchMode(outerMode); return { type: "styling", mode: parser.mode, style: "text", - body: body + body }; } + }); // Check for extra closing math delimiters defineFunction({ @@ -11868,18 +13195,20 @@ defineFunction({ allowedInText: true, allowedInMath: false }, - handler: function handler(context, args) { + + handler(context, args) { throw new src_ParseError("Mismatched " + context.funcName); } + }); -// CONCATENATED MODULE: ./src/functions/mathchoice.js +;// CONCATENATED MODULE: ./src/functions/mathchoice.js -var mathchoice_chooseMathStyle = function chooseMathStyle(group, options) { +const chooseMathStyle = (group, options) => { switch (options.style.size) { case src_Style.DISPLAY.size: return group.display; @@ -11902,64 +13231,67 @@ defineFunction({ type: "mathchoice", names: ["\\mathchoice"], props: { - numArgs: 4 + numArgs: 4, + primitive: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; + handler: (_ref, args) => { + let { + parser + } = _ref; return { type: "mathchoice", mode: parser.mode, - display: defineFunction_ordargument(args[0]), - text: defineFunction_ordargument(args[1]), - script: defineFunction_ordargument(args[2]), - scriptscript: defineFunction_ordargument(args[3]) + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) }; }, - htmlBuilder: function htmlBuilder(group, options) { - var body = mathchoice_chooseMathStyle(group, options); - var elements = buildHTML_buildExpression(body, options, false); + htmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + const elements = buildExpression(body, options, false); return buildCommon.makeFragment(elements); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var body = mathchoice_chooseMathStyle(group, options); + mathmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); return buildExpressionRow(body, options); } }); -// CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js +;// CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js + + + // For an operator with limits, assemble the base, sup, and sub into a span. -// For an operator with limits, assemble the base, sup, and sub into a span. -var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) { - // IE 8 clips \int if it is in a display: inline-block. We wrap it - // in a new span so it is an inline, and works. +const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { base = buildCommon.makeSpan([], [base]); - var sub; - var sup; // We manually have to handle the superscripts and subscripts. This, + const subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup); + let sub; + let sup; // We manually have to handle the superscripts and subscripts. This, // aside from the kern calculations, is copied from supsub. if (supGroup) { - var elem = buildHTML_buildGroup(supGroup, options.havingStyle(style.sup()), options); + const elem = buildGroup(supGroup, options.havingStyle(style.sup()), options); sup = { - elem: elem, + elem, kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) }; } if (subGroup) { - var _elem = buildHTML_buildGroup(subGroup, options.havingStyle(style.sub()), options); - + const elem = buildGroup(subGroup, options.havingStyle(style.sub()), options); sub = { - elem: _elem, - kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - elem.height) }; } // Build the final group as a vlist of the possible subscript, base, // and possible superscript. - var finalGroup; + let finalGroup; if (sup && sub) { - var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + const bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; finalGroup = buildCommon.makeVList({ positionType: "bottom", positionData: bottom, @@ -11969,7 +13301,7 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -11982,14 +13314,14 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }] }, options); } else if (sub) { - var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note + const top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note // that we are supposed to shift the limits by 1/2 of the slant, // but since we are centering the limits adding a full slant of // margin will shift by 1/2 that. @@ -12003,7 +13335,7 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -12013,11 +13345,10 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG }] }, options); } else if (sup) { - var _bottom = base.depth + baseShift; - + const bottom = base.depth + baseShift; finalGroup = buildCommon.makeVList({ positionType: "bottom", - positionData: _bottom, + positionData: bottom, children: [{ type: "elem", elem: base @@ -12027,7 +13358,7 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 @@ -12040,9 +13371,19 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG return base; } - return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options); + const parts = [finalGroup]; + + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + const spacer = buildCommon.makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + + return buildCommon.makeSpan(["mop", "op-limits"], parts, options); }; -// CONCATENATED MODULE: ./src/functions/op.js +;// CONCATENATED MODULE: ./src/functions/op.js // Limits, symbols @@ -12054,50 +13395,49 @@ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subG + // Most operators have a large successor symbol, but these don't. -var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +const noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also // "supsub" since some of them (like \int) can affect super/subscripting. -var op_htmlBuilder = function htmlBuilder(grp, options) { +const op_htmlBuilder = (grp, options) => { // Operators are handled in the TeXbook pg. 443-444, rule 13(a). - var supGroup; - var subGroup; - var hasLimits = false; - var group; - var supSub = checkNodeType(grp, "supsub"); + let supGroup; + let subGroup; + let hasLimits = false; + let group; - if (supSub) { + if (grp.type === "supsub") { // If we have limits, supsub will pass us its group to handle. Pull // out the superscript and subscript and set the group to the op in // its base. - supGroup = supSub.sup; - subGroup = supSub.sub; - group = assertNodeType(supSub.base, "op"); + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); hasLimits = true; } else { group = assertNodeType(grp, "op"); } - var style = options.style; - var large = false; + const style = options.style; + let large = false; if (style.size === src_Style.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) { // Most symbol operators get larger in displaystyle (rule 13) large = true; } - var base; + let base; if (group.symbol) { // If this is a symbol, create the symbol. - var fontName = large ? "Size2-Regular" : "Size1-Regular"; - var stash = ""; + const fontName = large ? "Size2-Regular" : "Size1-Regular"; + let stash = ""; if (group.name === "\\oiint" || group.name === "\\oiiint") { // No font glyphs yet, so use a glyph w/o the oval. // TODO: When font glyphs are available, delete this code. - stash = group.name.substr(1); // $FlowFixMe - + stash = group.name.slice(1); group.name = stash === "oiint" ? "\\iint" : "\\iiint"; } @@ -12106,8 +13446,8 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { if (stash.length > 0) { // We're in \oiint or \oiiint. Overlay the oval. // TODO: When font glyphs are available, delete this code. - var italic = base.italic; - var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); + const italic = base.italic; + const oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); base = buildCommon.makeVList({ positionType: "individualShift", children: [{ @@ -12119,8 +13459,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { elem: oval, shift: large ? 0.08 : 0 }] - }, options); // $FlowFixMe - + }, options); group.name = "\\" + stash; base.classes.unshift("mop"); // $FlowFixMe @@ -12128,22 +13467,20 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { } } else if (group.body) { // If this is a list, compose that list. - var inner = buildHTML_buildExpression(group.body, options, true); + const inner = buildExpression(group.body, options, true); - if (inner.length === 1 && inner[0] instanceof domTree_SymbolNode) { + if (inner.length === 1 && inner[0] instanceof SymbolNode) { base = inner[0]; base.classes[0] = "mop"; // replace old mclass } else { - base = buildCommon.makeSpan(["mop"], buildCommon.tryCombineChars(inner), options); + base = buildCommon.makeSpan(["mop"], inner, options); } } else { // Otherwise, this is a text operator. Build the text from the // operator's name. - // TODO(emily): Add a space in the middle of some of these - // operators, like \limsup - var output = []; + const output = []; - for (var i = 1; i < group.name.length; i++) { + for (let i = 1; i < group.name.length; i++) { output.push(buildCommon.mathsym(group.name[i], group.mode, options)); } @@ -12151,10 +13488,10 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { } // If content of op is a single symbol, shift it vertically. - var baseShift = 0; - var slant = 0; + let baseShift = 0; + let slant = 0; - if ((base instanceof domTree_SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { // We suppress the shift of the base of \overset and \underset. Otherwise, // shift the symbol so its center lies on the axis (rule 13). It // appears that our fonts have the centers of the symbols already @@ -12168,40 +13505,40 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { } if (hasLimits) { - return assembleSupSub_assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); } else { if (baseShift) { base.style.position = "relative"; - base.style.top = baseShift + "em"; + base.style.top = makeEm(baseShift); } return base; } }; -var op_mathmlBuilder = function mathmlBuilder(group, options) { - var node; +const op_mathmlBuilder = (group, options) => { + let node; if (group.symbol) { // This is a symbol. Just add the symbol. - node = new mathMLTree_MathNode("mo", [buildMathML_makeText(group.name, group.mode)]); + node = new MathNode("mo", [makeText(group.name, group.mode)]); if (utils.contains(noSuccessor, group.name)) { node.setAttribute("largeop", "false"); } } else if (group.body) { // This is an operator with children. Add them. - node = new mathMLTree_MathNode("mo", buildMathML_buildExpression(group.body, options)); + node = new MathNode("mo", buildMathML_buildExpression(group.body, options)); } else { // This is a text operator. Add all of the characters from the // operator's name. - node = new mathMLTree_MathNode("mi", [new mathMLTree_TextNode(group.name.slice(1))]); // Append an . + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an . // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 - var operator = new mathMLTree_MathNode("mo", [buildMathML_makeText("\u2061", "text")]); + const operator = new MathNode("mo", [makeText("\u2061", "text")]); if (group.parentIsSupSub) { - node = new mathMLTree_MathNode("mo", [node, operator]); + node = new MathNode("mrow", [node, operator]); } else { node = newDocumentFragment([node, operator]); } @@ -12210,30 +13547,32 @@ var op_mathmlBuilder = function mathmlBuilder(group, options) { return node; }; -var singleCharBigOps = { +const singleCharBigOps = { "\u220F": "\\prod", "\u2210": "\\coprod", "\u2211": "\\sum", - "\u22C0": "\\bigwedge", - "\u22C1": "\\bigvee", - "\u22C2": "\\bigcap", - "\u22C3": "\\bigcup", - "\u2A00": "\\bigodot", - "\u2A01": "\\bigoplus", - "\u2A02": "\\bigotimes", - "\u2A04": "\\biguplus", - "\u2A06": "\\bigsqcup" + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" }; defineFunction({ type: "op", - names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22C0", "\u22C1", "\u22C2", "\u22C3", "\u2A00", "\u2A01", "\u2A02", "\u2A04", "\u2A06"], + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], props: { numArgs: 0 }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var fName = funcName; + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + let fName = funcName; if (fName.length === 1) { fName = singleCharBigOps[fName]; @@ -12257,18 +13596,21 @@ defineFunction({ type: "op", names: ["\\mathop"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser; - var body = args[0]; + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; return { type: "op", mode: parser.mode, limits: false, parentIsSupSub: false, symbol: false, - body: defineFunction_ordargument(body) + body: ordargument(body) }; }, htmlBuilder: op_htmlBuilder, @@ -12277,12 +13619,12 @@ defineFunction({ // displaystyle, and whether they are symbols and should grow in // displaystyle. These four groups cover the four possible choices. -var singleCharIntegrals = { - "\u222B": "\\int", - "\u222C": "\\iint", - "\u222D": "\\iiint", - "\u222E": "\\oint", - "\u222F": "\\oiint", +const singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", "\u2230": "\\oiiint" }; // No limits, not symbols @@ -12292,9 +13634,12 @@ defineFunction({ props: { numArgs: 0 }, - handler: function handler(_ref3) { - var parser = _ref3.parser, - funcName = _ref3.funcName; + + handler(_ref3) { + let { + parser, + funcName + } = _ref3; return { type: "op", mode: parser.mode, @@ -12304,6 +13649,7 @@ defineFunction({ name: funcName }; }, + htmlBuilder: op_htmlBuilder, mathmlBuilder: op_mathmlBuilder }); // Limits, not symbols @@ -12314,9 +13660,12 @@ defineFunction({ props: { numArgs: 0 }, - handler: function handler(_ref4) { - var parser = _ref4.parser, - funcName = _ref4.funcName; + + handler(_ref4) { + let { + parser, + funcName + } = _ref4; return { type: "op", mode: parser.mode, @@ -12326,20 +13675,24 @@ defineFunction({ name: funcName }; }, + htmlBuilder: op_htmlBuilder, mathmlBuilder: op_mathmlBuilder }); // No limits, symbols defineFunction({ type: "op", - names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222B", "\u222C", "\u222D", "\u222E", "\u222F", "\u2230"], + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], props: { numArgs: 0 }, - handler: function handler(_ref5) { - var parser = _ref5.parser, - funcName = _ref5.funcName; - var fName = funcName; + + handler(_ref5) { + let { + parser, + funcName + } = _ref5; + let fName = funcName; if (fName.length === 1) { fName = singleCharIntegrals[fName]; @@ -12354,10 +13707,12 @@ defineFunction({ name: fName }; }, + htmlBuilder: op_htmlBuilder, mathmlBuilder: op_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/operatorname.js +;// CONCATENATED MODULE: ./src/functions/operatorname.js + @@ -12368,32 +13723,32 @@ defineFunction({ // NOTE: Unlike most `htmlBuilder`s, this one handles not only // "operatorname", but also "supsub" since \operatorname* can -var operatorname_htmlBuilder = function htmlBuilder(grp, options) { +// affect super/subscripting. +const operatorname_htmlBuilder = (grp, options) => { // Operators are handled in the TeXbook pg. 443-444, rule 13(a). - var supGroup; - var subGroup; - var hasLimits = false; - var group; - var supSub = checkNodeType(grp, "supsub"); + let supGroup; + let subGroup; + let hasLimits = false; + let group; - if (supSub) { + if (grp.type === "supsub") { // If we have limits, supsub will pass us its group to handle. Pull // out the superscript and subscript and set the group to the op in // its base. - supGroup = supSub.sup; - subGroup = supSub.sub; - group = assertNodeType(supSub.base, "operatorname"); + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); hasLimits = true; } else { group = assertNodeType(grp, "operatorname"); } - var base; + let base; if (group.body.length > 0) { - var body = group.body.map(function (child) { + const body = group.body.map(child => { // $FlowFixMe: Check if the node has a string `text` property. - var childText = child.text; + const childText = child.text; if (typeof childText === "string") { return { @@ -12406,12 +13761,12 @@ var operatorname_htmlBuilder = function htmlBuilder(grp, options) { } }); // Consolidate function names into symbol characters. - var expression = buildHTML_buildExpression(body, options.withFont("mathrm"), true); + const expression = buildExpression(body, options.withFont("mathrm"), true); - for (var i = 0; i < expression.length; i++) { - var child = expression[i]; + for (let i = 0; i < expression.length; i++) { + const child = expression[i]; - if (child instanceof domTree_SymbolNode) { + if (child instanceof SymbolNode) { // Per amsopn package, // change minus to hyphen and \ast to asterisk child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); @@ -12424,20 +13779,20 @@ var operatorname_htmlBuilder = function htmlBuilder(grp, options) { } if (hasLimits) { - return assembleSupSub_assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); } else { return base; } }; -var operatorname_mathmlBuilder = function mathmlBuilder(group, options) { +const operatorname_mathmlBuilder = (group, options) => { // The steps taken here are similar to the html version. - var expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? + let expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? - var isAllString = true; // default + let isAllString = true; // default - for (var i = 0; i < expression.length; i++) { - var node = expression[i]; + for (let i = 0; i < expression.length; i++) { + const node = expression[i]; if (node instanceof mathMLTree.SpaceNode) {// Do nothing } else if (node instanceof mathMLTree.MathNode) { @@ -12452,7 +13807,7 @@ var operatorname_mathmlBuilder = function mathmlBuilder(group, options) { case "mo": { - var child = node.children[0]; + const child = node.children[0]; if (node.children.length === 1 && child instanceof mathMLTree.TextNode) { child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); @@ -12473,20 +13828,18 @@ var operatorname_mathmlBuilder = function mathmlBuilder(group, options) { if (isAllString) { // Write a single TextNode instead of multiple nested tags. - var word = expression.map(function (node) { - return node.toText(); - }).join(""); + const word = expression.map(node => node.toText()).join(""); expression = [new mathMLTree.TextNode(word)]; } - var identifier = new mathMLTree.MathNode("mi", expression); + const identifier = new mathMLTree.MathNode("mi", expression); identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as ⁡ // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp - var operator = new mathMLTree.MathNode("mo", [buildMathML_makeText("\u2061", "text")]); + const operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]); if (group.parentIsSupSub) { - return new mathMLTree.MathNode("mo", [identifier, operator]); + return new mathMLTree.MathNode("mrow", [identifier, operator]); } else { return mathMLTree.newDocumentFragment([identifier, operator]); } @@ -12496,19 +13849,21 @@ var operatorname_mathmlBuilder = function mathmlBuilder(group, options) { defineFunction({ type: "operatorname", - names: ["\\operatorname", "\\operatorname*"], + names: ["\\operatorname@", "\\operatornamewithlimits"], props: { numArgs: 1 }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var body = args[0]; + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; return { type: "operatorname", mode: parser.mode, - body: defineFunction_ordargument(body), - alwaysHandleSupSub: funcName === "\\operatorname*", + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", limits: false, parentIsSupSub: false }; @@ -12516,25 +13871,29 @@ defineFunction({ htmlBuilder: operatorname_htmlBuilder, mathmlBuilder: operatorname_mathmlBuilder }); -// CONCATENATED MODULE: ./src/functions/ordgroup.js +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); +;// CONCATENATED MODULE: ./src/functions/ordgroup.js defineFunctionBuilders({ type: "ordgroup", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { if (group.semisimple) { - return buildCommon.makeFragment(buildHTML_buildExpression(group.body, options, false)); + return buildCommon.makeFragment(buildExpression(group.body, options, false)); } - return buildCommon.makeSpan(["mord"], buildHTML_buildExpression(group.body, options, true), options); + return buildCommon.makeSpan(["mord"], buildExpression(group.body, options, true), options); }, - mathmlBuilder: function mathmlBuilder(group, options) { + + mathmlBuilder(group, options) { return buildExpressionRow(group.body, options, true); } + }); -// CONCATENATED MODULE: ./src/functions/overline.js +;// CONCATENATED MODULE: ./src/functions/overline.js @@ -12546,24 +13905,28 @@ defineFunction({ props: { numArgs: 1 }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var body = args[0]; + + handler(_ref, args) { + let { + parser + } = _ref; + const body = args[0]; return { type: "overline", mode: parser.mode, - body: body + body }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Overlines are handled in the TeXbook pg 443, Rule 9. // Build the inner group in the cramped style. - var innerGroup = buildHTML_buildGroup(group.body, options.havingCrampedStyle()); // Create the line above the body + const innerGroup = buildGroup(group.body, options.havingCrampedStyle()); // Create the line above the body - var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns + const line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns - var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; - var vlist = buildCommon.makeVList({ + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -12581,15 +13944,17 @@ defineFunction({ }, options); return buildCommon.makeSpan(["mord", "overline"], [vlist], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]); + + mathmlBuilder(group, options) { + const operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); operator.setAttribute("stretchy", "true"); - var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]); + const node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]); node.setAttribute("accent", "true"); return node; } + }); -// CONCATENATED MODULE: ./src/functions/phantom.js +;// CONCATENATED MODULE: ./src/functions/phantom.js @@ -12602,23 +13967,25 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var body = args[0]; + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[0]; return { type: "phantom", mode: parser.mode, - body: defineFunction_ordargument(body) + body: ordargument(body) }; }, - htmlBuilder: function htmlBuilder(group, options) { - var elements = buildHTML_buildExpression(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. // See "color" for more details. return buildCommon.makeFragment(elements); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var inner = buildMathML_buildExpression(group.body, options); + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(group.body, options); return new mathMLTree.MathNode("mphantom", inner); } }); @@ -12629,22 +13996,24 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref2, args) { - var parser = _ref2.parser; - var body = args[0]; + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; return { type: "hphantom", mode: parser.mode, - body: body + body }; }, - htmlBuilder: function htmlBuilder(group, options) { - var node = buildCommon.makeSpan([], [buildHTML_buildGroup(group.body, options.withPhantom())]); + htmlBuilder: (group, options) => { + let node = buildCommon.makeSpan([], [buildGroup(group.body, options.withPhantom())]); node.height = 0; node.depth = 0; if (node.children) { - for (var i = 0; i < node.children.length; i++) { + for (let i = 0; i < node.children.length; i++) { node.children[i].height = 0; node.children[i].depth = 0; } @@ -12661,10 +14030,10 @@ defineFunction({ return buildCommon.makeSpan(["mord"], [node], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var inner = buildMathML_buildExpression(defineFunction_ordargument(group.body), options); - var phantom = new mathMLTree.MathNode("mphantom", inner); - var node = new mathMLTree.MathNode("mpadded", [phantom]); + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(ordargument(group.body), options); + const phantom = new mathMLTree.MathNode("mphantom", inner); + const node = new mathMLTree.MathNode("mpadded", [phantom]); node.setAttribute("height", "0px"); node.setAttribute("depth", "0px"); return node; @@ -12677,29 +14046,31 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref3, args) { - var parser = _ref3.parser; - var body = args[0]; + handler: (_ref3, args) => { + let { + parser + } = _ref3; + const body = args[0]; return { type: "vphantom", mode: parser.mode, - body: body + body }; }, - htmlBuilder: function htmlBuilder(group, options) { - var inner = buildCommon.makeSpan(["inner"], [buildHTML_buildGroup(group.body, options.withPhantom())]); - var fix = buildCommon.makeSpan(["fix"], []); + htmlBuilder: (group, options) => { + const inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]); + const fix = buildCommon.makeSpan(["fix"], []); return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var inner = buildMathML_buildExpression(defineFunction_ordargument(group.body), options); - var phantom = new mathMLTree.MathNode("mphantom", inner); - var node = new mathMLTree.MathNode("mpadded", [phantom]); + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(ordargument(group.body), options); + const phantom = new mathMLTree.MathNode("mphantom", inner); + const node = new mathMLTree.MathNode("mpadded", [phantom]); node.setAttribute("width", "0px"); return node; } }); -// CONCATENATED MODULE: ./src/functions/raisebox.js +;// CONCATENATED MODULE: ./src/functions/raisebox.js @@ -12716,20 +14087,24 @@ defineFunction({ argTypes: ["size", "hbox"], allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; - var amount = assertNodeType(args[0], "size").value; - var body = args[1]; + + handler(_ref, args) { + let { + parser + } = _ref; + const amount = assertNodeType(args[0], "size").value; + const body = args[1]; return { type: "raisebox", mode: parser.mode, dy: amount, - body: body + body }; }, - htmlBuilder: function htmlBuilder(group, options) { - var body = buildHTML_buildGroup(group.body, options); - var dy = units_calculateSize(group.dy, options); + + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const dy = calculateSize(group.dy, options); return buildCommon.makeVList({ positionType: "shift", positionData: -dy, @@ -12739,14 +14114,37 @@ defineFunction({ }] }, options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); - var dy = group.dy.number + group.dy.unit; + + mathmlBuilder(group, options) { + const node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + const dy = group.dy.number + group.dy.unit; node.setAttribute("voffset", dy); return node; } + +}); +;// CONCATENATED MODULE: ./src/functions/relax.js + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + let { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } + }); -// CONCATENATED MODULE: ./src/functions/rule.js +;// CONCATENATED MODULE: ./src/functions/rule.js @@ -12760,11 +14158,14 @@ defineFunction({ numOptionalArgs: 1, argTypes: ["size", "size", "size"] }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser; - var shift = optArgs[0]; - var width = assertNodeType(args[0], "size"); - var height = assertNodeType(args[1], "size"); + + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const shift = optArgs[0]; + const width = assertNodeType(args[0], "size"); + const height = assertNodeType(args[1], "size"); return { type: "rule", mode: parser.mode, @@ -12773,17 +14174,18 @@ defineFunction({ height: height.value }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Make an empty span for the rule - var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units + const rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units - var width = units_calculateSize(group.width, options); - var height = units_calculateSize(group.height, options); - var shift = group.shift ? units_calculateSize(group.shift, options) : 0; // Style the rule to the right size + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size - rule.style.borderRightWidth = width + "em"; - rule.style.borderTopWidth = height + "em"; - rule.style.bottom = shift + "em"; // Record the height and width + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); // Record the height and width rule.width = width; rule.height = height + shift; @@ -12794,41 +14196,44 @@ defineFunction({ rule.maxFontSize = height * 1.125 * options.sizeMultiplier; return rule; }, - mathmlBuilder: function mathmlBuilder(group, options) { - var width = units_calculateSize(group.width, options); - var height = units_calculateSize(group.height, options); - var shift = group.shift ? units_calculateSize(group.shift, options) : 0; - var color = options.color && options.getColor() || "black"; - var rule = new mathMLTree.MathNode("mspace"); + + mathmlBuilder(group, options) { + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; + const color = options.color && options.getColor() || "black"; + const rule = new mathMLTree.MathNode("mspace"); rule.setAttribute("mathbackground", color); - rule.setAttribute("width", width + "em"); - rule.setAttribute("height", height + "em"); - var wrapper = new mathMLTree.MathNode("mpadded", [rule]); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + const wrapper = new mathMLTree.MathNode("mpadded", [rule]); if (shift >= 0) { - wrapper.setAttribute("height", "+" + shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); } else { - wrapper.setAttribute("height", shift + "em"); - wrapper.setAttribute("depth", "+" + -shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); } - wrapper.setAttribute("voffset", shift + "em"); + wrapper.setAttribute("voffset", makeEm(shift)); return wrapper; } + }); -// CONCATENATED MODULE: ./src/functions/sizing.js +;// CONCATENATED MODULE: ./src/functions/sizing.js + function sizingGroup(value, options, baseOptions) { - var inner = buildHTML_buildExpression(value, options, false); - var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize + const inner = buildExpression(value, options, false); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize // manually. Handle nested size changes. - for (var i = 0; i < inner.length; i++) { - var pos = inner[i].classes.indexOf("sizing"); + for (let i = 0; i < inner.length; i++) { + const pos = inner[i].classes.indexOf("sizing"); if (pos < 0) { Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); @@ -12845,12 +14250,12 @@ function sizingGroup(value, options, baseOptions) { return buildCommon.makeFragment(inner); } -var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; -var sizing_htmlBuilder = function htmlBuilder(group, options) { +const sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +const sizing_htmlBuilder = (group, options) => { // Handle sizing operators like \Huge. Real TeX doesn't actually allow // these functions inside of math expressions, so we do some special // handling. - var newOptions = options.havingSize(group.size); + const newOptions = options.havingSize(group.size); return sizingGroup(group.body, newOptions, options); }; defineFunction({ @@ -12860,34 +14265,36 @@ defineFunction({ numArgs: 0, allowedInText: true }, - handler: function handler(_ref, args) { - var breakOnTokenText = _ref.breakOnTokenText, - funcName = _ref.funcName, - parser = _ref.parser; - var body = parser.parseExpression(false, breakOnTokenText); + handler: (_ref, args) => { + let { + breakOnTokenText, + funcName, + parser + } = _ref; + const body = parser.parseExpression(false, breakOnTokenText); return { type: "sizing", mode: parser.mode, // Figure out what size to use based on the list of functions above size: sizeFuncs.indexOf(funcName) + 1, - body: body + body }; }, htmlBuilder: sizing_htmlBuilder, - mathmlBuilder: function mathmlBuilder(group, options) { - var newOptions = options.havingSize(group.size); - var inner = buildMathML_buildExpression(group.body, newOptions); - var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size + mathmlBuilder: (group, options) => { + const newOptions = options.havingSize(group.size); + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size // changes, because we don't keep state of what style we're currently // in, so we can't reset the size to normal before changing it. Now // that we're passing an options parameter we should be able to fix // this. - node.setAttribute("mathsize", newOptions.sizeMultiplier + "em"); + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); return node; } }); -// CONCATENATED MODULE: ./src/functions/smash.js +;// CONCATENATED MODULE: ./src/functions/smash.js // smash, with optional [tb], as in AMS @@ -12903,20 +14310,22 @@ defineFunction({ numOptionalArgs: 1, allowedInText: true }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser; - var smashHeight = false; - var smashDepth = false; - var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let smashHeight = false; + let smashDepth = false; + const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); if (tbArg) { // Optional [tb] argument is engaged. // ref: amsmath: \renewcommand{\smash}[1][tb]{% // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% - var letter = ""; + let letter = ""; - for (var i = 0; i < tbArg.body.length; ++i) { - var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. + for (let i = 0; i < tbArg.body.length; ++i) { + const node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. letter = node.text; @@ -12935,17 +14344,17 @@ defineFunction({ smashDepth = true; } - var body = args[0]; + const body = args[0]; return { type: "smash", mode: parser.mode, - body: body, - smashHeight: smashHeight, - smashDepth: smashDepth + body, + smashHeight, + smashDepth }; }, - htmlBuilder: function htmlBuilder(group, options) { - var node = buildCommon.makeSpan([], [buildHTML_buildGroup(group.body, options)]); + htmlBuilder: (group, options) => { + const node = buildCommon.makeSpan([], [buildGroup(group.body, options)]); if (!group.smashHeight && !group.smashDepth) { return node; @@ -12955,7 +14364,7 @@ defineFunction({ node.height = 0; // In order to influence makeVList, we have to reset the children. if (node.children) { - for (var i = 0; i < node.children.length; i++) { + for (let i = 0; i < node.children.length; i++) { node.children[i].height = 0; } } @@ -12965,8 +14374,8 @@ defineFunction({ node.depth = 0; if (node.children) { - for (var _i = 0; _i < node.children.length; _i++) { - node.children[_i].depth = 0; + for (let i = 0; i < node.children.length; i++) { + node.children[i].depth = 0; } } } // At this point, we've reset the TeX-like height and depth values. @@ -12975,7 +14384,7 @@ defineFunction({ // from acting on that line height. So we'll call makeVList now. - var smashedNode = buildCommon.makeVList({ + const smashedNode = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -12985,8 +14394,8 @@ defineFunction({ return buildCommon.makeSpan(["mord"], [smashedNode], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + mathmlBuilder: (group, options) => { + const node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); if (group.smashHeight) { node.setAttribute("height", "0px"); @@ -12999,7 +14408,8 @@ defineFunction({ return node; } }); -// CONCATENATED MODULE: ./src/functions/sqrt.js +;// CONCATENATED MODULE: ./src/functions/sqrt.js + @@ -13014,22 +14424,26 @@ defineFunction({ numArgs: 1, numOptionalArgs: 1 }, - handler: function handler(_ref, args, optArgs) { - var parser = _ref.parser; - var index = optArgs[0]; - var body = args[0]; + + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const index = optArgs[0]; + const body = args[0]; return { type: "sqrt", mode: parser.mode, - body: body, - index: index + body, + index }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Square roots are handled in the TeXbook pg. 443, Rule 11. // First, we do the same steps as in overline to build the inner group // and line - var inner = buildHTML_buildGroup(group.body, options.havingCrampedStyle()); + let inner = buildGroup(group.body, options.havingCrampedStyle()); if (inner.height === 0) { // Render a small surd. @@ -13040,34 +14454,34 @@ defineFunction({ inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter - var metrics = options.fontMetrics(); - var theta = metrics.defaultRuleThickness; - var phi = theta; + const metrics = options.fontMetrics(); + const theta = metrics.defaultRuleThickness; + let phi = theta; if (options.style.id < src_Style.TEXT.id) { phi = options.fontMetrics().xHeight; } // Calculate the clearance between the body and line - var lineClearance = theta + phi / 4; - var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size + let lineClearance = theta + phi / 4; + const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size - var _delimiter$sqrtImage = delimiter.sqrtImage(minDelimiterHeight, options), - img = _delimiter$sqrtImage.span, - ruleWidth = _delimiter$sqrtImage.ruleWidth, - advanceWidth = _delimiter$sqrtImage.advanceWidth; - - var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size + const { + span: img, + ruleWidth, + advanceWidth + } = delimiter.sqrtImage(minDelimiterHeight, options); + const delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size if (delimDepth > inner.height + inner.depth + lineClearance) { lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; } // Shift the sqrt image - var imgShift = img.height - inner.height - lineClearance - ruleWidth; - inner.style.paddingLeft = advanceWidth + "em"; // Overlay the image and the argument. + const imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument. - var body = buildCommon.makeVList({ + const body = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -13090,13 +14504,13 @@ defineFunction({ } else { // Handle the optional root index // The index is always in scriptscript style - var newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT); - var rootm = buildHTML_buildGroup(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX + const newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT); + const rootm = buildGroup(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX // source, in the definition of `\r@@t`. - var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly + const toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly - var rootVList = buildCommon.makeVList({ + const rootVList = buildCommon.makeVList({ positionType: "shift", positionData: -toShift, children: [{ @@ -13106,23 +14520,27 @@ defineFunction({ }, options); // Add a class surrounding it so we can add on the appropriate // kerning - var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); + const rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); } }, - mathmlBuilder: function mathmlBuilder(group, options) { - var body = group.body, - index = group.index; + + mathmlBuilder(group, options) { + const { + body, + index + } = group; return index ? new mathMLTree.MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildMathML_buildGroup(body, options)]); } + }); -// CONCATENATED MODULE: ./src/functions/styling.js +;// CONCATENATED MODULE: ./src/functions/styling.js -var styling_styleMap = { +const styling_styleMap = { "display": src_Style.DISPLAY, "text": src_Style.TEXT, "script": src_Style.SCRIPT, @@ -13133,52 +14551,59 @@ defineFunction({ names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], props: { numArgs: 0, - allowedInText: true + allowedInText: true, + primitive: true }, - handler: function handler(_ref, args) { - var breakOnTokenText = _ref.breakOnTokenText, - funcName = _ref.funcName, - parser = _ref.parser; + + handler(_ref, args) { + let { + breakOnTokenText, + funcName, + parser + } = _ref; // parse out the implicit body - var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + const body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. // here and in buildHTML and de-dupe the enumeration of all the styles). // $FlowFixMe: The names above exactly match the styles. - var style = funcName.slice(1, funcName.length - 5); + const style = funcName.slice(1, funcName.length - 5); return { type: "styling", mode: parser.mode, // Figure out what style to use by pulling out the style from // the function name - style: style, - body: body + style, + body }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Style changes are handled in the TeXbook on pg. 442, Rule 3. - var newStyle = styling_styleMap[group.style]; - var newOptions = options.havingStyle(newStyle).withFont(''); + const newStyle = styling_styleMap[group.style]; + const newOptions = options.havingStyle(newStyle).withFont(''); return sizingGroup(group.body, newOptions, options); }, - mathmlBuilder: function mathmlBuilder(group, options) { + + mathmlBuilder(group, options) { // Figure out what style we're changing to. - var newStyle = styling_styleMap[group.style]; - var newOptions = options.havingStyle(newStyle); - var inner = buildMathML_buildExpression(group.body, newOptions); - var node = new mathMLTree.MathNode("mstyle", inner); - var styleAttributes = { + const newStyle = styling_styleMap[group.style]; + const newOptions = options.havingStyle(newStyle); + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new mathMLTree.MathNode("mstyle", inner); + const styleAttributes = { "display": ["0", "true"], "text": ["0", "false"], "script": ["1", "false"], "scriptscript": ["2", "false"] }; - var attr = styleAttributes[group.style]; + const attr = styleAttributes[group.style]; node.setAttribute("scriptlevel", attr[0]); node.setAttribute("displaystyle", attr[1]); return node; } + }); -// CONCATENATED MODULE: ./src/functions/supsub.js +;// CONCATENATED MODULE: ./src/functions/supsub.js @@ -13200,24 +14625,23 @@ defineFunction({ * its inner element should handle the superscripts and subscripts instead of * handling them itself. */ -var supsub_htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { - var base = group.base; +const htmlBuilderDelegate = function (group, options) { + const base = group.base; if (!base) { return null; } else if (base.type === "op") { // Operators handle supsubs differently when they have limits // (e.g. `\displaystyle\sum_2^3`) - var delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub); + const delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub); return delegate ? op_htmlBuilder : null; } else if (base.type === "operatorname") { - var _delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits); - - return _delegate ? operatorname_htmlBuilder : null; + const delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits); + return delegate ? operatorname_htmlBuilder : null; } else if (base.type === "accent") { - return utils.isCharacterBox(base.base) ? accent_htmlBuilder : null; + return utils.isCharacterBox(base.base) ? htmlBuilder : null; } else if (base.type === "horizBrace") { - var isSup = !group.sub; + const isSup = !group.sub; return isSup === base.isOver ? horizBrace_htmlBuilder : null; } else { return null; @@ -13228,32 +14652,35 @@ var supsub_htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { defineFunctionBuilders({ type: "supsub", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Superscript and subscripts are handled in the TeXbook on page // 445-446, rules 18(a-f). // Here is where we defer to the inner group if it should handle // superscripts and subscripts itself. - var builderDelegate = supsub_htmlBuilderDelegate(group, options); + const builderDelegate = htmlBuilderDelegate(group, options); if (builderDelegate) { return builderDelegate(group, options); } - var valueBase = group.base, - valueSup = group.sup, - valueSub = group.sub; - var base = buildHTML_buildGroup(valueBase, options); - var supm; - var subm; - var metrics = options.fontMetrics(); // Rule 18a + const { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + const base = buildGroup(valueBase, options); + let supm; + let subm; + const metrics = options.fontMetrics(); // Rule 18a - var supShift = 0; - var subShift = 0; - var isCharacterBox = valueBase && utils.isCharacterBox(valueBase); + let supShift = 0; + let subShift = 0; + const isCharacterBox = valueBase && utils.isCharacterBox(valueBase); if (valueSup) { - var newOptions = options.havingStyle(options.style.sup()); - supm = buildHTML_buildGroup(valueSup, newOptions, options); + const newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup(valueSup, newOptions, options); if (!isCharacterBox) { supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; @@ -13261,17 +14688,16 @@ defineFunctionBuilders({ } if (valueSub) { - var _newOptions = options.havingStyle(options.style.sub()); - - subm = buildHTML_buildGroup(valueSub, _newOptions, options); + const newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup(valueSub, newOptions, options); if (!isCharacterBox) { - subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; + subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier; } } // Rule 18c - var minSupShift; + let minSupShift; if (options.style === src_Style.DISPLAY) { minSupShift = metrics.sup1; @@ -13283,34 +14709,34 @@ defineFunctionBuilders({ // appropriately for use as the marginRight. - var multiplier = options.sizeMultiplier; - var marginRight = 0.5 / metrics.ptPerEm / multiplier + "em"; - var marginLeft = null; + const multiplier = options.sizeMultiplier; + const marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + let marginLeft = null; if (subm) { // Subscripts shouldn't be shifted by the base's italic correction. // Account for that by shifting the subscript back the appropriate // amount. Note we only do this when the base is a single symbol. - var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + const isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); - if (base instanceof domTree_SymbolNode || isOiint) { + if (base instanceof SymbolNode || isOiint) { // $FlowFixMe - marginLeft = -base.italic + "em"; + marginLeft = makeEm(-base.italic); } } - var supsub; + let supsub; if (supm && subm) { supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); subShift = Math.max(subShift, metrics.sub2); - var ruleWidth = metrics.defaultRuleThickness; // Rule 18e + const ruleWidth = metrics.defaultRuleThickness; // Rule 18e - var maxWidth = 4 * ruleWidth; + const maxWidth = 4 * ruleWidth; if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { subShift = maxWidth - (supShift - supm.depth) + subm.height; - var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); if (psi > 0) { supShift += psi; @@ -13318,17 +14744,17 @@ defineFunctionBuilders({ } } - var vlistElem = [{ + const vlistElem = [{ type: "elem", elem: subm, shift: subShift, - marginRight: marginRight, - marginLeft: marginLeft + marginRight, + marginLeft }, { type: "elem", elem: supm, shift: -supShift, - marginRight: marginRight + marginRight }]; supsub = buildCommon.makeVList({ positionType: "individualShift", @@ -13337,16 +14763,16 @@ defineFunctionBuilders({ } else if (subm) { // Rule 18b subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); - var _vlistElem = [{ + const vlistElem = [{ type: "elem", elem: subm, - marginLeft: marginLeft, - marginRight: marginRight + marginLeft, + marginRight }]; supsub = buildCommon.makeVList({ positionType: "shift", positionData: subShift, - children: _vlistElem + children: vlistElem }, options); } else if (supm) { // Rule 18c, d @@ -13357,7 +14783,7 @@ defineFunctionBuilders({ children: [{ type: "elem", elem: supm, - marginRight: marginRight + marginRight }] }, options); } else { @@ -13365,22 +14791,22 @@ defineFunctionBuilders({ } // Wrap the supsub vlist in a span.msupsub to reset text-align. - var mclass = getTypeOfDomTree(base, "right") || "mord"; + const mclass = getTypeOfDomTree(base, "right") || "mord"; return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { + + mathmlBuilder(group, options) { // Is the inner group a relevant horizonal brace? - var isBrace = false; - var isOver; - var isSup; - var horizBrace = checkNodeType(group.base, "horizBrace"); + let isBrace = false; + let isOver; + let isSup; - if (horizBrace) { + if (group.base && group.base.type === "horizBrace") { isSup = !!group.sup; - if (isSup === horizBrace.isOver) { + if (isSup === group.base.isOver) { isBrace = true; - isOver = horizBrace.isOver; + isOver = group.base.isOver; } } @@ -13388,7 +14814,7 @@ defineFunctionBuilders({ group.base.parentIsSupSub = true; } - var children = [buildMathML_buildGroup(group.base, options)]; + const children = [buildMathML_buildGroup(group.base, options)]; if (group.sub) { children.push(buildMathML_buildGroup(group.sub, options)); @@ -13398,12 +14824,12 @@ defineFunctionBuilders({ children.push(buildMathML_buildGroup(group.sup, options)); } - var nodeType; + let nodeType; if (isBrace) { nodeType = isOver ? "mover" : "munder"; } else if (!group.sub) { - var base = group.base; + const base = group.base; if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { nodeType = "mover"; @@ -13413,32 +14839,32 @@ defineFunctionBuilders({ nodeType = "msup"; } } else if (!group.sup) { - var _base = group.base; + const base = group.base; - if (_base && _base.type === "op" && _base.limits && (options.style === src_Style.DISPLAY || _base.alwaysHandleSupSub)) { + if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { nodeType = "munder"; - } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === src_Style.DISPLAY)) { + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) { nodeType = "munder"; } else { nodeType = "msub"; } } else { - var _base2 = group.base; + const base = group.base; - if (_base2 && _base2.type === "op" && _base2.limits && options.style === src_Style.DISPLAY) { + if (base && base.type === "op" && base.limits && options.style === src_Style.DISPLAY) { nodeType = "munderover"; - } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || _base2.limits)) { + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || base.limits)) { nodeType = "munderover"; } else { nodeType = "msubsup"; } } - var node = new mathMLTree.MathNode(nodeType, children); - return node; + return new mathMLTree.MathNode(nodeType, children); } + }); -// CONCATENATED MODULE: ./src/functions/symbolsOp.js +;// CONCATENATED MODULE: ./src/functions/symbolsOp.js @@ -13446,14 +14872,16 @@ defineFunctionBuilders({ defineFunctionBuilders({ type: "atom", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { return buildCommon.mathsym(group.text, group.mode, options, ["m" + group.family]); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mo", [buildMathML_makeText(group.text, group.mode)]); + + mathmlBuilder(group, options) { + const node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]); if (group.family === "bin") { - var variant = buildMathML_getVariant(group, options); + const variant = getVariant(group, options); if (variant === "bold-italic") { node.setAttribute("mathvariant", variant); @@ -13468,26 +14896,30 @@ defineFunctionBuilders({ return node; } + }); -// CONCATENATED MODULE: ./src/functions/symbolsOrd.js +;// CONCATENATED MODULE: ./src/functions/symbolsOrd.js // "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in -var defaultVariant = { +// src/symbols.js. +const defaultVariant = { "mi": "italic", "mn": "normal", "mtext": "normal" }; defineFunctionBuilders({ type: "mathord", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { return buildCommon.makeOrd(group, options, "mathord"); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node = new mathMLTree.MathNode("mi", [buildMathML_makeText(group.text, group.mode, options)]); - var variant = buildMathML_getVariant(group, options) || "italic"; + + mathmlBuilder(group, options) { + const node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]); + const variant = getVariant(group, options) || "italic"; if (variant !== defaultVariant[node.type]) { node.setAttribute("mathvariant", variant); @@ -13495,22 +14927,23 @@ defineFunctionBuilders({ return node; } + }); defineFunctionBuilders({ type: "textord", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { return buildCommon.makeOrd(group, options, "textord"); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var text = buildMathML_makeText(group.text, group.mode, options); - var variant = buildMathML_getVariant(group, options) || "normal"; - var node; + + mathmlBuilder(group, options) { + const text = makeText(group.text, group.mode, options); + const variant = getVariant(group, options) || "normal"; + let node; if (group.mode === 'text') { node = new mathMLTree.MathNode("mtext", [text]); } else if (/[0-9]/.test(group.text)) { - // TODO(kevinb) merge adjacent nodes - // do it as a post processing step node = new mathMLTree.MathNode("mn", [text]); } else if (group.text === "\\prime") { node = new mathMLTree.MathNode("mo", [text]); @@ -13524,14 +14957,15 @@ defineFunctionBuilders({ return node; } + }); -// CONCATENATED MODULE: ./src/functions/symbolsSpacing.js +;// CONCATENATED MODULE: ./src/functions/symbolsSpacing.js // A map of CSS-based spacing functions to their CSS class. -var cssSpace = { +const cssSpace = { "\\nobreak": "nobreak", "\\allowbreak": "allowbreak" }; // A lookup table to determine whether a spacing function/symbol should be @@ -13540,7 +14974,7 @@ var cssSpace = { // the associated value may have a `className` specifying an extra CSS class // to add to the created `span`. -var regularSpace = { +const regularSpace = { " ": {}, "\\ ": {}, "~": { @@ -13555,14 +14989,15 @@ var regularSpace = { defineFunctionBuilders({ type: "spacing", - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { if (regularSpace.hasOwnProperty(group.text)) { - var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these + const className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these // things has an entry in the symbols table, so these will be turned // into appropriate outputs. if (group.mode === "text") { - var ord = buildCommon.makeOrd(group, options, "textord"); + const ord = buildCommon.makeOrd(group, options, "textord"); ord.classes.push(className); return ord; } else { @@ -13575,11 +15010,12 @@ defineFunctionBuilders({ throw new src_ParseError("Unknown type of space \"" + group.text + "\""); } }, - mathmlBuilder: function mathmlBuilder(group, options) { - var node; + + mathmlBuilder(group, options) { + let node; if (regularSpace.hasOwnProperty(group.text)) { - node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\xA0")]); + node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\u00a0")]); } else if (cssSpace.hasOwnProperty(group.text)) { // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored return new mathMLTree.MathNode("mspace"); @@ -13589,22 +15025,24 @@ defineFunctionBuilders({ return node; } + }); -// CONCATENATED MODULE: ./src/functions/tag.js +;// CONCATENATED MODULE: ./src/functions/tag.js -var tag_pad = function pad() { - var padNode = new mathMLTree.MathNode("mtd", []); +const pad = () => { + const padNode = new mathMLTree.MathNode("mtd", []); padNode.setAttribute("width", "50%"); return padNode; }; defineFunctionBuilders({ type: "tag", - mathmlBuilder: function mathmlBuilder(group, options) { - var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [tag_pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), tag_pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + + mathmlBuilder(group, options) { + const table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); table.setAttribute("width", "100%"); return table; // TODO: Left-aligned tags. // Currently, the group and options passed here do not contain @@ -13614,31 +15052,32 @@ defineFunctionBuilders({ // in MathML if browsers supported . Since they don't, we // need to rewrite the way this function is called. } + }); -// CONCATENATED MODULE: ./src/functions/text.js +;// CONCATENATED MODULE: ./src/functions/text.js // Non-mathy text, possibly in a font -var textFontFamilies = { +const textFontFamilies = { "\\text": undefined, "\\textrm": "textrm", "\\textsf": "textsf", "\\texttt": "texttt", "\\textnormal": "textrm" }; -var textFontWeights = { +const textFontWeights = { "\\textbf": "textbf", "\\textmd": "textmd" }; -var textFontShapes = { +const textFontShapes = { "\\textit": "textit", "\\textup": "textup" }; -var optionsWithFont = function optionsWithFont(group, options) { - var font = group.font; // Checks if the argument is a font family or a font style. +const optionsWithFont = (group, options) => { + const font = group.font; // Checks if the argument is a font family or a font style. if (!font) { return options; @@ -13660,31 +15099,37 @@ defineFunction({ props: { numArgs: 1, argTypes: ["text"], - greediness: 2, + allowedInArgument: true, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser, - funcName = _ref.funcName; - var body = args[0]; + + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; return { type: "text", mode: parser.mode, - body: defineFunction_ordargument(body), + body: ordargument(body), font: funcName }; }, - htmlBuilder: function htmlBuilder(group, options) { - var newOptions = optionsWithFont(group, options); - var inner = buildHTML_buildExpression(group.body, newOptions, true); - return buildCommon.makeSpan(["mord", "text"], buildCommon.tryCombineChars(inner), newOptions); + + htmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + const inner = buildExpression(group.body, newOptions, true); + return buildCommon.makeSpan(["mord", "text"], inner, newOptions); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var newOptions = optionsWithFont(group, options); + + mathmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); return buildExpressionRow(group.body, newOptions); } + }); -// CONCATENATED MODULE: ./src/functions/underline.js +;// CONCATENATED MODULE: ./src/functions/underline.js @@ -13697,23 +15142,27 @@ defineFunction({ numArgs: 1, allowedInText: true }, - handler: function handler(_ref, args) { - var parser = _ref.parser; + + handler(_ref, args) { + let { + parser + } = _ref; return { type: "underline", mode: parser.mode, body: args[0] }; }, - htmlBuilder: function htmlBuilder(group, options) { + + htmlBuilder(group, options) { // Underlines are handled in the TeXbook pg 443, Rule 10. // Build the inner group. - var innerGroup = buildHTML_buildGroup(group.body, options); // Create the line to go below the body + const innerGroup = buildGroup(group.body, options); // Create the line to go below the body - var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns + const line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns - var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; - var vlist = buildCommon.makeVList({ + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = buildCommon.makeVList({ positionType: "top", positionData: innerGroup.height, children: [{ @@ -13732,15 +15181,67 @@ defineFunction({ }, options); return buildCommon.makeSpan(["mord", "underline"], [vlist], options); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]); + + mathmlBuilder(group, options) { + const operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); operator.setAttribute("stretchy", "true"); - var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]); + const node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]); node.setAttribute("accentunder", "true"); return node; } + +}); +;// CONCATENATED MODULE: ./src/functions/vcenter.js + + + + + // \vcenter: Vertically center the argument group on the math axis. + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const axisHeight = options.fontMetrics().axisHeight; + const dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return buildCommon.makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + return new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)], ["vcenter"]); + } + }); -// CONCATENATED MODULE: ./src/functions/verb.js +;// CONCATENATED MODULE: ./src/functions/verb.js @@ -13752,21 +15253,23 @@ defineFunction({ numArgs: 0, allowedInText: true }, - handler: function handler(context, args, optArgs) { + + handler(context, args, optArgs) { // \verb and \verb* are dealt with directly in Parser.js. // If we end up here, it's because of a failure to match the two delimiters // in the regex in Lexer.js. LaTeX raises the following error when \verb is // terminated by end of line (or file). throw new src_ParseError("\\verb ended by end of line instead of matching delimiter"); }, - htmlBuilder: function htmlBuilder(group, options) { - var text = makeVerb(group); - var body = []; // \verb enters text mode and therefore is sized like \textstyle - var newOptions = options.havingStyle(options.style.text()); + htmlBuilder(group, options) { + const text = makeVerb(group); + const body = []; // \verb enters text mode and therefore is sized like \textstyle + + const newOptions = options.havingStyle(options.style.text()); - for (var i = 0; i < text.length; i++) { - var c = text[i]; + for (let i = 0; i < text.length; i++) { + let c = text[i]; if (c === '~') { c = '\\textasciitilde'; @@ -13777,12 +15280,14 @@ defineFunction({ return buildCommon.makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), buildCommon.tryCombineChars(body), newOptions); }, - mathmlBuilder: function mathmlBuilder(group, options) { - var text = new mathMLTree.TextNode(makeVerb(group)); - var node = new mathMLTree.MathNode("mtext", [text]); + + mathmlBuilder(group, options) { + const text = new mathMLTree.TextNode(makeVerb(group)); + const node = new mathMLTree.MathNode("mtext", [text]); node.setAttribute("mathvariant", "monospace"); return node; } + }); /** * Converts verb group into body string. @@ -13791,13 +15296,11 @@ defineFunction({ * \verb replaces each space with a no-break space \xA0 */ -var makeVerb = function makeVerb(group) { - return group.body.replace(/ /g, group.star ? "\u2423" : '\xA0'); -}; -// CONCATENATED MODULE: ./src/functions.js +const makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); +;// CONCATENATED MODULE: ./src/functions.js /** Include this to ensure that all functions are defined. */ -var functions = _functions; +const functions = _functions; /* harmony default export */ var src_functions = (functions); // TODO(kevinb): have functions return an object and call defineFunction with // that object in this file instead of relying on side-effects. @@ -13840,7 +15343,14 @@ var functions = _functions; -// CONCATENATED MODULE: ./src/Lexer.js + + + + + + + +;// CONCATENATED MODULE: ./src/Lexer.js /** * The Lexer class handles tokenizing the input in various ways. Since our * parser expects us to be able to backtrack, the lexer allows lexing from any @@ -13866,37 +15376,44 @@ var functions = _functions; * - does not match bare surrogate code units * - matches any BMP character except for those just described * - matches any valid Unicode surrogate pair - * - matches a backslash followed by one or more letters - * - matches a backslash followed by any BMP character, including newline + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace * Just because the Lexer matches something doesn't mean it's valid input: * If there is no matching function or symbol definition, the Parser will * still reject the input. */ -var spaceRegexString = "[ \r\n\t]"; -var controlWordRegexString = "\\\\[a-zA-Z@]+"; -var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; -var controlWordWhitespaceRegexString = "" + controlWordRegexString + spaceRegexString + "*"; -var controlWordWhitespaceRegex = new RegExp("^(" + controlWordRegexString + ")" + spaceRegexString + "*$"); -var combiningDiacriticalMarkString = "[\u0300-\u036F]"; -var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); -var tokenRegexString = "(" + spaceRegexString + "+)|" + // whitespace +const spaceRegexString = "[ \r\n\t]"; +const controlWordRegexString = "\\\\[a-zA-Z@]+"; +const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +const controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +const controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +const combiningDiacriticalMarkString = "[\u0300-\u036f]"; +const combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +const tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace +controlSpaceRegexString + "|") + // \whitespace "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint combiningDiacriticalMarkString + "*") + // ...plus accents "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair combiningDiacriticalMarkString + "*") + // ...plus accents -"|\\\\verb\\*([^]).*?\\3" + // \verb* -"|\\\\verb([^*a-zA-Z]).*?\\4" + // \verb unstarred -"|\\\\operatorname\\*" + ( // \operatorname* +"|\\\\verb\\*([^]).*?\\4" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred "|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces "|" + controlSymbolRegexString + ")"); // \\, \', etc. /** Main Lexer class */ -var Lexer_Lexer = -/*#__PURE__*/ -function () { - // category codes, only supports comment characters (14) for now - function Lexer(input, settings) { +class Lexer { + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + constructor(input, settings) { this.input = void 0; this.settings = void 0; this.tokenRegex = void 0; @@ -13906,40 +15423,40 @@ function () { this.settings = settings; this.tokenRegex = new RegExp(tokenRegexString, 'g'); this.catcodes = { - "%": 14 // comment character + "%": 14, + // comment character + "~": 13 // active character }; } - var _proto = Lexer.prototype; - - _proto.setCatcode = function setCatcode(char, code) { + setCatcode(char, code) { this.catcodes[char] = code; } /** * This function lexes a single token. */ - ; - _proto.lex = function lex() { - var input = this.input; - var pos = this.tokenRegex.lastIndex; + + lex() { + const input = this.input; + const pos = this.tokenRegex.lastIndex; if (pos === input.length) { - return new Token_Token("EOF", new SourceLocation(this, pos, pos)); + return new Token("EOF", new SourceLocation(this, pos, pos)); } - var match = this.tokenRegex.exec(input); + const match = this.tokenRegex.exec(input); if (match === null || match.index !== pos) { - throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token_Token(input[pos], new SourceLocation(this, pos, pos + 1))); + throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); } - var text = match[2] || " "; + const text = match[6] || match[3] || (match[2] ? "\\ " : " "); if (this.catcodes[text] === 14) { // comment character - var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); if (nlIndex === -1) { this.tokenRegex.lastIndex = input.length; // EOF @@ -13950,23 +15467,13 @@ function () { } return this.lex(); - } // Trim any trailing whitespace from control word match - - - var controlMatch = text.match(controlWordWhitespaceRegex); - - if (controlMatch) { - text = controlMatch[1]; } - return new Token_Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); - }; - - return Lexer; -}(); - + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } -// CONCATENATED MODULE: ./src/Namespace.js +} +;// CONCATENATED MODULE: ./src/Namespace.js /** * A `Namespace` refers to a space of nameable things like macros or lengths, * which can be `set` either globally or local to a nested group, using an @@ -13975,17 +15482,14 @@ function () { * `set` takes time proportional to the depth of group nesting. */ - -var Namespace_Namespace = -/*#__PURE__*/ -function () { +class Namespace { /** * Both arguments are optional. The first argument is an object of * built-in mappings which never change. The second argument is an object * of initial (global-level) mappings, which will constantly change * according to any global/top-level `set`s done. */ - function Namespace(builtins, globalMacros) { + constructor(builtins, globalMacros) { if (builtins === void 0) { builtins = {}; } @@ -14006,26 +15510,24 @@ function () { */ - var _proto = Namespace.prototype; - - _proto.beginGroup = function beginGroup() { + beginGroup() { this.undefStack.push({}); } /** * End current nested group, restoring values before the group began. */ - ; - _proto.endGroup = function endGroup() { + + endGroup() { if (this.undefStack.length === 0) { throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); } - var undefs = this.undefStack.pop(); + const undefs = this.undefStack.pop(); - for (var undef in undefs) { + for (const undef in undefs) { if (undefs.hasOwnProperty(undef)) { - if (undefs[undef] === undefined) { + if (undefs[undef] == null) { delete this.current[undef]; } else { this.current[undef] = undefs[undef]; @@ -14033,13 +15535,24 @@ function () { } } } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } /** * Detect whether `name` has a definition. Equivalent to * `get(name) != null`. */ - ; - _proto.has = function has(name) { + + has(name) { return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); } /** @@ -14050,9 +15563,9 @@ function () { * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or * `if (namespace.has(...))`. */ - ; - _proto.get = function get(name) { + + get(name) { if (this.current.hasOwnProperty(name)) { return this.current[name]; } else { @@ -14064,10 +15577,11 @@ function () { * Local set() sets the current value and (when appropriate) adds an undo * operation to the undo stack. Global set() may change the undo * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. */ - ; - _proto.set = function set(name, value, global) { + + set(name, value, global) { if (global === void 0) { global = false; } @@ -14077,7 +15591,7 @@ function () { // by destroying any undos currently scheduled for this name, // and adding an undo with the *new* value (in case it later gets // locally reset within this environment). - for (var i = 0; i < this.undefStack.length; i++) { + for (let i = 0; i < this.undefStack.length; i++) { delete this.undefStack[i][name]; } @@ -14088,42 +15602,72 @@ function () { // Undo this set at end of this group (possibly to `undefined`), // unless an undo is already in place, in which case that older // value is the correct one. - var top = this.undefStack[this.undefStack.length - 1]; + const top = this.undefStack[this.undefStack.length - 1]; if (top && !top.hasOwnProperty(name)) { top[name] = this.current[name]; } } - this.current[name] = value; - }; - - return Namespace; -}(); - + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } -// CONCATENATED MODULE: ./src/macros.js +} +;// CONCATENATED MODULE: ./src/macros.js /** * Predefined macros for KaTeX. * This can be used to define some commands in terms of others. */ +// Export global macros object from defineMacro +const macros = _macros; +/* harmony default export */ var src_macros = (macros); -var builtinMacros = {}; -/* harmony default export */ var macros = (builtinMacros); // This function might one day accept an additional argument and do more things. -function defineMacro(name, body) { - builtinMacros[name] = body; -} ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// // macro tools -// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + const t = context.popToken(); + + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + const t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + + return { + tokens: [t], + numArgs: 0 + }; +}); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 // TeX source: \long\def\@firstoftwo#1#2{#1} defineMacro("\\@firstoftwo", function (context) { - var args = context.consumeArgs(2); + const args = context.consumeArgs(2); return { tokens: args[0], numArgs: 0 @@ -14132,19 +15676,21 @@ defineMacro("\\@firstoftwo", function (context) { // TeX source: \long\def\@secondoftwo#1#2{#2} defineMacro("\\@secondoftwo", function (context) { - var args = context.consumeArgs(2); + const args = context.consumeArgs(2); return { tokens: args[1], numArgs: 0 }; }); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) -// symbol. If it matches #1, then the macro expands to #2; otherwise, #3. -// Note, however, that it does not consume the next symbol in either case. +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. defineMacro("\\@ifnextchar", function (context) { - var args = context.consumeArgs(3); // symbol, if, else + const args = context.consumeArgs(3); // symbol, if, else - var nextToken = context.future(); + context.consumeSpaces(); + const nextToken = context.future(); if (args[0].length === 1 && args[0][0].text === nextToken.text) { return { @@ -14165,7 +15711,7 @@ defineMacro("\\@ifnextchar", function (context) { defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode defineMacro("\\TextOrMath", function (context) { - var args = context.consumeArgs(2); + const args = context.consumeArgs(2); if (context.mode === 'text') { return { @@ -14180,7 +15726,7 @@ defineMacro("\\TextOrMath", function (context) { } }); // Lookup table for parsing numbers in base 8 through 16 -var digitToNumber = { +const digitToNumber = { "0": 0, "1": 1, "2": 2, @@ -14214,9 +15760,9 @@ var digitToNumber = { // calls to a function \@char dealt with in the Parser. defineMacro("\\char", function (context) { - var token = context.popToken(); - var base; - var number = ''; + let token = context.popToken(); + let base; + let number = ''; if (token.text === "'") { base = 8; @@ -14246,7 +15792,7 @@ defineMacro("\\char", function (context) { throw new src_ParseError("Invalid base-" + base + " digit " + token.text); } - var digit; + let digit; while ((digit = digitToNumber[context.future().text]) != null && digit < base) { number *= base; @@ -14256,87 +15802,19 @@ defineMacro("\\char", function (context) { } return "\\@char{" + number + "}"; -}); // Basic support for macro definitions: -// \def\macro{expansion} -// \def\macro#1{expansion} -// \def\macro#1#2{expansion} -// \def\macro#1#2#3#4#5#6#7#8#9{expansion} -// Also the \gdef and \global\def equivalents - -var macros_def = function def(context, global) { - var arg = context.consumeArgs(1)[0]; - - if (arg.length !== 1) { - throw new src_ParseError("\\gdef's first argument must be a macro name"); - } - - var name = arg[0].text; // Count argument specifiers, and check they are in the order #1 #2 ... - - var numArgs = 0; - arg = context.consumeArgs(1)[0]; - - while (arg.length === 1 && arg[0].text === "#") { - arg = context.consumeArgs(1)[0]; - - if (arg.length !== 1) { - throw new src_ParseError("Invalid argument number length \"" + arg.length + "\""); - } - - if (!/^[1-9]$/.test(arg[0].text)) { - throw new src_ParseError("Invalid argument number \"" + arg[0].text + "\""); - } - - numArgs++; - - if (parseInt(arg[0].text) !== numArgs) { - throw new src_ParseError("Argument number \"" + arg[0].text + "\" out of order"); - } - - arg = context.consumeArgs(1)[0]; - } // Final arg is the expansion of the macro - - - context.macros.set(name, { - tokens: arg, - numArgs: numArgs - }, global); - return ''; -}; - -defineMacro("\\gdef", function (context) { - return macros_def(context, true); -}); -defineMacro("\\def", function (context) { - return macros_def(context, false); -}); -defineMacro("\\global", function (context) { - var next = context.consumeArgs(1)[0]; - - if (next.length !== 1) { - throw new src_ParseError("Invalid command after \\global"); - } - - var command = next[0].text; // TODO: Should expand command - - if (command === "\\def") { - // \global\def is equivalent to \gdef - return macros_def(context, true); - } else { - throw new src_ParseError("Invalid command '" + command + "' after \\global"); - } }); // \newcommand{\macro}[args]{definition} // \renewcommand{\macro}[args]{definition} // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} -var macros_newcommand = function newcommand(context, existsOK, nonexistsOK) { - var arg = context.consumeArgs(1)[0]; +const newcommand = (context, existsOK, nonexistsOK) => { + let arg = context.consumeArg().tokens; if (arg.length !== 1) { throw new src_ParseError("\\newcommand's first argument must be a macro name"); } - var name = arg[0].text; - var exists = context.isDefined(name); + const name = arg[0].text; + const exists = context.isDefined(name); if (exists && !existsOK) { throw new src_ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); @@ -14346,12 +15824,12 @@ var macros_newcommand = function newcommand(context, existsOK, nonexistsOK) { throw new src_ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); } - var numArgs = 0; - arg = context.consumeArgs(1)[0]; + let numArgs = 0; + arg = context.consumeArg().tokens; if (arg.length === 1 && arg[0].text === "[") { - var argText = ''; - var token = context.expandNextToken(); + let argText = ''; + let token = context.expandNextToken(); while (token.text !== "]" && token.text !== "EOF") { // TODO: Should properly expand arg, e.g., ignore {}s @@ -14364,36 +15842,52 @@ var macros_newcommand = function newcommand(context, existsOK, nonexistsOK) { } numArgs = parseInt(argText); - arg = context.consumeArgs(1)[0]; + arg = context.consumeArg().tokens; } // Final arg is the expansion of the macro context.macros.set(name, { tokens: arg, - numArgs: numArgs + numArgs }); return ''; }; -defineMacro("\\newcommand", function (context) { - return macros_newcommand(context, false, true); +defineMacro("\\newcommand", context => newcommand(context, false, true)); +defineMacro("\\renewcommand", context => newcommand(context, true, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true)); // terminal (console) tools + +defineMacro("\\message", context => { + const arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.log(arg.reverse().map(token => token.text).join("")); + return ''; }); -defineMacro("\\renewcommand", function (context) { - return macros_newcommand(context, true, false); +defineMacro("\\errmessage", context => { + const arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.error(arg.reverse().map(token => token.text).join("")); + return ''; }); -defineMacro("\\providecommand", function (context) { - return macros_newcommand(context, true, true); +defineMacro("\\show", context => { + const tok = context.popToken(); + const name = tok.text; // eslint-disable-next-line no-console + + console.log(tok, context.macros.get(name), src_functions[name], src_symbols.math[name], src_symbols.text[name]); + return ''; }); ////////////////////////////////////////////////////////////////////// // Grouping // \let\bgroup={ \let\egroup=} defineMacro("\\bgroup", "{"); defineMacro("\\egroup", "}"); // Symbols from latex.ltx: +// \def~{\nobreakspace{}} // \def\lq{`} // \def\rq{'} // \def \aa {\r a} // \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); defineMacro("\\lq", "`"); defineMacro("\\rq", "'"); defineMacro("\\aa", "\\r a"); @@ -14426,11 +15920,15 @@ defineMacro("\\Bbbk", "\\Bbb{k}"); // Unicode middle dot // The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays // the dot at U+22C5 and gives it punct spacing. -defineMacro("\xB7", "\\cdotp"); // \llap and \rlap render their contents in text mode +defineMacro("\u00b7", "\\cdotp"); // \llap and \rlap render their contents in text mode defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); -defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \not is defined by base/fontmath.ltx via +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360 + +defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353 + +defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} // It's thus treated like a \mathrel, but defined by a symbol that has zero // width but extends to the right. We use \rlap to get that spacing. @@ -14463,9 +15961,15 @@ defineMacro("\u231C", "\\ulcorner"); defineMacro("\u231D", "\\urcorner"); defineMacro("\u231E", "\\llcorner"); defineMacro("\u231F", "\\lrcorner"); -defineMacro("\xA9", "\\copyright"); -defineMacro("\xAE", "\\textregistered"); -defineMacro("\uFE0F", "\\textregistered"); ////////////////////////////////////////////////////////////////////// +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); +defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. + +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); ////////////////////////////////////////////////////////////////////// // LaTeX_2ε // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} @@ -14473,7 +15977,7 @@ defineMacro("\uFE0F", "\\textregistered"); ///////////////////////////////////// // The zero-width rule gets us an equivalent to the vertical 6pt kern. defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}"); -defineMacro("\u22EE", "\\vdots"); ////////////////////////////////////////////////////////////////////// +defineMacro("\u22ee", "\\vdots"); ////////////////////////////////////////////////////////////////////// // amsmath.sty // http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf // Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, @@ -14494,7 +15998,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} -defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;} // \def\implies{\DOTSB\;\Longrightarrow\;} @@ -14504,7 +16008,7 @@ defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro. -var dotsByToken = { +const dotsByToken = { ',': '\\dotsc', '\\not': '\\dotsb', // \keybin@ checks for the following: @@ -14565,12 +16069,12 @@ defineMacro("\\dots", function (context) { // (in text mode), and it's unlikely we'd see any of the math commands // that affect the behavior of \dots when in text mode. So fine for now // (until we support \ifmmode ... \else ... \fi). - var thedots = '\\dotso'; - var next = context.expandAfterFuture().text; + let thedots = '\\dotso'; + const next = context.expandAfterFuture().text; if (next in dotsByToken) { thedots = dotsByToken[next]; - } else if (next.substr(0, 4) === '\\not') { + } else if (next.slice(0, 4) === '\\not') { thedots = '\\dotsb'; } else if (next in src_symbols.math) { if (utils.contains(['bin', 'rel'], src_symbols.math[next].group)) { @@ -14580,7 +16084,7 @@ defineMacro("\\dots", function (context) { return thedots; }); -var spaceAfterDots = { +const spaceAfterDots = { // \rightdelim@ checks for the following: ')': true, ']': true, @@ -14605,7 +16109,7 @@ var spaceAfterDots = { ',': true }; defineMacro("\\dotso", function (context) { - var next = context.future().text; + const next = context.future().text; if (next in spaceAfterDots) { return "\\ldots\\,"; @@ -14614,7 +16118,7 @@ defineMacro("\\dotso", function (context) { } }); defineMacro("\\dotsc", function (context) { - var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for + const next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for // ';' and '.', but doesn't check for ','. if (next in spaceAfterDots && next !== ',') { @@ -14624,7 +16128,7 @@ defineMacro("\\dotsc", function (context) { } }); defineMacro("\\cdots", function (context) { - var next = context.future().text; + const next = context.future().text; if (next in spaceAfterDots) { return "\\@cdots\\,"; @@ -14688,7 +16192,7 @@ defineMacro("\\qquad", "\\hskip2em\\relax"); // \tag@in@display form of \tag defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); -defineMacro("\\tag@literal", function (context) { +defineMacro("\\tag@literal", context => { if (context.macros.get("\\df@tag")) { throw new src_ParseError("Multiple \\tag"); } @@ -14707,16 +16211,13 @@ defineMacro("\\tag@literal", function (context) { defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); -defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); // \pmb -- A simulation of bold. -// The version in ambsy.sty works by typesetting three copies of the argument -// with small offsets. We use two copies. We omit the vertical offset because -// of rendering problems that makeVList encounters in Safari. - -defineMacro("\\pmb", "\\html@mathml{" + "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + "{\\mathbf{#1}}"); ////////////////////////////////////////////////////////////////////// +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); ////////////////////////////////////////////////////////////////////// // LaTeX source2e -// \\ defaults to \newline, but changes to \cr within array environment +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} -defineMacro("\\\\", "\\newline"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} // TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't // support \@ yet, so that's omitted, and we add \text so that the result // doesn't look funny in math mode. @@ -14736,7 +16237,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e // We compute the corresponding \raisebox when A is rendered in \normalsize // \scriptstyle, which has a scale factor of 0.7 (see Options.js). -var latexRaiseA = fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1] + "em"; +const latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]); defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} @@ -14819,6 +16320,14 @@ defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\d defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); ////////////////////////////////////////////////////////////////////// +// From amsopn.sty + +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); ////////////////////////////////////////////////////////////////////// // MathML alternates for KaTeX glyphs in the Unicode private area defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); @@ -14834,16 +16343,18 @@ defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); -defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); ////////////////////////////////////////////////////////////////////// +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); ////////////////////////////////////////////////////////////////////// // stmaryrd and semantic // The stmaryrd and semantic packages render the next four items by calling a // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. -defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27E6}}"); -defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27E7}}"); -defineMacro("\u27E6", "\\llbracket"); // blackboard bold [ +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ -defineMacro("\u27E7", "\\rrbracket"); // blackboard bold ] +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); @@ -14852,7 +16363,11 @@ defineMacro("\u2983", "\\lBrace"); // blackboard bold { defineMacro("\u2984", "\\rBrace"); // blackboard bold } // TODO: Create variable sized versions of the last two items. I believe that // will require new font glyphs. -////////////////////////////////////////////////////////////////////// +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. + +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); ////////////////////////////////////////////////////////////////////// // texvc.sty // The texvc package contains macros available in mediawiki pages. // We omit the functions deprecated at @@ -14928,7 +16443,78 @@ defineMacro("\\Zeta", "\\mathrm{Z}"); ////////////////////////////////////////// defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); -defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); // Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); ////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); + +const braketHelper = one => context => { + const left = context.consumeArg().tokens; + const middle = context.consumeArg().tokens; + const middleDouble = context.consumeArg().tokens; + const right = context.consumeArg().tokens; + const oldMiddle = context.macros.get("|"); + const oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + + const midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + + let doubled = double; + + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + const nextToken = context.future(); + + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + + context.macros.set("|", midMacro(false)); + + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + + const arg = context.consumeArg().tokens; + const expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; + +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); // has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx + +defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); @@ -14986,7 +16572,7 @@ defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); -// CONCATENATED MODULE: ./src/MacroExpander.js +;// CONCATENATED MODULE: ./src/MacroExpander.js /** * This file contains the “gullet” where macros are expanded * until only non-macro tokens remain. @@ -15000,9 +16586,7 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); // List of commands that act like macros but aren't defined as a macro, // function, or symbol. Used in `isDefined`. -var implicitCommands = { - "\\relax": true, - // MacroExpander.js +const implicitCommands = { "^": true, // Parser.js "_": true, @@ -15012,11 +16596,8 @@ var implicitCommands = { "\\nolimits": true // Parser.js }; - -var MacroExpander_MacroExpander = -/*#__PURE__*/ -function () { - function MacroExpander(input, settings, mode) { +class MacroExpander { + constructor(input, settings, mode) { this.settings = void 0; this.expansionCount = void 0; this.lexer = void 0; @@ -15027,7 +16608,7 @@ function () { this.expansionCount = 0; this.feed(input); // Make new global namespace - this.macros = new Namespace_Namespace(macros, settings.macros); + this.macros = new Namespace(src_macros, settings.macros); this.mode = mode; this.stack = []; // contains tokens in REVERSE order } @@ -15037,42 +16618,49 @@ function () { */ - var _proto = MacroExpander.prototype; - - _proto.feed = function feed(input) { - this.lexer = new Lexer_Lexer(input, this.settings); + feed(input) { + this.lexer = new Lexer(input, this.settings); } /** * Switches between "text" and "math" modes. */ - ; - _proto.switchMode = function switchMode(newMode) { + + switchMode(newMode) { this.mode = newMode; } /** * Start a new group nesting within all namespaces. */ - ; - _proto.beginGroup = function beginGroup() { + + beginGroup() { this.macros.beginGroup(); } /** * End current group nesting within all namespaces. */ - ; - _proto.endGroup = function endGroup() { + + endGroup() { this.macros.endGroup(); } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + this.macros.endGroups(); + } /** * Returns the topmost token on the stack, without expanding it. * Similar in behavior to TeX's `\futurelet`. */ - ; - _proto.future = function future() { + + future() { if (this.stack.length === 0) { this.pushToken(this.lexer.lex()); } @@ -15082,9 +16670,9 @@ function () { /** * Remove and return the next unexpanded token. */ - ; - _proto.popToken = function popToken() { + + popToken() { this.future(); // ensure non-empty stack return this.stack.pop(); @@ -15093,29 +16681,64 @@ function () { * Add a given token to the token stack. In particular, this get be used * to put back a token returned from one of the other methods. */ - ; - _proto.pushToken = function pushToken(token) { + + pushToken(token) { this.stack.push(token); } /** * Append an array of tokens to the token stack. */ - ; - _proto.pushTokens = function pushTokens(tokens) { - var _this$stack; - (_this$stack = this.stack).push.apply(_this$stack, tokens); + pushTokens(tokens) { + this.stack.push(...tokens); + } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + + + scanArgument(isOptional) { + let start; + let end; + let tokens; + + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + + if (this.future().text !== "[") { + return null; + } + + start = this.popToken(); // don't include [ in tokens + + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } // indicate the end of an argument + + + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return start.range(end, ""); } /** * Consume all following space tokens, without expansion. */ - ; - _proto.consumeSpaces = function consumeSpaces() { + + consumeSpaces() { for (;;) { - var token = this.future(); + const token = this.future(); if (token.text === " ") { this.stack.pop(); @@ -15125,100 +16748,169 @@ function () { } } /** - * Consume the specified number of arguments from the token stream, - * and return the resulting array of arguments. + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + + + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + const tokens = []; + const isDelimited = delims && delims.length > 0; + + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + + const start = this.future(); + let tok; + let depth = 0; + let match = 0; + + do { + tok = this.popToken(); + tokens.push(tok); + + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + + if (depth === -1) { + throw new src_ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new src_ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + + + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + + tokens.reverse(); // to fit in with stack order + + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. */ - ; - - _proto.consumeArgs = function consumeArgs(numArgs) { - var args = []; // obtain arguments, either single token or balanced {…} group - for (var i = 0; i < numArgs; ++i) { - this.consumeSpaces(); // ignore spaces before each argument - var startOfArg = this.popToken(); + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new src_ParseError("The length of delimiters doesn't match the number of args!"); + } - if (startOfArg.text === "{") { - var arg = []; - var depth = 1; + const delims = delimiters[0]; - while (depth !== 0) { - var tok = this.popToken(); - arg.push(tok); + for (let i = 0; i < delims.length; i++) { + const tok = this.popToken(); - if (tok.text === "{") { - ++depth; - } else if (tok.text === "}") { - --depth; - } else if (tok.text === "EOF") { - throw new src_ParseError("End of input in macro argument", startOfArg); - } + if (delims[i] !== tok.text) { + throw new src_ParseError("Use of the macro doesn't match its definition", tok); } + } + } - arg.pop(); // remove last } - - arg.reverse(); // like above, to fit in with stack order + const args = []; - args[i] = arg; - } else if (startOfArg.text === "EOF") { - throw new src_ParseError("End of input expecting macro argument"); - } else { - args[i] = [startOfArg]; - } + for (let i = 0; i < numArgs; i++) { + args.push(this.consumeArg(delimiters && delimiters[i + 1]).tokens); } return args; } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + + + countExpansion(amount) { + this.expansionCount += amount; + + if (this.expansionCount > this.settings.maxExpand) { + throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } /** * Expand the next token only once if possible. * * If the token is expanded, the resulting tokens will be pushed onto - * the stack in reverse order and will be returned as an array, - * also in reverse order. + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. * - * If not, the next token will be returned without removing it - * from the stack. This case can be detected by a `Token` return value - * instead of an `Array` return value. + * If not, the return value is `false`, and the next token remains at the + * top of the stack. * * In either case, the next token will be on the top of the stack, - * or the stack will be empty. + * or the stack will be empty (in case of empty expansion + * and no other tokens). * * Used to implement `expandAfterFuture` and `expandNextToken`. * - * At the moment, macro expansion doesn't handle delimited macros, - * i.e. things like those defined by \def\foo#1\end{…}. - * See the TeX book page 202ff. for details on how those should behave. + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. */ - ; - _proto.expandOnce = function expandOnce() { - var topToken = this.popToken(); - var name = topToken.text; - var expansion = this._getExpansion(name); - - if (expansion == null) { - // mainly checking for undefined here - // Fully expanded - this.pushToken(topToken); - return topToken; - } + expandOnce(expandableOnly) { + const topToken = this.popToken(); + const name = topToken.text; + const expansion = !topToken.noexpand ? this._getExpansion(name) : null; - this.expansionCount++; + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new src_ParseError("Undefined control sequence: " + name); + } - if (this.expansionCount > this.settings.maxExpand) { - throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + this.pushToken(topToken); + return false; } - var tokens = expansion.tokens; + this.countExpansion(1); + let tokens = expansion.tokens; + const args = this.consumeArgs(expansion.numArgs, expansion.delimiters); if (expansion.numArgs) { - var args = this.consumeArgs(expansion.numArgs); // paste arguments in place of the placeholders - + // paste arguments in place of the placeholders tokens = tokens.slice(); // make a shallow copy - for (var i = tokens.length - 1; i >= 0; --i) { - var tok = tokens[i]; + for (let i = tokens.length - 1; i >= 0; --i) { + let tok = tokens[i]; if (tok.text === "#") { if (i === 0) { @@ -15231,10 +16923,8 @@ function () { // ## → # tokens.splice(i + 1, 1); // drop first # } else if (/^[1-9]$/.test(tok.text)) { - var _tokens; - // replace the placeholder with the indicated argument - (_tokens = tokens).splice.apply(_tokens, [i, 2].concat(args[+tok.text - 1])); + tokens.splice(i, 2, ...args[+tok.text - 1]); } else { throw new src_ParseError("Not a valid argument number", tok); } @@ -15244,7 +16934,7 @@ function () { this.pushTokens(tokens); - return tokens; + return tokens.length; } /** * Expand the next token only once (if possible), and return the resulting @@ -15252,29 +16942,29 @@ function () { * Similar in behavior to TeX's `\expandafter\futurelet`. * Equivalent to expandOnce() followed by future(). */ - ; - _proto.expandAfterFuture = function expandAfterFuture() { + + expandAfterFuture() { this.expandOnce(); return this.future(); } /** * Recursively expand first token, then return first non-expandable token. */ - ; - _proto.expandNextToken = function expandNextToken() { + + expandNextToken() { for (;;) { - var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. + if (this.expandOnce() === false) { + // fully expanded + const token = this.stack.pop(); // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ - if (expanded instanceof Token_Token) { - // \relax stops the expansion, but shouldn't get returned (a - // null return value couldn't get implemented as a function). - if (expanded.text === "\\relax") { - this.stack.pop(); - } else { - return this.stack.pop(); // === expanded + if (token.treatAsRelax) { + token.text = "\\relax"; } + + return token; } } // Flow unable to figure out that this pathway is impossible. // https://github.com/facebook/flow/issues/4808 @@ -15286,40 +16976,55 @@ function () { * Fully expand the given macro name and return the resulting list of * tokens, or return `undefined` if no such macro is defined. */ - ; - _proto.expandMacro = function expandMacro(name) { - if (!this.macros.get(name)) { - return undefined; - } - var output = []; - var oldStackLength = this.stack.length; - this.pushToken(new Token_Token(name)); + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + + + expandTokens(tokens) { + const output = []; + const oldStackLength = this.stack.length; + this.pushTokens(tokens); while (this.stack.length > oldStackLength) { - var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + const token = this.stack.pop(); + + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } - if (expanded instanceof Token_Token) { - output.push(this.stack.pop()); + output.push(token); } - } + } // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + + this.countExpansion(output.length); return output; } /** * Fully expand the given macro name and return the result as a string, * or return `undefined` if no such macro is defined. */ - ; - _proto.expandMacroAsText = function expandMacroAsText(name) { - var tokens = this.expandMacro(name); + + expandMacroAsText(name) { + const tokens = this.expandMacro(name); if (tokens) { - return tokens.map(function (token) { - return token.text; - }).join(""); + return tokens.map(token => token.text).join(""); } else { return tokens; } @@ -15328,32 +17033,42 @@ function () { * Returns the expanded macro as a reversed array of tokens and a macro * argument count. Or returns `null` if no such macro. */ - ; - _proto._getExpansion = function _getExpansion(name) { - var definition = this.macros.get(name); + + _getExpansion(name) { + const definition = this.macros.get(name); if (definition == null) { // mainly checking for undefined here return definition; + } // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + + + if (name.length === 1) { + const catcode = this.lexer.catcodes[name]; + + if (catcode != null && catcode !== 13) { + return; + } } - var expansion = typeof definition === "function" ? definition(this) : definition; + const expansion = typeof definition === "function" ? definition(this) : definition; if (typeof expansion === "string") { - var numArgs = 0; + let numArgs = 0; if (expansion.indexOf("#") !== -1) { - var stripped = expansion.replace(/##/g, ""); + const stripped = expansion.replace(/##/g, ""); while (stripped.indexOf("#" + (numArgs + 1)) !== -1) { ++numArgs; } } - var bodyLexer = new Lexer_Lexer(expansion, this.settings); - var tokens = []; - var tok = bodyLexer.lex(); + const bodyLexer = new Lexer(expansion, this.settings); + const tokens = []; + let tok = bodyLexer.lex(); while (tok.text !== "EOF") { tokens.push(tok); @@ -15362,9 +17077,9 @@ function () { tokens.reverse(); // to fit in with stack using push and pop - var expanded = { - tokens: tokens, - numArgs: numArgs + const expanded = { + tokens, + numArgs }; return expanded; } @@ -15377,705 +17092,130 @@ function () { * a function, a symbol, or one of the special commands listed in * `implicitCommands`. */ - ; - _proto.isDefined = function isDefined(name) { - return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); - }; - return MacroExpander; -}(); + isDefined(name) { + return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + /** + * Determine whether a command is expandable. + */ -// CONCATENATED MODULE: ./src/unicodeAccents.js -// Mapping of Unicode accent characters to their LaTeX equivalent in text and -// math mode (when they exist). -/* harmony default export */ var unicodeAccents = ({ - "\u0301": { - text: "\\'", - math: '\\acute' - }, - "\u0300": { - text: '\\`', - math: '\\grave' - }, - "\u0308": { - text: '\\"', - math: '\\ddot' - }, - "\u0303": { - text: '\\~', - math: '\\tilde' - }, - "\u0304": { - text: '\\=', - math: '\\bar' - }, - "\u0306": { - text: "\\u", - math: '\\breve' - }, - "\u030C": { - text: '\\v', - math: '\\check' - }, - "\u0302": { - text: '\\^', - math: '\\hat' - }, - "\u0307": { - text: '\\.', - math: '\\dot' - }, - "\u030A": { - text: '\\r', - math: '\\mathring' - }, - "\u030B": { - text: '\\H' + isExpandable(name) { + const macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : src_functions.hasOwnProperty(name) && !src_functions[name].primitive; } -}); -// CONCATENATED MODULE: ./src/unicodeSymbols.js -// This file is GENERATED by unicodeMake.js. DO NOT MODIFY. -/* harmony default export */ var unicodeSymbols = ({ - "\xE1": "a\u0301", - // á = \'{a} - "\xE0": "a\u0300", - // à = \`{a} - "\xE4": "a\u0308", - // ä = \"{a} - "\u01DF": "a\u0308\u0304", - // ǟ = \"\={a} - "\xE3": "a\u0303", - // ã = \~{a} - "\u0101": "a\u0304", - // ā = \={a} - "\u0103": "a\u0306", - // ă = \u{a} - "\u1EAF": "a\u0306\u0301", - // ắ = \u\'{a} - "\u1EB1": "a\u0306\u0300", - // ằ = \u\`{a} - "\u1EB5": "a\u0306\u0303", - // ẵ = \u\~{a} - "\u01CE": "a\u030C", - // ǎ = \v{a} - "\xE2": "a\u0302", - // â = \^{a} - "\u1EA5": "a\u0302\u0301", - // ấ = \^\'{a} - "\u1EA7": "a\u0302\u0300", - // ầ = \^\`{a} - "\u1EAB": "a\u0302\u0303", - // ẫ = \^\~{a} - "\u0227": "a\u0307", - // ȧ = \.{a} - "\u01E1": "a\u0307\u0304", - // ǡ = \.\={a} - "\xE5": "a\u030A", - // å = \r{a} - "\u01FB": "a\u030A\u0301", - // ǻ = \r\'{a} - "\u1E03": "b\u0307", - // ḃ = \.{b} - "\u0107": "c\u0301", - // ć = \'{c} - "\u010D": "c\u030C", - // č = \v{c} - "\u0109": "c\u0302", - // ĉ = \^{c} - "\u010B": "c\u0307", - // ċ = \.{c} - "\u010F": "d\u030C", - // ď = \v{d} - "\u1E0B": "d\u0307", - // ḋ = \.{d} - "\xE9": "e\u0301", - // é = \'{e} - "\xE8": "e\u0300", - // è = \`{e} - "\xEB": "e\u0308", - // ë = \"{e} - "\u1EBD": "e\u0303", - // ẽ = \~{e} - "\u0113": "e\u0304", - // ē = \={e} - "\u1E17": "e\u0304\u0301", - // ḗ = \=\'{e} - "\u1E15": "e\u0304\u0300", - // ḕ = \=\`{e} - "\u0115": "e\u0306", - // ĕ = \u{e} - "\u011B": "e\u030C", - // ě = \v{e} - "\xEA": "e\u0302", - // ê = \^{e} - "\u1EBF": "e\u0302\u0301", - // ế = \^\'{e} - "\u1EC1": "e\u0302\u0300", - // ề = \^\`{e} - "\u1EC5": "e\u0302\u0303", - // ễ = \^\~{e} - "\u0117": "e\u0307", - // ė = \.{e} - "\u1E1F": "f\u0307", - // ḟ = \.{f} - "\u01F5": "g\u0301", - // ǵ = \'{g} - "\u1E21": "g\u0304", - // ḡ = \={g} - "\u011F": "g\u0306", - // ğ = \u{g} - "\u01E7": "g\u030C", - // ǧ = \v{g} - "\u011D": "g\u0302", - // ĝ = \^{g} - "\u0121": "g\u0307", - // ġ = \.{g} - "\u1E27": "h\u0308", - // ḧ = \"{h} - "\u021F": "h\u030C", - // ȟ = \v{h} - "\u0125": "h\u0302", - // ĥ = \^{h} - "\u1E23": "h\u0307", - // ḣ = \.{h} - "\xED": "i\u0301", - // í = \'{i} - "\xEC": "i\u0300", - // ì = \`{i} - "\xEF": "i\u0308", - // ï = \"{i} - "\u1E2F": "i\u0308\u0301", - // ḯ = \"\'{i} - "\u0129": "i\u0303", - // ĩ = \~{i} - "\u012B": "i\u0304", - // ī = \={i} - "\u012D": "i\u0306", - // ĭ = \u{i} - "\u01D0": "i\u030C", - // ǐ = \v{i} - "\xEE": "i\u0302", - // î = \^{i} - "\u01F0": "j\u030C", - // ǰ = \v{j} - "\u0135": "j\u0302", - // ĵ = \^{j} - "\u1E31": "k\u0301", - // ḱ = \'{k} - "\u01E9": "k\u030C", - // ǩ = \v{k} - "\u013A": "l\u0301", - // ĺ = \'{l} - "\u013E": "l\u030C", - // ľ = \v{l} - "\u1E3F": "m\u0301", - // ḿ = \'{m} - "\u1E41": "m\u0307", - // ṁ = \.{m} - "\u0144": "n\u0301", - // ń = \'{n} - "\u01F9": "n\u0300", - // ǹ = \`{n} - "\xF1": "n\u0303", - // ñ = \~{n} - "\u0148": "n\u030C", - // ň = \v{n} - "\u1E45": "n\u0307", - // ṅ = \.{n} - "\xF3": "o\u0301", - // ó = \'{o} - "\xF2": "o\u0300", - // ò = \`{o} - "\xF6": "o\u0308", - // ö = \"{o} - "\u022B": "o\u0308\u0304", - // ȫ = \"\={o} - "\xF5": "o\u0303", - // õ = \~{o} - "\u1E4D": "o\u0303\u0301", - // ṍ = \~\'{o} - "\u1E4F": "o\u0303\u0308", - // ṏ = \~\"{o} - "\u022D": "o\u0303\u0304", - // ȭ = \~\={o} - "\u014D": "o\u0304", - // ō = \={o} - "\u1E53": "o\u0304\u0301", - // ṓ = \=\'{o} - "\u1E51": "o\u0304\u0300", - // ṑ = \=\`{o} - "\u014F": "o\u0306", - // ŏ = \u{o} - "\u01D2": "o\u030C", - // ǒ = \v{o} - "\xF4": "o\u0302", - // ô = \^{o} - "\u1ED1": "o\u0302\u0301", - // ố = \^\'{o} - "\u1ED3": "o\u0302\u0300", - // ồ = \^\`{o} - "\u1ED7": "o\u0302\u0303", - // ỗ = \^\~{o} - "\u022F": "o\u0307", - // ȯ = \.{o} - "\u0231": "o\u0307\u0304", - // ȱ = \.\={o} - "\u0151": "o\u030B", - // ő = \H{o} - "\u1E55": "p\u0301", - // ṕ = \'{p} - "\u1E57": "p\u0307", - // ṗ = \.{p} - "\u0155": "r\u0301", - // ŕ = \'{r} - "\u0159": "r\u030C", - // ř = \v{r} - "\u1E59": "r\u0307", - // ṙ = \.{r} - "\u015B": "s\u0301", - // ś = \'{s} - "\u1E65": "s\u0301\u0307", - // ṥ = \'\.{s} - "\u0161": "s\u030C", - // š = \v{s} - "\u1E67": "s\u030C\u0307", - // ṧ = \v\.{s} - "\u015D": "s\u0302", - // ŝ = \^{s} - "\u1E61": "s\u0307", - // ṡ = \.{s} - "\u1E97": "t\u0308", - // ẗ = \"{t} - "\u0165": "t\u030C", - // ť = \v{t} - "\u1E6B": "t\u0307", - // ṫ = \.{t} - "\xFA": "u\u0301", - // ú = \'{u} - "\xF9": "u\u0300", - // ù = \`{u} - "\xFC": "u\u0308", - // ü = \"{u} - "\u01D8": "u\u0308\u0301", - // ǘ = \"\'{u} - "\u01DC": "u\u0308\u0300", - // ǜ = \"\`{u} - "\u01D6": "u\u0308\u0304", - // ǖ = \"\={u} - "\u01DA": "u\u0308\u030C", - // ǚ = \"\v{u} - "\u0169": "u\u0303", - // ũ = \~{u} - "\u1E79": "u\u0303\u0301", - // ṹ = \~\'{u} - "\u016B": "u\u0304", - // ū = \={u} - "\u1E7B": "u\u0304\u0308", - // ṻ = \=\"{u} - "\u016D": "u\u0306", - // ŭ = \u{u} - "\u01D4": "u\u030C", - // ǔ = \v{u} - "\xFB": "u\u0302", - // û = \^{u} - "\u016F": "u\u030A", - // ů = \r{u} - "\u0171": "u\u030B", - // ű = \H{u} - "\u1E7D": "v\u0303", - // ṽ = \~{v} - "\u1E83": "w\u0301", - // ẃ = \'{w} - "\u1E81": "w\u0300", - // ẁ = \`{w} - "\u1E85": "w\u0308", - // ẅ = \"{w} - "\u0175": "w\u0302", - // ŵ = \^{w} - "\u1E87": "w\u0307", - // ẇ = \.{w} - "\u1E98": "w\u030A", - // ẘ = \r{w} - "\u1E8D": "x\u0308", - // ẍ = \"{x} - "\u1E8B": "x\u0307", - // ẋ = \.{x} - "\xFD": "y\u0301", - // ý = \'{y} - "\u1EF3": "y\u0300", - // ỳ = \`{y} - "\xFF": "y\u0308", - // ÿ = \"{y} - "\u1EF9": "y\u0303", - // ỹ = \~{y} - "\u0233": "y\u0304", - // ȳ = \={y} - "\u0177": "y\u0302", - // ŷ = \^{y} - "\u1E8F": "y\u0307", - // ẏ = \.{y} - "\u1E99": "y\u030A", - // ẙ = \r{y} - "\u017A": "z\u0301", - // ź = \'{z} - "\u017E": "z\u030C", - // ž = \v{z} - "\u1E91": "z\u0302", - // ẑ = \^{z} - "\u017C": "z\u0307", - // ż = \.{z} - "\xC1": "A\u0301", - // Á = \'{A} - "\xC0": "A\u0300", - // À = \`{A} - "\xC4": "A\u0308", - // Ä = \"{A} - "\u01DE": "A\u0308\u0304", - // Ǟ = \"\={A} - "\xC3": "A\u0303", - // Ã = \~{A} - "\u0100": "A\u0304", - // Ā = \={A} - "\u0102": "A\u0306", - // Ă = \u{A} - "\u1EAE": "A\u0306\u0301", - // Ắ = \u\'{A} - "\u1EB0": "A\u0306\u0300", - // Ằ = \u\`{A} - "\u1EB4": "A\u0306\u0303", - // Ẵ = \u\~{A} - "\u01CD": "A\u030C", - // Ǎ = \v{A} - "\xC2": "A\u0302", - // Â = \^{A} - "\u1EA4": "A\u0302\u0301", - // Ấ = \^\'{A} - "\u1EA6": "A\u0302\u0300", - // Ầ = \^\`{A} - "\u1EAA": "A\u0302\u0303", - // Ẫ = \^\~{A} - "\u0226": "A\u0307", - // Ȧ = \.{A} - "\u01E0": "A\u0307\u0304", - // Ǡ = \.\={A} - "\xC5": "A\u030A", - // Å = \r{A} - "\u01FA": "A\u030A\u0301", - // Ǻ = \r\'{A} - "\u1E02": "B\u0307", - // Ḃ = \.{B} - "\u0106": "C\u0301", - // Ć = \'{C} - "\u010C": "C\u030C", - // Č = \v{C} - "\u0108": "C\u0302", - // Ĉ = \^{C} - "\u010A": "C\u0307", - // Ċ = \.{C} - "\u010E": "D\u030C", - // Ď = \v{D} - "\u1E0A": "D\u0307", - // Ḋ = \.{D} - "\xC9": "E\u0301", - // É = \'{E} - "\xC8": "E\u0300", - // È = \`{E} - "\xCB": "E\u0308", - // Ë = \"{E} - "\u1EBC": "E\u0303", - // Ẽ = \~{E} - "\u0112": "E\u0304", - // Ē = \={E} - "\u1E16": "E\u0304\u0301", - // Ḗ = \=\'{E} - "\u1E14": "E\u0304\u0300", - // Ḕ = \=\`{E} - "\u0114": "E\u0306", - // Ĕ = \u{E} - "\u011A": "E\u030C", - // Ě = \v{E} - "\xCA": "E\u0302", - // Ê = \^{E} - "\u1EBE": "E\u0302\u0301", - // Ế = \^\'{E} - "\u1EC0": "E\u0302\u0300", - // Ề = \^\`{E} - "\u1EC4": "E\u0302\u0303", - // Ễ = \^\~{E} - "\u0116": "E\u0307", - // Ė = \.{E} - "\u1E1E": "F\u0307", - // Ḟ = \.{F} - "\u01F4": "G\u0301", - // Ǵ = \'{G} - "\u1E20": "G\u0304", - // Ḡ = \={G} - "\u011E": "G\u0306", - // Ğ = \u{G} - "\u01E6": "G\u030C", - // Ǧ = \v{G} - "\u011C": "G\u0302", - // Ĝ = \^{G} - "\u0120": "G\u0307", - // Ġ = \.{G} - "\u1E26": "H\u0308", - // Ḧ = \"{H} - "\u021E": "H\u030C", - // Ȟ = \v{H} - "\u0124": "H\u0302", - // Ĥ = \^{H} - "\u1E22": "H\u0307", - // Ḣ = \.{H} - "\xCD": "I\u0301", - // Í = \'{I} - "\xCC": "I\u0300", - // Ì = \`{I} - "\xCF": "I\u0308", - // Ï = \"{I} - "\u1E2E": "I\u0308\u0301", - // Ḯ = \"\'{I} - "\u0128": "I\u0303", - // Ĩ = \~{I} - "\u012A": "I\u0304", - // Ī = \={I} - "\u012C": "I\u0306", - // Ĭ = \u{I} - "\u01CF": "I\u030C", - // Ǐ = \v{I} - "\xCE": "I\u0302", - // Î = \^{I} - "\u0130": "I\u0307", - // İ = \.{I} - "\u0134": "J\u0302", - // Ĵ = \^{J} - "\u1E30": "K\u0301", - // Ḱ = \'{K} - "\u01E8": "K\u030C", - // Ǩ = \v{K} - "\u0139": "L\u0301", - // Ĺ = \'{L} - "\u013D": "L\u030C", - // Ľ = \v{L} - "\u1E3E": "M\u0301", - // Ḿ = \'{M} - "\u1E40": "M\u0307", - // Ṁ = \.{M} - "\u0143": "N\u0301", - // Ń = \'{N} - "\u01F8": "N\u0300", - // Ǹ = \`{N} - "\xD1": "N\u0303", - // Ñ = \~{N} - "\u0147": "N\u030C", - // Ň = \v{N} - "\u1E44": "N\u0307", - // Ṅ = \.{N} - "\xD3": "O\u0301", - // Ó = \'{O} - "\xD2": "O\u0300", - // Ò = \`{O} - "\xD6": "O\u0308", - // Ö = \"{O} - "\u022A": "O\u0308\u0304", - // Ȫ = \"\={O} - "\xD5": "O\u0303", - // Õ = \~{O} - "\u1E4C": "O\u0303\u0301", - // Ṍ = \~\'{O} - "\u1E4E": "O\u0303\u0308", - // Ṏ = \~\"{O} - "\u022C": "O\u0303\u0304", - // Ȭ = \~\={O} - "\u014C": "O\u0304", - // Ō = \={O} - "\u1E52": "O\u0304\u0301", - // Ṓ = \=\'{O} - "\u1E50": "O\u0304\u0300", - // Ṑ = \=\`{O} - "\u014E": "O\u0306", - // Ŏ = \u{O} - "\u01D1": "O\u030C", - // Ǒ = \v{O} - "\xD4": "O\u0302", - // Ô = \^{O} - "\u1ED0": "O\u0302\u0301", - // Ố = \^\'{O} - "\u1ED2": "O\u0302\u0300", - // Ồ = \^\`{O} - "\u1ED6": "O\u0302\u0303", - // Ỗ = \^\~{O} - "\u022E": "O\u0307", - // Ȯ = \.{O} - "\u0230": "O\u0307\u0304", - // Ȱ = \.\={O} - "\u0150": "O\u030B", - // Ő = \H{O} - "\u1E54": "P\u0301", - // Ṕ = \'{P} - "\u1E56": "P\u0307", - // Ṗ = \.{P} - "\u0154": "R\u0301", - // Ŕ = \'{R} - "\u0158": "R\u030C", - // Ř = \v{R} - "\u1E58": "R\u0307", - // Ṙ = \.{R} - "\u015A": "S\u0301", - // Ś = \'{S} - "\u1E64": "S\u0301\u0307", - // Ṥ = \'\.{S} - "\u0160": "S\u030C", - // Š = \v{S} - "\u1E66": "S\u030C\u0307", - // Ṧ = \v\.{S} - "\u015C": "S\u0302", - // Ŝ = \^{S} - "\u1E60": "S\u0307", - // Ṡ = \.{S} - "\u0164": "T\u030C", - // Ť = \v{T} - "\u1E6A": "T\u0307", - // Ṫ = \.{T} - "\xDA": "U\u0301", - // Ú = \'{U} - "\xD9": "U\u0300", - // Ù = \`{U} - "\xDC": "U\u0308", - // Ü = \"{U} - "\u01D7": "U\u0308\u0301", - // Ǘ = \"\'{U} - "\u01DB": "U\u0308\u0300", - // Ǜ = \"\`{U} - "\u01D5": "U\u0308\u0304", - // Ǖ = \"\={U} - "\u01D9": "U\u0308\u030C", - // Ǚ = \"\v{U} - "\u0168": "U\u0303", - // Ũ = \~{U} - "\u1E78": "U\u0303\u0301", - // Ṹ = \~\'{U} - "\u016A": "U\u0304", - // Ū = \={U} - "\u1E7A": "U\u0304\u0308", - // Ṻ = \=\"{U} - "\u016C": "U\u0306", - // Ŭ = \u{U} - "\u01D3": "U\u030C", - // Ǔ = \v{U} - "\xDB": "U\u0302", - // Û = \^{U} - "\u016E": "U\u030A", - // Ů = \r{U} - "\u0170": "U\u030B", - // Ű = \H{U} - "\u1E7C": "V\u0303", - // Ṽ = \~{V} - "\u1E82": "W\u0301", - // Ẃ = \'{W} - "\u1E80": "W\u0300", - // Ẁ = \`{W} - "\u1E84": "W\u0308", - // Ẅ = \"{W} - "\u0174": "W\u0302", - // Ŵ = \^{W} - "\u1E86": "W\u0307", - // Ẇ = \.{W} - "\u1E8C": "X\u0308", - // Ẍ = \"{X} - "\u1E8A": "X\u0307", - // Ẋ = \.{X} - "\xDD": "Y\u0301", - // Ý = \'{Y} - "\u1EF2": "Y\u0300", - // Ỳ = \`{Y} - "\u0178": "Y\u0308", - // Ÿ = \"{Y} - "\u1EF8": "Y\u0303", - // Ỹ = \~{Y} - "\u0232": "Y\u0304", - // Ȳ = \={Y} - "\u0176": "Y\u0302", - // Ŷ = \^{Y} - "\u1E8E": "Y\u0307", - // Ẏ = \.{Y} - "\u0179": "Z\u0301", - // Ź = \'{Z} - "\u017D": "Z\u030C", - // Ž = \v{Z} - "\u1E90": "Z\u0302", - // Ẑ = \^{Z} - "\u017B": "Z\u0307", - // Ż = \.{Z} - "\u03AC": "\u03B1\u0301", - // ά = \'{α} - "\u1F70": "\u03B1\u0300", - // ὰ = \`{α} - "\u1FB1": "\u03B1\u0304", - // ᾱ = \={α} - "\u1FB0": "\u03B1\u0306", - // ᾰ = \u{α} - "\u03AD": "\u03B5\u0301", - // έ = \'{ε} - "\u1F72": "\u03B5\u0300", - // ὲ = \`{ε} - "\u03AE": "\u03B7\u0301", - // ή = \'{η} - "\u1F74": "\u03B7\u0300", - // ὴ = \`{η} - "\u03AF": "\u03B9\u0301", - // ί = \'{ι} - "\u1F76": "\u03B9\u0300", - // ὶ = \`{ι} - "\u03CA": "\u03B9\u0308", - // ϊ = \"{ι} - "\u0390": "\u03B9\u0308\u0301", - // ΐ = \"\'{ι} - "\u1FD2": "\u03B9\u0308\u0300", - // ῒ = \"\`{ι} - "\u1FD1": "\u03B9\u0304", - // ῑ = \={ι} - "\u1FD0": "\u03B9\u0306", - // ῐ = \u{ι} - "\u03CC": "\u03BF\u0301", - // ό = \'{ο} - "\u1F78": "\u03BF\u0300", - // ὸ = \`{ο} - "\u03CD": "\u03C5\u0301", - // ύ = \'{υ} - "\u1F7A": "\u03C5\u0300", - // ὺ = \`{υ} - "\u03CB": "\u03C5\u0308", - // ϋ = \"{υ} - "\u03B0": "\u03C5\u0308\u0301", - // ΰ = \"\'{υ} - "\u1FE2": "\u03C5\u0308\u0300", - // ῢ = \"\`{υ} - "\u1FE1": "\u03C5\u0304", - // ῡ = \={υ} - "\u1FE0": "\u03C5\u0306", - // ῠ = \u{υ} - "\u03CE": "\u03C9\u0301", - // ώ = \'{ω} - "\u1F7C": "\u03C9\u0300", - // ὼ = \`{ω} - "\u038E": "\u03A5\u0301", - // Ύ = \'{Υ} - "\u1FEA": "\u03A5\u0300", - // Ὺ = \`{Υ} - "\u03AB": "\u03A5\u0308", - // Ϋ = \"{Υ} - "\u1FE9": "\u03A5\u0304", - // Ῡ = \={Υ} - "\u1FE8": "\u03A5\u0306", - // Ῠ = \u{Υ} - "\u038F": "\u03A9\u0301", - // Ώ = \'{Ω} - "\u1FFA": "\u03A9\u0300" // Ὼ = \`{Ω} +} +;// CONCATENATED MODULE: ./src/unicodeSupOrSub.js +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +const uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' }); -// CONCATENATED MODULE: ./src/Parser.js +;// CONCATENATED MODULE: ./src/Parser.js /* eslint no-constant-condition:0 */ @@ -16087,9 +17227,402 @@ function () { + // Pre-evaluate both modules as unicodeSymbols require String.normalize() - - +const unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +const unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; /** * This file contains the parser used to parse out a TeX expression from the @@ -16120,10 +17653,8 @@ function () { * * The functions return ParseNodes. */ -var Parser_Parser = -/*#__PURE__*/ -function () { - function Parser(input, settings) { +class Parser { + constructor(input, settings) { this.mode = void 0; this.gullet = void 0; this.settings = void 0; @@ -16133,7 +17664,7 @@ function () { this.mode = "math"; // Create a new macro expander (gullet) and (indirectly via that) also a // new lexer (mouth) for this parser (stomach, in the language of TeX) - this.gullet = new MacroExpander_MacroExpander(input, settings, this.mode); // Store the settings for use in parsing + this.gullet = new MacroExpander(input, settings, this.mode); // Store the settings for use in parsing this.settings = settings; // Count leftright depth (for \middle errors) @@ -16145,9 +17676,7 @@ function () { */ - var _proto = Parser.prototype; - - _proto.expect = function expect(text, consume) { + expect(text, consume) { if (consume === void 0) { consume = true; } @@ -16163,9 +17692,9 @@ function () { /** * Discards the current lookahead token, considering it consumed. */ - ; - _proto.consume = function consume() { + + consume() { this.nextToken = null; } /** @@ -16173,9 +17702,9 @@ function () { * beginning, or if the previous lookahead token was consume()d), * fetch the next token as the new lookahead token and return it. */ - ; - _proto.fetch = function fetch() { + + fetch() { if (this.nextToken == null) { this.nextToken = this.gullet.expandNextToken(); } @@ -16185,39 +17714,79 @@ function () { /** * Switches between "text" and "math" modes. */ - ; - _proto.switchMode = function switchMode(newMode) { + + switchMode(newMode) { this.mode = newMode; this.gullet.switchMode(newMode); } /** * Main parsing function, which parses an entire input. */ - ; - _proto.parse = function parse() { - // Create a group namespace for the math expression. - // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) - this.gullet.beginGroup(); // Use old \color behavior (same as LaTeX's \textcolor) if requested. + + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } // Use old \color behavior (same as LaTeX's \textcolor) if requested. // We do this within the group for the math expression, so it doesn't // pollute settings.macros. + if (this.settings.colorIsTextColor) { this.gullet.macros.set("\\color", "\\textcolor"); - } // Try to parse the input + } + try { + // Try to parse the input + const parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end - var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); // End the group namespace for the expression - this.expect("EOF"); // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } - this.gullet.endGroup(); + return parse; // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + + + subparse(tokens) { + // Save the next token from the current job. + const oldToken = this.nextToken; + this.consume(); // Run the new job, terminating it with an excess '}' + + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + const parse = this.parseExpression(false); + this.expect("}"); // Restore the next token from the current job. + + this.nextToken = oldToken; return parse; - }; + } - _proto.parseExpression = function parseExpression(breakOnInfix, breakOnTokenText) { - var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence han infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + const body = []; // Keep adding atoms to the body until we can't parse any more atoms (either // we reached the end, a }, or a \right) while (true) { @@ -16226,7 +17795,7 @@ function () { this.consumeSpaces(); } - var lex = this.fetch(); + const lex = this.fetch(); if (Parser.endOfExpression.indexOf(lex.text) !== -1) { break; @@ -16240,10 +17809,12 @@ function () { break; } - var atom = this.parseAtom(breakOnTokenText); + const atom = this.parseAtom(breakOnTokenText); if (!atom) { break; + } else if (atom.type === "internal") { + continue; } body.push(atom); @@ -16262,30 +17833,28 @@ function () { * There can only be one infix operator per group. If there's more than one * then the expression is ambiguous. This can be resolved by adding {}. */ - ; - _proto.handleInfixNodes = function handleInfixNodes(body) { - var overIndex = -1; - var funcName; - for (var i = 0; i < body.length; i++) { - var node = checkNodeType(body[i], "infix"); + handleInfixNodes(body) { + let overIndex = -1; + let funcName; - if (node) { + for (let i = 0; i < body.length; i++) { + if (body[i].type === "infix") { if (overIndex !== -1) { - throw new src_ParseError("only one infix operator per group", node.token); + throw new src_ParseError("only one infix operator per group", body[i].token); } overIndex = i; - funcName = node.replaceWith; + funcName = body[i].replaceWith; } } if (overIndex !== -1 && funcName) { - var numerNode; - var denomNode; - var numerBody = body.slice(0, overIndex); - var denomBody = body.slice(overIndex + 1); + let numerNode; + let denomNode; + const numerBody = body.slice(0, overIndex); + const denomBody = body.slice(overIndex + 1); if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { numerNode = numerBody[0]; @@ -16307,29 +17876,32 @@ function () { }; } - var _node; + let node; if (funcName === "\\\\abovefrac") { - _node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); } else { - _node = this.callFunction(funcName, [numerNode, denomNode], []); + node = this.callFunction(funcName, [numerNode, denomNode], []); } - return [_node]; + return [node]; } else { return body; } - } // The greediness of a superscript or subscript - ; - + } /** * Handle a subscript or superscript with nice errors. */ - _proto.handleSupSubscript = function handleSupSubscript(name) { - var symbolToken = this.fetch(); - var symbol = symbolToken.text; + + + handleSupSubscript(name // For error reporting. + ) { + const symbolToken = this.fetch(); + const symbol = symbolToken.text; this.consume(); - var group = this.parseGroup(name, false, Parser.SUPSUB_GREEDINESS, undefined, undefined, true); // ignore spaces before sup/subscript argument + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + const group = this.parseGroup(name); if (!group) { throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken); @@ -16341,12 +17913,12 @@ function () { * Converts the textual input of an unsupported command into a text node * contained within a color node whose color is determined by errorColor */ - ; - _proto.formatUnsupportedCmd = function formatUnsupportedCmd(text) { - var textordArray = []; - for (var i = 0; i < text.length; i++) { + formatUnsupportedCmd(text) { + const textordArray = []; + + for (let i = 0; i < text.length; i++) { textordArray.push({ type: "textord", mode: "text", @@ -16354,12 +17926,12 @@ function () { }); } - var textNode = { + const textNode = { type: "text", mode: this.mode, body: textordArray }; - var colorNode = { + const colorNode = { type: "color", mode: this.mode, color: this.settings.errorColor, @@ -16370,45 +17942,39 @@ function () { /** * Parses a group with optional super/subscripts. */ - ; - _proto.parseAtom = function parseAtom(breakOnTokenText) { + + parseAtom(breakOnTokenText) { // The body of an atom is an implicit group, so that things like // \left(x\right)^2 work correctly. - var base = this.parseGroup("atom", false, null, breakOnTokenText); // In text mode, we don't have superscripts or subscripts + const base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts if (this.mode === "text") { return base; } // Note that base may be empty (i.e. null) at this point. - var superscript; - var subscript; + let superscript; + let subscript; while (true) { // Guaranteed in math mode, so eat any spaces first. this.consumeSpaces(); // Lex the first token - var lex = this.fetch(); + const lex = this.fetch(); if (lex.text === "\\limits" || lex.text === "\\nolimits") { // We got a limit control - var opNode = checkNodeType(base, "op"); - - if (opNode) { - var limits = lex.text === "\\limits"; - opNode.limits = limits; - opNode.alwaysHandleSupSub = true; - } else { - opNode = checkNodeType(base, "operatorname"); - - if (opNode && opNode.alwaysHandleSupSub) { - var _limits = lex.text === "\\limits"; - - opNode.limits = _limits; - } else { - throw new src_ParseError("Limit controls must follow a math operator", lex); + if (base && base.type === "op") { + const limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; } + } else { + throw new src_ParseError("Limit controls must follow a math operator", lex); } this.consume(); @@ -16432,13 +17998,13 @@ function () { throw new src_ParseError("Double superscript", lex); } - var prime = { + const prime = { type: "textord", mode: this.mode, text: "\\prime" }; // Many primes can be grouped together, so we handle this here - var primes = [prime]; + const primes = [prime]; this.consume(); // Keep lexing tokens until we get something that's not a prime while (this.fetch().text === "'") { @@ -16459,6 +18025,47 @@ function () { mode: this.mode, body: primes }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + const isSub = unicodeSubRegEx.test(lex.text); + const subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); // Continue fetching tokens to fill out the string. + + while (true) { + const token = this.fetch().text; + + if (!uSubsAndSups[token]) { + break; + } + + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } // Now create a (sub|super)script. + + + const body = this.subparse(subsupTokens); + + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } } else { // If it wasn't ^, _, or ', stop parsing super/subscripts break; @@ -16484,13 +18091,13 @@ function () { /** * Parses an entire function, including its base and all of its arguments. */ - ; - _proto.parseFunction = function parseFunction(breakOnTokenText, name, // For error reporting. - greediness) { - var token = this.fetch(); - var func = token.text; - var funcData = src_functions[func]; + + parseFunction(breakOnTokenText, name // For determining its context + ) { + const token = this.fetch(); + const func = token.text; + const funcData = src_functions[func]; if (!funcData) { return null; @@ -16498,7 +18105,7 @@ function () { this.consume(); // consume command token - if (greediness != null && funcData.greediness <= greediness) { + if (name && name !== "atom" && !funcData.allowedInArgument) { throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); } else if (this.mode === "text" && !funcData.allowedInText) { throw new src_ParseError("Can't use function '" + func + "' in text mode", token); @@ -16506,25 +18113,25 @@ function () { throw new src_ParseError("Can't use function '" + func + "' in math mode", token); } - var _this$parseArguments = this.parseArguments(func, funcData), - args = _this$parseArguments.args, - optArgs = _this$parseArguments.optArgs; - + const { + args, + optArgs + } = this.parseArguments(func, funcData); return this.callFunction(func, args, optArgs, token, breakOnTokenText); } /** * Call a function handler with a suitable context and arguments. */ - ; - _proto.callFunction = function callFunction(name, args, optArgs, token, breakOnTokenText) { - var context = { + + callFunction(name, args, optArgs, token, breakOnTokenText) { + const context = { funcName: name, parser: this, - token: token, - breakOnTokenText: breakOnTokenText + token, + breakOnTokenText }; - var func = src_functions[name]; + const func = src_functions[name]; if (func && func.handler) { return func.handler(context, args, optArgs); @@ -16535,11 +18142,11 @@ function () { /** * Parses the arguments of a function or environment */ - ; - _proto.parseArguments = function parseArguments(func, // Should look like "\name" or "\begin{name}". + + parseArguments(func, // Should look like "\name" or "\begin{name}". funcData) { - var totalArgs = funcData.numArgs + funcData.numOptionalArgs; + const totalArgs = funcData.numArgs + funcData.numOptionalArgs; if (totalArgs === 0) { return { @@ -16548,118 +18155,98 @@ function () { }; } - var baseGreediness = funcData.greediness; - var args = []; - var optArgs = []; + const args = []; + const optArgs = []; - for (var i = 0; i < totalArgs; i++) { - var argType = funcData.argTypes && funcData.argTypes[i]; - var isOptional = i < funcData.numOptionalArgs; // Ignore spaces between arguments. As the TeXbook says: - // "After you have said ‘\def\row#1#2{...}’, you are allowed to - // put spaces between the arguments (e.g., ‘\row x n’), because - // TeX doesn’t use single spaces as undelimited arguments." - - var consumeSpaces = i > 0 && !isOptional || // Also consume leading spaces in math mode, as parseSymbol - // won't know what to do with them. This can only happen with - // macros, e.g. \frac\foo\foo where \foo expands to a space symbol. - // In LaTeX, the \foo's get treated as (blank) arguments. - // In KaTeX, for now, both spaces will get consumed. - // TODO(edemaine) - i === 0 && !isOptional && this.mode === "math"; - var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional, baseGreediness, consumeSpaces); - - if (!arg) { - if (isOptional) { - optArgs.push(null); - continue; - } + for (let i = 0; i < totalArgs; i++) { + let argType = funcData.argTypes && funcData.argTypes[i]; + const isOptional = i < funcData.numOptionalArgs; - throw new src_ParseError("Expected group after '" + func + "'", this.fetch()); + if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; } - (isOptional ? optArgs : args).push(arg); + const arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new src_ParseError("Null argument, please report this as a bug"); + } } return { - args: args, - optArgs: optArgs + args, + optArgs }; } /** * Parses a group when the mode is changing. */ - ; - _proto.parseGroupOfType = function parseGroupOfType(name, type, optional, greediness, consumeSpaces) { + + parseGroupOfType(name, type, optional) { switch (type) { case "color": - if (consumeSpaces) { - this.consumeSpaces(); - } - return this.parseColorGroup(optional); case "size": - if (consumeSpaces) { - this.consumeSpaces(); - } - return this.parseSizeGroup(optional); case "url": - return this.parseUrlGroup(optional, consumeSpaces); + return this.parseUrlGroup(optional); case "math": case "text": - return this.parseGroup(name, optional, greediness, undefined, type, consumeSpaces); + return this.parseArgumentGroup(optional, type); case "hbox": { // hbox argument type wraps the argument in the equivalent of // \hbox, which is like \text but switching to \textstyle size. - var group = this.parseGroup(name, optional, greediness, undefined, "text", consumeSpaces); - - if (!group) { - return group; - } - - var styledGroup = { + const group = this.parseArgumentGroup(optional, "text"); + return group != null ? { type: "styling", mode: group.mode, body: [group], style: "text" // simulate \textstyle - }; - return styledGroup; + } : null; } case "raw": { - if (consumeSpaces) { - this.consumeSpaces(); - } + const token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } - if (optional && this.fetch().text === "{") { - return null; + case "primitive": + { + if (optional) { + throw new src_ParseError("A primitive argument cannot be optional"); } - var token = this.parseStringGroup("raw", optional, true); + const group = this.parseGroup(name); - if (token) { - return { - type: "raw", - mode: "text", - string: token.text - }; - } else { - throw new src_ParseError("Expected raw group", this.fetch()); + if (group == null) { + throw new src_ParseError("Expected group as " + name, this.fetch()); } + + return group; } case "original": case null: case undefined: - return this.parseGroup(name, optional, greediness, undefined, undefined, consumeSpaces); + return this.parseArgumentGroup(optional); default: throw new src_ParseError("Unknown group type as " + name, this.fetch()); @@ -16668,9 +18255,9 @@ function () { /** * Discard any space tokens, fetching the next non-space token. */ - ; - _proto.consumeSpaces = function consumeSpaces() { + + consumeSpaces() { while (this.fetch().text === " ") { this.consume(); } @@ -16679,70 +18266,42 @@ function () { * Parses a group, essentially returning the string formed by the * brace-enclosed tokens plus some position information. */ - ; - - _proto.parseStringGroup = function parseStringGroup(modeName, // Used to describe the mode in error messages. - optional, raw) { - var groupBegin = optional ? "[" : "{"; - var groupEnd = optional ? "]" : "}"; - var beginToken = this.fetch(); - - if (beginToken.text !== groupBegin) { - if (optional) { - return null; - } else if (raw && beginToken.text !== "EOF" && /[^{}[\]]/.test(beginToken.text)) { - this.consume(); - return beginToken; - } - } - - var outerMode = this.mode; - this.mode = "text"; - this.expect(groupBegin); - var str = ""; - var firstToken = this.fetch(); - var nested = 0; // allow nested braces in raw string group - var lastToken = firstToken; - var nextToken; - while ((nextToken = this.fetch()).text !== groupEnd || raw && nested > 0) { - switch (nextToken.text) { - case "EOF": - throw new src_ParseError("Unexpected end of input in " + modeName, firstToken.range(lastToken, str)); + parseStringGroup(modeName, // Used to describe the mode in error messages. + optional) { + const argToken = this.gullet.scanArgument(optional); - case groupBegin: - nested++; - break; + if (argToken == null) { + return null; + } - case groupEnd: - nested--; - break; - } + let str = ""; + let nextToken; - lastToken = nextToken; - str += lastToken.text; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; this.consume(); } - this.expect(groupEnd); - this.mode = outerMode; - return firstToken.range(lastToken, str); + this.consume(); // consume the end of the argument + + argToken.text = str; + return argToken; } /** * Parses a regex-delimited group: the largest sequence of tokens * whose concatenated strings match `regex`. Returns the string * formed by the tokens plus some position information. */ - ; - _proto.parseRegexGroup = function parseRegexGroup(regex, modeName) { - var outerMode = this.mode; - this.mode = "text"; - var firstToken = this.fetch(); - var lastToken = firstToken; - var str = ""; - var nextToken; + + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + const firstToken = this.fetch(); + let lastToken = firstToken; + let str = ""; + let nextToken; while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { lastToken = nextToken; @@ -16754,28 +18313,27 @@ function () { throw new src_ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); } - this.mode = outerMode; return firstToken.range(lastToken, str); } /** * Parses a color description. */ - ; - _proto.parseColorGroup = function parseColorGroup(optional) { - var res = this.parseStringGroup("color", optional); - if (!res) { + parseColorGroup(optional) { + const res = this.parseStringGroup("color", optional); + + if (res == null) { return null; } - var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + const match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); if (!match) { throw new src_ParseError("Invalid color: '" + res.text + "'", res); } - var color = match[0]; + let color = match[0]; if (/^[0-9a-f]{6}$/i.test(color)) { // We allow a 6-digit HTML color spec without a leading "#". @@ -16787,19 +18345,21 @@ function () { return { type: "color-token", mode: this.mode, - color: color + color }; } /** * Parses a size specification, consisting of magnitude and unit. */ - ; - _proto.parseSizeGroup = function parseSizeGroup(optional) { - var res; - var isBlank = false; - if (!optional && this.fetch().text !== "{") { + parseSizeGroup(optional) { + let res; + let isBlank = false; // don't expand before parseStringGroup + + this.gullet.consumeSpaces(); + + if (!optional && this.gullet.future().text !== "{") { res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); } else { res = this.parseStringGroup("size", optional); @@ -16818,13 +18378,13 @@ function () { isBlank = true; // This is here specifically for \genfrac } - var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); if (!match) { throw new src_ParseError("Invalid size: '" + res.text + "'", res); } - var data = { + const data = { number: +(match[1] + match[2]), // sign + magnitude, cast to number unit: match[3] @@ -16838,23 +18398,26 @@ function () { type: "size", mode: this.mode, value: data, - isBlank: isBlank + isBlank }; } /** * Parses an URL, checking escaped letters and allowed protocols, * and setting the catcode of % as an active character (as in \hyperref). */ - ; - _proto.parseUrlGroup = function parseUrlGroup(optional, consumeSpaces) { + + parseUrlGroup(optional) { this.gullet.lexer.setCatcode("%", 13); // active character - var res = this.parseStringGroup("url", optional, true); // get raw string + this.gullet.lexer.setCatcode("~", 12); // other character + const res = this.parseStringGroup("url", optional); this.gullet.lexer.setCatcode("%", 14); // comment character - if (!res) { + this.gullet.lexer.setCatcode("~", 13); // active character + + if (res == null) { return null; } // hyperref package allows backslashes alone in href, but doesn't // generate valid links in such cases; we interpret this as @@ -16862,57 +18425,74 @@ function () { // replace backslashes with forward slashes. - var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); return { type: "url", mode: this.mode, - url: url + url }; } /** - * If `optional` is false or absent, this parses an ordinary group, - * which is either a single nucleus (like "x") or an expression - * in braces (like "{x+y}") or an implicit group, a group that starts - * at the current position, and ends right before a higher explicit - * group ends, or at EOF. - * If `optional` is true, it parses either a bracket-delimited expression - * (like "[x+y]") or returns null to indicate the absence of a - * bracket-enclosed group. - * If `mode` is present, switches to that mode while parsing the group, - * and switches back after. + * Parses an argument with the mode specified. */ - ; - _proto.parseGroup = function parseGroup(name, // For error reporting. - optional, greediness, breakOnTokenText, mode, consumeSpaces) { - // Switch to specified mode - var outerMode = this.mode; + + parseArgumentGroup(optional, mode) { + const argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + const outerMode = this.mode; if (mode) { + // Switch to specified mode this.switchMode(mode); - } // Consume spaces if requested, crucially *after* we switch modes, - // so that the next non-space token is parsed in the correct mode. + } + this.gullet.beginGroup(); + const expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end - if (consumeSpaces) { - this.consumeSpaces(); - } // Get first token + this.expect("EOF"); // expect the end of the argument + + this.gullet.endGroup(); + const result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ - var firstToken = this.fetch(); - var text = firstToken.text; - var result; // Try to parse an open brace or \begingroup + parseGroup(name, // For error reporting. + breakOnTokenText) { + const firstToken = this.fetch(); + const text = firstToken.text; + let result; // Try to parse an open brace or \begingroup - if (optional ? text === "[" : text === "{" || text === "\\begingroup") { + if (text === "{" || text === "\\begingroup") { this.consume(); - var groupEnd = Parser.endOfGroup[text]; // Start a new group namespace - + const groupEnd = text === "{" ? "}" : "\\endgroup"; this.gullet.beginGroup(); // If we get a brace, parse an expression - var expression = this.parseExpression(false, groupEnd); - var lastToken = this.fetch(); // Check that we got a matching closing brace - - this.expect(groupEnd); // End group namespace + const expression = this.parseExpression(false, groupEnd); + const lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace this.gullet.endGroup(); result = { @@ -16926,13 +18506,10 @@ function () { // use-begingroup-instead-of-bgroup semisimple: text === "\\begingroup" || undefined }; - } else if (optional) { - // Return nothing for an optional group - result = null; } else { // If there exists a function with this name, parse the function. // Otherwise, just return a nucleus - result = this.parseFunction(breakOnTokenText, name, greediness) || this.parseSymbol(); + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { if (this.settings.throwOnError) { @@ -16942,11 +18519,6 @@ function () { result = this.formatUnsupportedCmd(text); this.consume(); } - } // Switch mode back - - - if (mode) { - this.switchMode(outerMode); } return result; @@ -16959,15 +18531,15 @@ function () { * characters in its value. The representation is still ASCII source. * The group will be modified in place. */ - ; - _proto.formLigatures = function formLigatures(group) { - var n = group.length - 1; - for (var i = 0; i < n; ++i) { - var a = group[i]; // $FlowFixMe: Not every node type has a `text` property. + formLigatures(group) { + let n = group.length - 1; + + for (let i = 0; i < n; ++i) { + const a = group[i]; // $FlowFixMe: Not every node type has a `text` property. - var v = a.text; + const v = a.text; if (v === "-" && group[i + 1].text === "-") { if (i + 1 < n && group[i + 2].text === "-") { @@ -17004,16 +18576,16 @@ function () { * Parse a single symbol out of the string. Here, we handle single character * symbols and special functions like \verb. */ - ; - _proto.parseSymbol = function parseSymbol() { - var nucleus = this.fetch(); - var text = nucleus.text; + + parseSymbol() { + const nucleus = this.fetch(); + let text = nucleus.text; if (/^\\verb[^a-zA-Z]/.test(text)) { this.consume(); - var arg = text.slice(5); - var star = arg.charAt(0) === "*"; + let arg = text.slice(5); + const star = arg.charAt(0) === "*"; if (star) { arg = arg.slice(1); @@ -17031,7 +18603,7 @@ function () { type: "verb", mode: "text", body: arg, - star: star + star }; } // At this point, we should have a symbol, possibly with accents. // First expand any accented base symbol according to unicodeSymbols. @@ -17043,53 +18615,54 @@ function () { this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); } - text = unicodeSymbols[text[0]] + text.substr(1); + text = unicodeSymbols[text[0]] + text.slice(1); } // Strip off any combining characters - var match = combiningDiacriticalMarksEndRegex.exec(text); + const match = combiningDiacriticalMarksEndRegex.exec(text); if (match) { text = text.substring(0, match.index); if (text === 'i') { - text = "\u0131"; // dotless i, in math and text mode + text = '\u0131'; // dotless i, in math and text mode } else if (text === 'j') { - text = "\u0237"; // dotless j, in math and text mode + text = '\u0237'; // dotless j, in math and text mode } } // Recognize base symbol - var symbol; + let symbol; if (src_symbols[this.mode][text]) { if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) { this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); } - var group = src_symbols[this.mode][text].group; - var loc = SourceLocation.range(nucleus); - var s; + const group = src_symbols[this.mode][text].group; + const loc = SourceLocation.range(nucleus); + let s; if (ATOMS.hasOwnProperty(group)) { // $FlowFixMe - var family = group; + const family = group; s = { type: "atom", mode: this.mode, - family: family, - loc: loc, - text: text + family, + loc, + text }; } else { // $FlowFixMe s = { type: group, mode: this.mode, - loc: loc, - text: text + loc, + text }; - } + } // $FlowFixMe + symbol = s; } else if (text.charCodeAt(0) >= 0x80) { @@ -17113,7 +18686,7 @@ function () { type: "textord", mode: "text", loc: SourceLocation.range(nucleus), - text: text + text }; } else { return null; // EOF, ^, _, {, }, etc. @@ -17122,14 +18695,14 @@ function () { this.consume(); // Transform combining characters into accents if (match) { - for (var i = 0; i < match[0].length; i++) { - var accent = match[0][i]; + for (let i = 0; i < match[0].length; i++) { + const accent = match[0][i]; if (!unicodeAccents[accent]) { throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus); } - var command = unicodeAccents[accent][this.mode]; + const command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; if (!command) { throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); @@ -17142,38 +18715,19 @@ function () { label: command, isStretchy: false, isShifty: true, + // $FlowFixMe base: symbol }; } - } - - return symbol; - }; - - return Parser; -}(); + } // $FlowFixMe -Parser_Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; -Parser_Parser.endOfGroup = { - "[": "]", - "{": "}", - "\\begingroup": "\\endgroup" - /** - * Parses an "expression", which is a list of atoms. - * - * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This - * happens when functions have higher precendence han infix - * nodes in implicit parses. - * - * `breakOnTokenText`: The text of the token that the expression should end - * with, or `null` if something else should end the - * expression. - */ -}; -Parser_Parser.SUPSUB_GREEDINESS = 1; + return symbol; + } -// CONCATENATED MODULE: ./src/parseTree.js +} +Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; +;// CONCATENATED MODULE: ./src/parseTree.js /** * Provides a single function for parsing an expression using a Parser * TODO(emily): Remove this @@ -17181,18 +18735,22 @@ Parser_Parser.SUPSUB_GREEDINESS = 1; + /** * Parses an expression using a Parser, then returns the parsed result. */ -var parseTree_parseTree = function parseTree(toParse, settings) { +const parseTree = function (toParse, settings) { if (!(typeof toParse === 'string' || toParse instanceof String)) { throw new TypeError('KaTeX can only parse string typed expression'); } - var parser = new Parser_Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + const parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors delete parser.gullet.macros.current["\\df@tag"]; - var tree = parser.parse(); // If the input used \tag, it will set the \df@tag macro to the tag. + let tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render(). + + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag. // In this case, we separately parse the tag and wrap the tree. if (parser.gullet.macros.get("\\df@tag")) { @@ -17200,20 +18758,19 @@ var parseTree_parseTree = function parseTree(toParse, settings) { throw new src_ParseError("\\tag works only in display equations"); } - parser.gullet.feed("\\df@tag"); tree = [{ type: "tag", mode: "text", body: tree, - tag: parser.parse() + tag: parser.subparse([new Token("\\df@tag")]) }]; } return tree; }; -/* harmony default export */ var src_parseTree = (parseTree_parseTree); -// CONCATENATED MODULE: ./katex.js +/* harmony default export */ var src_parseTree = (parseTree); +;// CONCATENATED MODULE: ./katex.js /* eslint no-console:0 */ /** @@ -17233,13 +18790,14 @@ var parseTree_parseTree = function parseTree(toParse, settings) { + /** * Parse and build an expression, and place that expression in the DOM node * given. */ -var katex_render = function render(expression, baseNode, options) { +let render = function (expression, baseNode, options) { baseNode.textContent = ""; - var node = katex_renderToDomTree(expression, options).toNode(); + const node = renderToDomTree(expression, options).toNode(); baseNode.appendChild(node); }; // KaTeX's styles don't work properly in quirks mode. Print out an error, and // disable rendering. @@ -17249,7 +18807,7 @@ if (typeof document !== "undefined") { if (document.compatMode !== "CSS1Compat") { typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); - katex_render = function render() { + render = function () { throw new src_ParseError("KaTeX doesn't work in quirks mode."); }; } @@ -17259,8 +18817,8 @@ if (typeof document !== "undefined") { */ -var renderToString = function renderToString(expression, options) { - var markup = katex_renderToDomTree(expression, options).toMarkup(); +const renderToString = function (expression, options) { + const markup = renderToDomTree(expression, options).toMarkup(); return markup; }; /** @@ -17268,8 +18826,8 @@ var renderToString = function renderToString(expression, options) { */ -var katex_generateParseTree = function generateParseTree(expression, options) { - var settings = new Settings_Settings(options); +const generateParseTree = function (expression, options) { + const settings = new Settings(options); return src_parseTree(expression, settings); }; /** @@ -17279,12 +18837,12 @@ var katex_generateParseTree = function generateParseTree(expression, options) { */ -var katex_renderError = function renderError(error, expression, options) { +const renderError = function (error, expression, options) { if (options.throwOnError || !(error instanceof src_ParseError)) { throw error; } - var node = buildCommon.makeSpan(["katex-error"], [new domTree_SymbolNode(expression)]); + const node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]); node.setAttribute("title", error.toString()); node.setAttribute("style", "color:" + options.errorColor); return node; @@ -17295,14 +18853,14 @@ var katex_renderError = function renderError(error, expression, options) { */ -var katex_renderToDomTree = function renderToDomTree(expression, options) { - var settings = new Settings_Settings(options); +const renderToDomTree = function (expression, options) { + const settings = new Settings(options); try { - var tree = src_parseTree(expression, settings); - return buildTree_buildTree(tree, expression, settings); + const tree = src_parseTree(expression, settings); + return buildTree(tree, expression, settings); } catch (error) { - return katex_renderError(error, expression, settings); + return renderError(error, expression, settings); } }; /** @@ -17311,40 +18869,45 @@ var katex_renderToDomTree = function renderToDomTree(expression, options) { */ -var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { - var settings = new Settings_Settings(options); +const renderToHTMLTree = function (expression, options) { + const settings = new Settings(options); try { - var tree = src_parseTree(expression, settings); - return buildTree_buildHTMLTree(tree, expression, settings); + const tree = src_parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); } catch (error) { - return katex_renderError(error, expression, settings); + return renderError(error, expression, settings); } }; -/* harmony default export */ var katex_0 = ({ +/* harmony default export */ var katex = ({ /** * Current KaTeX version */ - version: "0.11.1", + version: "0.16.10", /** * Renders the given LaTeX into an HTML+MathML combination, and adds * it as a child to the specified DOM node. */ - render: katex_render, + render, /** * Renders the given LaTeX into an HTML+MathML combination string, * for sending to the client. */ - renderToString: renderToString, + renderToString, /** * KaTeX error, usually during parsing. */ ParseError: src_ParseError, + /** + * The shema of Settings + */ + SETTINGS_SCHEMA: SETTINGS_SCHEMA, + /** * Parses the given LaTeX into KaTeX's internal parse tree structure, * without rendering to HTML or MathML. @@ -17353,7 +18916,7 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { * The internal tree representation is unstable and is very likely * to change. Use at your own risk. */ - __parse: katex_generateParseTree, + __parse: generateParseTree, /** * Renders the given LaTeX into an HTML+MathML internal DOM tree @@ -17363,7 +18926,7 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { * The internal tree representation is unstable and is very likely * to change. Use at your own risk. */ - __renderToDomTree: katex_renderToDomTree, + __renderToDomTree: renderToDomTree, /** * Renders the given LaTeX into an HTML internal DOM tree representation, @@ -17373,7 +18936,7 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { * The internal tree representation is unstable and is very likely * to change. Use at your own risk. */ - __renderToHTMLTree: katex_renderToHTMLTree, + __renderToHTMLTree: renderToHTMLTree, /** * extends internal font metrics object with a new object @@ -17386,6 +18949,13 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { */ __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** * adds a new macro to builtin macro list */ @@ -17399,15 +18969,15 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { * to change. Use at your own risk. */ __domTree: { - Span: domTree_Span, - Anchor: domTree_Anchor, - SymbolNode: domTree_SymbolNode, + Span: Span, + Anchor: Anchor, + SymbolNode: SymbolNode, SvgNode: SvgNode, - PathNode: domTree_PathNode, + PathNode: PathNode, LineNode: LineNode } }); -// CONCATENATED MODULE: ./katex.webpack.js +;// CONCATENATED MODULE: ./katex.webpack.js /** * This is the webpack entry point for KaTeX. As ECMAScript, flow[1] and jest[2] * doesn't support CSS modules natively, a separate entry point is used and @@ -17418,8 +18988,9 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) { */ -/* harmony default export */ var katex_webpack = __webpack_exports__["default"] = (katex_0); - -/***/ }) -/******/ ])["default"]; +/* harmony default export */ var katex_webpack = (katex); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; }); \ No newline at end of file diff --git a/katex/katex.min.css b/katex/katex.min.css index c0cd1451ae..b5337aae64 100644 --- a/katex/katex.min.css +++ b/katex/katex.min.css @@ -1 +1 @@ -@font-face{font-family:KaTeX_AMS;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Caligraphic;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype");font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Caligraphic;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Fraktur;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype");font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Fraktur;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype");font-weight:700;font-style:normal}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype");font-weight:700;font-style:italic}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype");font-weight:400;font-style:italic}@font-face{font-family:KaTeX_Main;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Math;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype");font-weight:700;font-style:italic}@font-face{font-family:KaTeX_Math;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype");font-weight:400;font-style:italic}@font-face{font-family:"KaTeX_SansSerif";src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype");font-weight:700;font-style:normal}@font-face{font-family:"KaTeX_SansSerif";src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype");font-weight:400;font-style:italic}@font-face{font-family:"KaTeX_SansSerif";src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Script;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size1;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size2;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size3;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Size4;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype");font-weight:400;font-style:normal}@font-face{font-family:KaTeX_Typewriter;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype");font-weight:400;font-style:normal}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important}.katex .katex-version:after{content:"0.11.1"}.katex .katex-mathml{position:absolute;clip:rect(1px,1px,1px,1px);padding:0;border:0;height:1px;width:1px;overflow:hidden}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathdefault{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-weight:700;font-style:italic}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;vertical-align:bottom;position:relative}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;vertical-align:bottom;font-size:1px;width:2px;min-width:2px}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{display:inline-block;width:100%;border-bottom-style:solid}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .clap,.katex .llap,.katex .rlap{width:0;position:relative}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{display:inline-block;border:0 solid;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{display:inline-block;width:100%;border-bottom-style:solid}.katex .hdashline{display:inline-block;width:100%;border-bottom-style:dashed}.katex .sqrt>.root{margin-left:.27777778em;margin-right:-.55555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.83333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.16666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.66666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.45666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.14666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.71428571em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.85714286em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.14285714em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.28571429em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.42857143em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.71428571em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.05714286em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.46857143em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.96285714em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.55428571em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.55555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.66666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.77777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.88888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.11111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.30444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.76444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.41666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.58333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.66666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.83333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.72833333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.07333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.34722222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.41666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.48611111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.55555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.69444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.83333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.44027778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.72777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.28935185em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.34722222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.40509259em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.46296296em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.52083333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.69444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.83333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.20023148em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.43981481em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.24108004em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.28929605em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.33751205em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.38572806em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.43394407em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.48216008em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.57859209em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.69431051em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.83317261em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.19961427em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.20096463em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.24115756em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.28135048em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.32154341em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.36173633em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.40192926em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.48231511em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.57877814em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.69453376em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.83360129em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .op-limits>.vlist-t{text-align:center}.katex .accent>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{display:block;position:absolute;width:100%;height:inherit;fill:currentColor;stroke:currentColor;fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex svg path{stroke:none}.katex img{border-style:none;min-width:0;min-height:0;max-width:none;max-height:none}.katex .stretchy{width:100%;display:block;position:relative;overflow:hidden}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{width:100%;position:relative;overflow:hidden}.katex .halfarrow-left{position:absolute;left:0;width:50.2%;overflow:hidden}.katex .halfarrow-right{position:absolute;right:0;width:50.2%;overflow:hidden}.katex .brace-left{position:absolute;left:0;width:25.1%;overflow:hidden}.katex .brace-center{position:absolute;left:25%;width:50%;overflow:hidden}.katex .brace-right{position:absolute;right:0;width:25.1%;overflow:hidden}.katex .x-arrow-pad{padding:0 .5em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{box-sizing:border-box;border:.04em solid}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{text-align:left} +@font-face{font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.16.10"}.katex .katex-mathml{clip:rect(1px,1px,1px,1px);border:0;height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.27777778em;margin-right:-.55555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.83333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.16666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.66666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.45666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.14666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.71428571em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.85714286em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.14285714em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.28571429em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.42857143em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.71428571em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.05714286em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.46857143em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.96285714em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.55428571em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.55555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.66666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.77777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.88888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.11111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.33333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.30444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.76444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.41666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.58333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.66666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.83333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.72833333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.07333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.34722222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.41666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.48611111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.55555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.69444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.83333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.44027778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.72777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.28935185em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.34722222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.40509259em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.46296296em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.52083333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.69444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.83333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.20023148em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.43981481em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.24108004em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.28929605em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.33751205em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.38572806em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.43394407em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.48216008em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.57859209em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.69431051em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.83317261em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.19961427em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.20096463em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.24115756em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.28135048em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.32154341em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.36173633em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.40192926em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.48231511em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.57877814em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.69453376em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.83360129em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo} diff --git a/katex/katex.min.js b/katex/katex.min.js index 906ce12826..e701cfde7c 100644 --- a/katex/katex.min.js +++ b/katex/katex.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.katex=e():t.katex=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){},function(t,e,r){"use strict";r.r(e);r(0);var a=function(){function t(t,e,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=t,this.start=e,this.end=r}return t.range=function(e,r){return r?e&&e.loc&&r.loc&&e.loc.lexer===r.loc.lexer?new t(e.loc.lexer,e.loc.start,r.loc.end):null:e&&e.loc},t}(),n=function(){function t(t,e){this.text=void 0,this.loc=void 0,this.text=t,this.loc=e}return t.prototype.range=function(e,r){return new t(r,a.range(this,e))},t}(),i=function t(e,r){this.position=void 0;var a,n="KaTeX parse error: "+e,i=r&&r.loc;if(i&&i.start<=i.end){var o=i.lexer.input;a=i.start;var s=i.end;a===o.length?n+=" at end of input: ":n+=" at position "+(a+1)+": ";var h=o.slice(a,s).replace(/[^]/g,"$&\u0332");n+=(a>15?"\u2026"+o.slice(a-15,a):o.slice(0,a))+h+(s+15":">","<":"<",'"':""","'":"'"},l=/[&><"']/g;var m=function t(e){return"ordgroup"===e.type?1===e.body.length?t(e.body[0]):e:"color"===e.type?1===e.body.length?t(e.body[0]):e:"font"===e.type?t(e.body):e},c={contains:function(t,e){return-1!==t.indexOf(e)},deflt:function(t,e){return void 0===t?e:t},escape:function(t){return String(t).replace(l,function(t){return h[t]})},hyphenate:function(t){return t.replace(s,"-$1").toLowerCase()},getBaseElem:m,isCharacterBox:function(t){var e=m(t);return"mathord"===e.type||"textord"===e.type||"atom"===e.type},protocolFromUrl:function(t){var e=/^\s*([^\\\/#]*?)(?::|�*58|�*3a)/i.exec(t);return null!=e?e[1]:"_relative"}},u=function(){function t(t){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,t=t||{},this.displayMode=c.deflt(t.displayMode,!1),this.output=c.deflt(t.output,"htmlAndMathml"),this.leqno=c.deflt(t.leqno,!1),this.fleqn=c.deflt(t.fleqn,!1),this.throwOnError=c.deflt(t.throwOnError,!0),this.errorColor=c.deflt(t.errorColor,"#cc0000"),this.macros=t.macros||{},this.minRuleThickness=Math.max(0,c.deflt(t.minRuleThickness,0)),this.colorIsTextColor=c.deflt(t.colorIsTextColor,!1),this.strict=c.deflt(t.strict,"warn"),this.trust=c.deflt(t.trust,!1),this.maxSize=Math.max(0,c.deflt(t.maxSize,1/0)),this.maxExpand=Math.max(0,c.deflt(t.maxExpand,1e3))}var e=t.prototype;return e.reportNonstrict=function(t,e,r){var a=this.strict;if("function"==typeof a&&(a=a(t,e,r)),a&&"ignore"!==a){if(!0===a||"error"===a)throw new o("LaTeX-incompatible input and strict mode is set to 'error': "+e+" ["+t+"]",r);"warn"===a?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+e+" ["+t+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+a+"': "+e+" ["+t+"]")}},e.useStrictBehavior=function(t,e,r){var a=this.strict;if("function"==typeof a)try{a=a(t,e,r)}catch(t){a="error"}return!(!a||"ignore"===a)&&(!0===a||"error"===a||("warn"===a?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+e+" ["+t+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+a+"': "+e+" ["+t+"]"),!1)))},e.isTrusted=function(t){t.url&&!t.protocol&&(t.protocol=c.protocolFromUrl(t.url));var e="function"==typeof this.trust?this.trust(t):this.trust;return Boolean(e)},t}(),p=function(){function t(t,e,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=t,this.size=e,this.cramped=r}var e=t.prototype;return e.sup=function(){return d[f[this.id]]},e.sub=function(){return d[g[this.id]]},e.fracNum=function(){return d[x[this.id]]},e.fracDen=function(){return d[v[this.id]]},e.cramp=function(){return d[b[this.id]]},e.text=function(){return d[y[this.id]]},e.isTight=function(){return this.size>=2},t}(),d=[new p(0,0,!1),new p(1,0,!0),new p(2,1,!1),new p(3,1,!0),new p(4,2,!1),new p(5,2,!0),new p(6,3,!1),new p(7,3,!0)],f=[4,5,4,5,6,7,6,7],g=[5,5,5,5,7,7,7,7],x=[2,3,4,5,6,7,6,7],v=[3,3,5,5,7,7,7,7],b=[1,1,3,3,5,5,7,7],y=[0,1,2,3,2,3,2,3],w={DISPLAY:d[0],TEXT:d[2],SCRIPT:d[4],SCRIPTSCRIPT:d[6]},k=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];var S=[];function M(t){for(var e=0;e=S[e]&&t<=S[e+1])return!0;return!1}k.forEach(function(t){return t.blocks.forEach(function(t){return S.push.apply(S,t)})});var z={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:"M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",leftmapsto:"M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:"M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:"M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"},A=function(){function t(t){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=t,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}var e=t.prototype;return e.hasClass=function(t){return c.contains(this.classes,t)},e.toNode=function(){for(var t=document.createDocumentFragment(),e=0;e"},N=function(){function t(t,e,r,a){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,B.call(this,t,r,a),this.children=e||[]}var e=t.prototype;return e.setAttribute=function(t,e){this.attributes[t]=e},e.hasClass=function(t){return c.contains(this.classes,t)},e.toNode=function(){return C.call(this,"span")},e.toMarkup=function(){return q.call(this,"span")},t}(),I=function(){function t(t,e,r,a){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,B.call(this,e,a),this.children=r||[],this.setAttribute("href",t)}var e=t.prototype;return e.setAttribute=function(t,e){this.attributes[t]=e},e.hasClass=function(t){return c.contains(this.classes,t)},e.toNode=function(){return C.call(this,"a")},e.toMarkup=function(){return q.call(this,"a")},t}(),R=function(){function t(t,e,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=e,this.src=t,this.classes=["mord"],this.style=r}var e=t.prototype;return e.hasClass=function(t){return c.contains(this.classes,t)},e.toNode=function(){var t=document.createElement("img");for(var e in t.src=this.src,t.alt=this.alt,t.className="mord",this.style)this.style.hasOwnProperty(e)&&(t.style[e]=this.style[e]);return t},e.toMarkup=function(){var t=""+this.alt+"=n[0]&&t<=n[1])return r.name}return null}(this.text.charCodeAt(0));h&&this.classes.push(h+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=O[this.text])}var e=t.prototype;return e.hasClass=function(t){return c.contains(this.classes,t)},e.toNode=function(){var t=document.createTextNode(this.text),e=null;for(var r in this.italic>0&&((e=document.createElement("span")).style.marginRight=this.italic+"em"),this.classes.length>0&&((e=e||document.createElement("span")).className=T(this.classes)),this.style)this.style.hasOwnProperty(r)&&((e=e||document.createElement("span")).style[r]=this.style[r]);return e?(e.appendChild(t),e):t},e.toMarkup=function(){var t=!1,e="0&&(r+="margin-right:"+this.italic+"em;"),this.style)this.style.hasOwnProperty(a)&&(r+=c.hyphenate(a)+":"+this.style[a]+";");r&&(t=!0,e+=' style="'+c.escape(r)+'"');var n=c.escape(this.text);return t?(e+=">",e+=n,e+=""):n},t}(),L=function(){function t(t,e){this.children=void 0,this.attributes=void 0,this.children=t||[],this.attributes=e||{}}var e=t.prototype;return e.toNode=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");for(var e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);for(var r=0;r":""},t}(),P=function(){function t(t){this.attributes=void 0,this.attributes=t||{}}var e=t.prototype;return e.toNode=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","line");for(var e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);return t},e.toMarkup=function(){var t="",">"),$("math",Z,et,":",":"),$("math",Z,et,"\u2248","\\approx",!0),$("math",Z,et,"\u2245","\\cong",!0),$("math",Z,et,"\u2265","\\ge"),$("math",Z,et,"\u2265","\\geq",!0),$("math",Z,et,"\u2190","\\gets"),$("math",Z,et,">","\\gt"),$("math",Z,et,"\u2208","\\in",!0),$("math",Z,et,"\ue020","\\@not"),$("math",Z,et,"\u2282","\\subset",!0),$("math",Z,et,"\u2283","\\supset",!0),$("math",Z,et,"\u2286","\\subseteq",!0),$("math",Z,et,"\u2287","\\supseteq",!0),$("math",K,et,"\u2288","\\nsubseteq",!0),$("math",K,et,"\u2289","\\nsupseteq",!0),$("math",Z,et,"\u22a8","\\models"),$("math",Z,et,"\u2190","\\leftarrow",!0),$("math",Z,et,"\u2264","\\le"),$("math",Z,et,"\u2264","\\leq",!0),$("math",Z,et,"<","\\lt"),$("math",Z,et,"\u2192","\\rightarrow",!0),$("math",Z,et,"\u2192","\\to"),$("math",K,et,"\u2271","\\ngeq",!0),$("math",K,et,"\u2270","\\nleq",!0),$("math",Z,"spacing","\xa0","\\ "),$("math",Z,"spacing","\xa0","~"),$("math",Z,"spacing","\xa0","\\space"),$("math",Z,"spacing","\xa0","\\nobreakspace"),$("text",Z,"spacing","\xa0","\\ "),$("text",Z,"spacing","\xa0","~"),$("text",Z,"spacing","\xa0","\\space"),$("text",Z,"spacing","\xa0","\\nobreakspace"),$("math",Z,"spacing",null,"\\nobreak"),$("math",Z,"spacing",null,"\\allowbreak"),$("math",Z,"punct",",",","),$("math",Z,"punct",";",";"),$("math",K,J,"\u22bc","\\barwedge",!0),$("math",K,J,"\u22bb","\\veebar",!0),$("math",Z,J,"\u2299","\\odot",!0),$("math",Z,J,"\u2295","\\oplus",!0),$("math",Z,J,"\u2297","\\otimes",!0),$("math",Z,"textord","\u2202","\\partial",!0),$("math",Z,J,"\u2298","\\oslash",!0),$("math",K,J,"\u229a","\\circledcirc",!0),$("math",K,J,"\u22a1","\\boxdot",!0),$("math",Z,J,"\u25b3","\\bigtriangleup"),$("math",Z,J,"\u25bd","\\bigtriangledown"),$("math",Z,J,"\u2020","\\dagger"),$("math",Z,J,"\u22c4","\\diamond"),$("math",Z,J,"\u22c6","\\star"),$("math",Z,J,"\u25c3","\\triangleleft"),$("math",Z,J,"\u25b9","\\triangleright"),$("math",Z,"open","{","\\{"),$("text",Z,"textord","{","\\{"),$("text",Z,"textord","{","\\textbraceleft"),$("math",Z,"close","}","\\}"),$("text",Z,"textord","}","\\}"),$("text",Z,"textord","}","\\textbraceright"),$("math",Z,"open","{","\\lbrace"),$("math",Z,"close","}","\\rbrace"),$("math",Z,"open","[","\\lbrack"),$("text",Z,"textord","[","\\lbrack"),$("math",Z,"close","]","\\rbrack"),$("text",Z,"textord","]","\\rbrack"),$("math",Z,"open","(","\\lparen"),$("math",Z,"close",")","\\rparen"),$("text",Z,"textord","<","\\textless"),$("text",Z,"textord",">","\\textgreater"),$("math",Z,"open","\u230a","\\lfloor",!0),$("math",Z,"close","\u230b","\\rfloor",!0),$("math",Z,"open","\u2308","\\lceil",!0),$("math",Z,"close","\u2309","\\rceil",!0),$("math",Z,"textord","\\","\\backslash"),$("math",Z,"textord","\u2223","|"),$("math",Z,"textord","\u2223","\\vert"),$("text",Z,"textord","|","\\textbar"),$("math",Z,"textord","\u2225","\\|"),$("math",Z,"textord","\u2225","\\Vert"),$("text",Z,"textord","\u2225","\\textbardbl"),$("text",Z,"textord","~","\\textasciitilde"),$("text",Z,"textord","\\","\\textbackslash"),$("text",Z,"textord","^","\\textasciicircum"),$("math",Z,et,"\u2191","\\uparrow",!0),$("math",Z,et,"\u21d1","\\Uparrow",!0),$("math",Z,et,"\u2193","\\downarrow",!0),$("math",Z,et,"\u21d3","\\Downarrow",!0),$("math",Z,et,"\u2195","\\updownarrow",!0),$("math",Z,et,"\u21d5","\\Updownarrow",!0),$("math",Z,tt,"\u2210","\\coprod"),$("math",Z,tt,"\u22c1","\\bigvee"),$("math",Z,tt,"\u22c0","\\bigwedge"),$("math",Z,tt,"\u2a04","\\biguplus"),$("math",Z,tt,"\u22c2","\\bigcap"),$("math",Z,tt,"\u22c3","\\bigcup"),$("math",Z,tt,"\u222b","\\int"),$("math",Z,tt,"\u222b","\\intop"),$("math",Z,tt,"\u222c","\\iint"),$("math",Z,tt,"\u222d","\\iiint"),$("math",Z,tt,"\u220f","\\prod"),$("math",Z,tt,"\u2211","\\sum"),$("math",Z,tt,"\u2a02","\\bigotimes"),$("math",Z,tt,"\u2a01","\\bigoplus"),$("math",Z,tt,"\u2a00","\\bigodot"),$("math",Z,tt,"\u222e","\\oint"),$("math",Z,tt,"\u222f","\\oiint"),$("math",Z,tt,"\u2230","\\oiiint"),$("math",Z,tt,"\u2a06","\\bigsqcup"),$("math",Z,tt,"\u222b","\\smallint"),$("text",Z,"inner","\u2026","\\textellipsis"),$("math",Z,"inner","\u2026","\\mathellipsis"),$("text",Z,"inner","\u2026","\\ldots",!0),$("math",Z,"inner","\u2026","\\ldots",!0),$("math",Z,"inner","\u22ef","\\@cdots",!0),$("math",Z,"inner","\u22f1","\\ddots",!0),$("math",Z,"textord","\u22ee","\\varvdots"),$("math",Z,"accent-token","\u02ca","\\acute"),$("math",Z,"accent-token","\u02cb","\\grave"),$("math",Z,"accent-token","\xa8","\\ddot"),$("math",Z,"accent-token","~","\\tilde"),$("math",Z,"accent-token","\u02c9","\\bar"),$("math",Z,"accent-token","\u02d8","\\breve"),$("math",Z,"accent-token","\u02c7","\\check"),$("math",Z,"accent-token","^","\\hat"),$("math",Z,"accent-token","\u20d7","\\vec"),$("math",Z,"accent-token","\u02d9","\\dot"),$("math",Z,"accent-token","\u02da","\\mathring"),$("math",Z,Q,"\u0131","\\imath",!0),$("math",Z,Q,"\u0237","\\jmath",!0),$("text",Z,"textord","\u0131","\\i",!0),$("text",Z,"textord","\u0237","\\j",!0),$("text",Z,"textord","\xdf","\\ss",!0),$("text",Z,"textord","\xe6","\\ae",!0),$("text",Z,"textord","\xe6","\\ae",!0),$("text",Z,"textord","\u0153","\\oe",!0),$("text",Z,"textord","\xf8","\\o",!0),$("text",Z,"textord","\xc6","\\AE",!0),$("text",Z,"textord","\u0152","\\OE",!0),$("text",Z,"textord","\xd8","\\O",!0),$("text",Z,"accent-token","\u02ca","\\'"),$("text",Z,"accent-token","\u02cb","\\`"),$("text",Z,"accent-token","\u02c6","\\^"),$("text",Z,"accent-token","\u02dc","\\~"),$("text",Z,"accent-token","\u02c9","\\="),$("text",Z,"accent-token","\u02d8","\\u"),$("text",Z,"accent-token","\u02d9","\\."),$("text",Z,"accent-token","\u02da","\\r"),$("text",Z,"accent-token","\u02c7","\\v"),$("text",Z,"accent-token","\xa8",'\\"'),$("text",Z,"accent-token","\u02dd","\\H"),$("text",Z,"accent-token","\u25ef","\\textcircled");var rt={"--":!0,"---":!0,"``":!0,"''":!0};$("text",Z,"textord","\u2013","--"),$("text",Z,"textord","\u2013","\\textendash"),$("text",Z,"textord","\u2014","---"),$("text",Z,"textord","\u2014","\\textemdash"),$("text",Z,"textord","\u2018","`"),$("text",Z,"textord","\u2018","\\textquoteleft"),$("text",Z,"textord","\u2019","'"),$("text",Z,"textord","\u2019","\\textquoteright"),$("text",Z,"textord","\u201c","``"),$("text",Z,"textord","\u201c","\\textquotedblleft"),$("text",Z,"textord","\u201d","''"),$("text",Z,"textord","\u201d","\\textquotedblright"),$("math",Z,"textord","\xb0","\\degree",!0),$("text",Z,"textord","\xb0","\\degree"),$("text",Z,"textord","\xb0","\\textdegree",!0),$("math",Z,Q,"\xa3","\\pounds"),$("math",Z,Q,"\xa3","\\mathsterling",!0),$("text",Z,Q,"\xa3","\\pounds"),$("text",Z,Q,"\xa3","\\textsterling",!0),$("math",K,"textord","\u2720","\\maltese"),$("text",K,"textord","\u2720","\\maltese"),$("text",Z,"spacing","\xa0","\\ "),$("text",Z,"spacing","\xa0"," "),$("text",Z,"spacing","\xa0","~");for(var at=0;at<'0123456789/@."'.length;at++){var nt='0123456789/@."'.charAt(at);$("math",Z,"textord",nt,nt)}for(var it=0;it<'0123456789!@*()-=+[]<>|";:?/.,'.length;it++){var ot='0123456789!@*()-=+[]<>|";:?/.,'.charAt(it);$("text",Z,"textord",ot,ot)}for(var st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ht=0;ht=5?0:t>=3?1:2]){var r=Y[e]={cssEmPerMu:V.quad[e]/18};for(var a in V)V.hasOwnProperty(a)&&(r[a]=V[a][e])}return Y[e]}(this.size)),this._fontMetrics},e.getColor=function(){return this.phantom?"transparent":this.color},t}();kt.BASESIZE=6;var St=kt,Mt={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},zt={ex:!0,em:!0,mu:!0},At=function(t){return"string"!=typeof t&&(t=t.unit),t in Mt||t in zt||"ex"===t},Tt=function(t,e){var r;if(t.unit in Mt)r=Mt[t.unit]/e.fontMetrics().ptPerEm/e.sizeMultiplier;else if("mu"===t.unit)r=e.fontMetrics().cssEmPerMu;else{var a;if(a=e.style.isTight()?e.havingStyle(e.style.text()):e,"ex"===t.unit)r=a.fontMetrics().xHeight;else{if("em"!==t.unit)throw new o("Invalid unit: '"+t.unit+"'");r=a.fontMetrics().quad}a!==e&&(r*=a.sizeMultiplier/e.sizeMultiplier)}return Math.min(t.number*r,e.maxSize)},Bt=["\\imath","\u0131","\\jmath","\u0237","\\pounds","\\mathsterling","\\textsterling","\xa3"],Ct=function(t,e,r){return j[r][t]&&j[r][t].replace&&(t=j[r][t].replace),{value:t,metrics:G(t,e,r)}},qt=function(t,e,r,a,n){var i,o=Ct(t,e,r),s=o.metrics;if(t=o.value,s){var h=s.italic;("text"===r||a&&"mathit"===a.font)&&(h=0),i=new E(t,s.height,s.depth,h,s.skew,s.width,n)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+t+"' in style '"+e+"' and mode '"+r+"'"),i=new E(t,0,0,0,0,0,n);if(a){i.maxFontSize=a.sizeMultiplier,a.style.isTight()&&i.classes.push("mtight");var l=a.getColor();l&&(i.style.color=l)}return i},Nt=function(t,e){if(T(t.classes)!==T(e.classes)||t.skew!==e.skew||t.maxFontSize!==e.maxFontSize)return!1;for(var r in t.style)if(t.style.hasOwnProperty(r)&&t.style[r]!==e.style[r])return!1;for(var a in e.style)if(e.style.hasOwnProperty(a)&&t.style[a]!==e.style[a])return!1;return!0},It=function(t){for(var e=0,r=0,a=0,n=0;ne&&(e=i.height),i.depth>r&&(r=i.depth),i.maxFontSize>a&&(a=i.maxFontSize)}t.height=e,t.depth=r,t.maxFontSize=a},Rt=function(t,e,r,a){var n=new N(t,e,r,a);return It(n),n},Ot=function(t,e,r,a){return new N(t,e,r,a)},Et=function(t){var e=new A(t);return It(e),e},Lt=function(t,e,r){var a="";switch(t){case"amsrm":a="AMS";break;case"textrm":a="Main";break;case"textsf":a="SansSerif";break;case"texttt":a="Typewriter";break;default:a=t}return a+"-"+("textbf"===e&&"textit"===r?"BoldItalic":"textbf"===e?"Bold":"textit"===e?"Italic":"Regular")},Ht={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},Pt={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},Dt={fontMap:Ht,makeSymbol:qt,mathsym:function(t,e,r,a){return void 0===a&&(a=[]),"boldsymbol"===r.font&&Ct(t,"Main-Bold",e).metrics?qt(t,"Main-Bold",e,r,a.concat(["mathbf"])):"\\"===t||"main"===j[e][t].font?qt(t,"Main-Regular",e,r,a):qt(t,"AMS-Regular",e,r,a.concat(["amsrm"]))},makeSpan:Rt,makeSvgSpan:Ot,makeLineSpan:function(t,e,r){var a=Rt([t],[],e);return a.height=Math.max(r||e.fontMetrics().defaultRuleThickness,e.minRuleThickness),a.style.borderBottomWidth=a.height+"em",a.maxFontSize=1,a},makeAnchor:function(t,e,r,a){var n=new I(t,e,r,a);return It(n),n},makeFragment:Et,wrapFragment:function(t,e){return t instanceof A?Rt([],[t],e):t},makeVList:function(t,e){for(var r=function(t){if("individualShift"===t.positionType){for(var e=t.children,r=[e[0]],a=-e[0].shift-e[0].elem.depth,n=a,i=1;i0&&(i.push(pe(o,e)),o=[]),i.push(n[s]));o.length>0&&i.push(pe(o,e)),r&&((a=pe(se(r,e,!0))).classes=["tag"],i.push(a));var l=re(["katex-html"],i);if(l.setAttribute("aria-hidden","true"),a){var m=a.children[0];m.style.height=l.height+l.depth+"em",m.style.verticalAlign=-l.depth+"em"}return l}function fe(t){return new A(t)}var ge=function(){function t(t,e){this.type=void 0,this.attributes=void 0,this.children=void 0,this.type=t,this.attributes={},this.children=e||[]}var e=t.prototype;return e.setAttribute=function(t,e){this.attributes[t]=e},e.getAttribute=function(t){return this.attributes[t]},e.toNode=function(){var t=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var e in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,e)&&t.setAttribute(e,this.attributes[e]);for(var r=0;r"},e.toText=function(){return this.children.map(function(t){return t.toText()}).join("")},t}(),xe=function(){function t(t){this.text=void 0,this.text=t}var e=t.prototype;return e.toNode=function(){return document.createTextNode(this.text)},e.toMarkup=function(){return c.escape(this.toText())},e.toText=function(){return this.text},t}(),ve={MathNode:ge,TextNode:xe,SpaceNode:function(){function t(t){this.width=void 0,this.character=void 0,this.width=t,this.character=t>=.05555&&t<=.05556?"\u200a":t>=.1666&&t<=.1667?"\u2009":t>=.2222&&t<=.2223?"\u2005":t>=.2777&&t<=.2778?"\u2005\u200a":t>=-.05556&&t<=-.05555?"\u200a\u2063":t>=-.1667&&t<=-.1666?"\u2009\u2063":t>=-.2223&&t<=-.2222?"\u205f\u2063":t>=-.2778&&t<=-.2777?"\u2005\u2063":null}var e=t.prototype;return e.toNode=function(){if(this.character)return document.createTextNode(this.character);var t=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return t.setAttribute("width",this.width+"em"),t},e.toMarkup=function(){return this.character?""+this.character+"":''},e.toText=function(){return this.character?this.character:" "},t}(),newDocumentFragment:fe},be=function(t,e,r){return!j[e][t]||!j[e][t].replace||55349===t.charCodeAt(0)||rt.hasOwnProperty(t)&&r&&(r.fontFamily&&"tt"===r.fontFamily.substr(4,2)||r.font&&"tt"===r.font.substr(4,2))||(t=j[e][t].replace),new ve.TextNode(t)},ye=function(t){return 1===t.length?t[0]:new ve.MathNode("mrow",t)},we=function(t,e){if("texttt"===e.fontFamily)return"monospace";if("textsf"===e.fontFamily)return"textit"===e.fontShape&&"textbf"===e.fontWeight?"sans-serif-bold-italic":"textit"===e.fontShape?"sans-serif-italic":"textbf"===e.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===e.fontShape&&"textbf"===e.fontWeight)return"bold-italic";if("textit"===e.fontShape)return"italic";if("textbf"===e.fontWeight)return"bold";var r=e.font;if(!r||"mathnormal"===r)return null;var a=t.mode;if("mathit"===r)return"italic";if("boldsymbol"===r)return"bold-italic";if("mathbf"===r)return"bold";if("mathbb"===r)return"double-struck";if("mathfrak"===r)return"fraktur";if("mathscr"===r||"mathcal"===r)return"script";if("mathsf"===r)return"sans-serif";if("mathtt"===r)return"monospace";var n=t.text;return c.contains(["\\imath","\\jmath"],n)?null:(j[a][n]&&j[a][n].replace&&(n=j[a][n].replace),G(n,Dt.fontMap[r].fontName,a)?Dt.fontMap[r].variant:null)},ke=function(t,e,r){if(1===t.length){var a=Me(t[0],e);return r&&a instanceof ge&&"mo"===a.type&&(a.setAttribute("lspace","0em"),a.setAttribute("rspace","0em")),[a]}for(var n,i=[],o=0;o0&&(p.text=p.text.slice(0,1)+"\u0338"+p.text.slice(1),i.pop())}}}i.push(s),n=s}return i},Se=function(t,e,r){return ye(ke(t,e,r))},Me=function(t,e){if(!t)return new ve.MathNode("mrow");if(Jt[t.type])return Jt[t.type](t,e);throw new o("Got group of unknown type: '"+t.type+"'")};function ze(t,e,r,a){var n,i=ke(t,r);n=1===i.length&&i[0]instanceof ge&&c.contains(["mrow","mtable"],i[0].type)?i[0]:new ve.MathNode("mrow",i);var o=new ve.MathNode("annotation",[new ve.TextNode(e)]);o.setAttribute("encoding","application/x-tex");var s=new ve.MathNode("semantics",[n,o]),h=new ve.MathNode("math",[s]);h.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML");var l=a?"katex":"katex-mathml";return Dt.makeSpan([l],[h])}var Ae=function(t){return new St({style:t.displayMode?w.DISPLAY:w.TEXT,maxSize:t.maxSize,minRuleThickness:t.minRuleThickness})},Te=function(t,e){if(e.displayMode){var r=["katex-display"];e.leqno&&r.push("leqno"),e.fleqn&&r.push("fleqn"),t=Dt.makeSpan(r,[t])}return t},Be=function(t,e,r){var a,n=Ae(r);if("mathml"===r.output)return ze(t,e,n,!0);if("html"===r.output){var i=de(t,n);a=Dt.makeSpan(["katex"],[i])}else{var o=ze(t,e,n,!1),s=de(t,n);a=Dt.makeSpan(["katex"],[o,s])}return Te(a,r)},Ce={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb"},qe={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},Ne=function(t){return"ordgroup"===t.type?t.body.length:1},Ie=function(t,e,r,a){var n,i=t.height+t.depth+2*r;if(/fbox|color/.test(e)){if(n=Dt.makeSpan(["stretchy",e],[],a),"fbox"===e){var o=a.color&&a.getColor();o&&(n.style.borderColor=o)}}else{var s=[];/^[bx]cancel$/.test(e)&&s.push(new P({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(e)&&s.push(new P({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var h=new L(s,{width:"100%",height:i+"em"});n=Dt.makeSvgSpan([],[h],a)}return n.height=i,n.style.height=i+"em",n},Re=function(t){var e=new ve.MathNode("mo",[new ve.TextNode(Ce[t.substr(1)])]);return e.setAttribute("stretchy","true"),e},Oe=function(t,e){var r=function(){var r=4e5,a=t.label.substr(1);if(c.contains(["widehat","widecheck","widetilde","utilde"],a)){var n,i,o,s=Ne(t.base);if(s>5)"widehat"===a||"widecheck"===a?(n=420,r=2364,o=.42,i=a+"4"):(n=312,r=2340,o=.34,i="tilde4");else{var h=[1,1,2,2,3,3][s];"widehat"===a||"widecheck"===a?(r=[0,1062,2364,2364,2364][h],n=[0,239,300,360,420][h],o=[0,.24,.3,.3,.36,.42][h],i=a+h):(r=[0,600,1033,2339,2340][h],n=[0,260,286,306,312][h],o=[0,.26,.286,.3,.306,.34][h],i="tilde"+h)}var l=new H(i),m=new L([l],{width:"100%",height:o+"em",viewBox:"0 0 "+r+" "+n,preserveAspectRatio:"none"});return{span:Dt.makeSvgSpan([],[m],e),minWidth:0,height:o}}var u,p,d=[],f=qe[a],g=f[0],x=f[1],v=f[2],b=v/1e3,y=g.length;if(1===y)u=["hide-tail"],p=[f[3]];else if(2===y)u=["halfarrow-left","halfarrow-right"],p=["xMinYMin","xMaxYMin"];else{if(3!==y)throw new Error("Correct katexImagesData or update code here to support\n "+y+" children.");u=["brace-left","brace-center","brace-right"],p=["xMinYMin","xMidYMin","xMaxYMin"]}for(var w=0;w0&&(a.style.minWidth=n+"em"),a},Ee=function(t,e){var r,a,n,i=Vt(t,"supsub");i?(r=(a=Ft(i.base,"accent")).base,i.base=r,n=function(t){if(t instanceof N)return t;throw new Error("Expected span but got "+String(t)+".")}(ue(i,e)),i.base=a):r=(a=Ft(t,"accent")).base;var o=ue(r,e.havingCrampedStyle()),s=0;if(a.isShifty&&c.isCharacterBox(r)){var h=c.getBaseElem(r);s=D(ue(h,e.havingCrampedStyle())).skew}var l,m=Math.min(o.height,e.fontMetrics().xHeight);if(a.isStretchy)l=Oe(a,e),l=Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"elem",elem:l,wrapperClasses:["svg-align"],wrapperStyle:s>0?{width:"calc(100% - "+2*s+"em)",marginLeft:2*s+"em"}:void 0}]},e);else{var u,p;"\\vec"===a.label?(u=Dt.staticSvg("vec",e),p=Dt.svgData.vec[1]):((u=D(u=Dt.makeOrd({mode:a.mode,text:a.label},e,"textord"))).italic=0,p=u.width),l=Dt.makeSpan(["accent-body"],[u]);var d="\\textcircled"===a.label;d&&(l.classes.push("accent-full"),m=o.height);var f=s;d||(f-=p/2),l.style.left=f+"em","\\textcircled"===a.label&&(l.style.top=".2em"),l=Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:-m},{type:"elem",elem:l}]},e)}var g=Dt.makeSpan(["mord","accent"],[l],e);return n?(n.children[0]=g,n.height=Math.max(g.height,n.height),n.classes[0]="mord",n):g},Le=function(t,e){var r=t.isStretchy?Re(t.label):new ve.MathNode("mo",[be(t.label,t.mode)]),a=new ve.MathNode("mover",[Me(t.base,e),r]);return a.setAttribute("accent","true"),a},He=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(function(t){return"\\"+t}).join("|"));Qt({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:function(t,e){var r=e[0],a=!He.test(t.funcName),n=!a||"\\widehat"===t.funcName||"\\widetilde"===t.funcName||"\\widecheck"===t.funcName;return{type:"accent",mode:t.parser.mode,label:t.funcName,isStretchy:a,isShifty:n,base:r}},htmlBuilder:Ee,mathmlBuilder:Le}),Qt({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!1},handler:function(t,e){var r=e[0];return{type:"accent",mode:t.parser.mode,label:t.funcName,isStretchy:!1,isShifty:!0,base:r}},htmlBuilder:Ee,mathmlBuilder:Le}),Qt({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:function(t,e){var r=t.parser,a=t.funcName,n=e[0];return{type:"accentUnder",mode:r.mode,label:a,base:n}},htmlBuilder:function(t,e){var r=ue(t.base,e),a=Oe(t,e),n="\\utilde"===t.label?.12:0,i=Dt.makeVList({positionType:"bottom",positionData:a.height+n,children:[{type:"elem",elem:a,wrapperClasses:["svg-align"]},{type:"kern",size:n},{type:"elem",elem:r}]},e);return Dt.makeSpan(["mord","accentunder"],[i],e)},mathmlBuilder:function(t,e){var r=Re(t.label),a=new ve.MathNode("munder",[Me(t.base,e),r]);return a.setAttribute("accentunder","true"),a}});var Pe=function(t){var e=new ve.MathNode("mpadded",t?[t]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};Qt({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium"],props:{numArgs:1,numOptionalArgs:1},handler:function(t,e,r){var a=t.parser,n=t.funcName;return{type:"xArrow",mode:a.mode,label:n,body:e[0],below:r[0]}},htmlBuilder:function(t,e){var r,a=e.style,n=e.havingStyle(a.sup()),i=Dt.wrapFragment(ue(t.body,n,e),e);i.classes.push("x-arrow-pad"),t.below&&(n=e.havingStyle(a.sub()),(r=Dt.wrapFragment(ue(t.below,n,e),e)).classes.push("x-arrow-pad"));var o,s=Oe(t,e),h=-e.fontMetrics().axisHeight+.5*s.height,l=-e.fontMetrics().axisHeight-.5*s.height-.111;if((i.depth>.25||"\\xleftequilibrium"===t.label)&&(l-=i.depth),r){var m=-e.fontMetrics().axisHeight+r.height+.5*s.height+.111;o=Dt.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:l},{type:"elem",elem:s,shift:h},{type:"elem",elem:r,shift:m}]},e)}else o=Dt.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:l},{type:"elem",elem:s,shift:h}]},e);return o.children[0].children[0].children[1].classes.push("svg-align"),Dt.makeSpan(["mrel","x-arrow"],[o],e)},mathmlBuilder:function(t,e){var r,a=Re(t.label);if(t.body){var n=Pe(Me(t.body,e));if(t.below){var i=Pe(Me(t.below,e));r=new ve.MathNode("munderover",[a,i,n])}else r=new ve.MathNode("mover",[a,n])}else if(t.below){var o=Pe(Me(t.below,e));r=new ve.MathNode("munder",[a,o])}else r=Pe(),r=new ve.MathNode("mover",[a,r]);return r}}),Qt({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler:function(t,e){for(var r=t.parser,a=Ft(e[0],"ordgroup").body,n="",i=0;i","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],Je=[0,1.2,1.8,2.4,3],Qe=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],tr=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"stack"}],er=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],rr=function(t){if("small"===t.type)return"Main-Regular";if("large"===t.type)return"Size"+t.size+"-Regular";if("stack"===t.type)return"Size4-Regular";throw new Error("Add support for delim type '"+t.type+"' here.")},ar=function(t,e,r,a){for(var n=Math.min(2,3-a.style.size);ne)return r[n]}return r[r.length-1]},nr=function(t,e,r,a,n,i){var o;"<"===t||"\\lt"===t||"\u27e8"===t?t="\\langle":">"!==t&&"\\gt"!==t&&"\u27e9"!==t||(t="\\rangle"),o=c.contains(Ke,t)?Qe:c.contains($e,t)?er:tr;var s=ar(t,e,o,a);return"small"===s.type?function(t,e,r,a,n,i){var o=Dt.makeSymbol(t,"Main-Regular",n,a),s=Ue(o,e,a,i);return r&&Ge(s,a,e),s}(t,s.style,r,a,n,i):"large"===s.type?Ye(t,s.size,r,a,n,i):_e(t,e,r,a,n,i)},ir=function(t,e){var r,a,n=e.havingBaseSizing(),i=ar("\\surd",t*n.sizeMultiplier,er,n),o=n.sizeMultiplier,s=Math.max(0,e.minRuleThickness-e.fontMetrics().sqrtRuleThickness),h=0,l=0,m=0;return"small"===i.type?(t<1?o=1:t<1.4&&(o=.7),l=(1+s)/o,(r=je("sqrtMain",h=(1+s+.08)/o,m=1e3+1e3*s+80,s,e)).style.minWidth="0.853em",a=.833/o):"large"===i.type?(m=1080*Je[i.size],l=(Je[i.size]+s)/o,h=(Je[i.size]+s+.08)/o,(r=je("sqrtSize"+i.size,h,m,s,e)).style.minWidth="1.02em",a=1/o):(h=t+s+.08,l=t+s,m=Math.floor(1e3*t+s)+80,(r=je("sqrtTall",h,m,s,e)).style.minWidth="0.742em",a=1.056),r.height=l,r.style.height=h+"em",{span:r,advanceWidth:a,ruleWidth:(e.fontMetrics().sqrtRuleThickness+s)*o}},or=function(t,e,r,a,n){if("<"===t||"\\lt"===t||"\u27e8"===t?t="\\langle":">"!==t&&"\\gt"!==t&&"\u27e9"!==t||(t="\\rangle"),c.contains($e,t)||c.contains(Ke,t))return Ye(t,e,!1,r,a,n);if(c.contains(Ze,t))return _e(t,Je[e],!1,r,a,n);throw new o("Illegal delimiter: '"+t+"'")},sr=nr,hr=function(t,e,r,a,n,i){var o=a.fontMetrics().axisHeight*a.sizeMultiplier,s=5/a.fontMetrics().ptPerEm,h=Math.max(e-o,r+o),l=Math.max(h/500*901,2*h-s);return nr(t,l,!0,a,n,i)},lr={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},mr=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];function cr(t,e){var r=Yt(t);if(r&&c.contains(mr,r.text))return r;throw new o("Invalid delimiter: '"+(r?r.text:JSON.stringify(t))+"' after '"+e.funcName+"'",t)}function ur(t){if(!t.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}Qt({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1},handler:function(t,e){var r=cr(e[0],t);return{type:"delimsizing",mode:t.parser.mode,size:lr[t.funcName].size,mclass:lr[t.funcName].mclass,delim:r.text}},htmlBuilder:function(t,e){return"."===t.delim?Dt.makeSpan([t.mclass]):or(t.delim,t.size,e,t.mode,[t.mclass])},mathmlBuilder:function(t){var e=[];"."!==t.delim&&e.push(be(t.delim,t.mode));var r=new ve.MathNode("mo",e);return"mopen"===t.mclass||"mclose"===t.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r}}),Qt({type:"leftright-right",names:["\\right"],props:{numArgs:1},handler:function(t,e){var r=t.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new o("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:t.parser.mode,delim:cr(e[0],t).text,color:r}}}),Qt({type:"leftright",names:["\\left"],props:{numArgs:1},handler:function(t,e){var r=cr(e[0],t),a=t.parser;++a.leftrightDepth;var n=a.parseExpression(!1);--a.leftrightDepth,a.expect("\\right",!1);var i=Ft(a.parseFunction(),"leftright-right");return{type:"leftright",mode:a.mode,body:n,left:r.text,right:i.delim,rightColor:i.color}},htmlBuilder:function(t,e){ur(t);for(var r,a,n=se(t.body,e,!0,["mopen","mclose"]),i=0,o=0,s=!1,h=0;h-1?"mpadded":"menclose",[Me(t.body,e)]);switch(t.label){case"\\cancel":a.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":a.setAttribute("notation","downdiagonalstrike");break;case"\\sout":a.setAttribute("notation","horizontalstrike");break;case"\\fbox":a.setAttribute("notation","box");break;case"\\fcolorbox":case"\\colorbox":if(r=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,a.setAttribute("width","+"+2*r+"pt"),a.setAttribute("height","+"+2*r+"pt"),a.setAttribute("lspace",r+"pt"),a.setAttribute("voffset",r+"pt"),"\\fcolorbox"===t.label){var n=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);a.setAttribute("style","border: "+n+"em solid "+String(t.borderColor))}break;case"\\xcancel":a.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return t.backgroundColor&&a.setAttribute("mathbackground",t.backgroundColor),a};Qt({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,greediness:3,argTypes:["color","text"]},handler:function(t,e,r){var a=t.parser,n=t.funcName,i=Ft(e[0],"color-token").color,o=e[1];return{type:"enclose",mode:a.mode,label:n,backgroundColor:i,body:o}},htmlBuilder:pr,mathmlBuilder:dr}),Qt({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,greediness:3,argTypes:["color","color","text"]},handler:function(t,e,r){var a=t.parser,n=t.funcName,i=Ft(e[0],"color-token").color,o=Ft(e[1],"color-token").color,s=e[2];return{type:"enclose",mode:a.mode,label:n,backgroundColor:o,borderColor:i,body:s}},htmlBuilder:pr,mathmlBuilder:dr}),Qt({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler:function(t,e){return{type:"enclose",mode:t.parser.mode,label:"\\fbox",body:e[0]}}}),Qt({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout"],props:{numArgs:1},handler:function(t,e,r){var a=t.parser,n=t.funcName,i=e[0];return{type:"enclose",mode:a.mode,label:n,body:i}},htmlBuilder:pr,mathmlBuilder:dr});var fr={};function gr(t){for(var e=t.type,r=t.names,a=t.props,n=t.handler,i=t.htmlBuilder,o=t.mathmlBuilder,s={type:e,numArgs:a.numArgs||0,greediness:1,allowedInText:!1,numOptionalArgs:0,handler:n},h=0;h0&&(b+=.25),l.push({pos:b,isDashed:t[e]})}for(y(i[0]),r=0;r0&&(M<(B+=v)&&(M=B),B=0),t.addJot&&(M+=f),z.height=S,z.depth=M,b+=S,z.pos=b,b+=M+B,h[r]=z,y(i[r+1])}var C,q,N=b/2+e.fontMetrics().axisHeight,I=t.cols||[],R=[];for(a=0,q=0;a=s)){var P=void 0;(a>0||t.hskipBeforeAndAfter)&&0!==(P=c.deflt(O.pregap,p))&&((C=Dt.makeSpan(["arraycolsep"],[])).style.width=P+"em",R.push(C));var D=[];for(r=0;r0){for(var G=Dt.makeLineSpan("hline",e,m),Y=Dt.makeLineSpan("hdashline",e,m),W=[{type:"elem",elem:h,shift:0}];l.length>0;){var X=l.pop(),_=X.pos-N;X.isDashed?W.push({type:"elem",elem:Y,shift:_}):W.push({type:"elem",elem:G,shift:_})}h=Dt.makeVList({positionType:"individualShift",children:W},e)}return Dt.makeSpan(["mord"],[h],e)},wr={c:"center ",l:"left ",r:"right "},kr=function(t,e){var r=new ve.MathNode("mtable",t.body.map(function(t){return new ve.MathNode("mtr",t.map(function(t){return new ve.MathNode("mtd",[Me(t,e)])}))})),a=.5===t.arraystretch?.1:.16+t.arraystretch-1+(t.addJot?.09:0);r.setAttribute("rowspacing",a+"em");var n="",i="";if(t.cols){var o=t.cols,s="",h=!1,l=0,m=o.length;"separator"===o[0].type&&(n+="top ",l=1),"separator"===o[o.length-1].type&&(n+="bottom ",m-=1);for(var c=l;c0?"left ":"",n+=g[g.length-1].length>0?"right ":"";for(var x=1;x0&&c&&(d=1),a[u]={type:"align",align:p,pregap:d,postgap:0}}return n.colSeparationType=c?"align":"alignat",n};gr({type:"array",names:["array","darray"],props:{numArgs:1},handler:function(t,e){var r={cols:(Yt(e[0])?[e[0]]:Ft(e[0],"ordgroup").body).map(function(t){var e=Gt(t).text;if(-1!=="lcr".indexOf(e))return{type:"align",align:e};if("|"===e)return{type:"separator",separator:"|"};if(":"===e)return{type:"separator",separator:":"};throw new o("Unknown column alignment: "+e,t)}),hskipBeforeAndAfter:!0};return vr(t.parser,r,br(t.envName))},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix"],props:{numArgs:0},handler:function(t){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[t.envName],r=vr(t.parser,{hskipBeforeAndAfter:!1},br(t.envName));return e?{type:"leftright",mode:t.mode,body:[r],left:e[0],right:e[1],rightColor:void 0}:r},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["smallmatrix"],props:{numArgs:0},handler:function(t){var e=vr(t.parser,{arraystretch:.5},"script");return e.colSeparationType="small",e},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["subarray"],props:{numArgs:1},handler:function(t,e){var r=(Yt(e[0])?[e[0]]:Ft(e[0],"ordgroup").body).map(function(t){var e=Gt(t).text;if(-1!=="lc".indexOf(e))return{type:"align",align:e};throw new o("Unknown column alignment: "+e,t)});if(r.length>1)throw new o("{subarray} can contain only one column");var a={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5};if((a=vr(t.parser,a,"script")).body[0].length>1)throw new o("{subarray} can contain only one column");return a},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["cases","dcases"],props:{numArgs:0},handler:function(t){var e=vr(t.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},br(t.envName));return{type:"leftright",mode:t.mode,body:[e],left:"\\{",right:".",rightColor:void 0}},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["aligned"],props:{numArgs:0},handler:Sr,htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["gathered"],props:{numArgs:0},handler:function(t){return vr(t.parser,{cols:[{type:"align",align:"c"}],addJot:!0},"display")},htmlBuilder:yr,mathmlBuilder:kr}),gr({type:"array",names:["alignedat"],props:{numArgs:1},handler:Sr,htmlBuilder:yr,mathmlBuilder:kr}),Qt({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler:function(t,e){throw new o(t.funcName+" valid only within array environment")}});var Mr=fr;Qt({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler:function(t,e){var r=t.parser,a=t.funcName,n=e[0];if("ordgroup"!==n.type)throw new o("Invalid environment name",n);for(var i="",s=0;s=w.SCRIPT.id?r.text():w.DISPLAY:"text"===t&&r.size===w.DISPLAY.size?r=w.TEXT:"script"===t?r=w.SCRIPT:"scriptscript"===t&&(r=w.SCRIPTSCRIPT),r},Rr=function(t,e){var r,a=Ir(t.size,e.style),n=a.fracNum(),i=a.fracDen();r=e.havingStyle(n);var o=ue(t.numer,r,e);if(t.continued){var s=8.5/e.fontMetrics().ptPerEm,h=3.5/e.fontMetrics().ptPerEm;o.height=o.height0?3*c:7*c,d=e.fontMetrics().denom1):(m>0?(u=e.fontMetrics().num2,p=c):(u=e.fontMetrics().num3,p=3*c),d=e.fontMetrics().denom2),l){var y=e.fontMetrics().axisHeight;u-o.depth-(y+.5*m)0&&(e="."===(e=t)?null:e),e};Qt({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,greediness:6,argTypes:["math","math","size","text","math","math"]},handler:function(t,e){var r=t.parser,a=e[4],n=e[5],i=Vt(e[0],"atom");i&&(i=Ut(e[0],"open"));var o=i?Lr(i.text):null,s=Vt(e[1],"atom");s&&(s=Ut(e[1],"close"));var h,l=s?Lr(s.text):null,m=Ft(e[2],"size"),c=null;h=!!m.isBlank||(c=m.value).number>0;var u="auto",p=Vt(e[3],"ordgroup");if(p){if(p.body.length>0){var d=Ft(p.body[0],"textord");u=Er[Number(d.text)]}}else p=Ft(e[3],"textord"),u=Er[Number(p.text)];return{type:"genfrac",mode:r.mode,numer:a,denom:n,continued:!1,hasBarLine:h,barSize:c,leftDelim:o,rightDelim:l,size:u}},htmlBuilder:Rr,mathmlBuilder:Or}),Qt({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler:function(t,e){var r=t.parser,a=(t.funcName,t.token);return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:Ft(e[0],"size").value,token:a}}}),Qt({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:function(t,e){var r=t.parser,a=(t.funcName,e[0]),n=function(t){if(!t)throw new Error("Expected non-null, but got "+String(t));return t}(Ft(e[1],"infix").size),i=e[2],o=n.number>0;return{type:"genfrac",mode:r.mode,numer:a,denom:i,continued:!1,hasBarLine:o,barSize:n,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:Rr,mathmlBuilder:Or});var Hr=function(t,e){var r,a,n=e.style,i=Vt(t,"supsub");i?(r=i.sup?ue(i.sup,e.havingStyle(n.sup()),e):ue(i.sub,e.havingStyle(n.sub()),e),a=Ft(i.base,"horizBrace")):a=Ft(t,"horizBrace");var o,s=ue(a.base,e.havingBaseStyle(w.DISPLAY)),h=Oe(a,e);if(a.isOver?(o=Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:h}]},e)).children[0].children[0].children[1].classes.push("svg-align"):(o=Dt.makeVList({positionType:"bottom",positionData:s.depth+.1+h.height,children:[{type:"elem",elem:h},{type:"kern",size:.1},{type:"elem",elem:s}]},e)).children[0].children[0].children[0].classes.push("svg-align"),r){var l=Dt.makeSpan(["mord",a.isOver?"mover":"munder"],[o],e);o=a.isOver?Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:r}]},e):Dt.makeVList({positionType:"bottom",positionData:l.depth+.2+r.height+r.depth,children:[{type:"elem",elem:r},{type:"kern",size:.2},{type:"elem",elem:l}]},e)}return Dt.makeSpan(["mord",a.isOver?"mover":"munder"],[o],e)};Qt({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler:function(t,e){var r=t.parser,a=t.funcName;return{type:"horizBrace",mode:r.mode,label:a,isOver:/^\\over/.test(a),base:e[0]}},htmlBuilder:Hr,mathmlBuilder:function(t,e){var r=Re(t.label);return new ve.MathNode(t.isOver?"mover":"munder",[Me(t.base,e),r])}}),Qt({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:function(t,e){var r=t.parser,a=e[1],n=Ft(e[0],"url").url;return r.settings.isTrusted({command:"\\href",url:n})?{type:"href",mode:r.mode,href:n,body:ee(a)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:function(t,e){var r=se(t.body,e,!1);return Dt.makeAnchor(t.href,[],r,e)},mathmlBuilder:function(t,e){var r=Se(t.body,e);return r instanceof ge||(r=new ge("mrow",[r])),r.setAttribute("href",t.href),r}}),Qt({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:function(t,e){var r=t.parser,a=Ft(e[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:a}))return r.formatUnsupportedCmd("\\url");for(var n=[],i=0;i0&&(a=Tt(t.totalheight,e)-r,a=Number(a.toFixed(2)));var n=0;t.width.number>0&&(n=Tt(t.width,e));var i={height:r+a+"em"};n>0&&(i.width=n+"em"),a>0&&(i.verticalAlign=-a+"em");var o=new R(t.src,t.alt,i);return o.height=r,o.depth=a,o},mathmlBuilder:function(t,e){var r=new ve.MathNode("mglyph",[]);r.setAttribute("alt",t.alt);var a=Tt(t.height,e),n=0;if(t.totalheight.number>0&&(n=(n=Tt(t.totalheight,e)-a).toFixed(2),r.setAttribute("valign","-"+n+"em")),r.setAttribute("height",a+n+"em"),t.width.number>0){var i=Tt(t.width,e);r.setAttribute("width",i+"em")}return r.setAttribute("src",t.src),r}}),Qt({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],allowedInText:!0},handler:function(t,e){var r=t.parser,a=t.funcName,n=Ft(e[0],"size");if(r.settings.strict){var i="m"===a[1],o="mu"===n.value.unit;i?(o||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" supports only mu units, not "+n.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" works only in math mode")):o&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:n.value}},htmlBuilder:function(t,e){return Dt.makeGlue(t.dimension,e)},mathmlBuilder:function(t,e){var r=Tt(t.dimension,e);return new ve.SpaceNode(r)}}),Qt({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:function(t,e){var r=t.parser,a=t.funcName,n=e[0];return{type:"lap",mode:r.mode,alignment:a.slice(5),body:n}},htmlBuilder:function(t,e){var r;"clap"===t.alignment?(r=Dt.makeSpan([],[ue(t.body,e)]),r=Dt.makeSpan(["inner"],[r],e)):r=Dt.makeSpan(["inner"],[ue(t.body,e)]);var a=Dt.makeSpan(["fix"],[]),n=Dt.makeSpan([t.alignment],[r,a],e),i=Dt.makeSpan(["strut"]);return i.style.height=n.height+n.depth+"em",i.style.verticalAlign=-n.depth+"em",n.children.unshift(i),n=Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:n}]},e),Dt.makeSpan(["mord"],[n],e)},mathmlBuilder:function(t,e){var r=new ve.MathNode("mpadded",[Me(t.body,e)]);if("rlap"!==t.alignment){var a="llap"===t.alignment?"-1":"-0.5";r.setAttribute("lspace",a+"width")}return r.setAttribute("width","0px"),r}}),Qt({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler:function(t,e){var r=t.funcName,a=t.parser,n=a.mode;a.switchMode("math");var i="\\("===r?"\\)":"$",o=a.parseExpression(!1,i);return a.expect(i),a.switchMode(n),{type:"styling",mode:a.mode,style:"text",body:o}}}),Qt({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler:function(t,e){throw new o("Mismatched "+t.funcName)}});var Dr=function(t,e){switch(e.style.size){case w.DISPLAY.size:return t.display;case w.TEXT.size:return t.text;case w.SCRIPT.size:return t.script;case w.SCRIPTSCRIPT.size:return t.scriptscript;default:return t.text}};Qt({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4},handler:function(t,e){return{type:"mathchoice",mode:t.parser.mode,display:ee(e[0]),text:ee(e[1]),script:ee(e[2]),scriptscript:ee(e[3])}},htmlBuilder:function(t,e){var r=Dr(t,e),a=se(r,e,!1);return Dt.makeFragment(a)},mathmlBuilder:function(t,e){var r=Dr(t,e);return Se(r,e)}});var Fr=function(t,e,r,a,n,i,o){var s,h,l;if(t=Dt.makeSpan([],[t]),e){var m=ue(e,a.havingStyle(n.sup()),a);h={elem:m,kern:Math.max(a.fontMetrics().bigOpSpacing1,a.fontMetrics().bigOpSpacing3-m.depth)}}if(r){var c=ue(r,a.havingStyle(n.sub()),a);s={elem:c,kern:Math.max(a.fontMetrics().bigOpSpacing2,a.fontMetrics().bigOpSpacing4-c.height)}}if(h&&s){var u=a.fontMetrics().bigOpSpacing5+s.elem.height+s.elem.depth+s.kern+t.depth+o;l=Dt.makeVList({positionType:"bottom",positionData:u,children:[{type:"kern",size:a.fontMetrics().bigOpSpacing5},{type:"elem",elem:s.elem,marginLeft:-i+"em"},{type:"kern",size:s.kern},{type:"elem",elem:t},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:i+"em"},{type:"kern",size:a.fontMetrics().bigOpSpacing5}]},a)}else if(s){var p=t.height-o;l=Dt.makeVList({positionType:"top",positionData:p,children:[{type:"kern",size:a.fontMetrics().bigOpSpacing5},{type:"elem",elem:s.elem,marginLeft:-i+"em"},{type:"kern",size:s.kern},{type:"elem",elem:t}]},a)}else{if(!h)return t;var d=t.depth+o;l=Dt.makeVList({positionType:"bottom",positionData:d,children:[{type:"elem",elem:t},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:i+"em"},{type:"kern",size:a.fontMetrics().bigOpSpacing5}]},a)}return Dt.makeSpan(["mop","op-limits"],[l],a)},Vr=["\\smallint"],Ur=function(t,e){var r,a,n,i=!1,o=Vt(t,"supsub");o?(r=o.sup,a=o.sub,n=Ft(o.base,"op"),i=!0):n=Ft(t,"op");var s,h=e.style,l=!1;if(h.size===w.DISPLAY.size&&n.symbol&&!c.contains(Vr,n.name)&&(l=!0),n.symbol){var m=l?"Size2-Regular":"Size1-Regular",u="";if("\\oiint"!==n.name&&"\\oiiint"!==n.name||(u=n.name.substr(1),n.name="oiint"===u?"\\iint":"\\iiint"),s=Dt.makeSymbol(n.name,m,"math",e,["mop","op-symbol",l?"large-op":"small-op"]),u.length>0){var p=s.italic,d=Dt.staticSvg(u+"Size"+(l?"2":"1"),e);s=Dt.makeVList({positionType:"individualShift",children:[{type:"elem",elem:s,shift:0},{type:"elem",elem:d,shift:l?.08:0}]},e),n.name="\\"+u,s.classes.unshift("mop"),s.italic=p}}else if(n.body){var f=se(n.body,e,!0);1===f.length&&f[0]instanceof E?(s=f[0]).classes[0]="mop":s=Dt.makeSpan(["mop"],Dt.tryCombineChars(f),e)}else{for(var g=[],x=1;x0){for(var h=n.body.map(function(t){var e=t.text;return"string"==typeof e?{type:"textord",mode:t.mode,text:e}:t}),l=se(h,e.withFont("mathrm"),!0),m=0;m=0?s.setAttribute("height","+"+n+"em"):(s.setAttribute("height",n+"em"),s.setAttribute("depth","+"+-n+"em")),s.setAttribute("voffset",n+"em"),s}});var jr=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];Qt({type:"sizing",names:jr,props:{numArgs:0,allowedInText:!0},handler:function(t,e){var r=t.breakOnTokenText,a=t.funcName,n=t.parser,i=n.parseExpression(!1,r);return{type:"sizing",mode:n.mode,size:jr.indexOf(a)+1,body:i}},htmlBuilder:function(t,e){var r=e.havingSize(t.size);return _r(t.body,r,e)},mathmlBuilder:function(t,e){var r=e.havingSize(t.size),a=ke(t.body,r),n=new ve.MathNode("mstyle",a);return n.setAttribute("mathsize",r.sizeMultiplier+"em"),n}}),Qt({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:function(t,e,r){var a=t.parser,n=!1,i=!1,o=r[0]&&Ft(r[0],"ordgroup");if(o)for(var s="",h=0;hr.height+r.depth+i&&(i=(i+c-r.height-r.depth)/2);var u=h.height-r.height-i-l;r.style.paddingLeft=m+"em";var p=Dt.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+u)},{type:"elem",elem:h},{type:"kern",size:l}]},e);if(t.index){var d=e.havingStyle(w.SCRIPTSCRIPT),f=ue(t.index,d,e),g=.6*(p.height-p.depth),x=Dt.makeVList({positionType:"shift",positionData:-g,children:[{type:"elem",elem:f}]},e),v=Dt.makeSpan(["root"],[x]);return Dt.makeSpan(["mord","sqrt"],[v,p],e)}return Dt.makeSpan(["mord","sqrt"],[p],e)},mathmlBuilder:function(t,e){var r=t.body,a=t.index;return a?new ve.MathNode("mroot",[Me(r,e),Me(a,e)]):new ve.MathNode("msqrt",[Me(r,e)])}});var $r={display:w.DISPLAY,text:w.TEXT,script:w.SCRIPT,scriptscript:w.SCRIPTSCRIPT};Qt({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0},handler:function(t,e){var r=t.breakOnTokenText,a=t.funcName,n=t.parser,i=n.parseExpression(!0,r),o=a.slice(1,a.length-5);return{type:"styling",mode:n.mode,style:o,body:i}},htmlBuilder:function(t,e){var r=$r[t.style],a=e.havingStyle(r).withFont("");return _r(t.body,a,e)},mathmlBuilder:function(t,e){var r=$r[t.style],a=e.havingStyle(r),n=ke(t.body,a),i=new ve.MathNode("mstyle",n),o={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[t.style];return i.setAttribute("scriptlevel",o[0]),i.setAttribute("displaystyle",o[1]),i}});te({type:"supsub",htmlBuilder:function(t,e){var r=function(t,e){var r=t.base;return r?"op"===r.type?r.limits&&(e.style.size===w.DISPLAY.size||r.alwaysHandleSupSub)?Ur:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(e.style.size===w.DISPLAY.size||r.limits)?Xr:null:"accent"===r.type?c.isCharacterBox(r.base)?Ee:null:"horizBrace"===r.type&&!t.sub===r.isOver?Hr:null:null}(t,e);if(r)return r(t,e);var a,n,i,o=t.base,s=t.sup,h=t.sub,l=ue(o,e),m=e.fontMetrics(),u=0,p=0,d=o&&c.isCharacterBox(o);if(s){var f=e.havingStyle(e.style.sup());a=ue(s,f,e),d||(u=l.height-f.fontMetrics().supDrop*f.sizeMultiplier/e.sizeMultiplier)}if(h){var g=e.havingStyle(e.style.sub());n=ue(h,g,e),d||(p=l.depth+g.fontMetrics().subDrop*g.sizeMultiplier/e.sizeMultiplier)}i=e.style===w.DISPLAY?m.sup1:e.style.cramped?m.sup3:m.sup2;var x,v=e.sizeMultiplier,b=.5/m.ptPerEm/v+"em",y=null;if(n){var k=t.base&&"op"===t.base.type&&t.base.name&&("\\oiint"===t.base.name||"\\oiiint"===t.base.name);(l instanceof E||k)&&(y=-l.italic+"em")}if(a&&n){u=Math.max(u,i,a.depth+.25*m.xHeight),p=Math.max(p,m.sub2);var S=4*m.defaultRuleThickness;if(u-a.depth-(n.height-p)0&&(u+=M,p-=M)}var z=[{type:"elem",elem:n,shift:p,marginRight:b,marginLeft:y},{type:"elem",elem:a,shift:-u,marginRight:b}];x=Dt.makeVList({positionType:"individualShift",children:z},e)}else if(n){p=Math.max(p,m.sub1,n.height-.8*m.xHeight);var A=[{type:"elem",elem:n,marginLeft:y,marginRight:b}];x=Dt.makeVList({positionType:"shift",positionData:p,children:A},e)}else{if(!a)throw new Error("supsub must have either sup or sub.");u=Math.max(u,i,a.depth+.25*m.xHeight),x=Dt.makeVList({positionType:"shift",positionData:-u,children:[{type:"elem",elem:a,marginRight:b}]},e)}var T=me(l,"right")||"mord";return Dt.makeSpan([T],[l,Dt.makeSpan(["msupsub"],[x])],e)},mathmlBuilder:function(t,e){var r,a=!1,n=Vt(t.base,"horizBrace");n&&!!t.sup===n.isOver&&(a=!0,r=n.isOver),!t.base||"op"!==t.base.type&&"operatorname"!==t.base.type||(t.base.parentIsSupSub=!0);var i,o=[Me(t.base,e)];if(t.sub&&o.push(Me(t.sub,e)),t.sup&&o.push(Me(t.sup,e)),a)i=r?"mover":"munder";else if(t.sub)if(t.sup){var s=t.base;i=s&&"op"===s.type&&s.limits&&e.style===w.DISPLAY?"munderover":s&&"operatorname"===s.type&&s.alwaysHandleSupSub&&(e.style===w.DISPLAY||s.limits)?"munderover":"msubsup"}else{var h=t.base;i=h&&"op"===h.type&&h.limits&&(e.style===w.DISPLAY||h.alwaysHandleSupSub)?"munder":h&&"operatorname"===h.type&&h.alwaysHandleSupSub&&(h.limits||e.style===w.DISPLAY)?"munder":"msub"}else{var l=t.base;i=l&&"op"===l.type&&l.limits&&(e.style===w.DISPLAY||l.alwaysHandleSupSub)?"mover":l&&"operatorname"===l.type&&l.alwaysHandleSupSub&&(l.limits||e.style===w.DISPLAY)?"mover":"msup"}return new ve.MathNode(i,o)}}),te({type:"atom",htmlBuilder:function(t,e){return Dt.mathsym(t.text,t.mode,e,["m"+t.family])},mathmlBuilder:function(t,e){var r=new ve.MathNode("mo",[be(t.text,t.mode)]);if("bin"===t.family){var a=we(t,e);"bold-italic"===a&&r.setAttribute("mathvariant",a)}else"punct"===t.family?r.setAttribute("separator","true"):"open"!==t.family&&"close"!==t.family||r.setAttribute("stretchy","false");return r}});var Zr={mi:"italic",mn:"normal",mtext:"normal"};te({type:"mathord",htmlBuilder:function(t,e){return Dt.makeOrd(t,e,"mathord")},mathmlBuilder:function(t,e){var r=new ve.MathNode("mi",[be(t.text,t.mode,e)]),a=we(t,e)||"italic";return a!==Zr[r.type]&&r.setAttribute("mathvariant",a),r}}),te({type:"textord",htmlBuilder:function(t,e){return Dt.makeOrd(t,e,"textord")},mathmlBuilder:function(t,e){var r,a=be(t.text,t.mode,e),n=we(t,e)||"normal";return r="text"===t.mode?new ve.MathNode("mtext",[a]):/[0-9]/.test(t.text)?new ve.MathNode("mn",[a]):"\\prime"===t.text?new ve.MathNode("mo",[a]):new ve.MathNode("mi",[a]),n!==Zr[r.type]&&r.setAttribute("mathvariant",n),r}});var Kr={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Jr={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};te({type:"spacing",htmlBuilder:function(t,e){if(Jr.hasOwnProperty(t.text)){var r=Jr[t.text].className||"";if("text"===t.mode){var a=Dt.makeOrd(t,e,"textord");return a.classes.push(r),a}return Dt.makeSpan(["mspace",r],[Dt.mathsym(t.text,t.mode,e)],e)}if(Kr.hasOwnProperty(t.text))return Dt.makeSpan(["mspace",Kr[t.text]],[],e);throw new o('Unknown type of space "'+t.text+'"')},mathmlBuilder:function(t,e){if(!Jr.hasOwnProperty(t.text)){if(Kr.hasOwnProperty(t.text))return new ve.MathNode("mspace");throw new o('Unknown type of space "'+t.text+'"')}return new ve.MathNode("mtext",[new ve.TextNode("\xa0")])}});var Qr=function(){var t=new ve.MathNode("mtd",[]);return t.setAttribute("width","50%"),t};te({type:"tag",mathmlBuilder:function(t,e){var r=new ve.MathNode("mtable",[new ve.MathNode("mtr",[Qr(),new ve.MathNode("mtd",[Se(t.body,e)]),Qr(),new ve.MathNode("mtd",[Se(t.tag,e)])])]);return r.setAttribute("width","100%"),r}});var ta={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},ea={"\\textbf":"textbf","\\textmd":"textmd"},ra={"\\textit":"textit","\\textup":"textup"},aa=function(t,e){var r=t.font;return r?ta[r]?e.withTextFontFamily(ta[r]):ea[r]?e.withTextFontWeight(ea[r]):e.withTextFontShape(ra[r]):e};Qt({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup"],props:{numArgs:1,argTypes:["text"],greediness:2,allowedInText:!0},handler:function(t,e){var r=t.parser,a=t.funcName,n=e[0];return{type:"text",mode:r.mode,body:ee(n),font:a}},htmlBuilder:function(t,e){var r=aa(t,e),a=se(t.body,r,!0);return Dt.makeSpan(["mord","text"],Dt.tryCombineChars(a),r)},mathmlBuilder:function(t,e){var r=aa(t,e);return Se(t.body,r)}}),Qt({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler:function(t,e){return{type:"underline",mode:t.parser.mode,body:e[0]}},htmlBuilder:function(t,e){var r=ue(t.body,e),a=Dt.makeLineSpan("underline-line",e),n=e.fontMetrics().defaultRuleThickness,i=Dt.makeVList({positionType:"top",positionData:r.height,children:[{type:"kern",size:n},{type:"elem",elem:a},{type:"kern",size:3*n},{type:"elem",elem:r}]},e);return Dt.makeSpan(["mord","underline"],[i],e)},mathmlBuilder:function(t,e){var r=new ve.MathNode("mo",[new ve.TextNode("\u203e")]);r.setAttribute("stretchy","true");var a=new ve.MathNode("munder",[Me(t.body,e),r]);return a.setAttribute("accentunder","true"),a}}),Qt({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler:function(t,e,r){throw new o("\\verb ended by end of line instead of matching delimiter")},htmlBuilder:function(t,e){for(var r=na(t),a=[],n=e.havingStyle(e.style.text()),i=0;i0&&(this.undefStack[this.undefStack.length-1][t]=e)}else{var n=this.undefStack[this.undefStack.length-1];n&&!n.hasOwnProperty(t)&&(n[t]=this.current[t])}this.current[t]=e},t}(),ca={},ua=ca;function pa(t,e){ca[t]=e}pa("\\@firstoftwo",function(t){return{tokens:t.consumeArgs(2)[0],numArgs:0}}),pa("\\@secondoftwo",function(t){return{tokens:t.consumeArgs(2)[1],numArgs:0}}),pa("\\@ifnextchar",function(t){var e=t.consumeArgs(3),r=t.future();return 1===e[0].length&&e[0][0].text===r.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}}),pa("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),pa("\\TextOrMath",function(t){var e=t.consumeArgs(2);return"text"===t.mode?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});var da={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};pa("\\char",function(t){var e,r=t.popToken(),a="";if("'"===r.text)e=8,r=t.popToken();else if('"'===r.text)e=16,r=t.popToken();else if("`"===r.text)if("\\"===(r=t.popToken()).text[0])a=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new o("\\char` missing argument");a=r.text.charCodeAt(0)}else e=10;if(e){if(null==(a=da[r.text])||a>=e)throw new o("Invalid base-"+e+" digit "+r.text);for(var n;null!=(n=da[t.future().text])&&n":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};pa("\\dots",function(t){var e="\\dotso",r=t.expandAfterFuture().text;return r in xa?e=xa[r]:"\\not"===r.substr(0,4)?e="\\dotsb":r in j.math&&c.contains(["bin","rel"],j.math[r].group)&&(e="\\dotsb"),e});var va={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};pa("\\dotso",function(t){return t.future().text in va?"\\ldots\\,":"\\ldots"}),pa("\\dotsc",function(t){var e=t.future().text;return e in va&&","!==e?"\\ldots\\,":"\\ldots"}),pa("\\cdots",function(t){return t.future().text in va?"\\@cdots\\,":"\\@cdots"}),pa("\\dotsb","\\cdots"),pa("\\dotsm","\\cdots"),pa("\\dotsi","\\!\\cdots"),pa("\\dotsx","\\ldots\\,"),pa("\\DOTSI","\\relax"),pa("\\DOTSB","\\relax"),pa("\\DOTSX","\\relax"),pa("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),pa("\\,","\\tmspace+{3mu}{.1667em}"),pa("\\thinspace","\\,"),pa("\\>","\\mskip{4mu}"),pa("\\:","\\tmspace+{4mu}{.2222em}"),pa("\\medspace","\\:"),pa("\\;","\\tmspace+{5mu}{.2777em}"),pa("\\thickspace","\\;"),pa("\\!","\\tmspace-{3mu}{.1667em}"),pa("\\negthinspace","\\!"),pa("\\negmedspace","\\tmspace-{4mu}{.2222em}"),pa("\\negthickspace","\\tmspace-{5mu}{.277em}"),pa("\\enspace","\\kern.5em "),pa("\\enskip","\\hskip.5em\\relax"),pa("\\quad","\\hskip1em\\relax"),pa("\\qquad","\\hskip2em\\relax"),pa("\\tag","\\@ifstar\\tag@literal\\tag@paren"),pa("\\tag@paren","\\tag@literal{({#1})}"),pa("\\tag@literal",function(t){if(t.macros.get("\\df@tag"))throw new o("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),pa("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),pa("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),pa("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),pa("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),pa("\\pmb","\\html@mathml{\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}{\\mathbf{#1}}"),pa("\\\\","\\newline"),pa("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var ba=F["Main-Regular"]["T".charCodeAt(0)][1]-.7*F["Main-Regular"]["A".charCodeAt(0)][1]+"em";pa("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+ba+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),pa("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+ba+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),pa("\\hspace","\\@ifstar\\@hspacer\\@hspace"),pa("\\@hspace","\\hskip #1\\relax"),pa("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),pa("\\ordinarycolon",":"),pa("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),pa("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),pa("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),pa("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),pa("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),pa("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),pa("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),pa("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),pa("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),pa("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),pa("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),pa("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),pa("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),pa("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),pa("\u2237","\\dblcolon"),pa("\u2239","\\eqcolon"),pa("\u2254","\\coloneqq"),pa("\u2255","\\eqqcolon"),pa("\u2a74","\\Coloneqq"),pa("\\ratio","\\vcentcolon"),pa("\\coloncolon","\\dblcolon"),pa("\\colonequals","\\coloneqq"),pa("\\coloncolonequals","\\Coloneqq"),pa("\\equalscolon","\\eqqcolon"),pa("\\equalscoloncolon","\\Eqqcolon"),pa("\\colonminus","\\coloneq"),pa("\\coloncolonminus","\\Coloneq"),pa("\\minuscolon","\\eqcolon"),pa("\\minuscoloncolon","\\Eqcolon"),pa("\\coloncolonapprox","\\Colonapprox"),pa("\\coloncolonsim","\\Colonsim"),pa("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),pa("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),pa("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),pa("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),pa("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),pa("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),pa("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),pa("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),pa("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),pa("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),pa("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),pa("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),pa("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),pa("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),pa("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),pa("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),pa("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),pa("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),pa("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),pa("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),pa("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),pa("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),pa("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),pa("\u27e6","\\llbracket"),pa("\u27e7","\\rrbracket"),pa("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),pa("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),pa("\u2983","\\lBrace"),pa("\u2984","\\rBrace"),pa("\\darr","\\downarrow"),pa("\\dArr","\\Downarrow"),pa("\\Darr","\\Downarrow"),pa("\\lang","\\langle"),pa("\\rang","\\rangle"),pa("\\uarr","\\uparrow"),pa("\\uArr","\\Uparrow"),pa("\\Uarr","\\Uparrow"),pa("\\N","\\mathbb{N}"),pa("\\R","\\mathbb{R}"),pa("\\Z","\\mathbb{Z}"),pa("\\alef","\\aleph"),pa("\\alefsym","\\aleph"),pa("\\Alpha","\\mathrm{A}"),pa("\\Beta","\\mathrm{B}"),pa("\\bull","\\bullet"),pa("\\Chi","\\mathrm{X}"),pa("\\clubs","\\clubsuit"),pa("\\cnums","\\mathbb{C}"),pa("\\Complex","\\mathbb{C}"),pa("\\Dagger","\\ddagger"),pa("\\diamonds","\\diamondsuit"),pa("\\empty","\\emptyset"),pa("\\Epsilon","\\mathrm{E}"),pa("\\Eta","\\mathrm{H}"),pa("\\exist","\\exists"),pa("\\harr","\\leftrightarrow"),pa("\\hArr","\\Leftrightarrow"),pa("\\Harr","\\Leftrightarrow"),pa("\\hearts","\\heartsuit"),pa("\\image","\\Im"),pa("\\infin","\\infty"),pa("\\Iota","\\mathrm{I}"),pa("\\isin","\\in"),pa("\\Kappa","\\mathrm{K}"),pa("\\larr","\\leftarrow"),pa("\\lArr","\\Leftarrow"),pa("\\Larr","\\Leftarrow"),pa("\\lrarr","\\leftrightarrow"),pa("\\lrArr","\\Leftrightarrow"),pa("\\Lrarr","\\Leftrightarrow"),pa("\\Mu","\\mathrm{M}"),pa("\\natnums","\\mathbb{N}"),pa("\\Nu","\\mathrm{N}"),pa("\\Omicron","\\mathrm{O}"),pa("\\plusmn","\\pm"),pa("\\rarr","\\rightarrow"),pa("\\rArr","\\Rightarrow"),pa("\\Rarr","\\Rightarrow"),pa("\\real","\\Re"),pa("\\reals","\\mathbb{R}"),pa("\\Reals","\\mathbb{R}"),pa("\\Rho","\\mathrm{P}"),pa("\\sdot","\\cdot"),pa("\\sect","\\S"),pa("\\spades","\\spadesuit"),pa("\\sub","\\subset"),pa("\\sube","\\subseteq"),pa("\\supe","\\supseteq"),pa("\\Tau","\\mathrm{T}"),pa("\\thetasym","\\vartheta"),pa("\\weierp","\\wp"),pa("\\Zeta","\\mathrm{Z}"),pa("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),pa("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),pa("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),pa("\\blue","\\textcolor{##6495ed}{#1}"),pa("\\orange","\\textcolor{##ffa500}{#1}"),pa("\\pink","\\textcolor{##ff00af}{#1}"),pa("\\red","\\textcolor{##df0030}{#1}"),pa("\\green","\\textcolor{##28ae7b}{#1}"),pa("\\gray","\\textcolor{gray}{#1}"),pa("\\purple","\\textcolor{##9d38bd}{#1}"),pa("\\blueA","\\textcolor{##ccfaff}{#1}"),pa("\\blueB","\\textcolor{##80f6ff}{#1}"),pa("\\blueC","\\textcolor{##63d9ea}{#1}"),pa("\\blueD","\\textcolor{##11accd}{#1}"),pa("\\blueE","\\textcolor{##0c7f99}{#1}"),pa("\\tealA","\\textcolor{##94fff5}{#1}"),pa("\\tealB","\\textcolor{##26edd5}{#1}"),pa("\\tealC","\\textcolor{##01d1c1}{#1}"),pa("\\tealD","\\textcolor{##01a995}{#1}"),pa("\\tealE","\\textcolor{##208170}{#1}"),pa("\\greenA","\\textcolor{##b6ffb0}{#1}"),pa("\\greenB","\\textcolor{##8af281}{#1}"),pa("\\greenC","\\textcolor{##74cf70}{#1}"),pa("\\greenD","\\textcolor{##1fab54}{#1}"),pa("\\greenE","\\textcolor{##0d923f}{#1}"),pa("\\goldA","\\textcolor{##ffd0a9}{#1}"),pa("\\goldB","\\textcolor{##ffbb71}{#1}"),pa("\\goldC","\\textcolor{##ff9c39}{#1}"),pa("\\goldD","\\textcolor{##e07d10}{#1}"),pa("\\goldE","\\textcolor{##a75a05}{#1}"),pa("\\redA","\\textcolor{##fca9a9}{#1}"),pa("\\redB","\\textcolor{##ff8482}{#1}"),pa("\\redC","\\textcolor{##f9685d}{#1}"),pa("\\redD","\\textcolor{##e84d39}{#1}"),pa("\\redE","\\textcolor{##bc2612}{#1}"),pa("\\maroonA","\\textcolor{##ffbde0}{#1}"),pa("\\maroonB","\\textcolor{##ff92c6}{#1}"),pa("\\maroonC","\\textcolor{##ed5fa6}{#1}"),pa("\\maroonD","\\textcolor{##ca337c}{#1}"),pa("\\maroonE","\\textcolor{##9e034e}{#1}"),pa("\\purpleA","\\textcolor{##ddd7ff}{#1}"),pa("\\purpleB","\\textcolor{##c6b9fc}{#1}"),pa("\\purpleC","\\textcolor{##aa87ff}{#1}"),pa("\\purpleD","\\textcolor{##7854ab}{#1}"),pa("\\purpleE","\\textcolor{##543b78}{#1}"),pa("\\mintA","\\textcolor{##f5f9e8}{#1}"),pa("\\mintB","\\textcolor{##edf2df}{#1}"),pa("\\mintC","\\textcolor{##e0e5cc}{#1}"),pa("\\grayA","\\textcolor{##f6f7f7}{#1}"),pa("\\grayB","\\textcolor{##f0f1f2}{#1}"),pa("\\grayC","\\textcolor{##e3e5e6}{#1}"),pa("\\grayD","\\textcolor{##d6d8da}{#1}"),pa("\\grayE","\\textcolor{##babec2}{#1}"),pa("\\grayF","\\textcolor{##888d93}{#1}"),pa("\\grayG","\\textcolor{##626569}{#1}"),pa("\\grayH","\\textcolor{##3b3e40}{#1}"),pa("\\grayI","\\textcolor{##21242c}{#1}"),pa("\\kaBlue","\\textcolor{##314453}{#1}"),pa("\\kaGreen","\\textcolor{##71B307}{#1}");var ya={"\\relax":!0,"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},wa=function(){function t(t,e,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=e,this.expansionCount=0,this.feed(t),this.macros=new ma(ua,e.macros),this.mode=r,this.stack=[]}var e=t.prototype;return e.feed=function(t){this.lexer=new la(t,this.settings)},e.switchMode=function(t){this.mode=t},e.beginGroup=function(){this.macros.beginGroup()},e.endGroup=function(){this.macros.endGroup()},e.future=function(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]},e.popToken=function(){return this.future(),this.stack.pop()},e.pushToken=function(t){this.stack.push(t)},e.pushTokens=function(t){var e;(e=this.stack).push.apply(e,t)},e.consumeSpaces=function(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}},e.consumeArgs=function(t){for(var e=[],r=0;rthis.settings.maxExpand)throw new o("Too many expansions: infinite loop or need to increase maxExpand setting");var a=r.tokens;if(r.numArgs)for(var n=this.consumeArgs(r.numArgs),i=(a=a.slice()).length-1;i>=0;--i){var s=a[i];if("#"===s.text){if(0===i)throw new o("Incomplete placeholder at end of macro body",s);if("#"===(s=a[--i]).text)a.splice(i+1,1);else{if(!/^[1-9]$/.test(s.text))throw new o("Not a valid argument number",s);var h;(h=a).splice.apply(h,[i,2].concat(n[+s.text-1]))}}}return this.pushTokens(a),a},e.expandAfterFuture=function(){return this.expandOnce(),this.future()},e.expandNextToken=function(){for(;;){var t=this.expandOnce();if(t instanceof n){if("\\relax"!==t.text)return this.stack.pop();this.stack.pop()}}throw new Error},e.expandMacro=function(t){if(this.macros.get(t)){var e=[],r=this.stack.length;for(this.pushToken(new n(t));this.stack.length>r;){this.expandOnce()instanceof n&&e.push(this.stack.pop())}return e}},e.expandMacroAsText=function(t){var e=this.expandMacro(t);return e?e.map(function(t){return t.text}).join(""):e},e._getExpansion=function(t){var e=this.macros.get(t);if(null==e)return e;var r="function"==typeof e?e(this):e;if("string"==typeof r){var a=0;if(-1!==r.indexOf("#"))for(var n=r.replace(/##/g,"");-1!==n.indexOf("#"+(a+1));)++a;for(var i=new la(r,this.settings),o=[],s=i.lex();"EOF"!==s.text;)o.push(s),s=i.lex();return o.reverse(),{tokens:o,numArgs:a}}return r},e.isDefined=function(t){return this.macros.has(t)||ia.hasOwnProperty(t)||j.math.hasOwnProperty(t)||j.text.hasOwnProperty(t)||ya.hasOwnProperty(t)},t}(),ka={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"}},Sa={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\u010f":"d\u030c","\u1e0b":"d\u0307","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u013a":"l\u0301","\u013e":"l\u030c","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\u010e":"D\u030c","\u1e0a":"D\u0307","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0139":"L\u0301","\u013d":"L\u030c","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u0164":"T\u030c","\u1e6a":"T\u0307","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"},Ma=function(){function t(t,e){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new wa(t,e,this.mode),this.settings=e,this.leftrightDepth=0}var e=t.prototype;return e.expect=function(t,e){if(void 0===e&&(e=!0),this.fetch().text!==t)throw new o("Expected '"+t+"', got '"+this.fetch().text+"'",this.fetch());e&&this.consume()},e.consume=function(){this.nextToken=null},e.fetch=function(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken},e.switchMode=function(t){this.mode=t,this.gullet.switchMode(t)},e.parse=function(){this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");var t=this.parseExpression(!1);return this.expect("EOF"),this.gullet.endGroup(),t},e.parseExpression=function(e,r){for(var a=[];;){"math"===this.mode&&this.consumeSpaces();var n=this.fetch();if(-1!==t.endOfExpression.indexOf(n.text))break;if(r&&n.text===r)break;if(e&&ia[n.text]&&ia[n.text].infix)break;var i=this.parseAtom(r);if(!i)break;a.push(i)}return"text"===this.mode&&this.formLigatures(a),this.handleInfixNodes(a)},e.handleInfixNodes=function(t){for(var e,r=-1,a=0;a0&&!l||0===s&&!l&&"math"===this.mode,c=this.parseGroupOfType("argument to '"+t+"'",h,l,a,m);if(!c){if(l){i.push(null);continue}throw new o("Expected group after '"+t+"'",this.fetch())}(l?i:n).push(c)}return{args:n,optArgs:i}},e.parseGroupOfType=function(t,e,r,a,n){switch(e){case"color":return n&&this.consumeSpaces(),this.parseColorGroup(r);case"size":return n&&this.consumeSpaces(),this.parseSizeGroup(r);case"url":return this.parseUrlGroup(r,n);case"math":case"text":return this.parseGroup(t,r,a,void 0,e,n);case"hbox":var i=this.parseGroup(t,r,a,void 0,"text",n);return i?{type:"styling",mode:i.mode,body:[i],style:"text"}:i;case"raw":if(n&&this.consumeSpaces(),r&&"{"===this.fetch().text)return null;var s=this.parseStringGroup("raw",r,!0);if(s)return{type:"raw",mode:"text",string:s.text};throw new o("Expected raw group",this.fetch());case"original":case null:case void 0:return this.parseGroup(t,r,a,void 0,void 0,n);default:throw new o("Unknown group type as "+t,this.fetch())}},e.consumeSpaces=function(){for(;" "===this.fetch().text;)this.consume()},e.parseStringGroup=function(t,e,r){var a=e?"[":"{",n=e?"]":"}",i=this.fetch();if(i.text!==a){if(e)return null;if(r&&"EOF"!==i.text&&/[^{}[\]]/.test(i.text))return this.consume(),i}var s=this.mode;this.mode="text",this.expect(a);for(var h,l="",m=this.fetch(),c=0,u=m;(h=this.fetch()).text!==n||r&&c>0;){switch(h.text){case"EOF":throw new o("Unexpected end of input in "+t,m.range(u,l));case a:c++;break;case n:c--}l+=(u=h).text,this.consume()}return this.expect(n),this.mode=s,m.range(u,l)},e.parseRegexGroup=function(t,e){var r=this.mode;this.mode="text";for(var a,n=this.fetch(),i=n,s="";"EOF"!==(a=this.fetch()).text&&t.test(s+a.text);)s+=(i=a).text,this.consume();if(""===s)throw new o("Invalid "+e+": '"+n.text+"'",n);return this.mode=r,n.range(i,s)},e.parseColorGroup=function(t){var e=this.parseStringGroup("color",t);if(!e)return null;var r=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(e.text);if(!r)throw new o("Invalid color: '"+e.text+"'",e);var a=r[0];return/^[0-9a-f]{6}$/i.test(a)&&(a="#"+a),{type:"color-token",mode:this.mode,color:a}},e.parseSizeGroup=function(t){var e,r=!1;if(!(e=t||"{"===this.fetch().text?this.parseStringGroup("size",t):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size")))return null;t||0!==e.text.length||(e.text="0pt",r=!0);var a=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e.text);if(!a)throw new o("Invalid size: '"+e.text+"'",e);var n={number:+(a[1]+a[2]),unit:a[3]};if(!At(n))throw new o("Invalid unit: '"+n.unit+"'",e);return{type:"size",mode:this.mode,value:n,isBlank:r}},e.parseUrlGroup=function(t,e){this.gullet.lexer.setCatcode("%",13);var r=this.parseStringGroup("url",t,!0);if(this.gullet.lexer.setCatcode("%",14),!r)return null;var a=r.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:a}},e.parseGroup=function(e,r,n,i,s,h){var l=this.mode;s&&this.switchMode(s),h&&this.consumeSpaces();var m,c=this.fetch(),u=c.text;if(r?"["===u:"{"===u||"\\begingroup"===u){this.consume();var p=t.endOfGroup[u];this.gullet.beginGroup();var d=this.parseExpression(!1,p),f=this.fetch();this.expect(p),this.gullet.endGroup(),m={type:"ordgroup",mode:this.mode,loc:a.range(c,f),body:d,semisimple:"\\begingroup"===u||void 0}}else if(r)m=null;else if(null==(m=this.parseFunction(i,e,n)||this.parseSymbol())&&"\\"===u[0]&&!ya.hasOwnProperty(u)){if(this.settings.throwOnError)throw new o("Undefined control sequence: "+u,c);m=this.formatUnsupportedCmd(u),this.consume()}return s&&this.switchMode(l),m},e.formLigatures=function(t){for(var e=t.length-1,r=0;r=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+e[0]+'" used in math mode',t);var h,l=j[this.mode][e].group,m=a.range(t);if(W.hasOwnProperty(l)){var c=l;h={type:"atom",mode:this.mode,family:c,loc:m,text:e}}else h={type:l,mode:this.mode,loc:m,text:e};i=h}else{if(!(e.charCodeAt(0)>=128))return null;this.settings.strict&&(M(e.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+e[0]+'" used in math mode',t):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+e[0]+'" ('+e.charCodeAt(0)+")",t)),i={type:"textord",mode:"text",loc:a.range(t),text:e}}if(this.consume(),s)for(var u=0;u15?"\u2026"+e.slice(n-15,n):e.slice(0,n),a=o+15":">","<":"<",'"':""","'":"'"},i=/[&><"']/g;const a=function(e){return"ordgroup"===e.type||"color"===e.type?1===e.body.length?a(e.body[0]):e:"font"===e.type?a(e.body):e};var l={contains:function(e,t){return-1!==e.indexOf(t)},deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(i,(e=>s[e]))},hyphenate:function(e){return e.replace(o,"-$1").toLowerCase()},getBaseElem:a,isCharacterBox:function(e){const t=a(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},protocolFromUrl:function(e){const t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"}};const h={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand ",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function c(e){if(e.default)return e.default;const t=e.type,r=Array.isArray(t)?t[0]:t;if("string"!=typeof r)return r.enum[0];switch(r){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class m{constructor(e){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(const t in h)if(h.hasOwnProperty(t)){const r=h[t];this[t]=void 0!==e[t]?r.processor?r.processor(e[t]):e[t]:c(r)}}reportNonstrict(e,t,r){let o=this.strict;if("function"==typeof o&&(o=o(e,t,r)),o&&"ignore"!==o){if(!0===o||"error"===o)throw new n("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",r);"warn"===o?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+o+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,r){let n=this.strict;if("function"==typeof n)try{n=n(e,t,r)}catch(e){n="error"}return!(!n||"ignore"===n)&&(!0===n||"error"===n||("warn"===n?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+n+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){if(e.url&&!e.protocol){const t=l.protocolFromUrl(e.url);if(null==t)return!1;e.protocol=t}const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}class p{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return u[d[this.id]]}sub(){return u[g[this.id]]}fracNum(){return u[f[this.id]]}fracDen(){return u[b[this.id]]}cramp(){return u[y[this.id]]}text(){return u[x[this.id]]}isTight(){return this.size>=2}}const u=[new p(0,0,!1),new p(1,0,!0),new p(2,1,!1),new p(3,1,!0),new p(4,2,!1),new p(5,2,!0),new p(6,3,!1),new p(7,3,!0)],d=[4,5,4,5,6,7,6,7],g=[5,5,5,5,7,7,7,7],f=[2,3,4,5,6,7,6,7],b=[3,3,5,5,7,7,7,7],y=[1,1,3,3,5,5,7,7],x=[0,1,2,3,2,3,2,3];var w={DISPLAY:u[0],TEXT:u[2],SCRIPT:u[4],SCRIPTSCRIPT:u[6]};const v=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];const k=[];function S(e){for(let t=0;t=k[t]&&e<=k[t+1])return!0;return!1}v.forEach((e=>e.blocks.forEach((e=>k.push(...e)))));const M=80,z={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:"M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",leftmapsto:"M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:"M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:"M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};class A{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return l.contains(this.classes,e)}toNode(){const e=document.createDocumentFragment();for(let t=0;te.toText())).join("")}}var T={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}};const B={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},C={"\xc5":"A","\xd0":"D","\xde":"o","\xe5":"a","\xf0":"d","\xfe":"o","\u0410":"A","\u0411":"B","\u0412":"B","\u0413":"F","\u0414":"A","\u0415":"E","\u0416":"K","\u0417":"3","\u0418":"N","\u0419":"N","\u041a":"K","\u041b":"N","\u041c":"M","\u041d":"H","\u041e":"O","\u041f":"N","\u0420":"P","\u0421":"C","\u0422":"T","\u0423":"y","\u0424":"O","\u0425":"X","\u0426":"U","\u0427":"h","\u0428":"W","\u0429":"W","\u042a":"B","\u042b":"X","\u042c":"B","\u042d":"3","\u042e":"X","\u042f":"R","\u0430":"a","\u0431":"b","\u0432":"a","\u0433":"r","\u0434":"y","\u0435":"e","\u0436":"m","\u0437":"e","\u0438":"n","\u0439":"n","\u043a":"n","\u043b":"n","\u043c":"m","\u043d":"n","\u043e":"o","\u043f":"n","\u0440":"p","\u0441":"c","\u0442":"o","\u0443":"y","\u0444":"b","\u0445":"x","\u0446":"n","\u0447":"n","\u0448":"w","\u0449":"w","\u044a":"a","\u044b":"m","\u044c":"a","\u044d":"e","\u044e":"m","\u044f":"r"};function N(e,t,r){if(!T[t])throw new Error("Font metrics not found for font: "+t+".");let n=e.charCodeAt(0),o=T[t][n];if(!o&&e[0]in C&&(n=C[e[0]].charCodeAt(0),o=T[t][n]),o||"text"!==r||S(n)&&(o=T[t][77]),o)return{depth:o[0],height:o[1],italic:o[2],skew:o[3],width:o[4]}}const q={};const I=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],R=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],H=function(e,t){return t.size<2?e:I[e-1][t.size-1]};class O{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||O.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=R[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){const t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};for(const r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return new O(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:H(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:R[e-1]})}havingBaseStyle(e){e=e||this.style.text();const t=H(O.BASESIZE,e);return this.size===t&&this.textSize===O.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){let e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==O.BASESIZE?["sizing","reset-size"+this.size,"size"+O.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=function(e){let t;if(t=e>=5?0:e>=3?1:2,!q[t]){const e=q[t]={cssEmPerMu:B.quad[t]/18};for(const r in B)B.hasOwnProperty(r)&&(e[r]=B[r][t])}return q[t]}(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}O.BASESIZE=6;var E=O;const L={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},D={ex:!0,em:!0,mu:!0},V=function(e){return"string"!=typeof e&&(e=e.unit),e in L||e in D||"ex"===e},P=function(e,t){let r;if(e.unit in L)r=L[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if("mu"===e.unit)r=t.fontMetrics().cssEmPerMu;else{let o;if(o=t.style.isTight()?t.havingStyle(t.style.text()):t,"ex"===e.unit)r=o.fontMetrics().xHeight;else{if("em"!==e.unit)throw new n("Invalid unit: '"+e.unit+"'");r=o.fontMetrics().quad}o!==t&&(r*=o.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},F=function(e){return+e.toFixed(4)+"em"},G=function(e){return e.filter((e=>e)).join(" ")},U=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");const e=t.getColor();e&&(this.style.color=e)}},Y=function(e){const t=document.createElement(e);t.className=G(this.classes);for(const e in this.style)this.style.hasOwnProperty(e)&&(t.style[e]=this.style[e]);for(const e in this.attributes)this.attributes.hasOwnProperty(e)&&t.setAttribute(e,this.attributes[e]);for(let e=0;e",t};class W{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,U.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return l.contains(this.classes,e)}toNode(){return Y.call(this,"span")}toMarkup(){return X.call(this,"span")}}class _{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,U.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return l.contains(this.classes,e)}toNode(){return Y.call(this,"a")}toMarkup(){return X.call(this,"a")}}class j{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.style=r}hasClass(e){return l.contains(this.classes,e)}toNode(){const e=document.createElement("img");e.src=this.src,e.alt=this.alt,e.className="mord";for(const t in this.style)this.style.hasOwnProperty(t)&&(e.style[t]=this.style[t]);return e}toMarkup(){let e=''+l.escape(this.alt)+'=n[0]&&e<=n[1])return r.name}}return null}(this.text.charCodeAt(0));l&&this.classes.push(l+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=$[this.text])}hasClass(e){return l.contains(this.classes,e)}toNode(){const e=document.createTextNode(this.text);let t=null;this.italic>0&&(t=document.createElement("span"),t.style.marginRight=F(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=G(this.classes));for(const e in this.style)this.style.hasOwnProperty(e)&&(t=t||document.createElement("span"),t.style[e]=this.style[e]);return t?(t.appendChild(e),t):e}toMarkup(){let e=!1,t="0&&(r+="margin-right:"+this.italic+"em;");for(const e in this.style)this.style.hasOwnProperty(e)&&(r+=l.hyphenate(e)+":"+this.style[e]+";");r&&(e=!0,t+=' style="'+l.escape(r)+'"');const n=l.escape(this.text);return e?(t+=">",t+=n,t+="",t):n}}class K{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);for(let t=0;t':''}}class Q{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","line");for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);return e}toMarkup(){let e="","\\gt",!0),se(ie,le,ye,"\u2208","\\in",!0),se(ie,le,ye,"\ue020","\\@not"),se(ie,le,ye,"\u2282","\\subset",!0),se(ie,le,ye,"\u2283","\\supset",!0),se(ie,le,ye,"\u2286","\\subseteq",!0),se(ie,le,ye,"\u2287","\\supseteq",!0),se(ie,he,ye,"\u2288","\\nsubseteq",!0),se(ie,he,ye,"\u2289","\\nsupseteq",!0),se(ie,le,ye,"\u22a8","\\models"),se(ie,le,ye,"\u2190","\\leftarrow",!0),se(ie,le,ye,"\u2264","\\le"),se(ie,le,ye,"\u2264","\\leq",!0),se(ie,le,ye,"<","\\lt",!0),se(ie,le,ye,"\u2192","\\rightarrow",!0),se(ie,le,ye,"\u2192","\\to"),se(ie,he,ye,"\u2271","\\ngeq",!0),se(ie,he,ye,"\u2270","\\nleq",!0),se(ie,le,xe,"\xa0","\\ "),se(ie,le,xe,"\xa0","\\space"),se(ie,le,xe,"\xa0","\\nobreakspace"),se(ae,le,xe,"\xa0","\\ "),se(ae,le,xe,"\xa0"," "),se(ae,le,xe,"\xa0","\\space"),se(ae,le,xe,"\xa0","\\nobreakspace"),se(ie,le,xe,null,"\\nobreak"),se(ie,le,xe,null,"\\allowbreak"),se(ie,le,be,",",","),se(ie,le,be,";",";"),se(ie,he,me,"\u22bc","\\barwedge",!0),se(ie,he,me,"\u22bb","\\veebar",!0),se(ie,le,me,"\u2299","\\odot",!0),se(ie,le,me,"\u2295","\\oplus",!0),se(ie,le,me,"\u2297","\\otimes",!0),se(ie,le,we,"\u2202","\\partial",!0),se(ie,le,me,"\u2298","\\oslash",!0),se(ie,he,me,"\u229a","\\circledcirc",!0),se(ie,he,me,"\u22a1","\\boxdot",!0),se(ie,le,me,"\u25b3","\\bigtriangleup"),se(ie,le,me,"\u25bd","\\bigtriangledown"),se(ie,le,me,"\u2020","\\dagger"),se(ie,le,me,"\u22c4","\\diamond"),se(ie,le,me,"\u22c6","\\star"),se(ie,le,me,"\u25c3","\\triangleleft"),se(ie,le,me,"\u25b9","\\triangleright"),se(ie,le,fe,"{","\\{"),se(ae,le,we,"{","\\{"),se(ae,le,we,"{","\\textbraceleft"),se(ie,le,pe,"}","\\}"),se(ae,le,we,"}","\\}"),se(ae,le,we,"}","\\textbraceright"),se(ie,le,fe,"{","\\lbrace"),se(ie,le,pe,"}","\\rbrace"),se(ie,le,fe,"[","\\lbrack",!0),se(ae,le,we,"[","\\lbrack",!0),se(ie,le,pe,"]","\\rbrack",!0),se(ae,le,we,"]","\\rbrack",!0),se(ie,le,fe,"(","\\lparen",!0),se(ie,le,pe,")","\\rparen",!0),se(ae,le,we,"<","\\textless",!0),se(ae,le,we,">","\\textgreater",!0),se(ie,le,fe,"\u230a","\\lfloor",!0),se(ie,le,pe,"\u230b","\\rfloor",!0),se(ie,le,fe,"\u2308","\\lceil",!0),se(ie,le,pe,"\u2309","\\rceil",!0),se(ie,le,we,"\\","\\backslash"),se(ie,le,we,"\u2223","|"),se(ie,le,we,"\u2223","\\vert"),se(ae,le,we,"|","\\textbar",!0),se(ie,le,we,"\u2225","\\|"),se(ie,le,we,"\u2225","\\Vert"),se(ae,le,we,"\u2225","\\textbardbl"),se(ae,le,we,"~","\\textasciitilde"),se(ae,le,we,"\\","\\textbackslash"),se(ae,le,we,"^","\\textasciicircum"),se(ie,le,ye,"\u2191","\\uparrow",!0),se(ie,le,ye,"\u21d1","\\Uparrow",!0),se(ie,le,ye,"\u2193","\\downarrow",!0),se(ie,le,ye,"\u21d3","\\Downarrow",!0),se(ie,le,ye,"\u2195","\\updownarrow",!0),se(ie,le,ye,"\u21d5","\\Updownarrow",!0),se(ie,le,ge,"\u2210","\\coprod"),se(ie,le,ge,"\u22c1","\\bigvee"),se(ie,le,ge,"\u22c0","\\bigwedge"),se(ie,le,ge,"\u2a04","\\biguplus"),se(ie,le,ge,"\u22c2","\\bigcap"),se(ie,le,ge,"\u22c3","\\bigcup"),se(ie,le,ge,"\u222b","\\int"),se(ie,le,ge,"\u222b","\\intop"),se(ie,le,ge,"\u222c","\\iint"),se(ie,le,ge,"\u222d","\\iiint"),se(ie,le,ge,"\u220f","\\prod"),se(ie,le,ge,"\u2211","\\sum"),se(ie,le,ge,"\u2a02","\\bigotimes"),se(ie,le,ge,"\u2a01","\\bigoplus"),se(ie,le,ge,"\u2a00","\\bigodot"),se(ie,le,ge,"\u222e","\\oint"),se(ie,le,ge,"\u222f","\\oiint"),se(ie,le,ge,"\u2230","\\oiiint"),se(ie,le,ge,"\u2a06","\\bigsqcup"),se(ie,le,ge,"\u222b","\\smallint"),se(ae,le,ue,"\u2026","\\textellipsis"),se(ie,le,ue,"\u2026","\\mathellipsis"),se(ae,le,ue,"\u2026","\\ldots",!0),se(ie,le,ue,"\u2026","\\ldots",!0),se(ie,le,ue,"\u22ef","\\@cdots",!0),se(ie,le,ue,"\u22f1","\\ddots",!0),se(ie,le,we,"\u22ee","\\varvdots"),se(ie,le,ce,"\u02ca","\\acute"),se(ie,le,ce,"\u02cb","\\grave"),se(ie,le,ce,"\xa8","\\ddot"),se(ie,le,ce,"~","\\tilde"),se(ie,le,ce,"\u02c9","\\bar"),se(ie,le,ce,"\u02d8","\\breve"),se(ie,le,ce,"\u02c7","\\check"),se(ie,le,ce,"^","\\hat"),se(ie,le,ce,"\u20d7","\\vec"),se(ie,le,ce,"\u02d9","\\dot"),se(ie,le,ce,"\u02da","\\mathring"),se(ie,le,de,"\ue131","\\@imath"),se(ie,le,de,"\ue237","\\@jmath"),se(ie,le,we,"\u0131","\u0131"),se(ie,le,we,"\u0237","\u0237"),se(ae,le,we,"\u0131","\\i",!0),se(ae,le,we,"\u0237","\\j",!0),se(ae,le,we,"\xdf","\\ss",!0),se(ae,le,we,"\xe6","\\ae",!0),se(ae,le,we,"\u0153","\\oe",!0),se(ae,le,we,"\xf8","\\o",!0),se(ae,le,we,"\xc6","\\AE",!0),se(ae,le,we,"\u0152","\\OE",!0),se(ae,le,we,"\xd8","\\O",!0),se(ae,le,ce,"\u02ca","\\'"),se(ae,le,ce,"\u02cb","\\`"),se(ae,le,ce,"\u02c6","\\^"),se(ae,le,ce,"\u02dc","\\~"),se(ae,le,ce,"\u02c9","\\="),se(ae,le,ce,"\u02d8","\\u"),se(ae,le,ce,"\u02d9","\\."),se(ae,le,ce,"\xb8","\\c"),se(ae,le,ce,"\u02da","\\r"),se(ae,le,ce,"\u02c7","\\v"),se(ae,le,ce,"\xa8",'\\"'),se(ae,le,ce,"\u02dd","\\H"),se(ae,le,ce,"\u25ef","\\textcircled");const ve={"--":!0,"---":!0,"``":!0,"''":!0};se(ae,le,we,"\u2013","--",!0),se(ae,le,we,"\u2013","\\textendash"),se(ae,le,we,"\u2014","---",!0),se(ae,le,we,"\u2014","\\textemdash"),se(ae,le,we,"\u2018","`",!0),se(ae,le,we,"\u2018","\\textquoteleft"),se(ae,le,we,"\u2019","'",!0),se(ae,le,we,"\u2019","\\textquoteright"),se(ae,le,we,"\u201c","``",!0),se(ae,le,we,"\u201c","\\textquotedblleft"),se(ae,le,we,"\u201d","''",!0),se(ae,le,we,"\u201d","\\textquotedblright"),se(ie,le,we,"\xb0","\\degree",!0),se(ae,le,we,"\xb0","\\degree"),se(ae,le,we,"\xb0","\\textdegree",!0),se(ie,le,we,"\xa3","\\pounds"),se(ie,le,we,"\xa3","\\mathsterling",!0),se(ae,le,we,"\xa3","\\pounds"),se(ae,le,we,"\xa3","\\textsterling",!0),se(ie,he,we,"\u2720","\\maltese"),se(ae,he,we,"\u2720","\\maltese");const ke='0123456789/@."';for(let e=0;e{if(G(e.classes)!==G(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize)return!1;if(1===e.classes.length){const t=e.classes[0];if("mbin"===t||"mord"===t)return!1}for(const r in e.style)if(e.style.hasOwnProperty(r)&&e.style[r]!==t.style[r])return!1;for(const r in t.style)if(t.style.hasOwnProperty(r)&&e.style[r]!==t.style[r])return!1;return!0},Ie=function(e){let t=0,r=0,n=0;for(let o=0;ot&&(t=s.height),s.depth>r&&(r=s.depth),s.maxFontSize>n&&(n=s.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},Re=function(e,t,r,n){const o=new W(e,t,r,n);return Ie(o),o},He=(e,t,r,n)=>new W(e,t,r,n),Oe=function(e){const t=new A(e);return Ie(t),t},Ee=function(e,t,r){let n,o="";switch(e){case"amsrm":o="AMS";break;case"textrm":o="Main";break;case"textsf":o="SansSerif";break;case"texttt":o="Typewriter";break;default:o=e}return n="textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===t?"Italic":"Regular",o+"-"+n},Le={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},De={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]};var Ve={fontMap:Le,makeSymbol:Ne,mathsym:function(e,t,r,n){return void 0===n&&(n=[]),"boldsymbol"===r.font&&Ce(e,"Main-Bold",t).metrics?Ne(e,"Main-Bold",t,r,n.concat(["mathbf"])):"\\"===e||"main"===oe[t][e].font?Ne(e,"Main-Regular",t,r,n):Ne(e,"AMS-Regular",t,r,n.concat(["amsrm"]))},makeSpan:Re,makeSvgSpan:He,makeLineSpan:function(e,t,r){const n=Re([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=F(n.height),n.maxFontSize=1,n},makeAnchor:function(e,t,r,n){const o=new _(e,t,r,n);return Ie(o),o},makeFragment:Oe,wrapFragment:function(e,t){return e instanceof A?Re([],[e],t):e},makeVList:function(e,t){const{children:r,depth:n}=function(e){if("individualShift"===e.positionType){const t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth;let o=n;for(let e=1;e0)return Ne(s,h,o,t,i.concat(c));if(l){let e,n;if("boldsymbol"===l){const t=function(e,t,r,n,o){return"textord"!==o&&Ce(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}}(s,o,0,0,r);e=t.fontName,n=[t.fontClass]}else a?(e=Le[l].fontName,n=[l]):(e=Ee(l,t.fontWeight,t.fontShape),n=[l,t.fontWeight,t.fontShape]);if(Ce(s,e,o).metrics)return Ne(s,e,o,t,i.concat(n));if(ve.hasOwnProperty(s)&&"Typewriter"===e.slice(0,10)){const r=[];for(let a=0;a{const r=Re(["mspace"],[],t),n=P(e,t);return r.style.marginRight=F(n),r},staticSvg:function(e,t){const[r,n,o]=De[e],s=new J(r),i=new K([s],{width:F(n),height:F(o),style:"width:"+F(n),viewBox:"0 0 "+1e3*n+" "+1e3*o,preserveAspectRatio:"xMinYMin"}),a=He(["overlay"],[i],t);return a.height=o,a.style.height=F(o),a.style.width=F(n),a},svgData:De,tryCombineChars:e=>{for(let t=0;t{const r=t.classes[0],n=e.classes[0];"mbin"===r&&l.contains(et,n)?t.classes[0]="mord":"mbin"===n&&l.contains(Qe,r)&&(e.classes[0]="mord")}),{node:i},a,h),ot(o,((e,t)=>{const r=at(t),n=at(e),o=r&&n?e.hasClass("mtight")?Ye[r][n]:Ue[r][n]:null;if(o)return Ve.makeGlue(o,s)}),{node:i},a,h),o},ot=function(e,t,r,n,o){n&&e.push(n);let s=0;for(;sr=>{e.splice(t+1,0,r),s++})(s)}n&&e.pop()},st=function(e){return e instanceof A||e instanceof _||e instanceof W&&e.hasClass("enclosing")?e:null},it=function(e,t){const r=st(e);if(r){const e=r.children;if(e.length){if("right"===t)return it(e[e.length-1],"right");if("left"===t)return it(e[0],"left")}}return e},at=function(e,t){return e?(t&&(e=it(e,t)),rt[e.classes[0]]||null):null},lt=function(e,t){const r=["nulldelimiter"].concat(e.baseSizingClasses());return Je(t.concat(r))},ht=function(e,t,r){if(!e)return Je();if(We[e.type]){let n=We[e.type](e,t);if(r&&t.size!==r.size){n=Je(t.sizingClasses(r),[n],t);const e=t.sizeMultiplier/r.sizeMultiplier;n.height*=e,n.depth*=e}return n}throw new n("Got group of unknown type: '"+e.type+"'")};function ct(e,t){const r=Je(["base"],e,t),n=Je(["strut"]);return n.style.height=F(r.height+r.depth),r.depth&&(n.style.verticalAlign=F(-r.depth)),r.children.unshift(n),r}function mt(e,t){let r=null;1===e.length&&"tag"===e[0].type&&(r=e[0].tag,e=e[0].body);const n=nt(e,t,"root");let o;2===n.length&&n[1].hasClass("tag")&&(o=n.pop());const s=[];let i,a=[];for(let e=0;e0&&(s.push(ct(a,t)),a=[]),s.push(n[e]));a.length>0&&s.push(ct(a,t)),r?(i=ct(nt(r,t,!0)),i.classes=["tag"],s.push(i)):o&&s.push(o);const l=Je(["katex-html"],s);if(l.setAttribute("aria-hidden","true"),i){const e=i.children[0];e.style.height=F(l.height+l.depth),l.depth&&(e.style.verticalAlign=F(-l.depth))}return l}function pt(e){return new A(e)}class ut{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){const e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=G(this.classes));for(let t=0;t0&&(e+=' class ="'+l.escape(G(this.classes))+'"'),e+=">";for(let t=0;t",e}toText(){return this.children.map((e=>e.toText())).join("")}}class dt{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return l.escape(this.toText())}toText(){return this.text}}var gt={MathNode:ut,TextNode:dt,SpaceNode:class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?"\u200a":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200a":e>=-.05556&&e<=-.05555?"\u200a\u2063":e>=-.1667&&e<=-.1666?"\u2009\u2063":e>=-.2223&&e<=-.2222?"\u205f\u2063":e>=-.2778&&e<=-.2777?"\u2005\u2063":null}toNode(){if(this.character)return document.createTextNode(this.character);{const e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",F(this.width)),e}}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}},newDocumentFragment:pt};const ft=function(e,t,r){return!oe[t][e]||!oe[t][e].replace||55349===e.charCodeAt(0)||ve.hasOwnProperty(e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=oe[t][e].replace),new gt.TextNode(e)},bt=function(e){return 1===e.length?e[0]:new gt.MathNode("mrow",e)},yt=function(e,t){if("texttt"===t.fontFamily)return"monospace";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold";const r=t.font;if(!r||"mathnormal"===r)return null;const n=e.mode;if("mathit"===r)return"italic";if("boldsymbol"===r)return"textord"===e.type?"bold":"bold-italic";if("mathbf"===r)return"bold";if("mathbb"===r)return"double-struck";if("mathfrak"===r)return"fraktur";if("mathscr"===r||"mathcal"===r)return"script";if("mathsf"===r)return"sans-serif";if("mathtt"===r)return"monospace";let o=e.text;if(l.contains(["\\imath","\\jmath"],o))return null;oe[n][o]&&oe[n][o].replace&&(o=oe[n][o].replace);return N(o,Ve.fontMap[r].fontName,n)?Ve.fontMap[r].variant:null},xt=function(e,t,r){if(1===e.length){const n=vt(e[0],t);return r&&n instanceof ut&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];let o;for(let r=0;r0&&(e.text=e.text.slice(0,1)+"\u0338"+e.text.slice(1),n.pop())}}}n.push(s),o=s}return n},wt=function(e,t,r){return bt(xt(e,t,r))},vt=function(e,t){if(!e)return new gt.MathNode("mrow");if(_e[e.type]){return _e[e.type](e,t)}throw new n("Got group of unknown type: '"+e.type+"'")};function kt(e,t,r,n,o){const s=xt(e,r);let i;i=1===s.length&&s[0]instanceof ut&&l.contains(["mrow","mtable"],s[0].type)?s[0]:new gt.MathNode("mrow",s);const a=new gt.MathNode("annotation",[new gt.TextNode(t)]);a.setAttribute("encoding","application/x-tex");const h=new gt.MathNode("semantics",[i,a]),c=new gt.MathNode("math",[h]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");const m=o?"katex":"katex-mathml";return Ve.makeSpan([m],[c])}const St=function(e){return new E({style:e.displayMode?w.DISPLAY:w.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},Mt=function(e,t){if(t.displayMode){const r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=Ve.makeSpan(r,[e])}return e},zt=function(e,t,r){const n=St(r);let o;if("mathml"===r.output)return kt(e,t,n,r.displayMode,!0);if("html"===r.output){const t=mt(e,n);o=Ve.makeSpan(["katex"],[t])}else{const s=kt(e,t,n,r.displayMode,!1),i=mt(e,n);o=Ve.makeSpan(["katex"],[s,i])}return Mt(o,r)};const At={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},Tt={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]};var Bt=function(e,t,r,n,o){let s;const i=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(s=Ve.makeSpan(["stretchy",t],[],o),"fbox"===t){const e=o.color&&o.getColor();e&&(s.style.borderColor=e)}}else{const e=[];/^[bx]cancel$/.test(t)&&e.push(new Q({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&e.push(new Q({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));const r=new K(e,{width:"100%",height:F(i)});s=Ve.makeSvgSpan([],[r],o)}return s.height=i,s.style.height=F(i),s},Ct=function(e){const t=new gt.MathNode("mo",[new gt.TextNode(At[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},Nt=function(e,t){const{span:r,minWidth:n,height:o}=function(){let r=4e5;const n=e.label.slice(1);if(l.contains(["widehat","widecheck","widetilde","utilde"],n)){const s="ordgroup"===(o=e.base).type?o.body.length:1;let i,a,l;if(s>5)"widehat"===n||"widecheck"===n?(i=420,r=2364,l=.42,a=n+"4"):(i=312,r=2340,l=.34,a="tilde4");else{const e=[1,1,2,2,3,3][s];"widehat"===n||"widecheck"===n?(r=[0,1062,2364,2364,2364][e],i=[0,239,300,360,420][e],l=[0,.24,.3,.3,.36,.42][e],a=n+e):(r=[0,600,1033,2339,2340][e],i=[0,260,286,306,312][e],l=[0,.26,.286,.3,.306,.34][e],a="tilde"+e)}const h=new J(a),c=new K([h],{width:"100%",height:F(l),viewBox:"0 0 "+r+" "+i,preserveAspectRatio:"none"});return{span:Ve.makeSvgSpan([],[c],t),minWidth:0,height:l}}{const e=[],o=Tt[n],[s,i,a]=o,l=a/1e3,h=s.length;let c,m;if(1===h){c=["hide-tail"],m=[o[3]]}else if(2===h)c=["halfarrow-left","halfarrow-right"],m=["xMinYMin","xMaxYMin"];else{if(3!==h)throw new Error("Correct katexImagesData or update code here to support\n "+h+" children.");c=["brace-left","brace-center","brace-right"],m=["xMinYMin","xMidYMin","xMaxYMin"]}for(let n=0;n0&&(r.style.minWidth=F(n)),r};function qt(e,t){if(!e||e.type!==t)throw new Error("Expected node of type "+t+", but got "+(e?"node of type "+e.type:String(e)));return e}function It(e){const t=Rt(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?"node of type "+e.type:String(e)));return t}function Rt(e){return e&&("atom"===e.type||re.hasOwnProperty(e.type))?e:null}const Ht=(e,t)=>{let r,n,o;e&&"supsub"===e.type?(n=qt(e.base,"accent"),r=n.base,e.base=r,o=function(e){if(e instanceof W)return e;throw new Error("Expected span but got "+String(e)+".")}(ht(e,t)),e.base=n):(n=qt(e,"accent"),r=n.base);const s=ht(r,t.havingCrampedStyle());let i=0;if(n.isShifty&&l.isCharacterBox(r)){const e=l.getBaseElem(r);i=ee(ht(e,t.havingCrampedStyle())).skew}const a="\\c"===n.label;let h,c=a?s.height+s.depth:Math.min(s.height,t.fontMetrics().xHeight);if(n.isStretchy)h=Nt(n,t),h=Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:i>0?{width:"calc(100% - "+F(2*i)+")",marginLeft:F(2*i)}:void 0}]},t);else{let e,r;"\\vec"===n.label?(e=Ve.staticSvg("vec",t),r=Ve.svgData.vec[1]):(e=Ve.makeOrd({mode:n.mode,text:n.label},t,"textord"),e=ee(e),e.italic=0,r=e.width,a&&(c+=e.depth)),h=Ve.makeSpan(["accent-body"],[e]);const o="\\textcircled"===n.label;o&&(h.classes.push("accent-full"),c=s.height);let l=i;o||(l-=r/2),h.style.left=F(l),"\\textcircled"===n.label&&(h.style.top=".2em"),h=Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-c},{type:"elem",elem:h}]},t)}const m=Ve.makeSpan(["mord","accent"],[h],t);return o?(o.children[0]=m,o.height=Math.max(m.height,o.height),o.classes[0]="mord",o):m},Ot=(e,t)=>{const r=e.isStretchy?Ct(e.label):new gt.MathNode("mo",[ft(e.label,e.mode)]),n=new gt.MathNode("mover",[vt(e.base,t),r]);return n.setAttribute("accent","true"),n},Et=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map((e=>"\\"+e)).join("|"));je({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,t)=>{const r=Ze(t[0]),n=!Et.test(e.funcName),o=!n||"\\widehat"===e.funcName||"\\widetilde"===e.funcName||"\\widecheck"===e.funcName;return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,isShifty:o,base:r}},htmlBuilder:Ht,mathmlBuilder:Ot}),je({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=t[0];let n=e.parser.mode;return"math"===n&&(e.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+e.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}},htmlBuilder:Ht,mathmlBuilder:Ot}),je({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"accentUnder",mode:r.mode,label:n,base:o}},htmlBuilder:(e,t)=>{const r=ht(e.base,t),n=Nt(e,t),o="\\utilde"===e.label?.12:0,s=Ve.makeVList({positionType:"top",positionData:r.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:o},{type:"elem",elem:r}]},t);return Ve.makeSpan(["mord","accentunder"],[s],t)},mathmlBuilder:(e,t)=>{const r=Ct(e.label),n=new gt.MathNode("munder",[vt(e.base,t),r]);return n.setAttribute("accentunder","true"),n}});const Lt=e=>{const t=new gt.MathNode("mpadded",e?[e]:[]);return t.setAttribute("width","+0.6em"),t.setAttribute("lspace","0.3em"),t};je({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(e,t,r){let{parser:n,funcName:o}=e;return{type:"xArrow",mode:n.mode,label:o,body:t[0],below:r[0]}},htmlBuilder(e,t){const r=t.style;let n=t.havingStyle(r.sup());const o=Ve.wrapFragment(ht(e.body,n,t),t),s="\\x"===e.label.slice(0,2)?"x":"cd";let i;o.classes.push(s+"-arrow-pad"),e.below&&(n=t.havingStyle(r.sub()),i=Ve.wrapFragment(ht(e.below,n,t),t),i.classes.push(s+"-arrow-pad"));const a=Nt(e,t),l=-t.fontMetrics().axisHeight+.5*a.height;let h,c=-t.fontMetrics().axisHeight-.5*a.height-.111;if((o.depth>.25||"\\xleftequilibrium"===e.label)&&(c-=o.depth),i){const e=-t.fontMetrics().axisHeight+i.height+.5*a.height+.111;h=Ve.makeVList({positionType:"individualShift",children:[{type:"elem",elem:o,shift:c},{type:"elem",elem:a,shift:l},{type:"elem",elem:i,shift:e}]},t)}else h=Ve.makeVList({positionType:"individualShift",children:[{type:"elem",elem:o,shift:c},{type:"elem",elem:a,shift:l}]},t);return h.children[0].children[0].children[1].classes.push("svg-align"),Ve.makeSpan(["mrel","x-arrow"],[h],t)},mathmlBuilder(e,t){const r=Ct(e.label);let n;if(r.setAttribute("minsize","x"===e.label.charAt(0)?"1.75em":"3.0em"),e.body){const o=Lt(vt(e.body,t));if(e.below){const s=Lt(vt(e.below,t));n=new gt.MathNode("munderover",[r,s,o])}else n=new gt.MathNode("mover",[r,o])}else if(e.below){const o=Lt(vt(e.below,t));n=new gt.MathNode("munder",[r,o])}else n=Lt(),n=new gt.MathNode("mover",[r,n]);return n}});const Dt=Ve.makeSpan;function Vt(e,t){const r=nt(e.body,t,!0);return Dt([e.mclass],r,t)}function Pt(e,t){let r;const n=xt(e.body,t);return"minner"===e.mclass?r=new gt.MathNode("mpadded",n):"mord"===e.mclass?e.isCharacterBox?(r=n[0],r.type="mi"):r=new gt.MathNode("mi",n):(e.isCharacterBox?(r=n[0],r.type="mo"):r=new gt.MathNode("mo",n),"mbin"===e.mclass?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):"mopen"===e.mclass||"mclose"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0em"):"minner"===e.mclass&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em")),r}je({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"mclass",mode:r.mode,mclass:"m"+n.slice(5),body:Ke(o),isCharacterBox:l.isCharacterBox(o)}},htmlBuilder:Vt,mathmlBuilder:Pt});const Ft=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};je({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(e,t){let{parser:r}=e;return{type:"mclass",mode:r.mode,mclass:Ft(t[0]),body:Ke(t[1]),isCharacterBox:l.isCharacterBox(t[1])}}}),je({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(e,t){let{parser:r,funcName:n}=e;const o=t[1],s=t[0];let i;i="\\stackrel"!==n?Ft(o):"mrel";const a={type:"op",mode:o.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==n,body:Ke(o)},h={type:"supsub",mode:s.mode,base:a,sup:"\\underset"===n?null:s,sub:"\\underset"===n?s:null};return{type:"mclass",mode:r.mode,mclass:i,body:[h],isCharacterBox:l.isCharacterBox(h)}},htmlBuilder:Vt,mathmlBuilder:Pt}),je({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"pmb",mode:r.mode,mclass:Ft(t[0]),body:Ke(t[0])}},htmlBuilder(e,t){const r=nt(e.body,t,!0),n=Ve.makeSpan([e.mclass],r,t);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(e,t){const r=xt(e.body,t),n=new gt.MathNode("mstyle",r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});const Gt={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Ut=e=>"textord"===e.type&&"@"===e.text;function Yt(e,t,r){const n=Gt[e];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{const e={type:"atom",text:n,mode:"math",family:"rel"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{const e={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[e],[])}default:return{type:"textord",text:" ",mode:"math"}}}je({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;return{type:"cdlabel",mode:r.mode,side:n.slice(4),label:t[0]}},htmlBuilder(e,t){const r=t.havingStyle(t.style.sup()),n=Ve.wrapFragment(ht(e.label,r,t),t);return n.classes.push("cd-label-"+e.side),n.style.bottom=F(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(e,t){let r=new gt.MathNode("mrow",[vt(e.label,t)]);return r=new gt.MathNode("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new gt.MathNode("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),je({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(e,t){let{parser:r}=e;return{type:"cdlabelparent",mode:r.mode,fragment:t[0]}},htmlBuilder(e,t){const r=Ve.wrapFragment(ht(e.fragment,t),t);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder(e,t){return new gt.MathNode("mrow",[vt(e.fragment,t)])}}),je({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;const o=qt(t[0],"ordgroup").body;let s="";for(let e=0;e=1114111)throw new n("\\@char with invalid code point "+s);return a<=65535?i=String.fromCharCode(a):(a-=65536,i=String.fromCharCode(55296+(a>>10),56320+(1023&a))),{type:"textord",mode:r.mode,text:i}}});const Xt=(e,t)=>{const r=nt(e.body,t.withColor(e.color),!1);return Ve.makeFragment(r)},Wt=(e,t)=>{const r=xt(e.body,t.withColor(e.color)),n=new gt.MathNode("mstyle",r);return n.setAttribute("mathcolor",e.color),n};je({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(e,t){let{parser:r}=e;const n=qt(t[0],"color-token").color,o=t[1];return{type:"color",mode:r.mode,color:n,body:Ke(o)}},htmlBuilder:Xt,mathmlBuilder:Wt}),je({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(e,t){let{parser:r,breakOnTokenText:n}=e;const o=qt(t[0],"color-token").color;r.gullet.macros.set("\\current@color",o);const s=r.parseExpression(!0,n);return{type:"color",mode:r.mode,color:o,body:s}},htmlBuilder:Xt,mathmlBuilder:Wt}),je({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(e,t,r){let{parser:n}=e;const o="["===n.gullet.future().text?n.parseSizeGroup(!0):null,s=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:s,size:o&&qt(o,"size").value}},htmlBuilder(e,t){const r=Ve.makeSpan(["mspace"],[],t);return e.newLine&&(r.classes.push("newline"),e.size&&(r.style.marginTop=F(P(e.size,t)))),r},mathmlBuilder(e,t){const r=new gt.MathNode("mspace");return e.newLine&&(r.setAttribute("linebreak","newline"),e.size&&r.setAttribute("height",F(P(e.size,t)))),r}});const _t={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},jt=e=>{const t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new n("Expected a control sequence",e);return t},$t=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};je({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(e){let{parser:t,funcName:r}=e;t.consumeSpaces();const o=t.fetch();if(_t[o.text])return"\\global"!==r&&"\\\\globallong"!==r||(o.text=_t[o.text]),qt(t.parseFunction(),"internal");throw new n("Invalid token after macro prefix",o)}}),je({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e,o=t.gullet.popToken();const s=o.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(s))throw new n("Expected a control sequence",o);let i,a=0;const l=[[]];for(;"{"!==t.gullet.future().text;)if(o=t.gullet.popToken(),"#"===o.text){if("{"===t.gullet.future().text){i=t.gullet.future(),l[a].push("{");break}if(o=t.gullet.popToken(),!/^[1-9]$/.test(o.text))throw new n('Invalid argument number "'+o.text+'"');if(parseInt(o.text)!==a+1)throw new n('Argument number "'+o.text+'" out of order');a++,l.push([])}else{if("EOF"===o.text)throw new n("Expected a macro definition");l[a].push(o.text)}let{tokens:h}=t.gullet.consumeArg();return i&&h.unshift(i),"\\edef"!==r&&"\\xdef"!==r||(h=t.gullet.expandTokens(h),h.reverse()),t.gullet.macros.set(s,{tokens:h,numArgs:a,delimiters:l},r===_t[r]),{type:"internal",mode:t.mode}}}),je({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e;const n=jt(t.gullet.popToken());t.gullet.consumeSpaces();const o=(e=>{let t=e.gullet.popToken();return"="===t.text&&(t=e.gullet.popToken()," "===t.text&&(t=e.gullet.popToken())),t})(t);return $t(t,n,o,"\\\\globallet"===r),{type:"internal",mode:t.mode}}}),je({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e;const n=jt(t.gullet.popToken()),o=t.gullet.popToken(),s=t.gullet.popToken();return $t(t,n,s,"\\\\globalfuture"===r),t.gullet.pushToken(s),t.gullet.pushToken(o),{type:"internal",mode:t.mode}}});const Zt=function(e,t,r){const n=N(oe.math[e]&&oe.math[e].replace||e,t,r);if(!n)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return n},Kt=function(e,t,r,n){const o=r.havingBaseStyle(t),s=Ve.makeSpan(n.concat(o.sizingClasses(r)),[e],r),i=o.sizeMultiplier/r.sizeMultiplier;return s.height*=i,s.depth*=i,s.maxFontSize=o.sizeMultiplier,s},Jt=function(e,t,r){const n=t.havingBaseStyle(r),o=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=F(o),e.height-=o,e.depth+=o},Qt=function(e,t,r,n,o,s){const i=function(e,t,r,n){return Ve.makeSymbol(e,"Size"+t+"-Regular",r,n)}(e,t,o,n),a=Kt(Ve.makeSpan(["delimsizing","size"+t],[i],n),w.TEXT,n,s);return r&&Jt(a,n,w.TEXT),a},er=function(e,t,r){let n;n="Size1-Regular"===t?"delim-size1":"delim-size4";return{type:"elem",elem:Ve.makeSpan(["delimsizinginner",n],[Ve.makeSpan([],[Ve.makeSymbol(e,t,r)])])}},tr=function(e,t,r){const n=T["Size4-Regular"][e.charCodeAt(0)]?T["Size4-Regular"][e.charCodeAt(0)][4]:T["Size1-Regular"][e.charCodeAt(0)][4],o=new J("inner",function(e,t){switch(e){case"\u239c":return"M291 0 H417 V"+t+" H291z M291 0 H417 V"+t+" H291z";case"\u2223":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z";case"\u2225":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145zM367 0 H410 V"+t+" H367z M367 0 H410 V"+t+" H367z";case"\u239f":return"M457 0 H583 V"+t+" H457z M457 0 H583 V"+t+" H457z";case"\u23a2":return"M319 0 H403 V"+t+" H319z M319 0 H403 V"+t+" H319z";case"\u23a5":return"M263 0 H347 V"+t+" H263z M263 0 H347 V"+t+" H263z";case"\u23aa":return"M384 0 H504 V"+t+" H384z M384 0 H504 V"+t+" H384z";case"\u23d0":return"M312 0 H355 V"+t+" H312z M312 0 H355 V"+t+" H312z";case"\u2016":return"M257 0 H300 V"+t+" H257z M257 0 H300 V"+t+" H257zM478 0 H521 V"+t+" H478z M478 0 H521 V"+t+" H478z";default:return""}}(e,Math.round(1e3*t))),s=new K([o],{width:F(n),height:F(t),style:"width:"+F(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),i=Ve.makeSvgSpan([],[s],r);return i.height=t,i.style.height=F(t),i.style.width=F(n),{type:"elem",elem:i}},rr={type:"kern",size:-.008},nr=["|","\\lvert","\\rvert","\\vert"],or=["\\|","\\lVert","\\rVert","\\Vert"],sr=function(e,t,r,n,o,s){let i,a,h,c,m="",p=0;i=h=c=e,a=null;let u="Size1-Regular";"\\uparrow"===e?h=c="\u23d0":"\\Uparrow"===e?h=c="\u2016":"\\downarrow"===e?i=h="\u23d0":"\\Downarrow"===e?i=h="\u2016":"\\updownarrow"===e?(i="\\uparrow",h="\u23d0",c="\\downarrow"):"\\Updownarrow"===e?(i="\\Uparrow",h="\u2016",c="\\Downarrow"):l.contains(nr,e)?(h="\u2223",m="vert",p=333):l.contains(or,e)?(h="\u2225",m="doublevert",p=556):"["===e||"\\lbrack"===e?(i="\u23a1",h="\u23a2",c="\u23a3",u="Size4-Regular",m="lbrack",p=667):"]"===e||"\\rbrack"===e?(i="\u23a4",h="\u23a5",c="\u23a6",u="Size4-Regular",m="rbrack",p=667):"\\lfloor"===e||"\u230a"===e?(h=i="\u23a2",c="\u23a3",u="Size4-Regular",m="lfloor",p=667):"\\lceil"===e||"\u2308"===e?(i="\u23a1",h=c="\u23a2",u="Size4-Regular",m="lceil",p=667):"\\rfloor"===e||"\u230b"===e?(h=i="\u23a5",c="\u23a6",u="Size4-Regular",m="rfloor",p=667):"\\rceil"===e||"\u2309"===e?(i="\u23a4",h=c="\u23a5",u="Size4-Regular",m="rceil",p=667):"("===e||"\\lparen"===e?(i="\u239b",h="\u239c",c="\u239d",u="Size4-Regular",m="lparen",p=875):")"===e||"\\rparen"===e?(i="\u239e",h="\u239f",c="\u23a0",u="Size4-Regular",m="rparen",p=875):"\\{"===e||"\\lbrace"===e?(i="\u23a7",a="\u23a8",c="\u23a9",h="\u23aa",u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(i="\u23ab",a="\u23ac",c="\u23ad",h="\u23aa",u="Size4-Regular"):"\\lgroup"===e||"\u27ee"===e?(i="\u23a7",c="\u23a9",h="\u23aa",u="Size4-Regular"):"\\rgroup"===e||"\u27ef"===e?(i="\u23ab",c="\u23ad",h="\u23aa",u="Size4-Regular"):"\\lmoustache"===e||"\u23b0"===e?(i="\u23a7",c="\u23ad",h="\u23aa",u="Size4-Regular"):"\\rmoustache"!==e&&"\u23b1"!==e||(i="\u23ab",c="\u23a9",h="\u23aa",u="Size4-Regular");const d=Zt(i,u,o),g=d.height+d.depth,f=Zt(h,u,o),b=f.height+f.depth,y=Zt(c,u,o),x=y.height+y.depth;let v=0,k=1;if(null!==a){const e=Zt(a,u,o);v=e.height+e.depth,k=2}const S=g+x+v,M=S+Math.max(0,Math.ceil((t-S)/(k*b)))*k*b;let z=n.fontMetrics().axisHeight;r&&(z*=n.sizeMultiplier);const A=M/2-z,T=[];if(m.length>0){const e=M-g-x,t=Math.round(1e3*M),r=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+t+" v1759 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z\nM367 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v602 h84z\nM403 1759 V0 H319 V1759 v"+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+t+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(t+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(t+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(t+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(t+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}}(m,Math.round(1e3*e)),o=new J(m,r),s=(p/1e3).toFixed(3)+"em",i=(t/1e3).toFixed(3)+"em",a=new K([o],{width:s,height:i,viewBox:"0 0 "+p+" "+t}),l=Ve.makeSvgSpan([],[a],n);l.height=t/1e3,l.style.width=s,l.style.height=i,T.push({type:"elem",elem:l})}else{if(T.push(er(c,u,o)),T.push(rr),null===a){const e=M-g-x+.016;T.push(tr(h,e,n))}else{const e=(M-g-x-v)/2+.016;T.push(tr(h,e,n)),T.push(rr),T.push(er(a,u,o)),T.push(rr),T.push(tr(h,e,n))}T.push(rr),T.push(er(i,u,o))}const B=n.havingBaseStyle(w.TEXT),C=Ve.makeVList({positionType:"bottom",positionData:A,children:T},B);return Kt(Ve.makeSpan(["delimsizing","mult"],[C],B),w.TEXT,n,s)},ir=.08,ar=function(e,t,r,n,o){const s=function(e,t,r){t*=1e3;let n="";switch(e){case"sqrtMain":n=function(e,t){return"M95,"+(622+e+t)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+e/2.075+" -"+e+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+e)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,M);break;case"sqrtSize1":n=function(e,t){return"M263,"+(601+e+t)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+e/2.084+" -"+e+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+e)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,M);break;case"sqrtSize2":n=function(e,t){return"M983 "+(10+e+t)+"\nl"+e/3.13+" -"+e+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+e)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,M);break;case"sqrtSize3":n=function(e,t){return"M424,"+(2398+e+t)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+e/4.223+" -"+e+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+e)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+e)+" "+t+"\nh400000v"+(40+e)+"h-400000z"}(t,M);break;case"sqrtSize4":n=function(e,t){return"M473,"+(2713+e+t)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+e/5.298+" -"+e+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+e)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"}(t,M);break;case"sqrtTall":n=function(e,t,r){return"M702 "+(e+t)+"H400000"+(40+e)+"\nH742v"+(r-54-t-e)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+t+"H400000v"+(40+e)+"H742z"}(t,M,r)}return n}(e,n,r),i=new J(e,s),a=new K([i],{width:"400em",height:F(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return Ve.makeSvgSpan(["hide-tail"],[a],o)},lr=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","\\surd"],hr=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1"],cr=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],mr=[0,1.2,1.8,2.4,3],pr=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],ur=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"stack"}],dr=[{type:"small",style:w.SCRIPTSCRIPT},{type:"small",style:w.SCRIPT},{type:"small",style:w.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],gr=function(e){if("small"===e.type)return"Main-Regular";if("large"===e.type)return"Size"+e.size+"-Regular";if("stack"===e.type)return"Size4-Regular";throw new Error("Add support for delim type '"+e.type+"' here.")},fr=function(e,t,r,n){for(let o=Math.min(2,3-n.style.size);ot)return r[o]}return r[r.length-1]},br=function(e,t,r,n,o,s){let i;"<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),i=l.contains(cr,e)?pr:l.contains(lr,e)?dr:ur;const a=fr(e,t,i,n);return"small"===a.type?function(e,t,r,n,o,s){const i=Ve.makeSymbol(e,"Main-Regular",o,n),a=Kt(i,t,n,s);return r&&Jt(a,n,t),a}(e,a.style,r,n,o,s):"large"===a.type?Qt(e,a.size,r,n,o,s):sr(e,t,r,n,o,s)};var yr={sqrtImage:function(e,t){const r=t.havingBaseSizing(),n=fr("\\surd",e*r.sizeMultiplier,dr,r);let o=r.sizeMultiplier;const s=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness);let i,a,l=0,h=0,c=0;return"small"===n.type?(c=1e3+1e3*s+80,e<1?o=1:e<1.4&&(o=.7),l=(1+s+ir)/o,h=(1+s)/o,i=ar("sqrtMain",l,c,s,t),i.style.minWidth="0.853em",a=.833/o):"large"===n.type?(c=1080*mr[n.size],h=(mr[n.size]+s)/o,l=(mr[n.size]+s+ir)/o,i=ar("sqrtSize"+n.size,l,c,s,t),i.style.minWidth="1.02em",a=1/o):(l=e+s+ir,h=e+s,c=Math.floor(1e3*e+s)+80,i=ar("sqrtTall",l,c,s,t),i.style.minWidth="0.742em",a=1.056),i.height=h,i.style.height=F(l),{span:i,advanceWidth:a,ruleWidth:(t.fontMetrics().sqrtRuleThickness+s)*o}},sizedDelim:function(e,t,r,o,s){if("<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),l.contains(lr,e)||l.contains(cr,e))return Qt(e,t,!1,r,o,s);if(l.contains(hr,e))return sr(e,mr[t],!1,r,o,s);throw new n("Illegal delimiter: '"+e+"'")},sizeToMaxHeight:mr,customSizedDelim:br,leftRightDelim:function(e,t,r,n,o,s){const i=n.fontMetrics().axisHeight*n.sizeMultiplier,a=5/n.fontMetrics().ptPerEm,l=Math.max(t-i,r+i),h=Math.max(l/500*901,2*l-a);return br(e,h,!0,n,o,s)}};const xr={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},wr=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];function vr(e,t){const r=Rt(e);if(r&&l.contains(wr,r.text))return r;throw new n(r?"Invalid delimiter '"+r.text+"' after '"+t.funcName+"'":"Invalid delimiter type '"+e.type+"'",e)}function kr(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}je({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{const r=vr(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:xr[e.funcName].size,mclass:xr[e.funcName].mclass,delim:r.text}},htmlBuilder:(e,t)=>"."===e.delim?Ve.makeSpan([e.mclass]):yr.sizedDelim(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{const t=[];"."!==e.delim&&t.push(ft(e.delim,e.mode));const r=new gt.MathNode("mo",t);"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");const n=F(yr.sizeToMaxHeight[e.size]);return r.setAttribute("minsize",n),r.setAttribute("maxsize",n),r}}),je({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=e.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new n("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:e.parser.mode,delim:vr(t[0],e).text,color:r}}}),je({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=vr(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=qt(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},htmlBuilder:(e,t)=>{kr(e);const r=nt(e.body,t,!0,["mopen","mclose"]);let n,o,s=0,i=0,a=!1;for(let e=0;e{kr(e);const r=xt(e.body,t);if("."!==e.left){const t=new gt.MathNode("mo",[ft(e.left,e.mode)]);t.setAttribute("fence","true"),r.unshift(t)}if("."!==e.right){const t=new gt.MathNode("mo",[ft(e.right,e.mode)]);t.setAttribute("fence","true"),e.rightColor&&t.setAttribute("mathcolor",e.rightColor),r.push(t)}return bt(r)}}),je({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=vr(t[0],e);if(!e.parser.leftrightDepth)throw new n("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},htmlBuilder:(e,t)=>{let r;if("."===e.delim)r=lt(t,[]);else{r=yr.sizedDelim(e.delim,1,t,e.mode,[]);const n={delim:e.delim,options:t};r.isMiddle=n}return r},mathmlBuilder:(e,t)=>{const r="\\vert"===e.delim||"|"===e.delim?ft("|","text"):ft(e.delim,e.mode),n=new gt.MathNode("mo",[r]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});const Sr=(e,t)=>{const r=Ve.wrapFragment(ht(e.body,t),t),n=e.label.slice(1);let o,s=t.sizeMultiplier,i=0;const a=l.isCharacterBox(e.body);if("sout"===n)o=Ve.makeSpan(["stretchy","sout"]),o.height=t.fontMetrics().defaultRuleThickness/s,i=-.5*t.fontMetrics().xHeight;else if("phase"===n){const e=P({number:.6,unit:"pt"},t),n=P({number:.35,unit:"ex"},t);s/=t.havingBaseSizing().sizeMultiplier;const a=r.height+r.depth+e+n;r.style.paddingLeft=F(a/2+e);const l=Math.floor(1e3*a*s),c="M400000 "+(h=l)+" H0 L"+h/2+" 0 l65 45 L145 "+(h-80)+" H400000z",m=new K([new J("phase",c)],{width:"400em",height:F(l/1e3),viewBox:"0 0 400000 "+l,preserveAspectRatio:"xMinYMin slice"});o=Ve.makeSvgSpan(["hide-tail"],[m],t),o.style.height=F(a),i=r.depth+e+n}else{/cancel/.test(n)?a||r.classes.push("cancel-pad"):"angl"===n?r.classes.push("anglpad"):r.classes.push("boxpad");let s=0,l=0,h=0;/box/.test(n)?(h=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),s=t.fontMetrics().fboxsep+("colorbox"===n?0:h),l=s):"angl"===n?(h=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),s=4*h,l=Math.max(0,.25-r.depth)):(s=a?.2:0,l=s),o=Bt(r,n,s,l,t),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=F(h)):"angl"===n&&.049!==h&&(o.style.borderTopWidth=F(h),o.style.borderRightWidth=F(h)),i=r.depth+l,e.backgroundColor&&(o.style.backgroundColor=e.backgroundColor,e.borderColor&&(o.style.borderColor=e.borderColor))}var h;let c;if(e.backgroundColor)c=Ve.makeVList({positionType:"individualShift",children:[{type:"elem",elem:o,shift:i},{type:"elem",elem:r,shift:0}]},t);else{const e=/cancel|phase/.test(n)?["svg-align"]:[];c=Ve.makeVList({positionType:"individualShift",children:[{type:"elem",elem:r,shift:0},{type:"elem",elem:o,shift:i,wrapperClasses:e}]},t)}return/cancel/.test(n)&&(c.height=r.height,c.depth=r.depth),/cancel/.test(n)&&!a?Ve.makeSpan(["mord","cancel-lap"],[c],t):Ve.makeSpan(["mord"],[c],t)},Mr=(e,t)=>{let r=0;const n=new gt.MathNode(e.label.indexOf("colorbox")>-1?"mpadded":"menclose",[vt(e.body,t)]);switch(e.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(r=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*r+"pt"),n.setAttribute("height","+"+2*r+"pt"),n.setAttribute("lspace",r+"pt"),n.setAttribute("voffset",r+"pt"),"\\fcolorbox"===e.label){const r=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);n.setAttribute("style","border: "+r+"em solid "+String(e.borderColor))}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return e.backgroundColor&&n.setAttribute("mathbackground",e.backgroundColor),n};je({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(e,t,r){let{parser:n,funcName:o}=e;const s=qt(t[0],"color-token").color,i=t[1];return{type:"enclose",mode:n.mode,label:o,backgroundColor:s,body:i}},htmlBuilder:Sr,mathmlBuilder:Mr}),je({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(e,t,r){let{parser:n,funcName:o}=e;const s=qt(t[0],"color-token").color,i=qt(t[1],"color-token").color,a=t[2];return{type:"enclose",mode:n.mode,label:o,backgroundColor:i,borderColor:s,body:a}},htmlBuilder:Sr,mathmlBuilder:Mr}),je({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\fbox",body:t[0]}}}),je({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}},htmlBuilder:Sr,mathmlBuilder:Mr}),je({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\angl",body:t[0]}}});const zr={};function Ar(e){let{type:t,names:r,props:n,handler:o,htmlBuilder:s,mathmlBuilder:i}=e;const a={type:t,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:o};for(let e=0;e{if(!e.parser.settings.displayMode)throw new n("{"+e.envName+"} can be used only in display mode.")};function Rr(e){if(-1===e.indexOf("ed"))return-1===e.indexOf("*")}function Hr(e,t,r){let{hskipBeforeAndAfter:o,addJot:s,cols:i,arraystretch:a,colSeparationType:l,autoTag:h,singleRow:c,emptySingleRow:m,maxNumCols:p,leqno:u}=t;if(e.gullet.beginGroup(),c||e.gullet.macros.set("\\cr","\\\\\\relax"),!a){const t=e.gullet.expandMacroAsText("\\arraystretch");if(null==t)a=1;else if(a=parseFloat(t),!a||a<0)throw new n("Invalid \\arraystretch: "+t)}e.gullet.beginGroup();let d=[];const g=[d],f=[],b=[],y=null!=h?[]:void 0;function x(){h&&e.gullet.macros.set("\\@eqnsw","1",!0)}function w(){y&&(e.gullet.macros.get("\\df@tag")?(y.push(e.subparse([new Nr("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(h)&&"1"===e.gullet.macros.get("\\@eqnsw")))}for(x(),b.push(qr(e));;){let t=e.parseExpression(!1,c?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup(),t={type:"ordgroup",mode:e.mode,body:t},r&&(t={type:"styling",mode:e.mode,style:r,body:[t]}),d.push(t);const o=e.fetch().text;if("&"===o){if(p&&d.length===p){if(c||l)throw new n("Too many tab characters: &",e.nextToken);e.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}e.consume()}else{if("\\end"===o){w(),1===d.length&&"styling"===t.type&&0===t.body[0].body.length&&(g.length>1||!m)&&g.pop(),b.length0&&(x+=.25),c.push({pos:x,isDashed:e[t]})}for(v(i[0]),r=0;r0&&(p+=y,le)))for(r=0;r=a)continue;(o>0||e.hskipBeforeAndAfter)&&(i=l.deflt(c.pregap,u),0!==i&&(z=Ve.makeSpan(["arraycolsep"],[]),z.style.width=F(i),M.push(z)));let d=[];for(r=0;r0){const e=Ve.makeLineSpan("hline",t,m),r=Ve.makeLineSpan("hdashline",t,m),n=[{type:"elem",elem:h,shift:0}];for(;c.length>0;){const t=c.pop(),o=t.pos-k;t.isDashed?n.push({type:"elem",elem:r,shift:o}):n.push({type:"elem",elem:e,shift:o})}h=Ve.makeVList({positionType:"individualShift",children:n},t)}if(0===T.length)return Ve.makeSpan(["mord"],[h],t);{let e=Ve.makeVList({positionType:"individualShift",children:T},t);return e=Ve.makeSpan(["tag"],[e],t),Ve.makeFragment([h,e])}},Lr={c:"center ",l:"left ",r:"right "},Dr=function(e,t){const r=[],n=new gt.MathNode("mtd",[],["mtr-glue"]),o=new gt.MathNode("mtd",[],["mml-eqn-num"]);for(let s=0;s0){const t=e.cols;let r="",n=!1,o=0,i=t.length;"separator"===t[0].type&&(a+="top ",o=1),"separator"===t[t.length-1].type&&(a+="bottom ",i-=1);for(let e=o;e0?"left ":"",a+=c[c.length-1].length>0?"right ":"";for(let e=1;e-1?"alignat":"align",s="split"===e.envName,i=Hr(e.parser,{cols:r,addJot:!0,autoTag:s?void 0:Rr(e.envName),emptySingleRow:!0,colSeparationType:o,maxNumCols:s?2:void 0,leqno:e.parser.settings.leqno},"display");let a,l=0;const h={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&"ordgroup"===t[0].type){let e="";for(let r=0;r0&&c&&(n=1),r[e]={type:"align",align:t,pregap:n,postgap:0}}return i.colSeparationType=c?"align":"alignat",i};Ar({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){const r=(Rt(t[0])?[t[0]]:qt(t[0],"ordgroup").body).map((function(e){const t=It(e).text;if(-1!=="lcr".indexOf(t))return{type:"align",align:t};if("|"===t)return{type:"separator",separator:"|"};if(":"===t)return{type:"separator",separator:":"};throw new n("Unknown column alignment: "+t,e)})),o={cols:r,hskipBeforeAndAfter:!0,maxNumCols:r.length};return Hr(e.parser,o,Or(e.envName))},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){const t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")];let r="c";const o={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if("*"===e.envName.charAt(e.envName.length-1)){const t=e.parser;if(t.consumeSpaces(),"["===t.fetch().text){if(t.consume(),t.consumeSpaces(),r=t.fetch().text,-1==="lcr".indexOf(r))throw new n("Expected l or c or r",t.nextToken);t.consume(),t.consumeSpaces(),t.expect("]"),t.consume(),o.cols=[{type:"align",align:r}]}}const s=Hr(e.parser,o,Or(e.envName)),i=Math.max(0,...s.body.map((e=>e.length)));return s.cols=new Array(i).fill({type:"align",align:r}),t?{type:"leftright",mode:e.mode,body:[s],left:t[0],right:t[1],rightColor:void 0}:s},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=Hr(e.parser,{arraystretch:.5},"script");return t.colSeparationType="small",t},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){const r=(Rt(t[0])?[t[0]]:qt(t[0],"ordgroup").body).map((function(e){const t=It(e).text;if(-1!=="lc".indexOf(t))return{type:"align",align:t};throw new n("Unknown column alignment: "+t,e)}));if(r.length>1)throw new n("{subarray} can contain only one column");let o={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5};if(o=Hr(e.parser,o,"script"),o.body.length>0&&o.body[0].length>1)throw new n("{subarray} can contain only one column");return o},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=Hr(e.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},Or(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.indexOf("r")>-1?".":"\\{",right:e.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:Vr,htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){l.contains(["gather","gather*"],e.envName)&&Ir(e);const t={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:Rr(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Hr(e.parser,t,"display")},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:Vr,htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Ir(e);const t={autoTag:Rr(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return Hr(e.parser,t,"display")},htmlBuilder:Er,mathmlBuilder:Dr}),Ar({type:"array",names:["CD"],props:{numArgs:0},handler(e){return Ir(e),function(e){const t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();const r=e.fetch().text;if("&"!==r&&"\\\\"!==r){if("\\end"===r){0===t[t.length-1].length&&t.pop();break}throw new n("Expected \\\\ or \\cr or \\end",e.nextToken)}e.consume()}let r=[];const o=[r];for(let a=0;a-1);else{if(!("<>AV".indexOf(o)>-1))throw new n('Expected one of "<>AV=|." after @',l[t]);for(let e=0;e<2;e++){let r=!0;for(let h=t+1;h{const r=e.font,n=t.withFont(r);return ht(e.body,n)},Gr=(e,t)=>{const r=e.font,n=t.withFont(r);return vt(e.body,n)},Ur={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};je({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=Ze(t[0]);let s=n;return s in Ur&&(s=Ur[s]),{type:"font",mode:r.mode,font:s.slice(1),body:o}},htmlBuilder:Fr,mathmlBuilder:Gr}),je({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(e,t)=>{let{parser:r}=e;const n=t[0],o=l.isCharacterBox(n);return{type:"mclass",mode:r.mode,mclass:Ft(n),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:n}],isCharacterBox:o}}}),je({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(e,t)=>{let{parser:r,funcName:n,breakOnTokenText:o}=e;const{mode:s}=r,i=r.parseExpression(!0,o);return{type:"font",mode:s,font:"math"+n.slice(1),body:{type:"ordgroup",mode:r.mode,body:i}}},htmlBuilder:Fr,mathmlBuilder:Gr});const Yr=(e,t)=>{let r=t;return"display"===e?r=r.id>=w.SCRIPT.id?r.text():w.DISPLAY:"text"===e&&r.size===w.DISPLAY.size?r=w.TEXT:"script"===e?r=w.SCRIPT:"scriptscript"===e&&(r=w.SCRIPTSCRIPT),r},Xr=(e,t)=>{const r=Yr(e.size,t.style),n=r.fracNum(),o=r.fracDen();let s;s=t.havingStyle(n);const i=ht(e.numer,s,t);if(e.continued){const e=8.5/t.fontMetrics().ptPerEm,r=3.5/t.fontMetrics().ptPerEm;i.height=i.height0?3*c:7*c,u=t.fontMetrics().denom1):(h>0?(m=t.fontMetrics().num2,p=c):(m=t.fontMetrics().num3,p=3*c),u=t.fontMetrics().denom2),l){const e=t.fontMetrics().axisHeight;m-i.depth-(e+.5*h){let r=new gt.MathNode("mfrac",[vt(e.numer,t),vt(e.denom,t)]);if(e.hasBarLine){if(e.barSize){const n=P(e.barSize,t);r.setAttribute("linethickness",F(n))}}else r.setAttribute("linethickness","0px");const n=Yr(e.size,t.style);if(n.size!==t.style.size){r=new gt.MathNode("mstyle",[r]);const e=n.size===w.DISPLAY.size?"true":"false";r.setAttribute("displaystyle",e),r.setAttribute("scriptlevel","0")}if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new gt.MathNode("mo",[new gt.TextNode(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(r),null!=e.rightDelim){const r=new gt.MathNode("mo",[new gt.TextNode(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}return bt(t)}return r};je({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=t[1];let i,a=null,l=null,h="auto";switch(n){case"\\dfrac":case"\\frac":case"\\tfrac":i=!0;break;case"\\\\atopfrac":i=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i=!1,a="(",l=")";break;case"\\\\bracefrac":i=!1,a="\\{",l="\\}";break;case"\\\\brackfrac":i=!1,a="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}switch(n){case"\\dfrac":case"\\dbinom":h="display";break;case"\\tfrac":case"\\tbinom":h="text"}return{type:"genfrac",mode:r.mode,continued:!1,numer:o,denom:s,hasBarLine:i,leftDelim:a,rightDelim:l,size:h,barSize:null}},htmlBuilder:Xr,mathmlBuilder:Wr}),je({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=t[1];return{type:"genfrac",mode:r.mode,continued:!0,numer:o,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}}),je({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(e){let t,{parser:r,funcName:n,token:o}=e;switch(n){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;case"\\brace":t="\\\\bracefrac";break;case"\\brack":t="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:t,token:o}}});const _r=["display","text","script","scriptscript"],jr=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};je({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(e,t){let{parser:r}=e;const n=t[4],o=t[5],s=Ze(t[0]),i="atom"===s.type&&"open"===s.family?jr(s.text):null,a=Ze(t[1]),l="atom"===a.type&&"close"===a.family?jr(a.text):null,h=qt(t[2],"size");let c,m=null;h.isBlank?c=!0:(m=h.value,c=m.number>0);let p="auto",u=t[3];if("ordgroup"===u.type){if(u.body.length>0){const e=qt(u.body[0],"textord");p=_r[Number(e.text)]}}else u=qt(u,"textord"),p=_r[Number(u.text)];return{type:"genfrac",mode:r.mode,numer:n,denom:o,continued:!1,hasBarLine:c,barSize:m,leftDelim:i,rightDelim:l,size:p}},htmlBuilder:Xr,mathmlBuilder:Wr}),je({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(e,t){let{parser:r,funcName:n,token:o}=e;return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:qt(t[0],"size").value,token:o}}}),je({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e}(qt(t[1],"infix").size),i=t[2],a=s.number>0;return{type:"genfrac",mode:r.mode,numer:o,denom:i,continued:!1,hasBarLine:a,barSize:s,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:Xr,mathmlBuilder:Wr});const $r=(e,t)=>{const r=t.style;let n,o;"supsub"===e.type?(n=e.sup?ht(e.sup,t.havingStyle(r.sup()),t):ht(e.sub,t.havingStyle(r.sub()),t),o=qt(e.base,"horizBrace")):o=qt(e,"horizBrace");const s=ht(o.base,t.havingBaseStyle(w.DISPLAY)),i=Nt(o,t);let a;if(o.isOver?(a=Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:i}]},t),a.children[0].children[0].children[1].classes.push("svg-align")):(a=Ve.makeVList({positionType:"bottom",positionData:s.depth+.1+i.height,children:[{type:"elem",elem:i},{type:"kern",size:.1},{type:"elem",elem:s}]},t),a.children[0].children[0].children[0].classes.push("svg-align")),n){const e=Ve.makeSpan(["mord",o.isOver?"mover":"munder"],[a],t);a=o.isOver?Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"kern",size:.2},{type:"elem",elem:n}]},t):Ve.makeVList({positionType:"bottom",positionData:e.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:e}]},t)}return Ve.makeSpan(["mord",o.isOver?"mover":"munder"],[a],t)};je({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;return{type:"horizBrace",mode:r.mode,label:n,isOver:/^\\over/.test(n),base:t[0]}},htmlBuilder:$r,mathmlBuilder:(e,t)=>{const r=Ct(e.label);return new gt.MathNode(e.isOver?"mover":"munder",[vt(e.base,t),r])}}),je({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[1],o=qt(t[0],"url").url;return r.settings.isTrusted({command:"\\href",url:o})?{type:"href",mode:r.mode,href:o,body:Ke(n)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(e,t)=>{const r=nt(e.body,t,!1);return Ve.makeAnchor(e.href,[],r,t)},mathmlBuilder:(e,t)=>{let r=wt(e.body,t);return r instanceof ut||(r=new ut("mrow",[r])),r.setAttribute("href",e.href),r}}),je({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=qt(t[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:n}))return r.formatUnsupportedCmd("\\url");const o=[];for(let e=0;e{let{parser:r,funcName:o,token:s}=e;const i=qt(t[0],"raw").string,a=t[1];let l;r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");const h={};switch(o){case"\\htmlClass":h.class=i,l={command:"\\htmlClass",class:i};break;case"\\htmlId":h.id=i,l={command:"\\htmlId",id:i};break;case"\\htmlStyle":h.style=i,l={command:"\\htmlStyle",style:i};break;case"\\htmlData":{const e=i.split(",");for(let t=0;t{const r=nt(e.body,t,!1),n=["enclosing"];e.attributes.class&&n.push(...e.attributes.class.trim().split(/\s+/));const o=Ve.makeSpan(n,r,t);for(const t in e.attributes)"class"!==t&&e.attributes.hasOwnProperty(t)&&o.setAttribute(t,e.attributes[t]);return o},mathmlBuilder:(e,t)=>wt(e.body,t)}),je({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;return{type:"htmlmathml",mode:r.mode,html:Ke(t[0]),mathml:Ke(t[1])}},htmlBuilder:(e,t)=>{const r=nt(e.html,t,!1);return Ve.makeFragment(r)},mathmlBuilder:(e,t)=>wt(e.mathml,t)});const Zr=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{const t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new n("Invalid size: '"+e+"' in \\includegraphics");const r={number:+(t[1]+t[2]),unit:t[3]};if(!V(r))throw new n("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};je({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(e,t,r)=>{let{parser:o}=e,s={number:0,unit:"em"},i={number:.9,unit:"em"},a={number:0,unit:"em"},l="";if(r[0]){const e=qt(r[0],"raw").string.split(",");for(let t=0;t{const r=P(e.height,t);let n=0;e.totalheight.number>0&&(n=P(e.totalheight,t)-r);let o=0;e.width.number>0&&(o=P(e.width,t));const s={height:F(r+n)};o>0&&(s.width=F(o)),n>0&&(s.verticalAlign=F(-n));const i=new j(e.src,e.alt,s);return i.height=r,i.depth=n,i},mathmlBuilder:(e,t)=>{const r=new gt.MathNode("mglyph",[]);r.setAttribute("alt",e.alt);const n=P(e.height,t);let o=0;if(e.totalheight.number>0&&(o=P(e.totalheight,t)-n,r.setAttribute("valign",F(-o))),r.setAttribute("height",F(n+o)),e.width.number>0){const n=P(e.width,t);r.setAttribute("width",F(n))}return r.setAttribute("src",e.src),r}}),je({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=qt(t[0],"size");if(r.settings.strict){const e="m"===n[1],t="mu"===o.value.unit;e?(t||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, not "+o.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):t&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:o.value}},htmlBuilder(e,t){return Ve.makeGlue(e.dimension,t)},mathmlBuilder(e,t){const r=P(e.dimension,t);return new gt.SpaceNode(r)}}),je({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"lap",mode:r.mode,alignment:n.slice(5),body:o}},htmlBuilder:(e,t)=>{let r;"clap"===e.alignment?(r=Ve.makeSpan([],[ht(e.body,t)]),r=Ve.makeSpan(["inner"],[r],t)):r=Ve.makeSpan(["inner"],[ht(e.body,t)]);const n=Ve.makeSpan(["fix"],[]);let o=Ve.makeSpan([e.alignment],[r,n],t);const s=Ve.makeSpan(["strut"]);return s.style.height=F(o.height+o.depth),o.depth&&(s.style.verticalAlign=F(-o.depth)),o.children.unshift(s),o=Ve.makeSpan(["thinbox"],[o],t),Ve.makeSpan(["mord","vbox"],[o],t)},mathmlBuilder:(e,t)=>{const r=new gt.MathNode("mpadded",[vt(e.body,t)]);if("rlap"!==e.alignment){const t="llap"===e.alignment?"-1":"-0.5";r.setAttribute("lspace",t+"width")}return r.setAttribute("width","0px"),r}}),je({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){let{funcName:r,parser:n}=e;const o=n.mode;n.switchMode("math");const s="\\("===r?"\\)":"$",i=n.parseExpression(!1,s);return n.expect(s),n.switchMode(o),{type:"styling",mode:n.mode,style:"text",body:i}}}),je({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new n("Mismatched "+e.funcName)}});const Kr=(e,t)=>{switch(t.style.size){case w.DISPLAY.size:return e.display;case w.TEXT.size:return e.text;case w.SCRIPT.size:return e.script;case w.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};je({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(e,t)=>{let{parser:r}=e;return{type:"mathchoice",mode:r.mode,display:Ke(t[0]),text:Ke(t[1]),script:Ke(t[2]),scriptscript:Ke(t[3])}},htmlBuilder:(e,t)=>{const r=Kr(e,t),n=nt(r,t,!1);return Ve.makeFragment(n)},mathmlBuilder:(e,t)=>{const r=Kr(e,t);return wt(r,t)}});const Jr=(e,t,r,n,o,s,i)=>{e=Ve.makeSpan([],[e]);const a=r&&l.isCharacterBox(r);let h,c,m;if(t){const e=ht(t,n.havingStyle(o.sup()),n);c={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-e.depth)}}if(r){const e=ht(r,n.havingStyle(o.sub()),n);h={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-e.height)}}if(c&&h){const t=n.fontMetrics().bigOpSpacing5+h.elem.height+h.elem.depth+h.kern+e.depth+i;m=Ve.makeVList({positionType:"bottom",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:h.elem,marginLeft:F(-s)},{type:"kern",size:h.kern},{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:F(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else if(h){const t=e.height-i;m=Ve.makeVList({positionType:"top",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:h.elem,marginLeft:F(-s)},{type:"kern",size:h.kern},{type:"elem",elem:e}]},n)}else{if(!c)return e;{const t=e.depth+i;m=Ve.makeVList({positionType:"bottom",positionData:t,children:[{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:F(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}}const p=[m];if(h&&0!==s&&!a){const e=Ve.makeSpan(["mspace"],[],n);e.style.marginRight=F(s),p.unshift(e)}return Ve.makeSpan(["mop","op-limits"],p,n)},Qr=["\\smallint"],en=(e,t)=>{let r,n,o,s=!1;"supsub"===e.type?(r=e.sup,n=e.sub,o=qt(e.base,"op"),s=!0):o=qt(e,"op");const i=t.style;let a,h=!1;if(i.size===w.DISPLAY.size&&o.symbol&&!l.contains(Qr,o.name)&&(h=!0),o.symbol){const e=h?"Size2-Regular":"Size1-Regular";let r="";if("\\oiint"!==o.name&&"\\oiiint"!==o.name||(r=o.name.slice(1),o.name="oiint"===r?"\\iint":"\\iiint"),a=Ve.makeSymbol(o.name,e,"math",t,["mop","op-symbol",h?"large-op":"small-op"]),r.length>0){const e=a.italic,n=Ve.staticSvg(r+"Size"+(h?"2":"1"),t);a=Ve.makeVList({positionType:"individualShift",children:[{type:"elem",elem:a,shift:0},{type:"elem",elem:n,shift:h?.08:0}]},t),o.name="\\"+r,a.classes.unshift("mop"),a.italic=e}}else if(o.body){const e=nt(o.body,t,!0);1===e.length&&e[0]instanceof Z?(a=e[0],a.classes[0]="mop"):a=Ve.makeSpan(["mop"],e,t)}else{const e=[];for(let r=1;r{let r;if(e.symbol)r=new ut("mo",[ft(e.name,e.mode)]),l.contains(Qr,e.name)&&r.setAttribute("largeop","false");else if(e.body)r=new ut("mo",xt(e.body,t));else{r=new ut("mi",[new dt(e.name.slice(1))]);const t=new ut("mo",[ft("\u2061","text")]);r=e.parentIsSupSub?new ut("mrow",[r,t]):pt([r,t])}return r},rn={"\u220f":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22c0":"\\bigwedge","\u22c1":"\\bigvee","\u22c2":"\\bigcap","\u22c3":"\\bigcup","\u2a00":"\\bigodot","\u2a01":"\\bigoplus","\u2a02":"\\bigotimes","\u2a04":"\\biguplus","\u2a06":"\\bigsqcup"};je({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","\u220f","\u2210","\u2211","\u22c0","\u22c1","\u22c2","\u22c3","\u2a00","\u2a01","\u2a02","\u2a04","\u2a06"],props:{numArgs:0},handler:(e,t)=>{let{parser:r,funcName:n}=e,o=n;return 1===o.length&&(o=rn[o]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:o}},htmlBuilder:en,mathmlBuilder:tn}),je({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:Ke(n)}},htmlBuilder:en,mathmlBuilder:tn});const nn={"\u222b":"\\int","\u222c":"\\iint","\u222d":"\\iiint","\u222e":"\\oint","\u222f":"\\oiint","\u2230":"\\oiiint"};je({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:en,mathmlBuilder:tn}),je({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:en,mathmlBuilder:tn}),je({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222b","\u222c","\u222d","\u222e","\u222f","\u2230"],props:{numArgs:0},handler(e){let{parser:t,funcName:r}=e,n=r;return 1===n.length&&(n=nn[n]),{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:en,mathmlBuilder:tn});const on=(e,t)=>{let r,n,o,s,i=!1;if("supsub"===e.type?(r=e.sup,n=e.sub,o=qt(e.base,"operatorname"),i=!0):o=qt(e,"operatorname"),o.body.length>0){const e=o.body.map((e=>{const t=e.text;return"string"==typeof t?{type:"textord",mode:e.mode,text:t}:e})),r=nt(e,t.withFont("mathrm"),!0);for(let e=0;e{let{parser:r,funcName:n}=e;const o=t[0];return{type:"operatorname",mode:r.mode,body:Ke(o),alwaysHandleSupSub:"\\operatornamewithlimits"===n,limits:!1,parentIsSupSub:!1}},htmlBuilder:on,mathmlBuilder:(e,t)=>{let r=xt(e.body,t.withFont("mathrm")),n=!0;for(let e=0;ee.toText())).join("");r=[new gt.TextNode(e)]}const o=new gt.MathNode("mi",r);o.setAttribute("mathvariant","normal");const s=new gt.MathNode("mo",[ft("\u2061","text")]);return e.parentIsSupSub?new gt.MathNode("mrow",[o,s]):gt.newDocumentFragment([o,s])}}),Br("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),$e({type:"ordgroup",htmlBuilder(e,t){return e.semisimple?Ve.makeFragment(nt(e.body,t,!1)):Ve.makeSpan(["mord"],nt(e.body,t,!0),t)},mathmlBuilder(e,t){return wt(e.body,t,!0)}}),je({type:"overline",names:["\\overline"],props:{numArgs:1},handler(e,t){let{parser:r}=e;const n=t[0];return{type:"overline",mode:r.mode,body:n}},htmlBuilder(e,t){const r=ht(e.body,t.havingCrampedStyle()),n=Ve.makeLineSpan("overline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*o},{type:"elem",elem:n},{type:"kern",size:o}]},t);return Ve.makeSpan(["mord","overline"],[s],t)},mathmlBuilder(e,t){const r=new gt.MathNode("mo",[new gt.TextNode("\u203e")]);r.setAttribute("stretchy","true");const n=new gt.MathNode("mover",[vt(e.body,t),r]);return n.setAttribute("accent","true"),n}}),je({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"phantom",mode:r.mode,body:Ke(n)}},htmlBuilder:(e,t)=>{const r=nt(e.body,t.withPhantom(),!1);return Ve.makeFragment(r)},mathmlBuilder:(e,t)=>{const r=xt(e.body,t);return new gt.MathNode("mphantom",r)}}),je({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"hphantom",mode:r.mode,body:n}},htmlBuilder:(e,t)=>{let r=Ve.makeSpan([],[ht(e.body,t.withPhantom())]);if(r.height=0,r.depth=0,r.children)for(let e=0;e{const r=xt(Ke(e.body),t),n=new gt.MathNode("mphantom",r),o=new gt.MathNode("mpadded",[n]);return o.setAttribute("height","0px"),o.setAttribute("depth","0px"),o}}),je({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"vphantom",mode:r.mode,body:n}},htmlBuilder:(e,t)=>{const r=Ve.makeSpan(["inner"],[ht(e.body,t.withPhantom())]),n=Ve.makeSpan(["fix"],[]);return Ve.makeSpan(["mord","rlap"],[r,n],t)},mathmlBuilder:(e,t)=>{const r=xt(Ke(e.body),t),n=new gt.MathNode("mphantom",r),o=new gt.MathNode("mpadded",[n]);return o.setAttribute("width","0px"),o}}),je({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(e,t){let{parser:r}=e;const n=qt(t[0],"size").value,o=t[1];return{type:"raisebox",mode:r.mode,dy:n,body:o}},htmlBuilder(e,t){const r=ht(e.body,t),n=P(e.dy,t);return Ve.makeVList({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]},t)},mathmlBuilder(e,t){const r=new gt.MathNode("mpadded",[vt(e.body,t)]),n=e.dy.number+e.dy.unit;return r.setAttribute("voffset",n),r}}),je({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler(e){let{parser:t}=e;return{type:"internal",mode:t.mode}}}),je({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler(e,t,r){let{parser:n}=e;const o=r[0],s=qt(t[0],"size"),i=qt(t[1],"size");return{type:"rule",mode:n.mode,shift:o&&qt(o,"size").value,width:s.value,height:i.value}},htmlBuilder(e,t){const r=Ve.makeSpan(["mord","rule"],[],t),n=P(e.width,t),o=P(e.height,t),s=e.shift?P(e.shift,t):0;return r.style.borderRightWidth=F(n),r.style.borderTopWidth=F(o),r.style.bottom=F(s),r.width=n,r.height=o+s,r.depth=-s,r.maxFontSize=1.125*o*t.sizeMultiplier,r},mathmlBuilder(e,t){const r=P(e.width,t),n=P(e.height,t),o=e.shift?P(e.shift,t):0,s=t.color&&t.getColor()||"black",i=new gt.MathNode("mspace");i.setAttribute("mathbackground",s),i.setAttribute("width",F(r)),i.setAttribute("height",F(n));const a=new gt.MathNode("mpadded",[i]);return o>=0?a.setAttribute("height",F(o)):(a.setAttribute("height",F(o)),a.setAttribute("depth",F(-o))),a.setAttribute("voffset",F(o)),a}});const an=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];je({type:"sizing",names:an,props:{numArgs:0,allowedInText:!0},handler:(e,t)=>{let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!1,r);return{type:"sizing",mode:o.mode,size:an.indexOf(n)+1,body:s}},htmlBuilder:(e,t)=>{const r=t.havingSize(e.size);return sn(e.body,r,t)},mathmlBuilder:(e,t)=>{const r=t.havingSize(e.size),n=xt(e.body,r),o=new gt.MathNode("mstyle",n);return o.setAttribute("mathsize",F(r.sizeMultiplier)),o}}),je({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(e,t,r)=>{let{parser:n}=e,o=!1,s=!1;const i=r[0]&&qt(r[0],"ordgroup");if(i){let e="";for(let t=0;t{const r=Ve.makeSpan([],[ht(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return r;if(e.smashHeight&&(r.height=0,r.children))for(let e=0;e{const r=new gt.MathNode("mpadded",[vt(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),je({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(e,t,r){let{parser:n}=e;const o=r[0],s=t[0];return{type:"sqrt",mode:n.mode,body:s,index:o}},htmlBuilder(e,t){let r=ht(e.body,t.havingCrampedStyle());0===r.height&&(r.height=t.fontMetrics().xHeight),r=Ve.wrapFragment(r,t);const n=t.fontMetrics().defaultRuleThickness;let o=n;t.style.idr.height+r.depth+s&&(s=(s+c-r.height-r.depth)/2);const m=a.height-r.height-s-l;r.style.paddingLeft=F(h);const p=Ve.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+m)},{type:"elem",elem:a},{type:"kern",size:l}]},t);if(e.index){const r=t.havingStyle(w.SCRIPTSCRIPT),n=ht(e.index,r,t),o=.6*(p.height-p.depth),s=Ve.makeVList({positionType:"shift",positionData:-o,children:[{type:"elem",elem:n}]},t),i=Ve.makeSpan(["root"],[s]);return Ve.makeSpan(["mord","sqrt"],[i,p],t)}return Ve.makeSpan(["mord","sqrt"],[p],t)},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new gt.MathNode("mroot",[vt(r,t),vt(n,t)]):new gt.MathNode("msqrt",[vt(r,t)])}});const ln={display:w.DISPLAY,text:w.TEXT,script:w.SCRIPT,scriptscript:w.SCRIPTSCRIPT};je({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e,t){let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!0,r),i=n.slice(1,n.length-5);return{type:"styling",mode:o.mode,style:i,body:s}},htmlBuilder(e,t){const r=ln[e.style],n=t.havingStyle(r).withFont("");return sn(e.body,n,t)},mathmlBuilder(e,t){const r=ln[e.style],n=t.havingStyle(r),o=xt(e.body,n),s=new gt.MathNode("mstyle",o),i={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[e.style];return s.setAttribute("scriptlevel",i[0]),s.setAttribute("displaystyle",i[1]),s}});$e({type:"supsub",htmlBuilder(e,t){const r=function(e,t){const r=e.base;if(r)return"op"===r.type?r.limits&&(t.style.size===w.DISPLAY.size||r.alwaysHandleSupSub)?en:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(t.style.size===w.DISPLAY.size||r.limits)?on:null:"accent"===r.type?l.isCharacterBox(r.base)?Ht:null:"horizBrace"===r.type&&!e.sub===r.isOver?$r:null;return null}(e,t);if(r)return r(e,t);const{base:n,sup:o,sub:s}=e,i=ht(n,t);let a,h;const c=t.fontMetrics();let m=0,p=0;const u=n&&l.isCharacterBox(n);if(o){const e=t.havingStyle(t.style.sup());a=ht(o,e,t),u||(m=i.height-e.fontMetrics().supDrop*e.sizeMultiplier/t.sizeMultiplier)}if(s){const e=t.havingStyle(t.style.sub());h=ht(s,e,t),u||(p=i.depth+e.fontMetrics().subDrop*e.sizeMultiplier/t.sizeMultiplier)}let d;d=t.style===w.DISPLAY?c.sup1:t.style.cramped?c.sup3:c.sup2;const g=t.sizeMultiplier,f=F(.5/c.ptPerEm/g);let b,y=null;if(h){const t=e.base&&"op"===e.base.type&&e.base.name&&("\\oiint"===e.base.name||"\\oiiint"===e.base.name);(i instanceof Z||t)&&(y=F(-i.italic))}if(a&&h){m=Math.max(m,d,a.depth+.25*c.xHeight),p=Math.max(p,c.sub2);const e=4*c.defaultRuleThickness;if(m-a.depth-(h.height-p)0&&(m+=t,p-=t)}const r=[{type:"elem",elem:h,shift:p,marginRight:f,marginLeft:y},{type:"elem",elem:a,shift:-m,marginRight:f}];b=Ve.makeVList({positionType:"individualShift",children:r},t)}else if(h){p=Math.max(p,c.sub1,h.height-.8*c.xHeight);const e=[{type:"elem",elem:h,marginLeft:y,marginRight:f}];b=Ve.makeVList({positionType:"shift",positionData:p,children:e},t)}else{if(!a)throw new Error("supsub must have either sup or sub.");m=Math.max(m,d,a.depth+.25*c.xHeight),b=Ve.makeVList({positionType:"shift",positionData:-m,children:[{type:"elem",elem:a,marginRight:f}]},t)}const x=at(i,"right")||"mord";return Ve.makeSpan([x],[i,Ve.makeSpan(["msupsub"],[b])],t)},mathmlBuilder(e,t){let r,n,o=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0);const s=[vt(e.base,t)];let i;if(e.sub&&s.push(vt(e.sub,t)),e.sup&&s.push(vt(e.sup,t)),o)i=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;i=r&&"op"===r.type&&r.limits&&t.style===w.DISPLAY||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.style===w.DISPLAY||r.limits)?"munderover":"msubsup"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===w.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===w.DISPLAY)?"munder":"msub"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===w.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===w.DISPLAY)?"mover":"msup"}return new gt.MathNode(i,s)}}),$e({type:"atom",htmlBuilder(e,t){return Ve.mathsym(e.text,e.mode,t,["m"+e.family])},mathmlBuilder(e,t){const r=new gt.MathNode("mo",[ft(e.text,e.mode)]);if("bin"===e.family){const n=yt(e,t);"bold-italic"===n&&r.setAttribute("mathvariant",n)}else"punct"===e.family?r.setAttribute("separator","true"):"open"!==e.family&&"close"!==e.family||r.setAttribute("stretchy","false");return r}});const hn={mi:"italic",mn:"normal",mtext:"normal"};$e({type:"mathord",htmlBuilder(e,t){return Ve.makeOrd(e,t,"mathord")},mathmlBuilder(e,t){const r=new gt.MathNode("mi",[ft(e.text,e.mode,t)]),n=yt(e,t)||"italic";return n!==hn[r.type]&&r.setAttribute("mathvariant",n),r}}),$e({type:"textord",htmlBuilder(e,t){return Ve.makeOrd(e,t,"textord")},mathmlBuilder(e,t){const r=ft(e.text,e.mode,t),n=yt(e,t)||"normal";let o;return o="text"===e.mode?new gt.MathNode("mtext",[r]):/[0-9]/.test(e.text)?new gt.MathNode("mn",[r]):"\\prime"===e.text?new gt.MathNode("mo",[r]):new gt.MathNode("mi",[r]),n!==hn[o.type]&&o.setAttribute("mathvariant",n),o}});const cn={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},mn={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};$e({type:"spacing",htmlBuilder(e,t){if(mn.hasOwnProperty(e.text)){const r=mn[e.text].className||"";if("text"===e.mode){const n=Ve.makeOrd(e,t,"textord");return n.classes.push(r),n}return Ve.makeSpan(["mspace",r],[Ve.mathsym(e.text,e.mode,t)],t)}if(cn.hasOwnProperty(e.text))return Ve.makeSpan(["mspace",cn[e.text]],[],t);throw new n('Unknown type of space "'+e.text+'"')},mathmlBuilder(e,t){let r;if(!mn.hasOwnProperty(e.text)){if(cn.hasOwnProperty(e.text))return new gt.MathNode("mspace");throw new n('Unknown type of space "'+e.text+'"')}return r=new gt.MathNode("mtext",[new gt.TextNode("\xa0")]),r}});const pn=()=>{const e=new gt.MathNode("mtd",[]);return e.setAttribute("width","50%"),e};$e({type:"tag",mathmlBuilder(e,t){const r=new gt.MathNode("mtable",[new gt.MathNode("mtr",[pn(),new gt.MathNode("mtd",[wt(e.body,t)]),pn(),new gt.MathNode("mtd",[wt(e.tag,t)])])]);return r.setAttribute("width","100%"),r}});const un={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},dn={"\\textbf":"textbf","\\textmd":"textmd"},gn={"\\textit":"textit","\\textup":"textup"},fn=(e,t)=>{const r=e.font;return r?un[r]?t.withTextFontFamily(un[r]):dn[r]?t.withTextFontWeight(dn[r]):t.withTextFontShape(gn[r]):t};je({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"text",mode:r.mode,body:Ke(o),font:n}},htmlBuilder(e,t){const r=fn(e,t),n=nt(e.body,r,!0);return Ve.makeSpan(["mord","text"],n,r)},mathmlBuilder(e,t){const r=fn(e,t);return wt(e.body,r)}}),je({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"underline",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=ht(e.body,t),n=Ve.makeLineSpan("underline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ve.makeVList({positionType:"top",positionData:r.height,children:[{type:"kern",size:o},{type:"elem",elem:n},{type:"kern",size:3*o},{type:"elem",elem:r}]},t);return Ve.makeSpan(["mord","underline"],[s],t)},mathmlBuilder(e,t){const r=new gt.MathNode("mo",[new gt.TextNode("\u203e")]);r.setAttribute("stretchy","true");const n=new gt.MathNode("munder",[vt(e.body,t),r]);return n.setAttribute("accentunder","true"),n}}),je({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(e,t){let{parser:r}=e;return{type:"vcenter",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=ht(e.body,t),n=t.fontMetrics().axisHeight,o=.5*(r.height-n-(r.depth+n));return Ve.makeVList({positionType:"shift",positionData:o,children:[{type:"elem",elem:r}]},t)},mathmlBuilder(e,t){return new gt.MathNode("mpadded",[vt(e.body,t)],["vcenter"])}}),je({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(e,t,r){throw new n("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(e,t){const r=bn(e),n=[],o=t.havingStyle(t.style.text());for(let t=0;te.body.replace(/ /g,e.star?"\u2423":"\xa0");var yn=Xe;const xn="[ \r\n\t]",wn="(\\\\[a-zA-Z@]+)"+xn+"*",vn="[\u0300-\u036f]",kn=new RegExp(vn+"+$"),Sn="("+xn+"+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-\u2027\u202a-\ud7ff\uf900-\uffff]"+vn+"*|[\ud800-\udbff][\udc00-\udfff]"+vn+"*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|"+wn+"|\\\\[^\ud800-\udfff])";class Mn{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Sn,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){const e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Nr("EOF",new Cr(this,t,t));const r=this.tokenRegex.exec(e);if(null===r||r.index!==t)throw new n("Unexpected character: '"+e[t]+"'",new Nr(e[t],new Cr(this,t,t+1)));const o=r[6]||r[3]||(r[2]?"\\ ":" ");if(14===this.catcodes[o]){const t=e.indexOf("\n",this.tokenRegex.lastIndex);return-1===t?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=t+1,this.lex()}return new Nr(o,new Cr(this,t,this.tokenRegex.lastIndex))}}class zn{constructor(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new n("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");const e=this.undefStack.pop();for(const t in e)e.hasOwnProperty(t)&&(null==e[t]?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,r){if(void 0===r&&(r=!1),r){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{const t=this.undefStack[this.undefStack.length-1];t&&!t.hasOwnProperty(e)&&(t[e]=this.current[e])}null==t?delete this.current[e]:this.current[e]=t}}var An=Tr;Br("\\noexpand",(function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}})),Br("\\expandafter",(function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}})),Br("\\@firstoftwo",(function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}})),Br("\\@secondoftwo",(function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}})),Br("\\@ifnextchar",(function(e){const t=e.consumeArgs(3);e.consumeSpaces();const r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}})),Br("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Br("\\TextOrMath",(function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}}));const Tn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Br("\\char",(function(e){let t,r=e.popToken(),o="";if("'"===r.text)t=8,r=e.popToken();else if('"'===r.text)t=16,r=e.popToken();else if("`"===r.text)if(r=e.popToken(),"\\"===r.text[0])o=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new n("\\char` missing argument");o=r.text.charCodeAt(0)}else t=10;if(t){if(o=Tn[r.text],null==o||o>=t)throw new n("Invalid base-"+t+" digit "+r.text);let s;for(;null!=(s=Tn[e.future().text])&&s{let o=e.consumeArg().tokens;if(1!==o.length)throw new n("\\newcommand's first argument must be a macro name");const s=o[0].text,i=e.isDefined(s);if(i&&!t)throw new n("\\newcommand{"+s+"} attempting to redefine "+s+"; use \\renewcommand");if(!i&&!r)throw new n("\\renewcommand{"+s+"} when command "+s+" does not yet exist; use \\newcommand");let a=0;if(o=e.consumeArg().tokens,1===o.length&&"["===o[0].text){let t="",r=e.expandNextToken();for(;"]"!==r.text&&"EOF"!==r.text;)t+=r.text,r=e.expandNextToken();if(!t.match(/^\s*[0-9]+\s*$/))throw new n("Invalid number of arguments: "+t);a=parseInt(t),o=e.consumeArg().tokens}return e.macros.set(s,{tokens:o,numArgs:a}),""};Br("\\newcommand",(e=>Bn(e,!1,!0))),Br("\\renewcommand",(e=>Bn(e,!0,!1))),Br("\\providecommand",(e=>Bn(e,!0,!0))),Br("\\message",(e=>{const t=e.consumeArgs(1)[0];return console.log(t.reverse().map((e=>e.text)).join("")),""})),Br("\\errmessage",(e=>{const t=e.consumeArgs(1)[0];return console.error(t.reverse().map((e=>e.text)).join("")),""})),Br("\\show",(e=>{const t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),yn[r],oe.math[r],oe.text[r]),""})),Br("\\bgroup","{"),Br("\\egroup","}"),Br("~","\\nobreakspace"),Br("\\lq","`"),Br("\\rq","'"),Br("\\aa","\\r a"),Br("\\AA","\\r A"),Br("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xa9}"),Br("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),Br("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xae}"),Br("\u212c","\\mathscr{B}"),Br("\u2130","\\mathscr{E}"),Br("\u2131","\\mathscr{F}"),Br("\u210b","\\mathscr{H}"),Br("\u2110","\\mathscr{I}"),Br("\u2112","\\mathscr{L}"),Br("\u2133","\\mathscr{M}"),Br("\u211b","\\mathscr{R}"),Br("\u212d","\\mathfrak{C}"),Br("\u210c","\\mathfrak{H}"),Br("\u2128","\\mathfrak{Z}"),Br("\\Bbbk","\\Bbb{k}"),Br("\xb7","\\cdotp"),Br("\\llap","\\mathllap{\\textrm{#1}}"),Br("\\rlap","\\mathrlap{\\textrm{#1}}"),Br("\\clap","\\mathclap{\\textrm{#1}}"),Br("\\mathstrut","\\vphantom{(}"),Br("\\underbar","\\underline{\\text{#1}}"),Br("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'),Br("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}"),Br("\\ne","\\neq"),Br("\u2260","\\neq"),Br("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}"),Br("\u2209","\\notin"),Br("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}"),Br("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"),Br("\u225a","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225a}}"),Br("\u225b","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225b}}"),Br("\u225d","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225d}}"),Br("\u225e","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225e}}"),Br("\u225f","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225f}}"),Br("\u27c2","\\perp"),Br("\u203c","\\mathclose{!\\mkern-0.8mu!}"),Br("\u220c","\\notni"),Br("\u231c","\\ulcorner"),Br("\u231d","\\urcorner"),Br("\u231e","\\llcorner"),Br("\u231f","\\lrcorner"),Br("\xa9","\\copyright"),Br("\xae","\\textregistered"),Br("\ufe0f","\\textregistered"),Br("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),Br("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),Br("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),Br("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),Br("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}"),Br("\u22ee","\\vdots"),Br("\\varGamma","\\mathit{\\Gamma}"),Br("\\varDelta","\\mathit{\\Delta}"),Br("\\varTheta","\\mathit{\\Theta}"),Br("\\varLambda","\\mathit{\\Lambda}"),Br("\\varXi","\\mathit{\\Xi}"),Br("\\varPi","\\mathit{\\Pi}"),Br("\\varSigma","\\mathit{\\Sigma}"),Br("\\varUpsilon","\\mathit{\\Upsilon}"),Br("\\varPhi","\\mathit{\\Phi}"),Br("\\varPsi","\\mathit{\\Psi}"),Br("\\varOmega","\\mathit{\\Omega}"),Br("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Br("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),Br("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Br("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Br("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Br("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");const Cn={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};Br("\\dots",(function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in Cn?t=Cn[r]:("\\not"===r.slice(0,4)||r in oe.math&&l.contains(["bin","rel"],oe.math[r].group))&&(t="\\dotsb"),t}));const Nn={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Br("\\dotso",(function(e){return e.future().text in Nn?"\\ldots\\,":"\\ldots"})),Br("\\dotsc",(function(e){const t=e.future().text;return t in Nn&&","!==t?"\\ldots\\,":"\\ldots"})),Br("\\cdots",(function(e){return e.future().text in Nn?"\\@cdots\\,":"\\@cdots"})),Br("\\dotsb","\\cdots"),Br("\\dotsm","\\cdots"),Br("\\dotsi","\\!\\cdots"),Br("\\dotsx","\\ldots\\,"),Br("\\DOTSI","\\relax"),Br("\\DOTSB","\\relax"),Br("\\DOTSX","\\relax"),Br("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Br("\\,","\\tmspace+{3mu}{.1667em}"),Br("\\thinspace","\\,"),Br("\\>","\\mskip{4mu}"),Br("\\:","\\tmspace+{4mu}{.2222em}"),Br("\\medspace","\\:"),Br("\\;","\\tmspace+{5mu}{.2777em}"),Br("\\thickspace","\\;"),Br("\\!","\\tmspace-{3mu}{.1667em}"),Br("\\negthinspace","\\!"),Br("\\negmedspace","\\tmspace-{4mu}{.2222em}"),Br("\\negthickspace","\\tmspace-{5mu}{.277em}"),Br("\\enspace","\\kern.5em "),Br("\\enskip","\\hskip.5em\\relax"),Br("\\quad","\\hskip1em\\relax"),Br("\\qquad","\\hskip2em\\relax"),Br("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Br("\\tag@paren","\\tag@literal{({#1})}"),Br("\\tag@literal",(e=>{if(e.macros.get("\\df@tag"))throw new n("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"})),Br("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),Br("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Br("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Br("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Br("\\newline","\\\\\\relax"),Br("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");const qn=F(T["Main-Regular"]["T".charCodeAt(0)][1]-.7*T["Main-Regular"]["A".charCodeAt(0)][1]);Br("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+qn+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),Br("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+qn+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),Br("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Br("\\@hspace","\\hskip #1\\relax"),Br("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Br("\\ordinarycolon",":"),Br("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),Br("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),Br("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),Br("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),Br("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),Br("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),Br("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),Br("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),Br("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),Br("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),Br("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),Br("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),Br("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),Br("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),Br("\u2237","\\dblcolon"),Br("\u2239","\\eqcolon"),Br("\u2254","\\coloneqq"),Br("\u2255","\\eqqcolon"),Br("\u2a74","\\Coloneqq"),Br("\\ratio","\\vcentcolon"),Br("\\coloncolon","\\dblcolon"),Br("\\colonequals","\\coloneqq"),Br("\\coloncolonequals","\\Coloneqq"),Br("\\equalscolon","\\eqqcolon"),Br("\\equalscoloncolon","\\Eqqcolon"),Br("\\colonminus","\\coloneq"),Br("\\coloncolonminus","\\Coloneq"),Br("\\minuscolon","\\eqcolon"),Br("\\minuscoloncolon","\\Eqcolon"),Br("\\coloncolonapprox","\\Colonapprox"),Br("\\coloncolonsim","\\Colonsim"),Br("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Br("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Br("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Br("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Br("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),Br("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Br("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Br("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Br("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Br("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),Br("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),Br("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),Br("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),Br("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),Br("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),Br("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),Br("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),Br("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),Br("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),Br("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),Br("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),Br("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),Br("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),Br("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),Br("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),Br("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),Br("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),Br("\\imath","\\html@mathml{\\@imath}{\u0131}"),Br("\\jmath","\\html@mathml{\\@jmath}{\u0237}"),Br("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),Br("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),Br("\u27e6","\\llbracket"),Br("\u27e7","\\rrbracket"),Br("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),Br("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),Br("\u2983","\\lBrace"),Br("\u2984","\\rBrace"),Br("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29b5}}"),Br("\u29b5","\\minuso"),Br("\\darr","\\downarrow"),Br("\\dArr","\\Downarrow"),Br("\\Darr","\\Downarrow"),Br("\\lang","\\langle"),Br("\\rang","\\rangle"),Br("\\uarr","\\uparrow"),Br("\\uArr","\\Uparrow"),Br("\\Uarr","\\Uparrow"),Br("\\N","\\mathbb{N}"),Br("\\R","\\mathbb{R}"),Br("\\Z","\\mathbb{Z}"),Br("\\alef","\\aleph"),Br("\\alefsym","\\aleph"),Br("\\Alpha","\\mathrm{A}"),Br("\\Beta","\\mathrm{B}"),Br("\\bull","\\bullet"),Br("\\Chi","\\mathrm{X}"),Br("\\clubs","\\clubsuit"),Br("\\cnums","\\mathbb{C}"),Br("\\Complex","\\mathbb{C}"),Br("\\Dagger","\\ddagger"),Br("\\diamonds","\\diamondsuit"),Br("\\empty","\\emptyset"),Br("\\Epsilon","\\mathrm{E}"),Br("\\Eta","\\mathrm{H}"),Br("\\exist","\\exists"),Br("\\harr","\\leftrightarrow"),Br("\\hArr","\\Leftrightarrow"),Br("\\Harr","\\Leftrightarrow"),Br("\\hearts","\\heartsuit"),Br("\\image","\\Im"),Br("\\infin","\\infty"),Br("\\Iota","\\mathrm{I}"),Br("\\isin","\\in"),Br("\\Kappa","\\mathrm{K}"),Br("\\larr","\\leftarrow"),Br("\\lArr","\\Leftarrow"),Br("\\Larr","\\Leftarrow"),Br("\\lrarr","\\leftrightarrow"),Br("\\lrArr","\\Leftrightarrow"),Br("\\Lrarr","\\Leftrightarrow"),Br("\\Mu","\\mathrm{M}"),Br("\\natnums","\\mathbb{N}"),Br("\\Nu","\\mathrm{N}"),Br("\\Omicron","\\mathrm{O}"),Br("\\plusmn","\\pm"),Br("\\rarr","\\rightarrow"),Br("\\rArr","\\Rightarrow"),Br("\\Rarr","\\Rightarrow"),Br("\\real","\\Re"),Br("\\reals","\\mathbb{R}"),Br("\\Reals","\\mathbb{R}"),Br("\\Rho","\\mathrm{P}"),Br("\\sdot","\\cdot"),Br("\\sect","\\S"),Br("\\spades","\\spadesuit"),Br("\\sub","\\subset"),Br("\\sube","\\subseteq"),Br("\\supe","\\supseteq"),Br("\\Tau","\\mathrm{T}"),Br("\\thetasym","\\vartheta"),Br("\\weierp","\\wp"),Br("\\Zeta","\\mathrm{Z}"),Br("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Br("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Br("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),Br("\\bra","\\mathinner{\\langle{#1}|}"),Br("\\ket","\\mathinner{|{#1}\\rangle}"),Br("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Br("\\Bra","\\left\\langle#1\\right|"),Br("\\Ket","\\left|#1\\right\\rangle");const In=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,i=t.macros.get("|"),a=t.macros.get("\\|");t.macros.beginGroup();const l=t=>r=>{e&&(r.macros.set("|",i),o.length&&r.macros.set("\\|",a));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",l(!1)),o.length&&t.macros.set("\\|",l(!0));const h=t.consumeArg().tokens,c=t.expandTokens([...s,...h,...r]);return t.macros.endGroup(),{tokens:c.reverse(),numArgs:0}};Br("\\bra@ket",In(!1)),Br("\\bra@set",In(!0)),Br("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Br("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Br("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Br("\\angln","{\\angl n}"),Br("\\blue","\\textcolor{##6495ed}{#1}"),Br("\\orange","\\textcolor{##ffa500}{#1}"),Br("\\pink","\\textcolor{##ff00af}{#1}"),Br("\\red","\\textcolor{##df0030}{#1}"),Br("\\green","\\textcolor{##28ae7b}{#1}"),Br("\\gray","\\textcolor{gray}{#1}"),Br("\\purple","\\textcolor{##9d38bd}{#1}"),Br("\\blueA","\\textcolor{##ccfaff}{#1}"),Br("\\blueB","\\textcolor{##80f6ff}{#1}"),Br("\\blueC","\\textcolor{##63d9ea}{#1}"),Br("\\blueD","\\textcolor{##11accd}{#1}"),Br("\\blueE","\\textcolor{##0c7f99}{#1}"),Br("\\tealA","\\textcolor{##94fff5}{#1}"),Br("\\tealB","\\textcolor{##26edd5}{#1}"),Br("\\tealC","\\textcolor{##01d1c1}{#1}"),Br("\\tealD","\\textcolor{##01a995}{#1}"),Br("\\tealE","\\textcolor{##208170}{#1}"),Br("\\greenA","\\textcolor{##b6ffb0}{#1}"),Br("\\greenB","\\textcolor{##8af281}{#1}"),Br("\\greenC","\\textcolor{##74cf70}{#1}"),Br("\\greenD","\\textcolor{##1fab54}{#1}"),Br("\\greenE","\\textcolor{##0d923f}{#1}"),Br("\\goldA","\\textcolor{##ffd0a9}{#1}"),Br("\\goldB","\\textcolor{##ffbb71}{#1}"),Br("\\goldC","\\textcolor{##ff9c39}{#1}"),Br("\\goldD","\\textcolor{##e07d10}{#1}"),Br("\\goldE","\\textcolor{##a75a05}{#1}"),Br("\\redA","\\textcolor{##fca9a9}{#1}"),Br("\\redB","\\textcolor{##ff8482}{#1}"),Br("\\redC","\\textcolor{##f9685d}{#1}"),Br("\\redD","\\textcolor{##e84d39}{#1}"),Br("\\redE","\\textcolor{##bc2612}{#1}"),Br("\\maroonA","\\textcolor{##ffbde0}{#1}"),Br("\\maroonB","\\textcolor{##ff92c6}{#1}"),Br("\\maroonC","\\textcolor{##ed5fa6}{#1}"),Br("\\maroonD","\\textcolor{##ca337c}{#1}"),Br("\\maroonE","\\textcolor{##9e034e}{#1}"),Br("\\purpleA","\\textcolor{##ddd7ff}{#1}"),Br("\\purpleB","\\textcolor{##c6b9fc}{#1}"),Br("\\purpleC","\\textcolor{##aa87ff}{#1}"),Br("\\purpleD","\\textcolor{##7854ab}{#1}"),Br("\\purpleE","\\textcolor{##543b78}{#1}"),Br("\\mintA","\\textcolor{##f5f9e8}{#1}"),Br("\\mintB","\\textcolor{##edf2df}{#1}"),Br("\\mintC","\\textcolor{##e0e5cc}{#1}"),Br("\\grayA","\\textcolor{##f6f7f7}{#1}"),Br("\\grayB","\\textcolor{##f0f1f2}{#1}"),Br("\\grayC","\\textcolor{##e3e5e6}{#1}"),Br("\\grayD","\\textcolor{##d6d8da}{#1}"),Br("\\grayE","\\textcolor{##babec2}{#1}"),Br("\\grayF","\\textcolor{##888d93}{#1}"),Br("\\grayG","\\textcolor{##626569}{#1}"),Br("\\grayH","\\textcolor{##3b3e40}{#1}"),Br("\\grayI","\\textcolor{##21242c}{#1}"),Br("\\kaBlue","\\textcolor{##314453}{#1}"),Br("\\kaGreen","\\textcolor{##71B307}{#1}");const Rn={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Hn{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new zn(An,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new Mn(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,r,n;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken(),({tokens:n,end:r}=this.consumeArg(["]"]))}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new Nr("EOF",r.loc)),this.pushTokens(n),t.range(r,"")}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(e){const t=[],r=e&&e.length>0;r||this.consumeSpaces();const o=this.future();let s,i=0,a=0;do{if(s=this.popToken(),t.push(s),"{"===s.text)++i;else if("}"===s.text){if(--i,-1===i)throw new n("Extra }",s)}else if("EOF"===s.text)throw new n("Unexpected end of input in a macro argument, expected '"+(e&&r?e[a]:"}")+"'",s);if(e&&r)if((0===i||1===i&&"{"===e[a])&&s.text===e[a]){if(++a,a===e.length){t.splice(-a,a);break}}else a=0}while(0!==i||r);return"{"===o.text&&"}"===t[t.length-1].text&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:o,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new n("The length of delimiters doesn't match the number of args!");const r=t[0];for(let e=0;ethis.settings.maxExpand)throw new n("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){const t=this.popToken(),r=t.text,o=t.noexpand?null:this._getExpansion(r);if(null==o||e&&o.unexpandable){if(e&&null==o&&"\\"===r[0]&&!this.isDefined(r))throw new n("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);let s=o.tokens;const i=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let e=s.length-1;e>=0;--e){let t=s[e];if("#"===t.text){if(0===e)throw new n("Incomplete placeholder at end of macro body",t);if(t=s[--e],"#"===t.text)s.splice(e+1,1);else{if(!/^[1-9]$/.test(t.text))throw new n("Not a valid argument number",t);s.splice(e,2,...i[+t.text-1])}}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){const e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Nr(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){const e=this.stack.pop();e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(e)}return this.countExpansion(t.length),t}expandMacroAsText(e){const t=this.expandMacro(e);return t?t.map((e=>e.text)).join(""):t}_getExpansion(e){const t=this.macros.get(e);if(null==t)return t;if(1===e.length){const t=this.lexer.catcodes[e];if(null!=t&&13!==t)return}const r="function"==typeof t?t(this):t;if("string"==typeof r){let e=0;if(-1!==r.indexOf("#")){const t=r.replace(/##/g,"");for(;-1!==t.indexOf("#"+(e+1));)++e}const t=new Mn(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||yn.hasOwnProperty(e)||oe.math.hasOwnProperty(e)||oe.text.hasOwnProperty(e)||Rn.hasOwnProperty(e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:yn.hasOwnProperty(e)&&!yn[e].primitive}}const On=/^[\u208a\u208b\u208c\u208d\u208e\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2090\u2091\u2095\u1d62\u2c7c\u2096\u2097\u2098\u2099\u2092\u209a\u1d63\u209b\u209c\u1d64\u1d65\u2093\u1d66\u1d67\u1d68\u1d69\u1d6a]/,En=Object.freeze({"\u208a":"+","\u208b":"-","\u208c":"=","\u208d":"(","\u208e":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1d62":"i","\u2c7c":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209a":"p","\u1d63":"r","\u209b":"s","\u209c":"t","\u1d64":"u","\u1d65":"v","\u2093":"x","\u1d66":"\u03b2","\u1d67":"\u03b3","\u1d68":"\u03c1","\u1d69":"\u03d5","\u1d6a":"\u03c7","\u207a":"+","\u207b":"-","\u207c":"=","\u207d":"(","\u207e":")","\u2070":"0","\xb9":"1","\xb2":"2","\xb3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1d2c":"A","\u1d2e":"B","\u1d30":"D","\u1d31":"E","\u1d33":"G","\u1d34":"H","\u1d35":"I","\u1d36":"J","\u1d37":"K","\u1d38":"L","\u1d39":"M","\u1d3a":"N","\u1d3c":"O","\u1d3e":"P","\u1d3f":"R","\u1d40":"T","\u1d41":"U","\u2c7d":"V","\u1d42":"W","\u1d43":"a","\u1d47":"b","\u1d9c":"c","\u1d48":"d","\u1d49":"e","\u1da0":"f","\u1d4d":"g","\u02b0":"h","\u2071":"i","\u02b2":"j","\u1d4f":"k","\u02e1":"l","\u1d50":"m","\u207f":"n","\u1d52":"o","\u1d56":"p","\u02b3":"r","\u02e2":"s","\u1d57":"t","\u1d58":"u","\u1d5b":"v","\u02b7":"w","\u02e3":"x","\u02b8":"y","\u1dbb":"z","\u1d5d":"\u03b2","\u1d5e":"\u03b3","\u1d5f":"\u03b4","\u1d60":"\u03d5","\u1d61":"\u03c7","\u1dbf":"\u03b8"}),Ln={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"},"\u0327":{text:"\\c"}},Dn={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u1e09":"c\u0327\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\xe7":"c\u0327","\u010f":"d\u030c","\u1e0b":"d\u0307","\u1e11":"d\u0327","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u1e1d":"e\u0327\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u0229":"e\u0327","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u0123":"g\u0327","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\u1e29":"h\u0327","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u0137":"k\u0327","\u013a":"l\u0301","\u013e":"l\u030c","\u013c":"l\u0327","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\u0146":"n\u0327","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u0157":"r\u0327","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u015f":"s\u0327","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\u0163":"t\u0327","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u1e08":"C\u0327\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\xc7":"C\u0327","\u010e":"D\u030c","\u1e0a":"D\u0307","\u1e10":"D\u0327","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u1e1c":"E\u0327\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u0228":"E\u0327","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u0122":"G\u0327","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\u1e28":"H\u0327","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0136":"K\u0327","\u0139":"L\u0301","\u013d":"L\u030c","\u013b":"L\u0327","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\u0145":"N\u0327","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u0156":"R\u0327","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u015e":"S\u0327","\u0164":"T\u030c","\u1e6a":"T\u0307","\u0162":"T\u0327","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"};class Vn{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new Hn(e,t,this.mode),this.settings=t,this.leftrightDepth=0}expect(e,t){if(void 0===t&&(t=!0),this.fetch().text!==e)throw new n("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{const e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){const t=this.nextToken;this.consume(),this.gullet.pushToken(new Nr("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(-1!==Vn.endOfExpression.indexOf(n.text))break;if(t&&n.text===t)break;if(e&&yn[n.text]&&yn[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&r.push(o)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){let t,r=-1;for(let o=0;o=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);const r=oe[this.mode][t].group,n=Cr.range(e);let s;if(te.hasOwnProperty(r)){const e=r;s={type:"atom",mode:this.mode,family:e,loc:n,text:t}}else s={type:r,mode:this.mode,loc:n,text:t};o=s}else{if(!(t.charCodeAt(0)>=128))return null;this.settings.strict&&(S(t.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'" ('+t.charCodeAt(0)+")",e)),o={type:"textord",mode:"text",loc:Cr.range(e),text:t}}if(this.consume(),r)for(let t=0;t 15) { left = "…" + input.slice(start - 15, start); @@ -120,7 +130,7 @@ class ParseError { left = input.slice(0, start); } - let right; + var right; if (end + 15 < input.length) { right = input.slice(end, end + 15) + "…"; @@ -131,14 +141,20 @@ class ParseError { error += left + underlined + right; } // Some hackery to make ParseError a prototype of Error // See http://stackoverflow.com/a/8460753 + // $FlowFixMe - const self = new Error(error); + var self = new Error(error); self.name = "ParseError"; // $FlowFixMe - self.__proto__ = ParseError.prototype; // $FlowFixMe - + self.__proto__ = ParseError.prototype; self.position = start; + + if (start != null && end != null) { + self.length = end - start; + } + + self.rawMessage = message; return self; } @@ -155,7 +171,7 @@ ParseError.prototype.__proto__ = Error.prototype; /** * Return whether an element is contained in a list */ -const contains = function contains(list, elem) { +var contains = function contains(list, elem) { return list.indexOf(elem) !== -1; }; /** @@ -164,25 +180,25 @@ const contains = function contains(list, elem) { */ -const deflt = function deflt(setting, defaultIfUndefined) { +var deflt = function deflt(setting, defaultIfUndefined) { return setting === undefined ? defaultIfUndefined : setting; }; // hyphenate and escape adapted from Facebook's React under Apache 2 license -const uppercase = /([A-Z])/g; +var uppercase = /([A-Z])/g; -const hyphenate = function hyphenate(str) { +var hyphenate = function hyphenate(str) { return str.replace(uppercase, "-$1").toLowerCase(); }; -const ESCAPE_LOOKUP = { +var ESCAPE_LOOKUP = { "&": "&", ">": ">", "<": "<", "\"": """, "'": "'" }; -const ESCAPE_REGEX = /[&><"']/g; +var ESCAPE_REGEX = /[&><"']/g; /** * Escapes text to prevent scripting attacks. */ @@ -197,7 +213,7 @@ function escape(text) { */ -const getBaseElem = function getBaseElem(group) { +var getBaseElem = function getBaseElem(group) { if (group.type === "ordgroup") { if (group.body.length === 1) { return getBaseElem(group.body[0]); @@ -223,13 +239,13 @@ const getBaseElem = function getBaseElem(group) { */ -const isCharacterBox = function isCharacterBox(group) { - const baseElem = getBaseElem(group); // These are all they types of groups which hold single characters +var isCharacterBox = function isCharacterBox(group) { + var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom"; }; -const assert = function assert(value) { +var assert = function assert(value) { if (!value) { throw new Error('Expected non-null, but got ' + String(value)); } @@ -238,12 +254,34 @@ const assert = function assert(value) { }; /** * Return the protocol of a URL, or "_relative" if the URL does not specify a - * protocol (and thus is relative). + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). */ -const protocolFromUrl = function protocolFromUrl(url) { - const protocol = /^\s*([^\\/#]*?)(?::|�*58|�*3a)/i.exec(url); - return protocol != null ? protocol[1] : "_relative"; +var protocolFromUrl = function protocolFromUrl(url) { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + // eslint-disable-next-line no-control-regex + var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + + if (!protocol) { + return "_relative"; + } // Reject weird colons + + + if (protocol[2] !== ":") { + return null; + } // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + + + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } // Lowercase the protocol + + + return protocol[1].toLowerCase(); }; var utils = { contains, @@ -256,7 +294,126 @@ var utils = { }; /* eslint no-console:0 */ +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; + +function getDefaultValue(schema) { + if (schema.default) { + return schema.default; + } + + var type = schema.type; + var defaultType = Array.isArray(type) ? type[0] : type; + + if (typeof defaultType !== 'string') { + return defaultType.enum[0]; + } + + switch (defaultType) { + case 'boolean': + return false; + + case 'string': + return ''; + + case 'number': + return 0; + case 'object': + return {}; + } +} /** * The main Settings object * @@ -267,6 +424,8 @@ var utils = { * math (true), meaning that the math starts in \displaystyle * and is placed in a block with vertical margin. */ + + class Settings { constructor(options) { this.displayMode = void 0; @@ -282,21 +441,19 @@ class Settings { this.trust = void 0; this.maxSize = void 0; this.maxExpand = void 0; + this.globalGroup = void 0; // allow null options options = options || {}; - this.displayMode = utils.deflt(options.displayMode, false); - this.output = utils.deflt(options.output, "htmlAndMathml"); - this.leqno = utils.deflt(options.leqno, false); - this.fleqn = utils.deflt(options.fleqn, false); - this.throwOnError = utils.deflt(options.throwOnError, true); - this.errorColor = utils.deflt(options.errorColor, "#cc0000"); - this.macros = options.macros || {}; - this.minRuleThickness = Math.max(0, utils.deflt(options.minRuleThickness, 0)); - this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); - this.strict = utils.deflt(options.strict, "warn"); - this.trust = utils.deflt(options.trust, false); - this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity)); - this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000)); + + for (var prop in SETTINGS_SCHEMA) { + if (SETTINGS_SCHEMA.hasOwnProperty(prop)) { + // $FlowFixMe + var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options + // $FlowFixMe + + this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema); + } + } } /** * Report nonstrict (non-LaTeX-compatible) input. @@ -305,7 +462,7 @@ class Settings { reportNonstrict(errorCode, errorMsg, token) { - let strict = this.strict; + var strict = this.strict; if (typeof strict === "function") { // Allow return value of strict function to be boolean or string @@ -316,12 +473,12 @@ class Settings { if (!strict || strict === "ignore") { return; } else if (strict === true || strict === "error") { - throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + `${errorMsg} [${errorCode}]`, token); + throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); } else if (strict === "warn") { - typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + `${errorMsg} [${errorCode}]`); + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); } else { // won't happen in type-safe code - typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); } } /** @@ -335,7 +492,7 @@ class Settings { useStrictBehavior(errorCode, errorMsg, token) { - let strict = this.strict; + var strict = this.strict; if (typeof strict === "function") { // Allow return value of strict function to be boolean or string @@ -354,11 +511,11 @@ class Settings { } else if (strict === true || strict === "error") { return true; } else if (strict === "warn") { - typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + `${errorMsg} [${errorCode}]`); + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); return false; } else { // won't happen in type-safe code - typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); return false; } } @@ -374,10 +531,16 @@ class Settings { isTrusted(context) { if (context.url && !context.protocol) { - context.protocol = utils.protocolFromUrl(context.url); + var protocol = utils.protocolFromUrl(context.url); + + if (protocol == null) { + return false; + } + + context.protocol = protocol; } - const trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; return Boolean(trust); } @@ -453,7 +616,7 @@ class Style { text() { - return styles[text[this.id]]; + return styles[text$1[this.id]]; } /** * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) @@ -469,23 +632,23 @@ class Style { // IDs of the different styles -const D = 0; -const Dc = 1; -const T = 2; -const Tc = 3; -const S = 4; -const Sc = 5; -const SS = 6; -const SSc = 7; // Instances of the different styles - -const styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another - -const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; -const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; -const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; -const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; -const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; -const text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. +var D = 0; +var Dc = 1; +var T = 2; +var Tc = 3; +var S = 4; +var Sc = 5; +var SS = 6; +var SSc = 7; // Instances of the different styles + +var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another + +var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var text$1 = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. var Style$1 = { DISPLAY: styles[D], @@ -511,18 +674,23 @@ var Style$1 = { * Unicode block data for the families of scripts we support in \text{}. * Scripts only need to appear here if they do not have font metrics. */ -const scriptData = [{ +var scriptData = [{ // Latin characters beyond the Latin-1 characters we have metrics for. // Needed for Czech, Hungarian and Turkish text, for example. name: 'latin', blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B - [0x0300, 0x036f]] + [0x0300, 0x036f] // Combining Diacritical marks + ] }, { // The Cyrillic script used by Russian and related languages. // A Cyrillic subset used to be supported as explicitly defined // symbols in symbols.js name: 'cyrillic', blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] }, { // The Brahmic scripts of South and Southeast Asia // Devanagari (0900–097F) @@ -550,7 +718,9 @@ const scriptData = [{ name: "cjk", blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana [0x4E00, 0x9FAF], // CJK ideograms - [0xFF00, 0xFF60]] + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] }, { // Korean name: 'hangul', @@ -562,11 +732,11 @@ const scriptData = [{ */ function scriptFromCodepoint(codepoint) { - for (let i = 0; i < scriptData.length; i++) { - const script = scriptData[i]; + for (var i = 0; i < scriptData.length; i++) { + var script = scriptData[i]; - for (let i = 0; i < script.blocks.length; i++) { - const block = script.blocks[i]; + for (var _i = 0; _i < script.blocks.length; _i++) { + var block = script.blocks[_i]; if (codepoint >= block[0] && codepoint <= block[1]) { return script.name; @@ -581,7 +751,7 @@ function scriptFromCodepoint(codepoint) { * This is an optimization to make supportedCodepoint() fast. */ -const allBlocks = []; +var allBlocks = []; scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); /** * Given a codepoint, return true if it falls within one of the @@ -593,7 +763,7 @@ scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); */ function supportedCodepoint(codepoint) { - for (let i = 0; i < allBlocks.length; i += 2) { + for (var i = 0; i < allBlocks.length; i += 2) { if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { return true; } @@ -607,395 +777,246 @@ function supportedCodepoint(codepoint) { * It's a storehouse of path geometry for SVG images. */ // In all paths below, the viewBox-to-em scale is 1000:1. -const hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping. -// The viniculum of a \sqrt can be made thicker by a KaTeX rendering option. -// Think of variable extraViniculum as two detours in the SVG path. -// The detour begins at the lower left of the area labeled extraViniculum below. -// The detour proceeds one extraViniculum distance up and slightly to the right, -// displacing the radiused corner between surd and viniculum. The radius is +var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is // traversed as usual, then the detour resumes. It goes right, to the end of -// the very long viniculumn, then down one extraViniculum distance, +// the very long vinculum, then down one extraVinculum distance, // after which it resumes regular path geometry for the radical. -/* viniculum +/* vinculum / - /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraViniculum - / █████████████████████←0.04em (40 unit) std viniculum thickness + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness / / / / / /\ / / surd */ -const sqrtMain = function sqrtMain(extraViniculum, hLinePad) { +var sqrtMain = function sqrtMain(extraVinculum, hLinePad) { // sqrtMain path geometry is from glyph U221A in the font KaTeX Main - return `M95,${622 + extraViniculum + hLinePad} -c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14 -c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54 -c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10 -s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429 -c69,-144,104.5,-217.7,106.5,-221 -l${extraViniculum / 2.075} -${extraViniculum} -c5.3,-9.3,12,-14,20,-14 -H400000v${40 + extraViniculum}H845.2724 -s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 -c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z -M${834 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`; + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -const sqrtSize1 = function sqrtSize1(extraViniculum, hLinePad) { +var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) { // size1 is from glyph U221A in the font KaTeX_Size1-Regular - return `M263,${601 + extraViniculum + hLinePad}c0.7,0,18,39.7,52,119 -c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120 -c340,-704.7,510.7,-1060.3,512,-1067 -l${extraViniculum / 2.084} -${extraViniculum} -c4.7,-7.3,11,-11,19,-11 -H40000v${40 + extraViniculum}H1012.3 -s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232 -c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1 -s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26 -c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z -M${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`; + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -const sqrtSize2 = function sqrtSize2(extraViniculum, hLinePad) { +var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) { // size2 is from glyph U221A in the font KaTeX_Size2-Regular - return `M983 ${10 + extraViniculum + hLinePad} -l${extraViniculum / 3.13} -${extraViniculum} -c4,-6.7,10,-10,18,-10 H400000v${40 + extraViniculum} -H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7 -s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744 -c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30 -c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722 -c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5 -c53.7,-170.3,84.5,-266.8,92.5,-289.5z -M${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}h-400000z`; + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; }; -const sqrtSize3 = function sqrtSize3(extraViniculum, hLinePad) { +var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) { // size3 is from glyph U221A in the font KaTeX_Size3-Regular - return `M424,${2398 + extraViniculum + hLinePad} -c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514 -c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20 -s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121 -s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081 -l${extraViniculum / 4.223} -${extraViniculum}c4,-6.7,10,-10,18,-10 H400000 -v${40 + extraViniculum}H1014.6 -s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185 -c-2,6,-10,9,-24,9 -c-8,0,-12,-0.7,-12,-2z M${1001 + extraViniculum} ${hLinePad} -h400000v${40 + extraViniculum}h-400000z`; + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; }; -const sqrtSize4 = function sqrtSize4(extraViniculum, hLinePad) { +var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) { // size4 is from glyph U221A in the font KaTeX_Size4-Regular - return `M473,${2713 + extraViniculum + hLinePad} -c339.3,-1799.3,509.3,-2700,510,-2702 l${extraViniculum / 5.298} -${extraViniculum} -c3.3,-7.3,9.3,-11,18,-11 H400000v${40 + extraViniculum}H1017.7 -s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9 -c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200 -c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26 -s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104, -606zM${1001 + extraViniculum} ${hLinePad}h400000v${40 + extraViniculum}H1017.7z`; + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; + +var phasePath = function phasePath(y) { + var x = y / 2; // x coordinate at top of angle + + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; }; -const sqrtTall = function sqrtTall(extraViniculum, hLinePad, viewBoxHeight) { +var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) { // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular - // One path edge has a variable length. It runs vertically from the viniculumn - // to a point near (14 units) the bottom of the surd. The viniculum + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum // is normally 40 units thick. So the length of the line in question is: - const vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum; - return `M702 ${extraViniculum + hLinePad}H400000${40 + extraViniculum} -H742v${vertSegment}l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1 -h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170 -c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667 -219 661 l218 661zM702 ${hLinePad}H400000v${40 + extraViniculum}H742z`; + var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; }; -const sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) { - extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox. +var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. - let path = ""; + var path = ""; switch (size) { case "sqrtMain": - path = sqrtMain(extraViniculum, hLinePad); + path = sqrtMain(extraVinculum, hLinePad); break; case "sqrtSize1": - path = sqrtSize1(extraViniculum, hLinePad); + path = sqrtSize1(extraVinculum, hLinePad); break; case "sqrtSize2": - path = sqrtSize2(extraViniculum, hLinePad); + path = sqrtSize2(extraVinculum, hLinePad); break; case "sqrtSize3": - path = sqrtSize3(extraViniculum, hLinePad); + path = sqrtSize3(extraVinculum, hLinePad); break; case "sqrtSize4": - path = sqrtSize4(extraViniculum, hLinePad); + path = sqrtSize4(extraVinculum, hLinePad); break; case "sqrtTall": - path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight); + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); } return path; }; -const path = { +var innerPath = function innerPath(name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z"; + + case "\u2223": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z"; + + case "\u2225": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z"); + + case "\u239f": + return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z"; + + case "\u23a2": + return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z"; + + case "\u23a5": + return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z"; + + case "\u23aa": + return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z"; + + case "\u23d0": + return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z"; + + case "\u2016": + return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z"); + + default: + return ""; + } +}; +var path = { // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main - doubleleftarrow: `M262 157 -l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3 - 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28 - 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5 -c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5 - 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87 --86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7 --2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z -m8 0v40h399730v-40zm0 194v40h399730v-40z`, + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", // doublerightarrow is from glyph U+21D2 in font KaTeX Main - doublerightarrow: `M399738 392l --10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5 - 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88 --33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68 --17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18 --13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782 -c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3 --107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`, + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", // leftarrow is from glyph U+2190 in font KaTeX Main - leftarrow: `M400000 241H110l3-3c68.7-52.7 113.7-120 - 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8 --5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247 -c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208 - 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3 - 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202 - l-3-3h399890zM100 241v40h399900v-40z`, + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular - leftbrace: `M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117 --45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7 - 5-6 9-10 13-.7 1-7.3 1-20 1H6z`, - leftbraceunder: `M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13 - 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688 - 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7 --331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`, + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", // overgroup is from the MnSymbol package (public domain) - leftgroup: `M400000 80 -H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0 - 435 0h399565z`, - leftgroupunder: `M400000 262 -H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219 - 435 219h399565z`, + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", // Harpoons are from glyph U+21BD in font KaTeX Main - leftharpoon: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3 --3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5 --18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7 --196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`, - leftharpoonplus: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5 - 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3 --4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7 --10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z -m0 0v40h400000v-40z`, - leftharpoondown: `M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333 - 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5 - 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667 --152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`, - leftharpoondownplus: `M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12 - 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7 --2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0 -v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`, + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", // hook is from glyph U+21A9 in font KaTeX Main - lefthook: `M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5 --83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3 --68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21 - 71.5 23h399859zM103 281v-40h399897v40z`, - leftlinesegment: `M40 281 V428 H0 V94 H40 V241 H400000 v40z -M40 281 V428 H0 V94 H40 V241 H400000 v40z`, - leftmapsto: `M40 281 V448H0V74H40V241H400000v40z -M40 281 V448H0V74H40V241H400000v40z`, + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z", + leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z", // tofrom is from glyph U+21C4 in font KaTeX AMS Regular - leftToFrom: `M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23 --.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8 -c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3 - 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`, - longequal: `M0 50 h400000 v40H0z m0 194h40000v40H0z -M0 50 h400000 v40H0z m0 194h40000v40H0z`, - midbrace: `M200428 334 -c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14 --53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7 - 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11 - 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`, - midbraceunder: `M199572 214 -c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14 - 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3 - 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0 --5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`, - oiintSize1: `M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6 --320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z -m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8 -60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`, - oiintSize2: `M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8 --451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z -m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2 -c0 110 84 276 504 276s502.4-166 502.4-276z`, - oiiintSize1: `M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6 --480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z -m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0 -85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`, - oiiintSize2: `M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8 --707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z -m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1 -c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`, - rightarrow: `M0 241v40h399891c-47.3 35.3-84 78-110 128 --16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 - 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 - 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85 --40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 --12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 - 151.7 139 205zm0 0v40h399900v-40z`, - rightbrace: `M400000 542l --6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5 -s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1 -c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`, - rightbraceunder: `M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3 - 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237 --174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`, - rightgroup: `M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0 - 3-1 3-3v-38c-76-158-257-219-435-219H0z`, - rightgroupunder: `M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18 - 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`, - rightharpoon: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3 --3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2 --10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 - 69.2 92 94.5zm0 0v40h399900v-40z`, - rightharpoonplus: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11 --18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7 - 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z -m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`, - rightharpoondown: `M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8 - 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5 --7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95 --27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`, - rightharpoondownplus: `M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8 - 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 - 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3 --64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z -m0-194v40h400000v-40zm0 0v40h400000v-40z`, - righthook: `M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3 - 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0 --13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21 - 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`, - rightlinesegment: `M399960 241 V94 h40 V428 h-40 V281 H0 v-40z -M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`, - rightToFrom: `M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23 - 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32 --52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142 --167z M100 147v40h399900v-40zM0 341v40h399900v-40z`, + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z", + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z", + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular - twoheadleftarrow: `M0 167c68 40 - 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69 --70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3 --40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19 --37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101 - 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`, - twoheadrightarrow: `M400000 167 -c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3 - 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42 - 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333 --19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70 - 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`, + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", // tilde1 is a modified version of a glyph from the MnSymbol package - tilde1: `M200 55.538c-77 0-168 73.953-177 73.953-3 0-7 --2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0 - 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0 - 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128 --68.267.847-113-73.952-191-73.952z`, + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", // ditto tilde2, tilde3, & tilde4 - tilde2: `M344 55.266c-142 0-300.638 81.316-311.5 86.418 --8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9 - 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114 -c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751 - 181.476 676 181.476c-149 0-189-126.21-332-126.21z`, - tilde3: `M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457 --11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0 - 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697 - 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696 - -338 0-409-156.573-744-156.573z`, - tilde4: `M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345 --11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409 - 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9 - 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409 - -175.236-744-175.236z`, + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", // vec is from glyph U+20D7 in font KaTeX Main - vec: `M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5 -3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11 -10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63 --1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1 --7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59 -H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359 -c-16-25.333-24-45-24-59z`, + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", // widehat1 is a modified version of a glyph from the MnSymbol package - widehat1: `M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22 -c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`, + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", // ditto widehat2, widehat3, & widehat4 - widehat2: `M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10 --11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, - widehat3: `M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10 --11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, - widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10 --11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", // widecheck paths are all inverted versions of widehat - widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1, --5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`, - widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, --11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, - widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, --11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, - widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, --11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", // The next ten paths support reaction arrows from the mhchem package. // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX - // baraboveleftarrow is mostly from from glyph U+2190 in font KaTeX Main - baraboveleftarrow: `M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202 -c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5 -c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130 -s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47 -121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6 -s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11 -c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z -M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`, + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main - rightarrowabovebar: `M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32 --27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0 -13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39 --84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5 --119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 --12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 -151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`, + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em - baraboveshortleftharpoon: `M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 -c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17 -c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21 -c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40 -c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z -M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`, - rightharpoonaboveshortbar: `M0,241 l0,40c399126,0,399993,0,399993,0 -c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, --231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 -c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z -M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`, - shortbaraboveleftharpoon: `M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 -c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9, -1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7, --152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z -M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`, - shortrightharpoonabovebar: `M53,241l0,40c398570,0,399437,0,399437,0 -c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, --231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 -c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z -M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z` + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +var tallDelim = function tallDelim(label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z"; + + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } }; /** @@ -1028,9 +1049,9 @@ class DocumentFragment { toNode() { - const frag = document.createDocumentFragment(); + var frag = document.createDocumentFragment(); - for (let i = 0; i < this.children.length; i++) { + for (var i = 0; i < this.children.length; i++) { frag.appendChild(this.children[i].toNode()); } @@ -1040,9 +1061,9 @@ class DocumentFragment { toMarkup() { - let markup = ""; // Simply concatenate the markup for the children together. + var markup = ""; // Simply concatenate the markup for the children together. - for (let i = 0; i < this.children.length; i++) { + for (var i = 0; i < this.children.length; i++) { markup += this.children[i].toMarkup(); } @@ -1058,542 +1079,17 @@ class DocumentFragment { // To avoid this, we would subclass documentFragment separately for // MathML, but polyfills for subclassing is expensive per PR 1469. // $FlowFixMe: Only works for ChildType = MathDomNode. - const toText = child => child.toText(); + var toText = child => child.toText(); return this.children.map(toText).join(""); } } -/** - * These objects store the data about the DOM nodes we create, as well as some - * extra data. They can then be transformed into real DOM nodes with the - * `toNode` function or HTML markup using `toMarkup`. They are useful for both - * storing extra properties on the nodes, as well as providing a way to easily - * work with the DOM. - * - * Similar functions for working with MathML nodes exist in mathMLTree.js. - * - * TODO: refactor `span` and `anchor` into common superclass when - * target environments support class inheritance - */ - -/** - * Create an HTML className based on a list of classes. In addition to joining - * with spaces, we also remove empty classes. - */ -const createClass = function createClass(classes) { - return classes.filter(cls => cls).join(" "); -}; - -const initNode = function initNode(classes, options, style) { - this.classes = classes || []; - this.attributes = {}; - this.height = 0; - this.depth = 0; - this.maxFontSize = 0; - this.style = style || {}; - - if (options) { - if (options.style.isTight()) { - this.classes.push("mtight"); - } - - const color = options.getColor(); - - if (color) { - this.style.color = color; - } - } -}; -/** - * Convert into an HTML node - */ - - -const toNode = function toNode(tagName) { - const node = document.createElement(tagName); // Apply the class - - node.className = createClass(this.classes); // Apply inline styles - - for (const style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe Flow doesn't seem to understand span.style's type. - node.style[style] = this.style[style]; - } - } // Apply attributes - - - for (const attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } // Append the children, also as HTML nodes - - - for (let i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; -}; -/** - * Convert into an HTML markup string - */ - - -const toMarkup = function toMarkup(tagName) { - let markup = `<${tagName}`; // Add the class - - if (this.classes.length) { - markup += ` class="${utils.escape(createClass(this.classes))}"`; - } - - let styles = ""; // Add the styles, after hyphenation - - for (const style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += `${utils.hyphenate(style)}:${this.style[style]};`; - } - } - - if (styles) { - markup += ` style="${utils.escape(styles)}"`; - } // Add the attributes - - - for (const attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - markup += ` ${attr}="${utils.escape(this.attributes[attr])}"`; - } - } - - markup += ">"; // Add the markup of the children, also as markup - - for (let i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); - } - - markup += ``; - return markup; -}; // Making the type below exact with all optional fields doesn't work due to -// - https://github.com/facebook/flow/issues/4582 -// - https://github.com/facebook/flow/issues/5688 -// However, since *all* fields are optional, $Shape<> works as suggested in 5688 -// above. -// This type does not include all CSS properties. Additional properties should -// be added as needed. - - -/** - * This node represents a span node, with a className, a list of children, and - * an inline style. It also contains information about its height, depth, and - * maxFontSize. - * - * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan - * otherwise. This typesafety is important when HTML builders access a span's - * children. - */ -class Span { - constructor(classes, children, options, style) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.width = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options, style); - this.children = children || []; - } - /** - * Sets an arbitrary attribute on the span. Warning: use this wisely. Not - * all browsers support attributes the same, and having too many custom - * attributes is probably bad. - */ - - - setAttribute(attribute, value) { - this.attributes[attribute] = value; - } - - hasClass(className) { - return utils.contains(this.classes, className); - } - - toNode() { - return toNode.call(this, "span"); - } - - toMarkup() { - return toMarkup.call(this, "span"); - } - -} -/** - * This node represents an anchor () element with a hyperlink. See `span` - * for further details. - */ - -class Anchor { - constructor(href, classes, children, options) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options); - this.children = children || []; - this.setAttribute('href', href); - } - - setAttribute(attribute, value) { - this.attributes[attribute] = value; - } - - hasClass(className) { - return utils.contains(this.classes, className); - } - - toNode() { - return toNode.call(this, "a"); - } - - toMarkup() { - return toMarkup.call(this, "a"); - } - -} -/** - * This node represents an image embed () element. - */ - -class Img { - constructor(src, alt, style) { - this.src = void 0; - this.alt = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - this.alt = alt; - this.src = src; - this.classes = ["mord"]; - this.style = style; - } - - hasClass(className) { - return utils.contains(this.classes, className); - } - - toNode() { - const node = document.createElement("img"); - node.src = this.src; - node.alt = this.alt; - node.className = "mord"; // Apply inline styles - - for (const style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe - node.style[style] = this.style[style]; - } - } - - return node; - } - - toMarkup() { - let markup = `${this.alt} 0) { - span = document.createElement("span"); - span.style.marginRight = this.italic + "em"; - } - - if (this.classes.length > 0) { - span = span || document.createElement("span"); - span.className = createClass(this.classes); - } - - for (const style in this.style) { - if (this.style.hasOwnProperty(style)) { - span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. - - span.style[style] = this.style[style]; - } - } - - if (span) { - span.appendChild(node); - return span; - } else { - return node; - } - } - /** - * Creates markup for a symbol node. - */ - - - toMarkup() { - // TODO(alpert): More duplication than I'd like from - // span.prototype.toMarkup and symbolNode.prototype.toNode... - let needsSpan = false; - let markup = " 0) { - styles += "margin-right:" + this.italic + "em;"; - } - - for (const style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; - } - } - - if (styles) { - needsSpan = true; - markup += " style=\"" + utils.escape(styles) + "\""; - } - - const escaped = utils.escape(this.text); - - if (needsSpan) { - markup += ">"; - markup += escaped; - markup += ""; - return markup; - } else { - return escaped; - } - } - -} -/** - * SVG nodes are used to render stretchy wide elements. - */ - -class SvgNode { - constructor(children, attributes) { - this.children = void 0; - this.attributes = void 0; - this.children = children || []; - this.attributes = attributes || {}; - } - - toNode() { - const svgNS = "http://www.w3.org/2000/svg"; - const node = document.createElementNS(svgNS, "svg"); // Apply attributes - - for (const attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - for (let i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; - } - - toMarkup() { - let markup = "`; - } else { - return ``; - } - } - -} -class LineNode { - constructor(attributes) { - this.attributes = void 0; - this.attributes = attributes || {}; - } - - toNode() { - const svgNS = "http://www.w3.org/2000/svg"; - const node = document.createElementNS(svgNS, "line"); // Apply attributes - - for (const attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - return node; - } - - toMarkup() { - let markup = " but got ${String(group)}.`); - } -} - // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. -var metricMap = { +var fontMetricsData = { "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.68889, 0, 0, 0.72222], "66": [0, 0.68889, 0, 0, 0.66667], "67": [0, 0.68889, 0, 0, 0.72222], @@ -1621,6 +1117,7 @@ var metricMap = { "89": [0, 0.68889, 0, 0, 0.72222], "90": [0, 0.68889, 0, 0, 0.66667], "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], "165": [0, 0.675, 0.025, 0, 0.75], "174": [0.15559, 0.69224, 0, 0, 0.94666], "240": [0, 0.68889, 0, 0, 0.55556], @@ -1851,16 +1348,7 @@ var metricMap = { "57371": [0.13597, 0.63597, 0, 0, 0.77778] }, "Caligraphic-Regular": { - "48": [0, 0.43056, 0, 0, 0.5], - "49": [0, 0.43056, 0, 0, 0.5], - "50": [0, 0.43056, 0, 0, 0.5], - "51": [0.19444, 0.43056, 0, 0, 0.5], - "52": [0.19444, 0.43056, 0, 0, 0.5], - "53": [0.19444, 0.43056, 0, 0, 0.5], - "54": [0, 0.64444, 0, 0, 0.5], - "55": [0.19444, 0.43056, 0, 0, 0.5], - "56": [0, 0.64444, 0, 0, 0.5], - "57": [0.19444, 0.43056, 0, 0, 0.5], + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.68333, 0, 0.19445, 0.79847], "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], @@ -1886,9 +1374,11 @@ var metricMap = { "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], - "90": [0, 0.68333, 0.07944, 0.13889, 0.72473] + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] }, "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69141, 0, 0, 0.29574], "34": [0, 0.69141, 0, 0, 0.21471], "38": [0, 0.69141, 0, 0, 0.73786], @@ -1970,6 +1460,7 @@ var metricMap = { "120": [0.18906, 0.47534, 0, 0, 0.38865], "121": [0.18906, 0.47534, 0, 0, 0.49884], "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], "8216": [0, 0.69141, 0, 0, 0.21471], "8217": [0, 0.69141, 0, 0, 0.21471], "58112": [0, 0.62119, 0, 0, 0.49749], @@ -1982,6 +1473,7 @@ var metricMap = { "58119": [0, 0.47534, 0, 0, 0.50073] }, "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.35], "34": [0, 0.69444, 0, 0, 0.60278], "35": [0.19444, 0.69444, 0, 0, 0.95833], @@ -2075,6 +1567,8 @@ var metricMap = { "124": [0.25, 0.75, 0, 0, 0.31944], "125": [0.25, 0.75, 0, 0, 0.575], "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], "168": [0, 0.69444, 0, 0, 0.575], "172": [0, 0.44444, 0, 0, 0.76666], "176": [0, 0.69444, 0, 0, 0.86944], @@ -2176,6 +1670,7 @@ var metricMap = { "8764": [-0.10889, 0.39111, 0, 0, 0.89444], "8768": [0.19444, 0.69444, 0, 0, 0.31944], "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], "8776": [0.02444, 0.52444, 0, 0, 0.89444], "8781": [0.00222, 0.50222, 0, 0, 0.89444], "8801": [0.00222, 0.50222, 0, 0, 0.89444], @@ -2232,6 +1727,7 @@ var metricMap = { "57376": [0.19444, 0.69444, 0, 0, 0] }, "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.11417, 0, 0.38611], "34": [0, 0.69444, 0.07939, 0, 0.62055], "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], @@ -2318,7 +1814,7 @@ var metricMap = { "121": [0.19444, 0.44444, 0.105, 0, 0.56166], "122": [0, 0.44444, 0.13889, 0, 0.49055], "126": [0.35, 0.34444, 0.11472, 0, 0.59111], - "163": [0, 0.69444, 0, 0, 0.86853], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.69444, 0.11473, 0, 0.59111], "176": [0, 0.69444, 0, 0, 0.94888], "184": [0.17014, 0, 0, 0, 0.53222], @@ -2360,6 +1856,7 @@ var metricMap = { "8221": [0, 0.69444, 0.07939, 0, 0.62055] }, "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.12417, 0, 0.30667], "34": [0, 0.69444, 0.06961, 0, 0.51444], "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], @@ -2446,7 +1943,7 @@ var metricMap = { "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], "122": [0, 0.43056, 0.12292, 0, 0.40889], "126": [0.35, 0.31786, 0.11585, 0, 0.51111], - "163": [0, 0.69444, 0, 0, 0.76909], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.66786, 0.10474, 0, 0.51111], "176": [0, 0.69444, 0, 0, 0.83129], "184": [0.17014, 0, 0, 0, 0.46], @@ -2455,10 +1952,8 @@ var metricMap = { "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], "230": [0, 0.43056, 0.07514, 0, 0.71555], "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], - "305": [0, 0.43056, 0, 0.02778, 0.32246], "338": [0, 0.68333, 0.12028, 0, 0.98499], "339": [0, 0.43056, 0.07514, 0, 0.71555], - "567": [0.19444, 0.43056, 0, 0.08334, 0.38403], "710": [0, 0.69444, 0.06646, 0, 0.51111], "711": [0, 0.62847, 0.08295, 0, 0.51111], "713": [0, 0.56167, 0.10333, 0, 0.51111], @@ -2584,6 +2079,7 @@ var metricMap = { "125": [0.25, 0.75, 0, 0, 0.5], "126": [0.35, 0.31786, 0, 0, 0.5], "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], "167": [0.19444, 0.69444, 0, 0, 0.44445], "168": [0, 0.66786, 0, 0, 0.5], "172": [0, 0.43056, 0, 0, 0.66667], @@ -2631,7 +2127,7 @@ var metricMap = { "8221": [0, 0.69444, 0, 0, 0.5], "8224": [0.19444, 0.69444, 0, 0, 0.44445], "8225": [0.19444, 0.69444, 0, 0, 0.44445], - "8230": [0, 0.12, 0, 0, 1.172], + "8230": [0, 0.123, 0, 0, 1.172], "8242": [0, 0.55556, 0, 0, 0.275], "8407": [0, 0.71444, 0.15382, 0, 0.5], "8463": [0, 0.68889, 0, 0, 0.54028], @@ -2692,10 +2188,10 @@ var metricMap = { "8764": [-0.13313, 0.36687, 0, 0, 0.77778], "8768": [0.19444, 0.69444, 0, 0, 0.27778], "8771": [-0.03625, 0.46375, 0, 0, 0.77778], - "8773": [-0.022, 0.589, 0, 0, 1.0], + "8773": [-0.022, 0.589, 0, 0, 0.778], "8776": [-0.01688, 0.48312, 0, 0, 0.77778], "8781": [-0.03625, 0.46375, 0, 0, 0.77778], - "8784": [-0.133, 0.67, 0, 0, 0.778], + "8784": [-0.133, 0.673, 0, 0, 0.778], "8801": [-0.03625, 0.46375, 0, 0, 0.77778], "8804": [0.13597, 0.63597, 0, 0, 0.77778], "8805": [0.13597, 0.63597, 0, 0, 0.77778], @@ -2726,9 +2222,9 @@ var metricMap = { "8901": [-0.05555, 0.44445, 0, 0, 0.27778], "8902": [-0.03472, 0.46528, 0, 0, 0.5], "8904": [0.005, 0.505, 0, 0, 0.9], - "8942": [0.03, 0.9, 0, 0, 0.278], - "8943": [-0.19, 0.31, 0, 0, 1.172], - "8945": [-0.1, 0.82, 0, 0, 1.282], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], "8968": [0.25, 0.75, 0, 0, 0.44445], "8969": [0.25, 0.75, 0, 0, 0.44445], "8970": [0.25, 0.75, 0, 0, 0.44445], @@ -2736,7 +2232,7 @@ var metricMap = { "8994": [-0.14236, 0.35764, 0, 0, 1.0], "8995": [-0.14236, 0.35764, 0, 0, 1.0], "9136": [0.244, 0.744, 0, 0, 0.412], - "9137": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], "9651": [0.19444, 0.69444, 0, 0, 0.88889], "9657": [-0.03472, 0.46528, 0, 0, 0.5], "9661": [0.19444, 0.69444, 0, 0, 0.88889], @@ -2752,7 +2248,7 @@ var metricMap = { "10216": [0.25, 0.75, 0, 0, 0.38889], "10217": [0.25, 0.75, 0, 0, 0.38889], "10222": [0.244, 0.744, 0, 0, 0.412], - "10223": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], "10229": [0.011, 0.511, 0, 0, 1.609], "10230": [0.011, 0.511, 0, 0, 1.638], "10231": [0.011, 0.511, 0, 0, 1.859], @@ -2766,6 +2262,17 @@ var metricMap = { "57376": [0.19444, 0.69444, 0, 0, 0] }, "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], "65": [0, 0.68611, 0, 0, 0.86944], "66": [0, 0.68611, 0.04835, 0, 0.8664], "67": [0, 0.68611, 0.06979, 0, 0.81694], @@ -2818,6 +2325,7 @@ var metricMap = { "120": [0, 0.44444, 0, 0, 0.65903], "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], "915": [0, 0.68611, 0.15972, 0, 0.65694], "916": [0, 0.68611, 0, 0, 0.95833], "920": [0, 0.68611, 0.03194, 0, 0.86722], @@ -2858,9 +2366,22 @@ var metricMap = { "981": [0.19444, 0.69444, 0, 0, 0.7125], "982": [0, 0.44444, 0.03194, 0, 0.975], "1009": [0.19444, 0.44444, 0, 0, 0.6118], - "1013": [0, 0.44444, 0, 0, 0.48333] + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] }, "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], "65": [0, 0.68333, 0, 0.13889, 0.75], "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], @@ -2913,6 +2434,7 @@ var metricMap = { "120": [0, 0.43056, 0, 0.02778, 0.57153], "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], "916": [0, 0.68333, 0, 0.16667, 0.83334], "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], @@ -2953,104 +2475,12 @@ var metricMap = { "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], "982": [0, 0.43056, 0.02778, 0, 0.82813], "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "1013": [0, 0.43056, 0, 0.05556, 0.4059] - }, - "Math-Regular": { - "65": [0, 0.68333, 0, 0.13889, 0.75], - "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], - "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], - "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], - "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], - "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], - "71": [0, 0.68333, 0, 0.08334, 0.78625], - "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], - "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], - "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], - "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], - "76": [0, 0.68333, 0, 0.02778, 0.68056], - "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], - "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], - "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], - "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], - "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], - "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], - "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], - "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], - "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], - "86": [0, 0.68333, 0.22222, 0, 0.58333], - "87": [0, 0.68333, 0.13889, 0, 0.94445], - "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], - "89": [0, 0.68333, 0.22222, 0, 0.58056], - "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], - "97": [0, 0.43056, 0, 0, 0.52859], - "98": [0, 0.69444, 0, 0, 0.42917], - "99": [0, 0.43056, 0, 0.05556, 0.43276], - "100": [0, 0.69444, 0, 0.16667, 0.52049], - "101": [0, 0.43056, 0, 0.05556, 0.46563], - "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], - "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], - "104": [0, 0.69444, 0, 0, 0.57616], - "105": [0, 0.65952, 0, 0, 0.34451], - "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], - "107": [0, 0.69444, 0.03148, 0, 0.5206], - "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], - "109": [0, 0.43056, 0, 0, 0.87801], - "110": [0, 0.43056, 0, 0, 0.60023], - "111": [0, 0.43056, 0, 0.05556, 0.48472], - "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], - "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], - "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], - "115": [0, 0.43056, 0, 0.05556, 0.46875], - "116": [0, 0.61508, 0, 0.08334, 0.36111], - "117": [0, 0.43056, 0, 0.02778, 0.57246], - "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], - "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], - "120": [0, 0.43056, 0, 0.02778, 0.57153], - "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], - "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], - "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], - "916": [0, 0.68333, 0, 0.16667, 0.83334], - "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], - "923": [0, 0.68333, 0, 0.16667, 0.69445], - "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], - "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], - "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], - "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], - "934": [0, 0.68333, 0, 0.08334, 0.66667], - "936": [0, 0.68333, 0.11, 0.05556, 0.61222], - "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], - "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], - "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], - "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], - "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], - "949": [0, 0.43056, 0, 0.08334, 0.46632], - "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], - "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], - "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], - "953": [0, 0.43056, 0, 0.05556, 0.35394], - "954": [0, 0.43056, 0, 0, 0.57616], - "955": [0, 0.69444, 0, 0, 0.58334], - "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], - "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], - "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], - "959": [0, 0.43056, 0, 0.05556, 0.48472], - "960": [0, 0.43056, 0.03588, 0, 0.57003], - "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], - "963": [0, 0.43056, 0.03588, 0, 0.57141], - "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], - "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], - "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], - "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], - "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], - "969": [0, 0.43056, 0.03588, 0, 0.62245], - "977": [0, 0.69444, 0, 0.08334, 0.59144], - "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], - "982": [0, 0.43056, 0.02778, 0, 0.82813], - "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], - "1013": [0, 0.43056, 0, 0.05556, 0.4059] + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] }, "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.36667], "34": [0, 0.69444, 0, 0, 0.55834], "35": [0.19444, 0.69444, 0, 0, 0.91667], @@ -3138,6 +2568,7 @@ var metricMap = { "121": [0.19444, 0.45833, 0.01528, 0, 0.5], "122": [0, 0.45833, 0, 0, 0.47639], "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.69444, 0, 0, 0.55], "176": [0, 0.69444, 0, 0, 0.73334], "180": [0, 0.69444, 0, 0, 0.55], @@ -3171,6 +2602,7 @@ var metricMap = { "8221": [0, 0.69444, 0, 0, 0.55834] }, "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0.05733, 0, 0.31945], "34": [0, 0.69444, 0.00316, 0, 0.5], "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], @@ -3258,6 +2690,7 @@ var metricMap = { "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], "122": [0, 0.44444, 0.08752, 0, 0.43472], "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.67937, 0.06385, 0, 0.5], "176": [0, 0.69444, 0, 0, 0.73752], "184": [0.17014, 0, 0, 0, 0.44445], @@ -3292,6 +2725,7 @@ var metricMap = { "8221": [0, 0.69444, 0.00316, 0, 0.5] }, "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], "33": [0, 0.69444, 0, 0, 0.31945], "34": [0, 0.69444, 0, 0, 0.5], "35": [0.19444, 0.69444, 0, 0, 0.83334], @@ -3379,6 +2813,7 @@ var metricMap = { "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], "122": [0, 0.44444, 0, 0, 0.43472], "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], "168": [0, 0.67937, 0, 0, 0.5], "176": [0, 0.69444, 0, 0, 0.66667], "184": [0.17014, 0, 0, 0, 0.44445], @@ -3413,6 +2848,7 @@ var metricMap = { "8221": [0, 0.69444, 0, 0, 0.5] }, "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], "65": [0, 0.7, 0.22925, 0, 0.80253], "66": [0, 0.7, 0.04087, 0, 0.90757], "67": [0, 0.7, 0.1689, 0, 0.66619], @@ -3438,9 +2874,11 @@ var metricMap = { "87": [0, 0.7, 0.27523, 0, 0.80532], "88": [0, 0.7, 0.26006, 0, 0.94445], "89": [0, 0.7, 0.2939, 0, 0.70961], - "90": [0, 0.7, 0.24037, 0, 0.8212] + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] }, "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.35001, 0.85, 0, 0, 0.45834], "41": [0.35001, 0.85, 0, 0, 0.45834], "47": [0.35001, 0.85, 0, 0, 0.57778], @@ -3449,6 +2887,7 @@ var metricMap = { "93": [0.35001, 0.85, 0, 0, 0.41667], "123": [0.35001, 0.85, 0, 0, 0.58334], "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.72222, 0, 0, 0.55556], "732": [0, 0.72222, 0, 0, 0.55556], "770": [0, 0.72222, 0, 0, 0.55556], @@ -3486,6 +2925,7 @@ var metricMap = { "10758": [0.25001, 0.75, 0, 0, 0.83334] }, "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.65002, 1.15, 0, 0, 0.59722], "41": [0.65002, 1.15, 0, 0, 0.59722], "47": [0.65002, 1.15, 0, 0, 0.81111], @@ -3494,6 +2934,7 @@ var metricMap = { "93": [0.65002, 1.15, 0, 0, 0.47222], "123": [0.65002, 1.15, 0, 0, 0.66667], "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.75, 0, 0, 1.0], "732": [0, 0.75, 0, 0, 1.0], "770": [0, 0.75, 0, 0, 1.0], @@ -3523,6 +2964,7 @@ var metricMap = { "10758": [0.55001, 1.05, 0, 0, 1.11111] }, "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [0.95003, 1.45, 0, 0, 0.73611], "41": [0.95003, 1.45, 0, 0, 0.73611], "47": [0.95003, 1.45, 0, 0, 1.04445], @@ -3531,6 +2973,7 @@ var metricMap = { "93": [0.95003, 1.45, 0, 0, 0.52778], "123": [0.95003, 1.45, 0, 0, 0.75], "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.75, 0, 0, 1.44445], "732": [0, 0.75, 0, 0, 1.44445], "770": [0, 0.75, 0, 0, 1.44445], @@ -3544,6 +2987,7 @@ var metricMap = { "10217": [0.95003, 1.45, 0, 0, 0.75] }, "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], "40": [1.25003, 1.75, 0, 0, 0.79167], "41": [1.25003, 1.75, 0, 0, 0.79167], "47": [1.25003, 1.75, 0, 0, 1.27778], @@ -3552,6 +2996,7 @@ var metricMap = { "93": [1.25003, 1.75, 0, 0, 0.58334], "123": [1.25003, 1.75, 0, 0, 0.80556], "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], "710": [0, 0.825, 0, 0, 1.8889], "732": [0, 0.825, 0, 0, 1.8889], "770": [0, 0.825, 0, 0, 1.8889], @@ -3717,284 +3162,1237 @@ var metricMap = { "8242": [0, 0.61111, 0, 0, 0.525], "9251": [0.11111, 0.21944, 0, 0, 0.525] } -}; +}; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm + +}; // This map contains a mapping from font name and character code to character +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. + +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ + +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ + +function getGlobalMetrics(size) { + var sizeIndex; + + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + + return fontMetricsBySizeIndex[sizeIndex]; +} + +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ +var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; // In these types, "" (empty string) means "no change". + + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + + /** + * The base size index. + */ + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ''; + this.fontShape = data.fontShape || ''; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + + + extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + + for (var key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + + + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + + + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + + + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + + + havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + + + havingBaseSizing() { + var size; + + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + + break; + + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + + break; + + default: + size = 6; + // normalsize in textstyle or displaystyle + } + + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + + + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + + + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + + + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + + + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + + + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + + + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + + + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + + + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } + +} + +Options.BASESIZE = 6; + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX + +}; // Dictionary of relative units, for fast validity testing. + +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ + +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + + + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ + +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; + +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(cls => cls).join(" "); +}; + +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ + + +var toNode = function toNode(tagName) { + var node = document.createElement(tagName); // Apply the class + + node.className = createClass(this.classes); // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + node.style[style] = this.style[style]; + } + } // Apply attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } // Append the children, also as HTML nodes + + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; +/** + * Convert into an HTML markup string + */ + + +var toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; // Add the class + + if (this.classes.length) { + markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; + } + + var styles = ""; // Add the styles, after hyphenation + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + utils.escape(styles) + "\""; + } // Add the attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; // Add the markup of the children, also as markup + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + /** - * This file contains metrics regarding fonts and individual symbols. The sigma - * and xi variables, as well as the metricMap map contain data extracted from - * TeX, TeX font metrics, and the TTF files. These data are then exposed via the - * `metrics` variable and the getCharacterMetrics function. + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. */ -// In TeX, there are actually three sets of dimensions, one for each of -// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: -// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are -// provided in the arrays below, in that order. -// -// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively. -// This was determined by running the following script: -// -// latex -interaction=nonstopmode \ -// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ -// '$a$ \expandafter\show\the\textfont2' \ -// '\expandafter\show\the\scriptfont2' \ -// '\expandafter\show\the\scriptscriptfont2' \ -// '\stop' -// -// The metrics themselves were retreived using the following commands: -// -// tftopl cmsy10 -// tftopl cmsy7 -// tftopl cmsy5 -// -// The output of each of these commands is quite lengthy. The only part we -// care about is the FONTDIMEN section. Each value is measured in EMs. -const sigmasAndXis = { - slant: [0.250, 0.250, 0.250], - // sigma1 - space: [0.000, 0.000, 0.000], - // sigma2 - stretch: [0.000, 0.000, 0.000], - // sigma3 - shrink: [0.000, 0.000, 0.000], - // sigma4 - xHeight: [0.431, 0.431, 0.431], - // sigma5 - quad: [1.000, 1.171, 1.472], - // sigma6 - extraSpace: [0.000, 0.000, 0.000], - // sigma7 - num1: [0.677, 0.732, 0.925], - // sigma8 - num2: [0.394, 0.384, 0.387], - // sigma9 - num3: [0.444, 0.471, 0.504], - // sigma10 - denom1: [0.686, 0.752, 1.025], - // sigma11 - denom2: [0.345, 0.344, 0.532], - // sigma12 - sup1: [0.413, 0.503, 0.504], - // sigma13 - sup2: [0.363, 0.431, 0.404], - // sigma14 - sup3: [0.289, 0.286, 0.294], - // sigma15 - sub1: [0.150, 0.143, 0.200], - // sigma16 - sub2: [0.247, 0.286, 0.400], - // sigma17 - supDrop: [0.386, 0.353, 0.494], - // sigma18 - subDrop: [0.050, 0.071, 0.100], - // sigma19 - delim1: [2.390, 1.700, 1.980], - // sigma20 - delim2: [1.010, 1.157, 1.420], - // sigma21 - axisHeight: [0.250, 0.250, 0.250], - // sigma22 - // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; - // they correspond to the font parameters of the extension fonts (family 3). - // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to - // match cmex7, we'd use cmex7.tfm values for script and scriptscript - // values. - defaultRuleThickness: [0.04, 0.049, 0.049], - // xi8; cmex7: 0.049 - bigOpSpacing1: [0.111, 0.111, 0.111], - // xi9 - bigOpSpacing2: [0.166, 0.166, 0.166], - // xi10 - bigOpSpacing3: [0.2, 0.2, 0.2], - // xi11 - bigOpSpacing4: [0.6, 0.611, 0.611], - // xi12; cmex7: 0.611 - bigOpSpacing5: [0.1, 0.143, 0.143], - // xi13; cmex7: 0.143 - // The \sqrt rule width is taken from the height of the surd character. - // Since we use the same font at all sizes, this thickness doesn't scale. - sqrtRuleThickness: [0.04, 0.04, 0.04], - // This value determines how large a pt is, for metrics which are defined - // in terms of pts. - // This value is also used in katex.less; if you change it make sure the - // values match. - ptPerEm: [10.0, 10.0, 10.0], - // The space between adjacent `|` columns in an array definition. From - // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. - doubleRuleSep: [0.2, 0.2, 0.2], - // The width of separator lines in {array} environments. From - // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. - arrayRuleWidth: [0.04, 0.04, 0.04], - // Two values from LaTeX source2e: - fboxsep: [0.3, 0.3, 0.3], - // 3 pt / ptPerEm - fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ -}; // This map contains a mapping from font name and character code to character -// should have Latin-1 and Cyrillic characters, but may not depending on the -// operating system. The metrics do not account for extra height from the -// accents. In the case of Cyrillic characters which have both ascenders and -// descenders we prefer approximations with ascenders, primarily to prevent -// the fraction bar or root line from intersecting the glyph. -// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. -const extraCharacterMap = { - // Latin-1 - 'Å': 'A', - 'Ç': 'C', - 'Ð': 'D', - 'Þ': 'o', - 'å': 'a', - 'ç': 'c', - 'ð': 'd', - 'þ': 'o', - // Cyrillic - 'А': 'A', - 'Б': 'B', - 'В': 'B', - 'Г': 'F', - 'Д': 'A', - 'Е': 'E', - 'Ж': 'K', - 'З': '3', - 'И': 'N', - 'Й': 'N', - 'К': 'K', - 'Л': 'N', - 'М': 'M', - 'Н': 'H', - 'О': 'O', - 'П': 'N', - 'Р': 'P', - 'С': 'C', - 'Т': 'T', - 'У': 'y', - 'Ф': 'O', - 'Х': 'X', - 'Ц': 'U', - 'Ч': 'h', - 'Ш': 'W', - 'Щ': 'W', - 'Ъ': 'B', - 'Ы': 'X', - 'Ь': 'B', - 'Э': '3', - 'Ю': 'X', - 'Я': 'R', - 'а': 'a', - 'б': 'b', - 'в': 'a', - 'г': 'r', - 'д': 'y', - 'е': 'e', - 'ж': 'm', - 'з': 'e', - 'и': 'n', - 'й': 'n', - 'к': 'n', - 'л': 'n', - 'м': 'm', - 'н': 'n', - 'о': 'o', - 'п': 'n', - 'р': 'p', - 'с': 'c', - 'т': 'o', - 'у': 'y', - 'ф': 'b', - 'х': 'x', - 'ц': 'n', - 'ч': 'n', - 'ш': 'w', - 'щ': 'w', - 'ъ': 'a', - 'ы': 'm', - 'ь': 'a', - 'э': 'e', - 'ю': 'm', - 'я': 'r' + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "span"); + } + + toMarkup() { + return toMarkup.call(this, "span"); + } + +} +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ + +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "a"); + } + + toMarkup() { + return toMarkup.call(this, "a"); + } + +} +/** + * This node represents an image embed () element. + */ + +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.style = style; + } + + hasClass(className) { + return utils.contains(this.classes, className); + } + + toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe + node.style[style] = this.style[style]; + } + } + + return node; + } + + toMarkup() { + var markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. + + span.style[style] = this.style[style]; + } + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + + + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + this.italic + "em;"; + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + utils.escape(styles) + "\""; + } + + var escaped = utils.escape(this.text); + + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } + } /** - * This function is a convenience function for looking up information in the - * metricMap table. It takes a character as a string, and a font. - * - * Note: the `width` property may be undefined if fontMetricsData.js wasn't - * built using `Make extended_metrics`. + * SVG nodes are used to render stretchy wide elements. */ -function getCharacterMetrics(character, font, mode) { - if (!metricMap[font]) { - throw new Error(`Font metrics not found for font: ${font}.`); +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + } + + toMarkup() { + var markup = ""; + } else { + return ""; } } - if (metrics) { - return { - depth: metrics[0], - height: metrics[1], - italic: metrics[2], - skew: metrics[3], - width: metrics[4] - }; - } } -const fontMetricsBySizeIndex = {}; -/** - * Get the font metrics for a given size. - */ +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } -function getGlobalMetrics(size) { - let sizeIndex; + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); // Apply attributes - if (size >= 5) { - sizeIndex = 0; - } else if (size >= 3) { - sizeIndex = 1; - } else { - sizeIndex = 2; + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + return node; } - if (!fontMetricsBySizeIndex[sizeIndex]) { - const metrics = fontMetricsBySizeIndex[sizeIndex] = { - cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 - }; + toMarkup() { + var markup = " but got " + String(group) + "."); + } } /** @@ -4018,7 +4416,7 @@ function getGlobalMetrics(size) { // types for raw text tokens, and we want to avoid conflicts with higher-level // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by // looking up the `symbols` map. -const ATOMS = { +var ATOMS = { "bin": 1, "close": 1, "inner": 1, @@ -4026,14 +4424,14 @@ const ATOMS = { "punct": 1, "rel": 1 }; -const NON_ATOMS = { +var NON_ATOMS = { "accent-token": 1, "mathord": 1, "op-token": 1, "spacing": 1, "textord": 1 }; -const symbols = { +var symbols = { "math": {}, "text": {} }; @@ -4053,23 +4451,23 @@ function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { // This helps minify the code, and also spotting typos using jshint. // modes: -const math = "math"; -const text$1 = "text"; // fonts: - -const main = "main"; -const ams = "ams"; // groups: - -const accent = "accent-token"; -const bin = "bin"; -const close = "close"; -const inner = "inner"; -const mathord = "mathord"; -const op = "op-token"; -const open = "open"; -const punct = "punct"; -const rel = "rel"; -const spacing = "spacing"; -const textord = "textord"; // Now comes the symbol table +var math = "math"; +var text = "text"; // fonts: + +var main = "main"; +var ams = "ams"; // groups: + +var accent = "accent-token"; +var bin = "bin"; +var close = "close"; +var inner = "inner"; +var mathord = "mathord"; +var op = "op-token"; +var open = "open"; +var punct = "punct"; +var rel = "rel"; +var spacing = "spacing"; +var textord = "textord"; // Now comes the symbol table // Relation Symbols defineSymbol(math, main, rel, "\u2261", "\\equiv", true); @@ -4101,9 +4499,9 @@ defineSymbol(math, main, punct, "\u002e", "\\ldotp"); defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols defineSymbol(math, main, textord, "\u0023", "\\#"); -defineSymbol(text$1, main, textord, "\u0023", "\\#"); +defineSymbol(text, main, textord, "\u0023", "\\#"); defineSymbol(math, main, textord, "\u0026", "\\&"); -defineSymbol(text$1, main, textord, "\u0026", "\\&"); +defineSymbol(text, main, textord, "\u0026", "\\&"); defineSymbol(math, main, textord, "\u2135", "\\aleph", true); defineSymbol(math, main, textord, "\u2200", "\\forall", true); defineSymbol(math, main, textord, "\u210f", "\\hbar", true); @@ -4120,15 +4518,17 @@ defineSymbol(math, main, textord, "\u211c", "\\Re", true); defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); defineSymbol(math, main, textord, "\u2111", "\\Im", true); defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); -defineSymbol(text$1, main, textord, "\u00a7", "\\S", true); -defineSymbol(text$1, main, textord, "\u00b6", "\\P", true); // Math and Text +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text, main, textord, "\u00b6", "\\P"); // Math and Text defineSymbol(math, main, textord, "\u2020", "\\dag"); -defineSymbol(text$1, main, textord, "\u2020", "\\dag"); -defineSymbol(text$1, main, textord, "\u2020", "\\textdagger"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); defineSymbol(math, main, textord, "\u2021", "\\ddag"); -defineSymbol(text$1, main, textord, "\u2021", "\\ddag"); -defineSymbol(text$1, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); @@ -4141,8 +4541,8 @@ defineSymbol(math, main, bin, "\u228e", "\\uplus", true); defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); defineSymbol(math, main, bin, "\u2217", "\\ast"); defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); -defineSymbol(math, main, bin, "\u25ef", "\\bigcirc"); -defineSymbol(math, main, bin, "\u2219", "\\bullet"); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); defineSymbol(math, main, bin, "\u2021", "\\ddagger"); defineSymbol(math, main, bin, "\u2240", "\\wr", true); defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); @@ -4173,7 +4573,7 @@ defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations -defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceded by "@" each have a corresponding macro. defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); @@ -4243,7 +4643,7 @@ defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); -defineSymbol(text$1, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); defineSymbol(math, ams, textord, "\u2204", "\\nexists"); defineSymbol(math, ams, textord, "\u2127", "\\mho"); @@ -4256,9 +4656,10 @@ defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); -defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 (ð) to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text, main, textord, "\u00f0", "\u00f0"); defineSymbol(math, ams, textord, "\u2571", "\\diagup"); defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); defineSymbol(math, ams, textord, "\u25a1", "\\square"); @@ -4266,9 +4667,9 @@ defineSymbol(math, ams, textord, "\u25a1", "\\Box"); defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); -defineSymbol(text$1, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); -defineSymbol(text$1, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew defineSymbol(math, ams, textord, "\u2136", "\\beth", true); defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); @@ -4277,10 +4678,10 @@ defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters -defineSymbol(math, ams, open, "\u250c", "\\ulcorner", true); -defineSymbol(math, ams, close, "\u2510", "\\urcorner", true); -defineSymbol(math, ams, open, "\u2514", "\\llcorner", true); -defineSymbol(math, ams, close, "\u2518", "\\lrcorner", true); // AMS Binary Relations +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); @@ -4401,6 +4802,10 @@ defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font + +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font + defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); @@ -4421,13 +4826,13 @@ defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); defineSymbol(math, ams, rel, "\u21be", "\\restriction"); defineSymbol(math, main, textord, "\u2018", "`"); defineSymbol(math, main, textord, "$", "\\$"); -defineSymbol(text$1, main, textord, "$", "\\$"); -defineSymbol(text$1, main, textord, "$", "\\textdollar"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); defineSymbol(math, main, textord, "%", "\\%"); -defineSymbol(text$1, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); defineSymbol(math, main, textord, "_", "\\_"); -defineSymbol(text$1, main, textord, "_", "\\_"); -defineSymbol(text$1, main, textord, "_", "\\textunderscore"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); defineSymbol(math, main, textord, "\u2220", "\\angle", true); defineSymbol(math, main, textord, "\u221e", "\\infty", true); defineSymbol(math, main, textord, "\u2032", "\\prime"); @@ -4492,44 +4897,38 @@ defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); -defineSymbol(math, main, bin, "\u2217", "*"); +defineSymbol(math, main, bin, "\u2217", "*", true); defineSymbol(math, main, bin, "+", "+"); -defineSymbol(math, main, bin, "\u2212", "-"); +defineSymbol(math, main, bin, "\u2212", "-", true); defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); -defineSymbol(math, main, bin, "\u2218", "\\circ"); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); defineSymbol(math, main, bin, "\u00f7", "\\div", true); defineSymbol(math, main, bin, "\u00b1", "\\pm", true); defineSymbol(math, main, bin, "\u00d7", "\\times", true); defineSymbol(math, main, bin, "\u2229", "\\cap", true); defineSymbol(math, main, bin, "\u222a", "\\cup", true); -defineSymbol(math, main, bin, "\u2216", "\\setminus"); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); defineSymbol(math, main, bin, "\u2227", "\\land"); defineSymbol(math, main, bin, "\u2228", "\\lor"); defineSymbol(math, main, bin, "\u2227", "\\wedge", true); defineSymbol(math, main, bin, "\u2228", "\\vee", true); defineSymbol(math, main, textord, "\u221a", "\\surd"); -defineSymbol(math, main, open, "(", "("); -defineSymbol(math, main, open, "[", "["); defineSymbol(math, main, open, "\u27e8", "\\langle", true); defineSymbol(math, main, open, "\u2223", "\\lvert"); defineSymbol(math, main, open, "\u2225", "\\lVert"); -defineSymbol(math, main, close, ")", ")"); -defineSymbol(math, main, close, "]", "]"); defineSymbol(math, main, close, "?", "?"); defineSymbol(math, main, close, "!", "!"); defineSymbol(math, main, close, "\u27e9", "\\rangle", true); defineSymbol(math, main, close, "\u2223", "\\rvert"); defineSymbol(math, main, close, "\u2225", "\\rVert"); defineSymbol(math, main, rel, "=", "="); -defineSymbol(math, main, rel, "<", "<"); -defineSymbol(math, main, rel, ">", ">"); defineSymbol(math, main, rel, ":", ":"); defineSymbol(math, main, rel, "\u2248", "\\approx", true); defineSymbol(math, main, rel, "\u2245", "\\cong", true); defineSymbol(math, main, rel, "\u2265", "\\ge"); defineSymbol(math, main, rel, "\u2265", "\\geq", true); defineSymbol(math, main, rel, "\u2190", "\\gets"); -defineSymbol(math, main, rel, ">", "\\gt"); +defineSymbol(math, main, rel, ">", "\\gt", true); defineSymbol(math, main, rel, "\u2208", "\\in", true); defineSymbol(math, main, rel, "\ue020", "\\@not"); defineSymbol(math, main, rel, "\u2282", "\\subset", true); @@ -4542,20 +4941,19 @@ defineSymbol(math, main, rel, "\u22a8", "\\models"); defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); defineSymbol(math, main, rel, "\u2264", "\\le"); defineSymbol(math, main, rel, "\u2264", "\\leq", true); -defineSymbol(math, main, rel, "<", "\\lt"); +defineSymbol(math, main, rel, "<", "\\lt", true); defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); defineSymbol(math, main, rel, "\u2192", "\\to"); defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); defineSymbol(math, main, spacing, "\u00a0", "\\ "); -defineSymbol(math, main, spacing, "\u00a0", "~"); defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); -defineSymbol(text$1, main, spacing, "\u00a0", "\\ "); -defineSymbol(text$1, main, spacing, "\u00a0", "~"); -defineSymbol(text$1, main, spacing, "\u00a0", "\\space"); -defineSymbol(text$1, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", " "); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); defineSymbol(math, main, spacing, null, "\\nobreak"); defineSymbol(math, main, spacing, null, "\\allowbreak"); defineSymbol(math, main, punct, ",", ","); @@ -4577,22 +4975,22 @@ defineSymbol(math, main, bin, "\u22c6", "\\star"); defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); defineSymbol(math, main, open, "{", "\\{"); -defineSymbol(text$1, main, textord, "{", "\\{"); -defineSymbol(text$1, main, textord, "{", "\\textbraceleft"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); defineSymbol(math, main, close, "}", "\\}"); -defineSymbol(text$1, main, textord, "}", "\\}"); -defineSymbol(text$1, main, textord, "}", "\\textbraceright"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); defineSymbol(math, main, open, "{", "\\lbrace"); defineSymbol(math, main, close, "}", "\\rbrace"); -defineSymbol(math, main, open, "[", "\\lbrack"); -defineSymbol(text$1, main, textord, "[", "\\lbrack"); -defineSymbol(math, main, close, "]", "\\rbrack"); -defineSymbol(text$1, main, textord, "]", "\\rbrack"); -defineSymbol(math, main, open, "(", "\\lparen"); -defineSymbol(math, main, close, ")", "\\rparen"); -defineSymbol(text$1, main, textord, "<", "\\textless"); // in T1 fontenc +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc -defineSymbol(text$1, main, textord, ">", "\\textgreater"); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc defineSymbol(math, main, open, "\u230a", "\\lfloor", true); defineSymbol(math, main, close, "\u230b", "\\rfloor", true); @@ -4601,14 +4999,14 @@ defineSymbol(math, main, close, "\u2309", "\\rceil", true); defineSymbol(math, main, textord, "\\", "\\backslash"); defineSymbol(math, main, textord, "\u2223", "|"); defineSymbol(math, main, textord, "\u2223", "\\vert"); -defineSymbol(text$1, main, textord, "|", "\\textbar"); // in T1 fontenc +defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc defineSymbol(math, main, textord, "\u2225", "\\|"); defineSymbol(math, main, textord, "\u2225", "\\Vert"); -defineSymbol(text$1, main, textord, "\u2225", "\\textbardbl"); -defineSymbol(text$1, main, textord, "~", "\\textasciitilde"); -defineSymbol(text$1, main, textord, "\\", "\\textbackslash"); -defineSymbol(text$1, main, textord, "^", "\\textasciicircum"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text, main, textord, "~", "\\textasciitilde"); +defineSymbol(text, main, textord, "\\", "\\textbackslash"); +defineSymbol(text, main, textord, "^", "\\textasciicircum"); defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); @@ -4635,9 +5033,9 @@ defineSymbol(math, main, op, "\u222f", "\\oiint"); defineSymbol(math, main, op, "\u2230", "\\oiiint"); defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); defineSymbol(math, main, op, "\u222b", "\\smallint"); -defineSymbol(text$1, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); -defineSymbol(text$1, main, inner, "\u2026", "\\ldots", true); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); defineSymbol(math, main, inner, "\u2026", "\\ldots", true); defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); @@ -4653,741 +5051,322 @@ defineSymbol(math, main, accent, "\u02c7", "\\check"); defineSymbol(math, main, accent, "\u005e", "\\hat"); defineSymbol(math, main, accent, "\u20d7", "\\vec"); defineSymbol(math, main, accent, "\u02d9", "\\dot"); -defineSymbol(math, main, accent, "\u02da", "\\mathring"); -defineSymbol(math, main, mathord, "\u0131", "\\imath", true); -defineSymbol(math, main, mathord, "\u0237", "\\jmath", true); -defineSymbol(text$1, main, textord, "\u0131", "\\i", true); -defineSymbol(text$1, main, textord, "\u0237", "\\j", true); -defineSymbol(text$1, main, textord, "\u00df", "\\ss", true); -defineSymbol(text$1, main, textord, "\u00e6", "\\ae", true); -defineSymbol(text$1, main, textord, "\u00e6", "\\ae", true); -defineSymbol(text$1, main, textord, "\u0153", "\\oe", true); -defineSymbol(text$1, main, textord, "\u00f8", "\\o", true); -defineSymbol(text$1, main, textord, "\u00c6", "\\AE", true); -defineSymbol(text$1, main, textord, "\u0152", "\\OE", true); -defineSymbol(text$1, main, textord, "\u00d8", "\\O", true); -defineSymbol(text$1, main, accent, "\u02ca", "\\'"); // acute - -defineSymbol(text$1, main, accent, "\u02cb", "\\`"); // grave - -defineSymbol(text$1, main, accent, "\u02c6", "\\^"); // circumflex - -defineSymbol(text$1, main, accent, "\u02dc", "\\~"); // tilde - -defineSymbol(text$1, main, accent, "\u02c9", "\\="); // macron - -defineSymbol(text$1, main, accent, "\u02d8", "\\u"); // breve - -defineSymbol(text$1, main, accent, "\u02d9", "\\."); // dot above - -defineSymbol(text$1, main, accent, "\u02da", "\\r"); // ring above - -defineSymbol(text$1, main, accent, "\u02c7", "\\v"); // caron - -defineSymbol(text$1, main, accent, "\u00a8", '\\"'); // diaresis - -defineSymbol(text$1, main, accent, "\u02dd", "\\H"); // double acute - -defineSymbol(text$1, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph -// These ligatures are detected and created in Parser.js's `formLigatures`. - -const ligatures = { - "--": true, - "---": true, - "``": true, - "''": true -}; -defineSymbol(text$1, main, textord, "\u2013", "--"); -defineSymbol(text$1, main, textord, "\u2013", "\\textendash"); -defineSymbol(text$1, main, textord, "\u2014", "---"); -defineSymbol(text$1, main, textord, "\u2014", "\\textemdash"); -defineSymbol(text$1, main, textord, "\u2018", "`"); -defineSymbol(text$1, main, textord, "\u2018", "\\textquoteleft"); -defineSymbol(text$1, main, textord, "\u2019", "'"); -defineSymbol(text$1, main, textord, "\u2019", "\\textquoteright"); -defineSymbol(text$1, main, textord, "\u201c", "``"); -defineSymbol(text$1, main, textord, "\u201c", "\\textquotedblleft"); -defineSymbol(text$1, main, textord, "\u201d", "''"); -defineSymbol(text$1, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package - -defineSymbol(math, main, textord, "\u00b0", "\\degree", true); -defineSymbol(text$1, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package - -defineSymbol(text$1, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math -// mode, but among our fonts, only Main-Italic defines this character "163". - -defineSymbol(math, main, mathord, "\u00a3", "\\pounds"); -defineSymbol(math, main, mathord, "\u00a3", "\\mathsterling", true); -defineSymbol(text$1, main, mathord, "\u00a3", "\\pounds"); -defineSymbol(text$1, main, mathord, "\u00a3", "\\textsterling", true); -defineSymbol(math, ams, textord, "\u2720", "\\maltese"); -defineSymbol(text$1, ams, textord, "\u2720", "\\maltese"); -defineSymbol(text$1, main, spacing, "\u00a0", "\\ "); -defineSymbol(text$1, main, spacing, "\u00a0", " "); -defineSymbol(text$1, main, spacing, "\u00a0", "~"); // There are lots of symbols which are the same, so we add them in afterwards. -// All of these are textords in math mode - -const mathTextSymbols = "0123456789/@.\""; - -for (let i = 0; i < mathTextSymbols.length; i++) { - const ch = mathTextSymbols.charAt(i); - defineSymbol(math, main, textord, ch, ch); -} // All of these are textords in text mode - - -const textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,"; - -for (let i = 0; i < textSymbols.length; i++) { - const ch = textSymbols.charAt(i); - defineSymbol(text$1, main, textord, ch, ch); -} // All of these are textords in text mode, and mathords in math mode - - -const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -for (let i = 0; i < letters.length; i++) { - const ch = letters.charAt(i); - defineSymbol(math, main, mathord, ch, ch); - defineSymbol(text$1, main, textord, ch, ch); -} // Blackboard bold and script letters in Unicode range - - -defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold - -defineSymbol(text$1, ams, textord, "C", "\u2102"); -defineSymbol(math, ams, textord, "H", "\u210D"); -defineSymbol(text$1, ams, textord, "H", "\u210D"); -defineSymbol(math, ams, textord, "N", "\u2115"); -defineSymbol(text$1, ams, textord, "N", "\u2115"); -defineSymbol(math, ams, textord, "P", "\u2119"); -defineSymbol(text$1, ams, textord, "P", "\u2119"); -defineSymbol(math, ams, textord, "Q", "\u211A"); -defineSymbol(text$1, ams, textord, "Q", "\u211A"); -defineSymbol(math, ams, textord, "R", "\u211D"); -defineSymbol(text$1, ams, textord, "R", "\u211D"); -defineSymbol(math, ams, textord, "Z", "\u2124"); -defineSymbol(text$1, ams, textord, "Z", "\u2124"); -defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant - -defineSymbol(text$1, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. -// We support some letters in the Unicode range U+1D400 to U+1D7FF, -// Mathematical Alphanumeric Symbols. -// Some editors do not deal well with wide characters. So don't write the -// string into this file. Instead, create the string from the surrogate pair. - -let wideChar = ""; - -for (let i = 0; i < letters.length; i++) { - const ch = letters.charAt(i); // The hex numbers in the next line are a surrogate pair. - // 0xD835 is the high surrogate for all letters in the range we support. - // 0xDC00 is the low surrogate for bold A. - - wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fractur - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - - if (i < 26) { - // KaTeX fonts have only capital letters for blackboard bold and script. - // See exception for k below. - wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - } // TODO: Add bold script when it is supported by a KaTeX font. - -} // "k" is the only double struck lower case letter in the KaTeX fonts. - - -wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - -defineSymbol(math, main, mathord, "k", wideChar); -defineSymbol(text$1, main, textord, "k", wideChar); // Next, some wide character numerals - -for (let i = 0; i < 10; i++) { - const ch = i.toString(); - wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace - - defineSymbol(math, main, mathord, ch, wideChar); - defineSymbol(text$1, main, textord, ch, wideChar); -} // We add these Latin-1 letters as symbols for backwards-compatibility, -// but they are not actually in the font, nor are they supported by the -// Unicode accent mechanism, so they fall back to Times font and look ugly. -// TODO(edemaine): Fix this. - - -const extraLatin = "ÇÐÞçþ"; - -for (let i = 0; i < extraLatin.length; i++) { - const ch = extraLatin.charAt(i); - defineSymbol(math, main, mathord, ch, ch); - defineSymbol(text$1, main, textord, ch, ch); -} +defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA -defineSymbol(text$1, main, textord, "ð", "ð"); // Unicode versions of existing characters +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text, main, textord, "\u0131", "\\i", true); +defineSymbol(text, main, textord, "\u0237", "\\j", true); +defineSymbol(text, main, textord, "\u00df", "\\ss", true); +defineSymbol(text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text, main, textord, "\u0153", "\\oe", true); +defineSymbol(text, main, textord, "\u00f8", "\\o", true); +defineSymbol(text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text, main, textord, "\u0152", "\\OE", true); +defineSymbol(text, main, textord, "\u00d8", "\\O", true); +defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute -defineSymbol(text$1, main, textord, "\u2013", "–"); -defineSymbol(text$1, main, textord, "\u2014", "—"); -defineSymbol(text$1, main, textord, "\u2018", "‘"); -defineSymbol(text$1, main, textord, "\u2019", "’"); -defineSymbol(text$1, main, textord, "\u201c", "“"); -defineSymbol(text$1, main, textord, "\u201d", "”"); +defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave -/** - * This file provides support for Unicode range U+1D400 to U+1D7FF, - * Mathematical Alphanumeric Symbols. - * - * Function wideCharacterFont takes a wide character as input and returns - * the font information necessary to render it properly. - */ -/** - * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf - * That document sorts characters into groups by font type, say bold or italic. - * - * In the arrays below, each subarray consists three elements: - * * The CSS class of that group when in math mode. - * * The CSS class of that group when in text mode. - * * The font name, so that KaTeX can get font metrics. - */ +defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex -const wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright -["mathbf", "textbf", "Main-Bold"], // a-z bold upright -["mathdefault", "textit", "Math-Italic"], // A-Z italic -["mathdefault", "textit", "Math-Italic"], // a-z italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic -// Map fancy A-Z letters to script, not calligraphic. -// This aligns with unicode-math and math fonts (except Cambria Math). -["mathscr", "textscr", "Script-Regular"], // A-Z script -["", "", ""], // a-z script. No font -["", "", ""], // A-Z bold script. No font -["", "", ""], // a-z bold script. No font -["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur -["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur -["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck -["mathbb", "textbb", "AMS-Regular"], // k double-struck -["", "", ""], // A-Z bold Fraktur No font metrics -["", "", ""], // a-z bold Fraktur. No font. -["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif -["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif -["", "", ""], // A-Z bold italic sans. No font -["", "", ""], // a-z bold italic sans. No font -["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace -["mathtt", "texttt", "Typewriter-Regular"]]; -const wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold -["", "", ""], // 0-9 double-struck. No KaTeX font. -["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif -["mathtt", "texttt", "Typewriter-Regular"]]; -const wideCharacterFont = function wideCharacterFont(wideChar, mode) { - // IE doesn't support codePointAt(). So work with the surrogate pair. - const H = wideChar.charCodeAt(0); // high surrogate +defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde - const L = wideChar.charCodeAt(1); // low surrogate +defineSymbol(text, main, accent, "\u02c9", "\\="); // macron - const codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; - const j = mode === "math" ? 0 : 1; // column index for CSS class. +defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve - if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { - // wideLatinLetterData contains exactly 26 chars on each row. - // So we can calculate the relevant row. No traverse necessary. - const i = Math.floor((codePoint - 0x1D400) / 26); - return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; - } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { - // Numerals, ten per row. - const i = Math.floor((codePoint - 0x1D7CE) / 10); - return [wideNumeralData[i][2], wideNumeralData[i][j]]; - } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { - // dotless i or j - return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; - } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { - // Greek letters. Not supported, yet. - return ["", ""]; - } else { - // We don't support any wide characters outside 1D400–1D7FF. - throw new ParseError("Unsupported character: " + wideChar); - } -}; +defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above -/** - * This file contains information about the options that the Parser carries - * around with it while parsing. Data is held in an `Options` object, and when - * recursing, a new `Options` object can be created with the `.with*` and - * `.reset` functions. - */ -const sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. -// The size mappings are taken from TeX with \normalsize=10pt. -[1, 1, 1], // size1: [5, 5, 5] \tiny -[2, 1, 1], // size2: [6, 5, 5] -[3, 1, 1], // size3: [7, 5, 5] \scriptsize -[4, 2, 1], // size4: [8, 6, 5] \footnotesize -[5, 2, 1], // size5: [9, 6, 5] \small -[6, 3, 1], // size6: [10, 7, 5] \normalsize -[7, 4, 2], // size7: [12, 8, 6] \large -[8, 6, 3], // size8: [14.4, 10, 7] \Large -[9, 7, 6], // size9: [17.28, 12, 10] \LARGE -[10, 8, 7], // size10: [20.74, 14.4, 12] \huge -[11, 10, 9]]; -const sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if -// you change size indexes, change that function. -0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla -const sizeAtStyle = function sizeAtStyle(size, style) { - return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; -}; // In these types, "" (empty string) means "no change". +defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron -/** - * This is the main options class. It contains the current style, size, color, - * and font. - * - * Options objects should not be modified. To create a new Options with - * different properties, call a `.having*` method. - */ -class Options { - // A font family applies to a group of fonts (i.e. SansSerif), while a font - // represents a specific font (i.e. SansSerif Bold). - // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm +defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis - /** - * The base size index. - */ - constructor(data) { - this.style = void 0; - this.color = void 0; - this.size = void 0; - this.textSize = void 0; - this.phantom = void 0; - this.font = void 0; - this.fontFamily = void 0; - this.fontWeight = void 0; - this.fontShape = void 0; - this.sizeMultiplier = void 0; - this.maxSize = void 0; - this.minRuleThickness = void 0; - this._fontMetrics = void 0; - this.style = data.style; - this.color = data.color; - this.size = data.size || Options.BASESIZE; - this.textSize = data.textSize || this.size; - this.phantom = !!data.phantom; - this.font = data.font || ""; - this.fontFamily = data.fontFamily || ""; - this.fontWeight = data.fontWeight || ''; - this.fontShape = data.fontShape || ''; - this.sizeMultiplier = sizeMultipliers[this.size - 1]; - this.maxSize = data.maxSize; - this.minRuleThickness = data.minRuleThickness; - this._fontMetrics = undefined; - } - /** - * Returns a new options object with the same properties as "this". Properties - * from "extension" will be copied to the new options object. - */ +defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. - extend(extension) { - const data = { - style: this.style, - size: this.size, - textSize: this.textSize, - color: this.color, - phantom: this.phantom, - font: this.font, - fontFamily: this.fontFamily, - fontWeight: this.fontWeight, - fontShape: this.fontShape, - maxSize: this.maxSize, - minRuleThickness: this.minRuleThickness - }; +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(text, main, textord, "\u2013", "--", true); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); +defineSymbol(text, main, textord, "\u2014", "---", true); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text, main, textord, "\u2018", "`", true); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text, main, textord, "\u2019", "'", true); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201c", "``", true); +defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201d", "''", true); +defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package - for (const key in extension) { - if (extension.hasOwnProperty(key)) { - data[key] = extension[key]; - } - } +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package - return new Options(data); - } - /** - * Return an options object with the given style. If `this.style === style`, - * returns `this`. - */ +defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode - havingStyle(style) { - if (this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: sizeAtStyle(this.textSize, style) - }); - } - } - /** - * Return an options object with a cramped version of the current style. If - * the current style is cramped, returns `this`. - */ +var mathTextSymbols = "0123456789/@.\""; +for (var i = 0; i < mathTextSymbols.length; i++) { + var ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} // All of these are textords in text mode - havingCrampedStyle() { - return this.havingStyle(this.style.cramp()); - } - /** - * Return an options object with the given size and in at least `\textstyle`. - * Returns `this` if appropriate. - */ +var textSymbols = "0123456789!@*()-=+\";:?/.,"; - havingSize(size) { - if (this.size === size && this.textSize === size) { - return this; - } else { - return this.extend({ - style: this.style.text(), - size: size, - textSize: size, - sizeMultiplier: sizeMultipliers[size - 1] - }); - } - } - /** - * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, - * changes to at least `\textstyle`. - */ +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + defineSymbol(text, main, textord, _ch, _ch); +} // All of these are textords in text mode, and mathords in math mode - havingBaseStyle(style) { - style = style || this.style.text(); - const wantSize = sizeAtStyle(Options.BASESIZE, style); - if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: wantSize - }); - } - } - /** - * Remove the effect of sizing changes such as \Huge. - * Keep the effect of the current style, such as \scriptstyle. - */ +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); - havingBaseSizing() { - let size; + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text, main, textord, _ch2, _ch2); +} // Blackboard bold and script letters in Unicode range - switch (this.style.id) { - case 4: - case 5: - size = 3; // normalsize in scriptstyle - break; +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold - case 6: - case 7: - size = 1; // normalsize in scriptscriptstyle +defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant - break; +defineSymbol(text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. - default: - size = 6; - // normalsize in textstyle or displaystyle - } +var wideChar = ""; - return this.extend({ - style: this.style.text(), - size: size - }); - } - /** - * Create a new options object with the given color. - */ +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. - withColor(color) { - return this.extend({ - color: color - }); - } - /** - * Create a new options object with "phantom" set to true. - */ + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic - withPhantom() { - return this.extend({ - phantom: true - }); - } - /** - * Creates a new options object with the given math font or old text font. - * @type {[type]} - */ + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur - withFont(font) { - return this.extend({ - font - }); - } - /** - * Create a new options objects with the given fontFamily. - */ + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fractur + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif - withTextFontFamily(fontFamily) { - return this.extend({ - fontFamily, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic - withTextFontWeight(fontWeight) { - return this.extend({ - fontWeight, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); - withTextFontShape(fontShape) { - return this.extend({ - fontShape, - font: "" - }); - } - /** - * Return the CSS sizing classes required to switch from enclosing options - * `oldOptions` to `this`. Returns an array of classes. - */ + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script - sizingClasses(oldOptions) { - if (oldOptions.size !== this.size) { - return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; - } else { - return []; - } - } - /** - * Return the CSS sizing classes required to switch to the base size. Like - * `this.havingSize(BASESIZE).sizingClasses(this)`. - */ + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + } // TODO: Add bold script when it is supported by a KaTeX font. +} // "k" is the only double struck lower case letter in the KaTeX fonts. - baseSizingClasses() { - if (this.size !== Options.BASESIZE) { - return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; - } else { - return []; - } - } - /** - * Return the font metrics for this size. - */ +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - fontMetrics() { - if (!this._fontMetrics) { - this._fontMetrics = getGlobalMetrics(this.size); - } +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text, main, textord, "k", wideChar); // Next, some wide character numerals - return this._fontMetrics; - } - /** - * Gets the CSS color of the current options object - */ +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold - getColor() { - if (this.phantom) { - return "transparent"; - } else { - return this.color; - } - } + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans -} + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace -Options.BASESIZE = 6; + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); +} // We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. -/** - * This file does conversion between units. In particular, it provides - * calculateSize to convert other units into ems. - */ -// Thus, multiplying a length by this number converts the length from units -// into pts. Dividing the result by ptPerEm gives the number of ems -// *assuming* a font size of ptPerEm (normal size, normal style). -const ptPerUnit = { - // https://en.wikibooks.org/wiki/LaTeX/Lengths and - // https://tex.stackexchange.com/a/8263 - "pt": 1, - // TeX point - "mm": 7227 / 2540, - // millimeter - "cm": 7227 / 254, - // centimeter - "in": 72.27, - // inch - "bp": 803 / 800, - // big (PostScript) points - "pc": 12, - // pica - "dd": 1238 / 1157, - // didot - "cc": 14856 / 1157, - // cicero (12 didot) - "nd": 685 / 642, - // new didot - "nc": 1370 / 107, - // new cicero (12 new didot) - "sp": 1 / 65536, - // scaled point (TeX's internal smallest unit) - // https://tex.stackexchange.com/a/41371 - "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +var extraLatin = "\u00d0\u00de\u00fe"; -}; // Dictionary of relative units, for fast validity testing. +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); -const relativeUnit = { - "ex": true, - "em": true, - "mu": true -}; + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text, main, textord, _ch5, _ch5); +} /** - * Determine whether the specified unit (either a string defining the unit - * or a "size" parse node containing a unit field) is valid. + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. */ -const validUnit = function validUnit(unit) { - if (typeof unit !== "string") { - unit = unit.unit; - } - - return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; -}; -/* - * Convert a "size" parse node (with numeric "number" and string "unit" fields, - * as parsed by functions.js argType "size") into a CSS em value for the - * current style/scale. `options` gives the current options. +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each subarray consists three elements: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. */ -const calculateSize = function calculateSize(sizeValue, options) { - let scale; - - if (sizeValue.unit in ptPerUnit) { - // Absolute units - scale = ptPerUnit[sizeValue.unit] // Convert unit to pt - / options.fontMetrics().ptPerEm // Convert pt to CSS em - / options.sizeMultiplier; // Unscale to make absolute units - } else if (sizeValue.unit === "mu") { - // `mu` units scale with scriptstyle/scriptscriptstyle. - scale = options.fontMetrics().cssEmPerMu; - } else { - // Other relative units always refer to the *textstyle* font - // in the current size. - let unitOptions; +var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright +["mathbf", "textbf", "Main-Bold"], // a-z bold upright +["mathnormal", "textit", "Math-Italic"], // A-Z italic +["mathnormal", "textit", "Math-Italic"], // a-z italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +["mathscr", "textscr", "Script-Regular"], // A-Z script +["", "", ""], // a-z script. No font +["", "", ""], // A-Z bold script. No font +["", "", ""], // a-z bold script. No font +["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur +["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur +["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck +["mathbb", "textbb", "AMS-Regular"], // k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur +["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif +["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif +["", "", ""], // A-Z bold italic sans. No font +["", "", ""], // a-z bold italic sans. No font +["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace +["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace +]; +var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold +["", "", ""], // 0-9 double-struck. No KaTeX font. +["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif +["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace +]; +var wideCharacterFont = function wideCharacterFont(wideChar, mode) { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate - if (options.style.isTight()) { - // isTight() means current style is script/scriptscript. - unitOptions = options.havingStyle(options.style.text()); - } else { - unitOptions = options; - } // TODO: In TeX these units are relative to the quad of the current - // *text* font, e.g. cmr10. KaTeX instead uses values from the - // comparably-sized *Computer Modern symbol* font. At 10pt, these - // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; - // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. - // TeX \showlists shows a kern of 1.13889 * fontsize; - // KaTeX shows a kern of 1.171 * fontsize. + var L = wideChar.charCodeAt(1); // low surrogate + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + var j = mode === "math" ? 0 : 1; // column index for CSS class. - if (sizeValue.unit === "ex") { - scale = unitOptions.fontMetrics().xHeight; - } else if (sizeValue.unit === "em") { - scale = unitOptions.fontMetrics().quad; - } else { - throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); - } + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); - if (unitOptions !== options) { - scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; - } + return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return ["", ""]; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new ParseError("Unsupported character: " + wideChar); } - - return Math.min(sizeValue.number * scale, options.maxSize); }; /* eslint no-console:0 */ -// The following have to be loaded from Main-Italic font, using class mathit -const mathitLetters = ["\\imath", "ı", // dotless i -"\\jmath", "ȷ", // dotless j -"\\pounds", "\\mathsterling", "\\textsterling", "£"]; + /** * Looks up the given symbol in fontMetrics, after applying any symbol * replacements defined in symbol.js */ - -const lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this. +var lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this. fontName, mode) { // Replace the value with its replaced value from symbol.js if (symbols[mode][value] && symbols[mode][value].replace) { @@ -5411,14 +5390,14 @@ fontName, mode) { */ -const makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { - const lookup = lookupSymbol(value, fontName, mode); - const metrics = lookup.metrics; +var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { + var lookup = lookupSymbol(value, fontName, mode); + var metrics = lookup.metrics; value = lookup.value; - let symbolNode; + var symbolNode; if (metrics) { - let italic = metrics.italic; + var italic = metrics.italic; if (mode === "text" || options && options.font === "mathit") { italic = 0; @@ -5427,7 +5406,7 @@ const makeSymbol = function makeSymbol(value, fontName, mode, options, classes) symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); } else { // TODO(emily): Figure out a good way to only print this in development - typeof console !== "undefined" && console.warn("No character metrics " + `for '${value}' in style '${fontName}' and mode '${mode}'`); + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); } @@ -5438,7 +5417,7 @@ const makeSymbol = function makeSymbol(value, fontName, mode, options, classes) symbolNode.classes.push("mtight"); } - const color = options.getColor(); + var color = options.getColor(); if (color) { symbolNode.style.color = color; @@ -5453,7 +5432,7 @@ const makeSymbol = function makeSymbol(value, fontName, mode, options, classes) */ -const mathsym = function mathsym(value, mode, options, classes) { +var mathsym = function mathsym(value, mode, options, classes) { if (classes === void 0) { classes = []; } @@ -5473,54 +5452,6 @@ const mathsym = function mathsym(value, mode, options, classes) { return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); } }; -/** - * Determines which of the two font names (Main-Italic and Math-Italic) and - * corresponding style tags (maindefault or mathit) to use for default math font, - * depending on the symbol. - */ - - -const mathdefault = function mathdefault(value, mode, options, classes) { - if (/[0-9]/.test(value.charAt(0)) || // glyphs for \imath and \jmath do not exist in Math-Italic so we - // need to use Main-Italic instead - utils.contains(mathitLetters, value)) { - return { - fontName: "Main-Italic", - fontClass: "mathit" - }; - } else { - return { - fontName: "Math-Italic", - fontClass: "mathdefault" - }; - } -}; -/** - * Determines which of the font names (Main-Italic, Math-Italic, and Caligraphic) - * and corresponding style tags (mathit, mathdefault, or mathcal) to use for font - * "mathnormal", depending on the symbol. Use this function instead of fontMap for - * font "mathnormal". - */ - - -const mathnormal = function mathnormal(value, mode, options, classes) { - if (utils.contains(mathitLetters, value)) { - return { - fontName: "Main-Italic", - fontClass: "mathit" - }; - } else if (/[0-9]/.test(value.charAt(0))) { - return { - fontName: "Caligraphic-Regular", - fontClass: "mathcal" - }; - } else { - return { - fontName: "Math-Italic", - fontClass: "mathdefault" - }; - } -}; /** * Determines which of the two font names (Main-Bold and Math-BoldItalic) and * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", @@ -5529,8 +5460,8 @@ const mathnormal = function mathnormal(value, mode, options, classes) { */ -const boldsymbol = function boldsymbol(value, mode, options, classes) { - if (lookupSymbol(value, "Math-BoldItalic", mode).metrics) { +var boldsymbol = function boldsymbol(value, mode, options, classes, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { return { fontName: "Math-BoldItalic", fontClass: "boldsymbol" @@ -5549,32 +5480,31 @@ const boldsymbol = function boldsymbol(value, mode, options, classes) { */ -const makeOrd = function makeOrd(group, options, type) { - const mode = group.mode; - const text = group.text; - const classes = ["mord"]; // Math mode or Old font (i.e. \rm) +var makeOrd = function makeOrd(group, options, type) { + var mode = group.mode; + var text = group.text; + var classes = ["mord"]; // Math mode or Old font (i.e. \rm) - const isFont = mode === "math" || mode === "text" && options.font; - const fontOrFamily = isFont ? options.font : options.fontFamily; + var isFont = mode === "math" || mode === "text" && options.font; + var fontOrFamily = isFont ? options.font : options.fontFamily; + var wideFontName = ""; + var wideFontClass = ""; if (text.charCodeAt(0) === 0xD835) { - // surrogate pairs get special treatment - const _wideCharacterFont = wideCharacterFont(text, mode), - wideFontName = _wideCharacterFont[0], - wideFontClass = _wideCharacterFont[1]; + [wideFontName, wideFontClass] = wideCharacterFont(text, mode); + } + if (wideFontName.length > 0) { + // surrogate pairs get special treatment return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); } else if (fontOrFamily) { - let fontName; - let fontClasses; + var fontName; + var fontClasses; - if (fontOrFamily === "boldsymbol" || fontOrFamily === "mathnormal") { - const fontData = fontOrFamily === "boldsymbol" ? boldsymbol(text, mode, options, classes) : mathnormal(text, mode, options, classes); + if (fontOrFamily === "boldsymbol") { + var fontData = boldsymbol(text, mode, options, classes, type); fontName = fontData.fontName; fontClasses = [fontData.fontClass]; - } else if (utils.contains(mathitLetters, text)) { - fontName = "Main-Italic"; - fontClasses = ["mathit"]; } else if (isFont) { fontName = fontMap[fontOrFamily].fontName; fontClasses = [fontOrFamily]; @@ -5585,11 +5515,11 @@ const makeOrd = function makeOrd(group, options, type) { if (lookupSymbol(text, fontName, mode).metrics) { return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); - } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") { + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { // Deconstruct ligatures in monospace fonts (\texttt, \tt). - const parts = []; + var parts = []; - for (let i = 0; i < text.length; i++) { + for (var i = 0; i < text.length; i++) { parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); } @@ -5599,22 +5529,24 @@ const makeOrd = function makeOrd(group, options, type) { if (type === "mathord") { - const fontLookup = mathdefault(text, mode, options, classes); - return makeSymbol(text, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass])); + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); } else if (type === "textord") { - const font = symbols[mode][text] && symbols[mode][text].font; + var font = symbols[mode][text] && symbols[mode][text].font; if (font === "ams") { - const fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); - return makeSymbol(text, fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); + var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); } else if (font === "main" || !font) { - const fontName = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); - return makeSymbol(text, fontName, mode, options, classes.concat(options.fontWeight, options.fontShape)); + var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape)); } else { // fonts added by plugins - const fontName = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class + var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class - return makeSymbol(text, fontName, mode, options, classes.concat(fontName, options.fontWeight, options.fontShape)); + + return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape)); } } else { throw new Error("unexpected type: " + type + " in makeOrd"); @@ -5626,19 +5558,29 @@ const makeOrd = function makeOrd(group, options, type) { */ -const canCombine = (prev, next) => { +var canCombine = (prev, next) => { if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) { return false; + } // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + + + if (prev.classes.length === 1) { + var cls = prev.classes[0]; + + if (cls === "mbin" || cls === "mord") { + return false; + } } - for (const style in prev.style) { + for (var style in prev.style) { if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { return false; } } - for (const style in next.style) { - if (next.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { + for (var _style in next.style) { + if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) { return false; } } @@ -5646,15 +5588,15 @@ const canCombine = (prev, next) => { return true; }; /** - * Combine consequetive domTree.symbolNodes into a single symbolNode. + * Combine consecutive domTree.symbolNodes into a single symbolNode. * Note: this function mutates the argument. */ -const tryCombineChars = chars => { - for (let i = 0; i < chars.length - 1; i++) { - const prev = chars[i]; - const next = chars[i + 1]; +var tryCombineChars = chars => { + for (var i = 0; i < chars.length - 1; i++) { + var prev = chars[i]; + var next = chars[i + 1]; if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { prev.text += next.text; @@ -5677,13 +5619,13 @@ const tryCombineChars = chars => { */ -const sizeElementFromChildren = function sizeElementFromChildren(elem) { - let height = 0; - let depth = 0; - let maxFontSize = 0; +var sizeElementFromChildren = function sizeElementFromChildren(elem) { + var height = 0; + var depth = 0; + var maxFontSize = 0; - for (let i = 0; i < elem.children.length; i++) { - const child = elem.children[i]; + for (var i = 0; i < elem.children.length; i++) { + var child = elem.children[i]; if (child.height > height) { height = child.height; @@ -5712,20 +5654,20 @@ const sizeElementFromChildren = function sizeElementFromChildren(elem) { */ -const makeSpan = function makeSpan(classes, children, options, style) { - const span = new Span(classes, children, options, style); +var makeSpan$2 = function makeSpan(classes, children, options, style) { + var span = new Span(classes, children, options, style); sizeElementFromChildren(span); return span; }; // SVG one is simpler -- doesn't require height, depth, max-font setting. // This is also a separate method for typesafety. -const makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); +var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); -const makeLineSpan = function makeLineSpan(className, options, thickness) { - const line = makeSpan([className], [], options); +var makeLineSpan = function makeLineSpan(className, options, thickness) { + var line = makeSpan$2([className], [], options); line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); - line.style.borderBottomWidth = line.height + "em"; + line.style.borderBottomWidth = makeEm(line.height); line.maxFontSize = 1.0; return line; }; @@ -5735,8 +5677,8 @@ const makeLineSpan = function makeLineSpan(className, options, thickness) { */ -const makeAnchor = function makeAnchor(href, classes, children, options) { - const anchor = new Anchor(href, classes, children, options); +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new Anchor(href, classes, children, options); sizeElementFromChildren(anchor); return anchor; }; @@ -5745,8 +5687,8 @@ const makeAnchor = function makeAnchor(href, classes, children, options) { */ -const makeFragment = function makeFragment(children) { - const fragment = new DocumentFragment(children); +var makeFragment = function makeFragment(children) { + var fragment = new DocumentFragment(children); sizeElementFromChildren(fragment); return fragment; }; @@ -5756,9 +5698,9 @@ const makeFragment = function makeFragment(children) { */ -const wrapFragment = function wrapFragment(group, options) { +var wrapFragment = function wrapFragment(group, options) { if (group instanceof DocumentFragment) { - return makeSpan([], [group], options); + return makeSpan$2([], [group], options); } return group; @@ -5769,18 +5711,19 @@ const wrapFragment = function wrapFragment(group, options) { // // This helper function for makeVList makes it easier to enforce type safety by // allowing early exits (returns) in the logic. -const getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { if (params.positionType === "individualShift") { - const oldChildren = params.children; - const children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be + var oldChildren = params.children; + var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be // shifted to the correct specified shift - const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; - let currPos = depth; + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; - for (let i = 1; i < oldChildren.length; i++) { - const diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; - const size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + var currPos = _depth; + + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); currPos = currPos + diff; children.push({ type: "kern", @@ -5791,19 +5734,19 @@ const getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { return { children, - depth + depth: _depth }; } - let depth; + var depth; if (params.positionType === "top") { // We always start at the bottom, so calculate the bottom by adding up // all the sizes - let bottom = params.positionData; + var bottom = params.positionData; - for (let i = 0; i < params.children.length; i++) { - const child = params.children[i]; + for (var _i = 0; _i < params.children.length; _i++) { + var child = params.children[_i]; bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; } @@ -5811,7 +5754,7 @@ const getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { } else if (params.positionType === "bottom") { depth = -params.positionData; } else { - const firstChild = params.children[0]; + var firstChild = params.children[0]; if (firstChild.type !== "elem") { throw new Error('First child must have type "elem".'); @@ -5822,7 +5765,7 @@ const getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { } else if (params.positionType === "firstBaseline") { depth = -firstChild.elem.depth; } else { - throw new Error(`Invalid positionType ${params.positionType}.`); + throw new Error("Invalid positionType " + params.positionType + "."); } } @@ -5839,10 +5782,11 @@ const getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { */ -const makeVList = function makeVList(params, options) { - const _getVListChildrenAndD = getVListChildrenAndDepth(params), - children = _getVListChildrenAndD.children, - depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to +var makeVList = function makeVList(params, options) { + var { + children, + depth + } = getVListChildrenAndDepth(params); // Create a strut that is taller than any list item. The strut is added to // each item, where it will determine the item's baseline. Since it has // `overflow:hidden`, the strut's top edge will sit on the item's line box's // top edge and the strut's bottom edge will sit on the item's baseline, @@ -5850,49 +5794,48 @@ const makeVList = function makeVList(params, options) { // be positioned precisely without worrying about font ascent and // line-height. + var pstrutSize = 0; - let pstrutSize = 0; - - for (let i = 0; i < children.length; i++) { - const child = children[i]; + for (var i = 0; i < children.length; i++) { + var child = children[i]; if (child.type === "elem") { - const elem = child.elem; + var elem = child.elem; pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); } } pstrutSize += 2; - const pstrut = makeSpan(["pstrut"], []); - pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets + var pstrut = makeSpan$2(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets - const realChildren = []; - let minPos = depth; - let maxPos = depth; - let currPos = depth; + var realChildren = []; + var minPos = depth; + var maxPos = depth; + var currPos = depth; - for (let i = 0; i < children.length; i++) { - const child = children[i]; + for (var _i2 = 0; _i2 < children.length; _i2++) { + var _child = children[_i2]; - if (child.type === "kern") { - currPos += child.size; + if (_child.type === "kern") { + currPos += _child.size; } else { - const elem = child.elem; - const classes = child.wrapperClasses || []; - const style = child.wrapperStyle || {}; - const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); - childWrap.style.top = -pstrutSize - currPos - elem.depth + "em"; - - if (child.marginLeft) { - childWrap.style.marginLeft = child.marginLeft; + var _elem = _child.elem; + var classes = _child.wrapperClasses || []; + var style = _child.wrapperStyle || {}; + var childWrap = makeSpan$2(classes, [pstrut, _elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); + + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; } - if (child.marginRight) { - childWrap.style.marginRight = child.marginRight; + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; } realChildren.push(childWrap); - currPos += elem.height + elem.depth; + currPos += _elem.height + _elem.depth; } minPos = Math.min(minPos, currPos); @@ -5902,10 +5845,10 @@ const makeVList = function makeVList(params, options) { // without overly expanding the containing line-box. - const vlist = makeSpan(["vlist"], realChildren); - vlist.style.height = maxPos + "em"; // A second row is used if necessary to represent the vlist's depth. + var vlist = makeSpan$2(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth. - let rows; + var rows; if (minPos < 0) { // We will define depth in an empty span with display: table-cell. @@ -5913,18 +5856,18 @@ const makeVList = function makeVList(params, options) { // contenteditable mode only, treats that span as if it contains some // text content. And that min-height over-rides our desired height. // So we put another empty span inside the depth strut span. - const emptySpan = makeSpan([], []); - const depthStrut = makeSpan(["vlist"], [emptySpan]); - depthStrut.style.height = -minPos + "em"; // Safari wants the first row to have inline content; otherwise it + var emptySpan = makeSpan$2([], []); + var depthStrut = makeSpan$2(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it // puts the bottom of the *second* row on the baseline. - const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); - rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + var topStrut = makeSpan$2(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan$2(["vlist-r"], [vlist, topStrut]), makeSpan$2(["vlist-r"], [depthStrut])]; } else { - rows = [makeSpan(["vlist-r"], [vlist])]; + rows = [makeSpan$2(["vlist-r"], [vlist])]; } - const vtable = makeSpan(["vlist-t"], rows); + var vtable = makeSpan$2(["vlist-t"], rows); if (rows.length === 2) { vtable.classes.push("vlist-t2"); @@ -5938,17 +5881,17 @@ const makeVList = function makeVList(params, options) { // static space between elements in a horizontal layout. -const makeGlue = (measurement, options) => { +var makeGlue = (measurement, options) => { // Make an empty span for the space - const rule = makeSpan(["mspace"], [], options); - const size = calculateSize(measurement, options); - rule.style.marginRight = `${size}em`; + var rule = makeSpan$2(["mspace"], [], options); + var size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); return rule; }; // Takes font options, and returns the appropriate fontLookup name -const retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) { - let baseFontName = ""; +var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) { + var baseFontName = ""; switch (fontFamily) { case "amsrm": @@ -5972,7 +5915,7 @@ const retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeigh // use fonts added by a plugin } - let fontStylesName; + var fontStylesName; if (fontWeight === "textbf" && fontShape === "textit") { fontStylesName = "BoldItalic"; @@ -5984,7 +5927,7 @@ const retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeigh fontStylesName = "Regular"; } - return `${baseFontName}-${fontStylesName}`; + return baseFontName + "-" + fontStylesName; }; /** * Maps TeX font commands to objects containing: @@ -5994,7 +5937,7 @@ const retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeigh // A map between tex font commands an MathML mathvariant attribute values -const fontMap = { +var fontMap = { // styles "mathbf": { variant: "bold", @@ -6012,12 +5955,13 @@ const fontMap = { variant: "italic", fontName: "Main-Italic" }, - // Default math font, "mathnormal" and "boldsymbol" are missing because they - // require the use of several fonts: Main-Italic and Math-Italic for default - // math font, Main-Italic, Math-Italic, Caligraphic for "mathnormal", and - // Math-BoldItalic and Main-Bold for "boldsymbol". This is handled by a - // special case in makeOrd which ends up calling mathdefault, mathnormal, - // and boldsymbol. + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. // families "mathbb": { variant: "double-struck", @@ -6044,7 +5988,7 @@ const fontMap = { fontName: "Typewriter-Regular" } }; -const svgData = { +var svgData = { // path, width, height vec: ["vec", 0.471, 0.714], // values from the font glyph @@ -6055,25 +5999,22 @@ const svgData = { oiiintSize2: ["oiiintSize2", 1.98, 0.659] }; -const staticSvg = function staticSvg(value, options) { +var staticSvg = function staticSvg(value, options) { // Create a span with inline SVG for the element. - const _svgData$value = svgData[value], - pathName = _svgData$value[0], - width = _svgData$value[1], - height = _svgData$value[2]; - const path = new PathNode(pathName); - const svgNode = new SvgNode([path], { - "width": width + "em", - "height": height + "em", + var [pathName, width, height] = svgData[value]; + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), // Override CSS rule `.katex svg { width: 100% }` - "style": "width:" + width + "em", + "style": "width:" + makeEm(width), "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, "preserveAspectRatio": "xMinYMin" }); - const span = makeSvgSpan(["overlay"], [svgNode], options); + var span = makeSvgSpan(["overlay"], [svgNode], options); span.height = height; - span.style.height = height + "em"; - span.style.width = width + "em"; + span.style.height = makeEm(height); + span.style.width = makeEm(width); return span; }; @@ -6081,7 +6022,7 @@ var buildCommon = { fontMap, makeSymbol, mathsym, - makeSpan, + makeSpan: makeSpan$2, makeSvgSpan, makeLineSpan, makeAnchor, @@ -6095,98 +6036,18 @@ var buildCommon = { tryCombineChars }; -/** - * Asserts that the node is of the given type and returns it with stricter - * typing. Throws if the node's type does not match. - */ -function assertNodeType(node, type) { - const typedNode = checkNodeType(node, type); - - if (!typedNode) { - throw new Error(`Expected node of type ${type}, but got ` + (node ? `node of type ${node.type}` : String(node))); - } // $FlowFixMe: Unsure why. - - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkNodeType(node, type) { - if (node && node.type === type) { - // The definition of ParseNode doesn't communicate to flow that - // `type: TYPE` (as that's not explicitly mentioned anywhere), though that - // happens to be true for all our value types. - // $FlowFixMe - return node; - } - - return null; -} -/** - * Asserts that the node is of the given type and returns it with stricter - * typing. Throws if the node's type does not match. - */ - -function assertAtomFamily(node, family) { - const typedNode = checkAtomFamily(node, family); - - if (!typedNode) { - throw new Error(`Expected node of type "atom" and family "${family}", but got ` + (node ? node.type === "atom" ? `atom of family ${node.family}` : `node of type ${node.type}` : String(node))); - } - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkAtomFamily(node, family) { - return node && node.type === "atom" && node.family === family ? node : null; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function assertSymbolNodeType(node) { - const typedNode = checkSymbolNodeType(node); - - if (!typedNode) { - throw new Error(`Expected node of symbol group type, but got ` + (node ? `node of type ${node.type}` : String(node))); - } - - return typedNode; -} -/** - * Returns the node more strictly typed iff it is of the given type. Otherwise, - * returns null. - */ - -function checkSymbolNodeType(node) { - if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { - // $FlowFixMe - return node; - } - - return null; -} - /** * Describes spaces between different classes of atoms. */ -const thinspace = { +var thinspace = { number: 3, unit: "mu" }; -const mediumspace = { +var mediumspace = { number: 4, unit: "mu" }; -const thickspace = { +var thickspace = { number: 5, unit: "mu" }; // Making the type below exact with all optional fields doesn't work due to @@ -6196,7 +6057,7 @@ const thickspace = { // above. // Spacing relationships for display and text styles -const spacings = { +var spacings = { mord: { mop: thinspace, mbin: mediumspace, @@ -6248,7 +6109,7 @@ const spacings = { } }; // Spacing relationships for script and scriptscript styles -const tightSpacings = { +var tightSpacings = { mord: { mop: thinspace }, @@ -6268,45 +6129,63 @@ const tightSpacings = { } }; +/** Context provided to function handlers for error messages. */ +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ + /** * All registered functions. * `functions.js` just exports this same dictionary again and makes it public. * `Parser.js` requires this dictionary. */ -const _functions = {}; +var _functions = {}; /** * All HTML builders. Should be only used in the `define*` and the `build*ML` * functions. */ -const _htmlGroupBuilders = {}; +var _htmlGroupBuilders = {}; /** * All MathML builders. Should be only used in the `define*` and the `build*ML` * functions. */ -const _mathmlGroupBuilders = {}; +var _mathmlGroupBuilders = {}; function defineFunction(_ref) { - let type = _ref.type, - names = _ref.names, - props = _ref.props, - handler = _ref.handler, - htmlBuilder = _ref.htmlBuilder, - mathmlBuilder = _ref.mathmlBuilder; + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; // Set default values of functions - const data = { + var data = { type, numArgs: props.numArgs, argTypes: props.argTypes, - greediness: props.greediness === undefined ? 1 : props.greediness, + allowedInArgument: !!props.allowedInArgument, allowedInText: !!props.allowedInText, allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, numOptionalArgs: props.numOptionalArgs || 0, infix: !!props.infix, + primitive: !!props.primitive, handler: handler }; - for (let i = 0; i < names.length; ++i) { + for (var i = 0; i < names.length; ++i) { _functions[names[i]] = data; } @@ -6327,9 +6206,11 @@ function defineFunction(_ref) { */ function defineFunctionBuilders(_ref2) { - let type = _ref2.type, - htmlBuilder = _ref2.htmlBuilder, - mathmlBuilder = _ref2.mathmlBuilder; + var { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; defineFunction({ type, names: [], @@ -6344,12 +6225,14 @@ function defineFunctionBuilders(_ref2) { htmlBuilder, mathmlBuilder }); -} // Since the corresponding buildHTML/buildMathML function expects a +} +var normalizeArgument = function normalizeArgument(arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; // Since the corresponding buildHTML/buildMathML function expects a // list of elements, we normalize for different kinds of arguments -const ordargument = function ordargument(arg) { - const node = checkNodeType(arg, "ordgroup"); - return node ? node.body : [arg]; +var ordargument = function ordargument(arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; }; /** @@ -6358,19 +6241,19 @@ const ordargument = function ordargument(arg) { * Then, the buildExpression, buildGroup, and various groupBuilders functions * are called, to produce a final HTML tree. */ -const makeSpan$1 = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +var makeSpan$1 = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, // and the text before Rule 19. -const binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; -const binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; -const styleMap = { +var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; +var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; +var styleMap$1 = { "display": Style$1.DISPLAY, "text": Style$1.TEXT, "script": Style$1.SCRIPT, "scriptscript": Style$1.SCRIPTSCRIPT }; -const DomEnum = { +var DomEnum = { mord: "mord", mop: "mop", mbin: "mbin", @@ -6389,56 +6272,59 @@ const DomEnum = { * a partial group (e.g. one created by \color). `surrounding` is an array * consisting type of nodes that will be added to the left and right. */ -const buildExpression = function buildExpression(expression, options, isRealGroup, surrounding) { +var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) { if (surrounding === void 0) { surrounding = [null, null]; } // Parse expressions into `groups`. - const groups = []; + var groups = []; - for (let i = 0; i < expression.length; i++) { - const output = buildGroup(expression[i], options); + for (var i = 0; i < expression.length; i++) { + var output = buildGroup$1(expression[i], options); if (output instanceof DocumentFragment) { - const children = output.children; + var children = output.children; groups.push(...children); } else { groups.push(output); } - } // If `expression` is a partial group, let the parent handle spacings - // to avoid processing groups multiple times. + } // Combine consecutive domTree.symbolNodes into a single symbolNode. + buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { return groups; } - let glueOptions = options; + var glueOptions = options; if (expression.length === 1) { - const node = checkNodeType(expression[0], "sizing") || checkNodeType(expression[0], "styling"); + var node = expression[0]; - if (!node) ; else if (node.type === "sizing") { + if (node.type === "sizing") { glueOptions = options.havingSize(node.size); } else if (node.type === "styling") { - glueOptions = options.havingStyle(styleMap[node.style]); + glueOptions = options.havingStyle(styleMap$1[node.style]); } } // Dummy spans for determining spacings between surrounding atoms. // If `expression` has no atoms on the left or right, class "leftmost" // or "rightmost", respectively, is used to indicate it. - const dummyPrev = makeSpan$1([surrounding[0] || "leftmost"], [], options); - const dummyNext = makeSpan$1([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element + var dummyPrev = makeSpan$1([surrounding[0] || "leftmost"], [], options); + var dummyNext = makeSpan$1([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element // of its `classes` array. A later cleanup should ensure this, for // instance by changing the signature of `makeSpan`. // Before determining what spaces to insert, perform bin cancellation. // Binary operators change to ordinary symbols in some contexts. + var isRoot = isRealGroup === "root"; traverseNonSpaceNodes(groups, (node, prev) => { - const prevType = prev.classes[0]; - const type = node.classes[0]; + var prevType = prev.classes[0]; + var type = node.classes[0]; if (prevType === "mbin" && utils.contains(binRightCanceller, type)) { prev.classes[0] = "mord"; @@ -6447,12 +6333,12 @@ const buildExpression = function buildExpression(expression, options, isRealGrou } }, { node: dummyPrev - }, dummyNext); + }, dummyNext, isRoot); traverseNonSpaceNodes(groups, (node, prev) => { - const prevType = getTypeOfDomTree(prev); - const type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. + var prevType = getTypeOfDomTree(prev); + var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. - const space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; + var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; if (space) { // Insert glue (spacing) after the `prev`. @@ -6460,7 +6346,7 @@ const buildExpression = function buildExpression(expression, options, isRealGrou } }, { node: dummyPrev - }, dummyNext); + }, dummyNext, isRoot); return groups; }; // Depth-first traverse non-space `nodes`, calling `callback` with the current and // previous node as arguments, optionally returning a node to insert after the @@ -6468,44 +6354,48 @@ const buildExpression = function buildExpression(expression, options, isRealGrou // function to insert after it. `next` is a node that will be added to the right. // Used for bin cancellation and inserting spacings. -const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next) { +var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) { if (next) { // temporarily append the right node, if exists nodes.push(next); } - let i = 0; + var i = 0; for (; i < nodes.length; i++) { - const node = nodes[i]; - const partialGroup = checkPartialGroup(node); + var node = nodes[i]; + var partialGroup = checkPartialGroup(node); if (partialGroup) { // Recursive DFS // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array - traverseNonSpaceNodes(partialGroup.children, callback, prev); + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); continue; } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit // spacing should go between atoms of different classes - if (node.classes[0] === "mspace") { - continue; - } + var nonspace = !node.hasClass("mspace"); - const result = callback(node, prev.node); + if (nonspace) { + var result = callback(node, prev.node); - if (result) { - if (prev.insertAfter) { - prev.insertAfter(result); - } else { - // insert at front - nodes.unshift(result); - i++; + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } } } - prev.node = node; + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan$1(["leftmost"]); // treat like beginning of line + } prev.insertAfter = (index => n => { nodes.splice(index + 1, 0, n); @@ -6519,8 +6409,8 @@ const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, pr }; // Check if given node is a partial group, i.e., does not affect spacing around. -const checkPartialGroup = function checkPartialGroup(node) { - if (node instanceof DocumentFragment || node instanceof Anchor) { +var checkPartialGroup = function checkPartialGroup(node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { return node; } @@ -6528,11 +6418,11 @@ const checkPartialGroup = function checkPartialGroup(node) { }; // Return the outermost node of a domTree. -const getOutermostNode = function getOutermostNode(node, side) { - const partialGroup = checkPartialGroup(node); +var getOutermostNode = function getOutermostNode(node, side) { + var partialGroup = checkPartialGroup(node); if (partialGroup) { - const children = partialGroup.children; + var children = partialGroup.children; if (children.length) { if (side === "right") { @@ -6548,7 +6438,7 @@ const getOutermostNode = function getOutermostNode(node, side) { // If `side` is given, it will get the type of the outermost node at given side. -const getTypeOfDomTree = function getTypeOfDomTree(node, side) { +var getTypeOfDomTree = function getTypeOfDomTree(node, side) { if (!node) { return null; } @@ -6561,8 +6451,8 @@ const getTypeOfDomTree = function getTypeOfDomTree(node, side) { return DomEnum[node.classes[0]] || null; }; -const makeNullDelimiter = function makeNullDelimiter(options, classes) { - const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); +var makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); return makeSpan$1(classes.concat(moreClasses)); }; /** @@ -6571,19 +6461,20 @@ const makeNullDelimiter = function makeNullDelimiter(options, classes) { * between parents and children. */ -const buildGroup = function buildGroup(group, options, baseOptions) { +var buildGroup$1 = function buildGroup(group, options, baseOptions) { if (!group) { return makeSpan$1(); } if (_htmlGroupBuilders[group.type]) { // Call the groupBuilders function - let groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account + // $FlowFixMe + var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account // for that size difference. if (baseOptions && options.size !== baseOptions.size) { groupNode = makeSpan$1(options.sizingClasses(baseOptions), [groupNode], options); - const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; groupNode.height *= multiplier; groupNode.depth *= multiplier; } @@ -6602,17 +6493,17 @@ const buildGroup = function buildGroup(group, options, baseOptions) { function buildHTMLUnbreakable(children, options) { // Compute height and depth of this chunk. - const body = makeSpan$1(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at + var body = makeSpan$1(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at // the height of the expression, and the bottom of the HTML element // falls at the depth of the expression. - // We used to have separate top and bottom struts, where the bottom strut - // would like to use `vertical-align: top`, but in IE 9 this lowers the - // baseline of the box to the bottom of this strut (instead of staying in - // the normal place) so we use an absolute value for vertical-align instead. - - const strut = makeSpan$1(["strut"]); - strut.style.height = body.height + body.depth + "em"; - strut.style.verticalAlign = -body.depth + "em"; + + var strut = makeSpan$1(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); return body; } @@ -6624,7 +6515,7 @@ function buildHTMLUnbreakable(children, options) { function buildHTML(tree, options) { // Strip off outer tag wrapper for processing below. - let tag = null; + var tag = null; if (tree.length === 1 && tree[0].type === "tag") { tag = tree[0].tag; @@ -6632,23 +6523,30 @@ function buildHTML(tree, options) { } // Build the expression contained in the tree - const expression = buildExpression(tree, options, true); - const children = []; // Create one base node for each chunk between potential line breaks. + var expression = buildExpression$1(tree, options, "root"); + var eqnNum; + + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + var children = []; // Create one base node for each chunk between potential line breaks. // The TeXBook [p.173] says "A formula will be broken only after a // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary // operation symbol like $+$ or $-$ or $\times$, where the relation or // binary operation is on the ``outer level'' of the formula (i.e., not // enclosed in {...} and not part of an \over construction)." - let parts = []; + var parts = []; - for (let i = 0; i < expression.length; i++) { + for (var i = 0; i < expression.length; i++) { parts.push(expression[i]); if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { // Put any post-operator glue on same line as operator. // Watch for \nobreak along the way, and stop at \newline. - let nobreak = false; + var nobreak = false; while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { i++; @@ -6683,22 +6581,27 @@ function buildHTML(tree, options) { } // Now, if there was a tag, build it too and append it as a final child. - let tagChild; + var tagChild; if (tag) { - tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true)); + tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true)); tagChild.classes = ["tag"]; children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); } - const htmlNode = makeSpan$1(["katex-html"], children); + var htmlNode = makeSpan$1(["katex-html"], children); htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children // (the height of the enclosing htmlNode) for proper vertical alignment. if (tagChild) { - const strut = tagChild.children[0]; - strut.style.height = htmlNode.height + htmlNode.depth + "em"; - strut.style.verticalAlign = -htmlNode.depth + "em"; + var strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } } return htmlNode; @@ -6710,7 +6613,7 @@ function buildHTML(tree, options) { * since we're mainly using MathML to improve accessibility, we don't manage * any of the styling state that the plain DOM nodes do. * - * The `toNode` and `toMarkup` functions work simlarly to how they do in + * The `toNode` and `toMarkup` functions work similarly to how they do in * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. */ function newDocumentFragment(children) { @@ -6723,13 +6626,15 @@ function newDocumentFragment(children) { */ class MathNode { - constructor(type, children) { + constructor(type, children, classes) { this.type = void 0; this.attributes = void 0; this.children = void 0; + this.classes = void 0; this.type = type; this.attributes = {}; this.children = children || []; + this.classes = classes || []; } /** * Sets an attribute on a MathML node. MathML depends on attributes to convey a @@ -6754,15 +6659,19 @@ class MathNode { toNode() { - const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); - for (const attr in this.attributes) { + for (var attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { node.setAttribute(attr, this.attributes[attr]); } } - for (let i = 0; i < this.children.length; i++) { + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (var i = 0; i < this.children.length; i++) { node.appendChild(this.children[i].toNode()); } @@ -6774,9 +6683,9 @@ class MathNode { toMarkup() { - let markup = "<" + this.type; // Add the attributes + var markup = "<" + this.type; // Add the attributes - for (const attr in this.attributes) { + for (var attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { markup += " " + attr + "=\""; markup += utils.escape(this.attributes[attr]); @@ -6784,9 +6693,13 @@ class MathNode { } } + if (this.classes.length > 0) { + markup += " class =\"" + utils.escape(createClass(this.classes)) + "\""; + } + markup += ">"; - for (let i = 0; i < this.children.length; i++) { + for (var i = 0; i < this.children.length; i++) { markup += this.children[i].toMarkup(); } @@ -6831,7 +6744,7 @@ class TextNode { } /** * Converts the text node into a string - * (representing the text iteself). + * (representing the text itself). */ @@ -6886,8 +6799,8 @@ class SpaceNode { if (this.character) { return document.createTextNode(this.character); } else { - const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); - node.setAttribute("width", this.width + "em"); + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); return node; } } @@ -6898,9 +6811,9 @@ class SpaceNode { toMarkup() { if (this.character) { - return `${this.character}`; + return "" + this.character + ""; } else { - return ``; + return ""; } } /** @@ -6926,7 +6839,7 @@ var mathMLTree = { }; /** - * This file converts a parse tree into a cooresponding MathML tree. The main + * This file converts a parse tree into a corresponding MathML tree. The main * entry point is the `buildMathML` function, which takes a parse tree from the * parser. */ @@ -6935,8 +6848,8 @@ var mathMLTree = { * Takes a symbol and converts it into a MathML text node after performing * optional replacement from symbols.js. */ -const makeText = function makeText(text, mode, options) { - if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.substr(4, 2) === "tt" || options.font && options.font.substr(4, 2) === "tt"))) { +var makeText = function makeText(text, mode, options) { + if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { text = symbols[mode][text].replace; } @@ -6947,7 +6860,7 @@ const makeText = function makeText(text, mode, options) { * unless the array has length 1. Always returns a single node. */ -const makeRow = function makeRow(body) { +var makeRow = function makeRow(body) { if (body.length === 1) { return body[0]; } else { @@ -6958,7 +6871,7 @@ const makeRow = function makeRow(body) { * Returns the math variant as a string or null if none is required. */ -const getVariant = function getVariant(group, options) { +var getVariant = function getVariant(group, options) { // Handle \text... font specifiers as best we can. // MathML has a limited list of allowable mathvariant specifiers; see // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt @@ -6982,18 +6895,18 @@ const getVariant = function getVariant(group, options) { return "bold"; } - const font = options.font; + var font = options.font; if (!font || font === "mathnormal") { return null; } - const mode = group.mode; + var mode = group.mode; if (font === "mathit") { return "italic"; } else if (font === "boldsymbol") { - return "bold-italic"; + return group.type === "textord" ? "bold" : "bold-italic"; } else if (font === "mathbf") { return "bold"; } else if (font === "mathbb") { @@ -7001,7 +6914,7 @@ const getVariant = function getVariant(group, options) { } else if (font === "mathfrak") { return "fraktur"; } else if (font === "mathscr" || font === "mathcal") { - // MathML makes no distinction between script and caligrahpic + // MathML makes no distinction between script and calligraphic return "script"; } else if (font === "mathsf") { return "sans-serif"; @@ -7009,7 +6922,7 @@ const getVariant = function getVariant(group, options) { return "monospace"; } - let text = group.text; + var text = group.text; if (utils.contains(["\\imath", "\\jmath"], text)) { return null; @@ -7019,7 +6932,7 @@ const getVariant = function getVariant(group, options) { text = symbols[mode][text].replace; } - const fontName = buildCommon.fontMap[font].fontName; + var fontName = buildCommon.fontMap[font].fontName; if (getCharacterMetrics(text, fontName, mode)) { return buildCommon.fontMap[font].variant; @@ -7033,9 +6946,9 @@ const getVariant = function getVariant(group, options) { * tag. */ -const buildExpression$1 = function buildExpression(expression, options, isOrdgroup) { +var buildExpression = function buildExpression(expression, options, isOrdgroup) { if (expression.length === 1) { - const group = buildGroup$1(expression[0], options); + var group = buildGroup(expression[0], options); if (isOrdgroup && group instanceof MathNode && group.type === "mo") { // When TeX writers want to suppress spacing on an operator, @@ -7047,44 +6960,44 @@ const buildExpression$1 = function buildExpression(expression, options, isOrdgro return [group]; } - const groups = []; - let lastGroup; + var groups = []; + var lastGroup; - for (let i = 0; i < expression.length; i++) { - const group = buildGroup$1(expression[i], options); + for (var i = 0; i < expression.length; i++) { + var _group = buildGroup(expression[i], options); - if (group instanceof MathNode && lastGroup instanceof MathNode) { + if (_group instanceof MathNode && lastGroup instanceof MathNode) { // Concatenate adjacent s - if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { - lastGroup.children.push(...group.children); + if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(..._group.children); continue; // Concatenate adjacent s - } else if (group.type === 'mn' && lastGroup.type === 'mn') { - lastGroup.children.push(...group.children); + } else if (_group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); continue; // Concatenate ... followed by . - } else if (group.type === 'mi' && group.children.length === 1 && lastGroup.type === 'mn') { - const child = group.children[0]; + } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') { + var child = _group.children[0]; if (child instanceof TextNode && child.text === '.') { - lastGroup.children.push(...group.children); + lastGroup.children.push(..._group.children); continue; } } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { - const lastChild = lastGroup.children[0]; + var lastChild = lastGroup.children[0]; - if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (group.type === 'mo' || group.type === 'mi' || group.type === 'mn')) { - const child = group.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { + var _child = _group.children[0]; - if (child instanceof TextNode && child.text.length > 0) { + if (_child instanceof TextNode && _child.text.length > 0) { // Overlay with combining character long solidus - child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); + _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1); groups.pop(); } } } } - groups.push(group); - lastGroup = group; + groups.push(_group); + lastGroup = _group; } return groups; @@ -7094,22 +7007,24 @@ const buildExpression$1 = function buildExpression(expression, options, isOrdgro * if there's more than one. Returns a single node instead of an array. */ -const buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { - return makeRow(buildExpression$1(expression, options, isOrdgroup)); +var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { + return makeRow(buildExpression(expression, options, isOrdgroup)); }; /** * Takes a group from the parser and calls the appropriate groupBuilders function * on it to produce a MathML node. */ -const buildGroup$1 = function buildGroup(group, options) { +var buildGroup = function buildGroup(group, options) { if (!group) { return new mathMLTree.MathNode("mrow"); } if (_mathmlGroupBuilders[group.type]) { // Call the groupBuilders function - const result = _mathmlGroupBuilders[group.type](group, options); + // $FlowFixMe + var result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe + return result; } else { throw new ParseError("Got group of unknown type: '" + group.type + "'"); @@ -7124,11 +7039,15 @@ const buildGroup$1 = function buildGroup(group, options) { * we can do appropriate styling. */ -function buildMathML(tree, texExpression, options, forMathmlOnly) { - const expression = buildExpression$1(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + var expression = buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics // tag correctly, unless it's a single or . - let wrapper; + var wrapper; if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) { wrapper = expression[0]; @@ -7137,21 +7056,26 @@ function buildMathML(tree, texExpression, options, forMathmlOnly) { } // Build a TeX annotation of the source - const annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); + var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); annotation.setAttribute("encoding", "application/x-tex"); - const semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); - const math = new mathMLTree.MathNode("math", [semantics]); - math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); // You can't style nodes, so we wrap the node in a span. + var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); + var math = new mathMLTree.MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + + if (isDisplayMode) { + math.setAttribute("display", "block"); + } // You can't style nodes, so we wrap the node in a span. // NOTE: The span class is not typed to have nodes as children, and // we don't want to make the children type more generic since the children // of span are expected to have more fields in `buildHtml` contexts. - const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe + + var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe return buildCommon.makeSpan([wrapperClass], [math]); } -const optionsFromSettings = function optionsFromSettings(settings) { +var optionsFromSettings = function optionsFromSettings(settings) { return new Options({ style: settings.displayMode ? Style$1.DISPLAY : Style$1.TEXT, maxSize: settings.maxSize, @@ -7159,9 +7083,9 @@ const optionsFromSettings = function optionsFromSettings(settings) { }); }; -const displayWrap = function displayWrap(node, settings) { +var displayWrap = function displayWrap(node, settings) { if (settings.displayMode) { - const classes = ["katex-display"]; + var classes = ["katex-display"]; if (settings.leqno) { classes.push("leqno"); @@ -7177,27 +7101,29 @@ const displayWrap = function displayWrap(node, settings) { return node; }; -const buildTree = function buildTree(tree, expression, settings) { - const options = optionsFromSettings(settings); - let katexNode; +var buildTree = function buildTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var katexNode; if (settings.output === "mathml") { - return buildMathML(tree, expression, options, true); + return buildMathML(tree, expression, options, settings.displayMode, true); } else if (settings.output === "html") { - const htmlNode = buildHTML(tree, options); + var htmlNode = buildHTML(tree, options); katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); } else { - const mathMLNode = buildMathML(tree, expression, options, false); - const htmlNode = buildHTML(tree, options); - katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, htmlNode]); + var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + + var _htmlNode = buildHTML(tree, options); + + katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]); } return displayWrap(katexNode, settings); }; -const buildHTMLTree = function buildHTMLTree(tree, expression, settings) { - const options = optionsFromSettings(settings); - const htmlNode = buildHTML(tree, options); - const katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); +var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var htmlNode = buildHTML(tree, options); + var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); return displayWrap(katexNode, settings); }; @@ -7206,7 +7132,7 @@ const buildHTMLTree = function buildHTMLTree(tree, expression, settings) { * for stretchy wide elements rendered from SVG files * and other CSS trickery. */ -const stretchyCodePoint = { +var stretchyCodePoint = { widehat: "^", widecheck: "ˇ", widetilde: "~", @@ -7246,12 +7172,15 @@ const stretchyCodePoint = { xrightleftarrows: "\u21c4", xrightequilibrium: "\u21cc", // Not a perfect match. - xleftequilibrium: "\u21cb" // None better available. - + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" }; -const mathMLnode = function mathMLnode(label) { - const node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.substr(1)])]); +var mathMLnode = function mathMLnode(label) { + var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); node.setAttribute("stretchy", "true"); return node; }; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. @@ -7292,14 +7221,17 @@ const mathMLnode = function mathMLnode(label) { // corresponds to 0.522 em inside the document. -const katexImagesData = { +var katexImagesData = { // path(s), minWidth, height, align overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], @@ -7310,6 +7242,7 @@ const katexImagesData = { xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], @@ -7337,599 +7270,1199 @@ const katexImagesData = { xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] }; -const groupLength = function groupLength(arg) { - if (arg.type === "ordgroup") { - return arg.body.length; - } else { - return 1; - } -}; +var groupLength = function groupLength(arg) { + if (arg.type === "ordgroup") { + return arg.body.length; + } else { + return 1; + } +}; + +var svgSpan = function svgSpan(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + + var label = group.label.slice(1); + + if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { + // Each type in the `if` statement corresponds to one of the ParseNode + // types below. This narrowing is required to access `grp.base`. + // $FlowFixMe + var grp = group; // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + + var numChars = groupLength(grp.base); + var viewBoxHeight; + var pathName; + + var _height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + _height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + _height = 0.34; + pathName = "tilde4"; + } + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(_height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: buildCommon.makeSvgSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + var data = katexImagesData[label]; + var [paths, _minWidth, _viewBoxHeight] = data; + + var _height2 = _viewBoxHeight / 1000; + + var numSvgChildren = paths.length; + var widthClasses; + var aligns; + + if (numSvgChildren === 1) { + // $FlowFixMe: All these cases must be of the 4-tuple type. + var align1 = data[3]; + widthClasses = ["hide-tail"]; + aligns = [align1]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + + for (var i = 0; i < numSvgChildren; i++) { + var _path = new PathNode(paths[i]); + + var _svgNode = new SvgNode([_path], { + "width": "400em", + "height": makeEm(_height2), + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + + var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options); + + if (numSvgChildren === 1) { + return { + span: _span, + minWidth: _minWidth, + height: _height2 + }; + } else { + _span.style.height = makeEm(_height2); + spans.push(_span); + } + } + + return { + span: buildCommon.makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + + + var { + span, + minWidth, + height + } = buildSvgSpan_(); // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + + span.height = height; + span.style.height = makeEm(height); + + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + var img; + var totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = buildCommon.makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + var color = options.color && options.getColor(); + + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + var lines = []; + + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + + var svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = buildCommon.makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +var stretchy = { + encloseSpan, + mathMLnode, + svgSpan +}; + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } // $FlowFixMe, >=0.125 + + + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function assertSymbolNodeType(node) { + var typedNode = checkSymbolNodeType(node); + + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + + return typedNode; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + // $FlowFixMe + return node; + } + + return null; +} + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +var htmlBuilder$a = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + var base; + var group; + var supSubGroup; + + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group + + base = group.base; // Stick the character box into the base of the supsub group + + grp.base = base; // Rerender the supsub group with its new base, and store that + // result. + + supSubGroup = assertSpan(buildGroup$1(grp, options)); // reset original base + + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } // Build the base group + + + var body = buildGroup$1(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + + var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + + var skew = 0; -const svgSpan = function svgSpan(group, options) { - // Create a span with inline SVG for the element. - function buildSvgSpan_() { - let viewBoxWidth = 400000; // default + if (mustShift) { + // If the base is a character box, then we want the skew of the + // innermost character. To do that, we find the innermost character: + var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it - const label = group.label.substr(1); + var baseGroup = buildGroup$1(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. - if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { - // Each type in the `if` statement corresponds to one of the ParseNode - // types below. This narrowing is required to access `grp.base`. - const grp = group; // There are four SVG images available for each function. - // Choose a taller image when there are more characters. + skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we + // removed with getBaseElem might contain things like \color which + // we can't get rid of. + // TODO(emily): Find a better way to get the skew + } - const numChars = groupLength(grp.base); - let viewBoxHeight; - let pathName; - let height; + var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent - if (numChars > 5) { - if (label === "widehat" || label === "widecheck") { - viewBoxHeight = 420; - viewBoxWidth = 2364; - height = 0.42; - pathName = label + "4"; - } else { - viewBoxHeight = 312; - viewBoxWidth = 2340; - height = 0.34; - pathName = "tilde4"; - } - } else { - const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent - if (label === "widehat" || label === "widecheck") { - viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; - viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; - height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; - pathName = label + imgIndex; - } else { - viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; - viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; - height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; - pathName = "tilde" + imgIndex; - } - } + var accentBody; - const path = new PathNode(pathName); - const svgNode = new SvgNode([path], { - "width": "100%", - "height": height + "em", - "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, - "preserveAspectRatio": "none" - }); - return { - span: buildCommon.makeSvgSpan([], [svgNode], options), - minWidth: 0, - height - }; + if (!group.isStretchy) { + var accent; + var width; + + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = buildCommon.staticSvg("vec", options); + width = buildCommon.svgData.vec[1]; } else { - const spans = []; - const data = katexImagesData[label]; - const paths = data[0], - minWidth = data[1], - viewBoxHeight = data[2]; - const height = viewBoxHeight / 1000; - const numSvgChildren = paths.length; - let widthClasses; - let aligns; + accent = buildCommon.makeOrd({ + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. - if (numSvgChildren === 1) { - // $FlowFixMe: All these cases must be of the 4-tuple type. - const align1 = data[3]; - widthClasses = ["hide-tail"]; - aligns = [align1]; - } else if (numSvgChildren === 2) { - widthClasses = ["halfarrow-left", "halfarrow-right"]; - aligns = ["xMinYMin", "xMaxYMin"]; - } else if (numSvgChildren === 3) { - widthClasses = ["brace-left", "brace-center", "brace-right"]; - aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; - } else { - throw new Error(`Correct katexImagesData or update code here to support - ${numSvgChildren} children.`); + accent.italic = 0; + width = accent.width; + + if (accentBelow) { + clearance += accent.depth; } + } - for (let i = 0; i < numSvgChildren; i++) { - const path = new PathNode(paths[i]); - const svgNode = new SvgNode([path], { - "width": "400em", - "height": height + "em", - "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, - "preserveAspectRatio": aligns[i] + " slice" - }); - const span = buildCommon.makeSvgSpan([widthClasses[i]], [svgNode], options); + accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. - if (numSvgChildren === 1) { - return { - span, - minWidth, - height - }; - } else { - span.style.height = height + "em"; - spans.push(span); - } - } + var accentFull = group.label === "\\textcircled"; - return { - span: buildCommon.makeSpan(["stretchy"], spans, options), - minWidth, - height - }; + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } // Shift the accent over by the skew. + + + var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + + if (!accentFull) { + left -= width / 2; } - } // buildSvgSpan_() + accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. - const _buildSvgSpan_ = buildSvgSpan_(), - span = _buildSvgSpan_.span, - minWidth = _buildSvgSpan_.minWidth, - height = _buildSvgSpan_.height; // Note that we are returning span.depth = 0. - // Any adjustments relative to the baseline must be done in buildHTML. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchy.svgSpan(group, options); + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } + var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); - span.height = height; - span.style.height = height + "em"; + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. - if (minWidth > 0) { - span.style.minWidth = minWidth + "em"; + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. + + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; } +}; - return span; +var mathmlBuilder$9 = (group, options) => { + var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; }; -const encloseSpan = function encloseSpan(inner, label, pad, options) { - // Return an image span for \cancel, \bcancel, \xcancel, or \fbox - let img; - const totalHeight = inner.height + inner.depth + 2 * pad; +var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); // Accents - if (/fbox|color/.test(label)) { - img = buildCommon.makeSpan(["stretchy", label], [], options); +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + var base = normalizeArgument(args[0]); + var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); // Text-mode accents - if (label === "fbox") { - const color = options.color && options.getColor(); +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + var base = args[0]; + var mode = context.parser.mode; - if (color) { - img.style.borderColor = color; - } + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; } - } else { - // \cancel, \bcancel, or \xcancel - // Since \cancel's SVG is inline and it omits the viewBox attribute, - // its stroke-width will not vary with span area. - const lines = []; - if (/^[bx]cancel$/.test(label)) { - lines.push(new LineNode({ - "x1": "0", - "y1": "0", - "x2": "100%", - "y2": "100%", - "stroke-width": "0.046em" - })); - } + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); - if (/^x?cancel$/.test(label)) { - lines.push(new LineNode({ - "x1": "0", - "y1": "100%", - "x2": "100%", - "y2": "0", - "stroke-width": "0.046em" - })); - } +// Horizontal overlap functions +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + var innerGroup = buildGroup$1(group.base, options); + var accentBody = stretchy.svgSpan(group, options); + var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns - const svgNode = new SvgNode(lines, { - "width": "100%", - "height": totalHeight + "em" - }); - img = buildCommon.makeSvgSpan([], [svgNode], options); + var vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; } +}); - img.height = totalHeight; - img.style.height = totalHeight + "em"; - return img; -}; +// Helper function +var paddedNode = group => { + var node = new mathMLTree.MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; // Stretchy arrows with an optional argument -var stretchy = { - encloseSpan, - mathMLnode, - svgSpan -}; -// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but -const htmlBuilder = (grp, options) => { - // Accents are handled in the TeXbook pg. 443, rule 12. - let base; - let group; - const supSub = checkNodeType(grp, "supsub"); - let supSubGroup; +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, - if (supSub) { - // If our base is a character box, and we have superscripts and - // subscripts, the supsub will defer to us. In particular, we want - // to attach the superscripts and subscripts to the inner body (so - // that the position of the superscripts and subscripts won't be - // affected by the height of the accent). We accomplish this by - // sticking the base of the accent into the base of the supsub, and - // rendering that, while keeping track of where the accent is. - // The real accent group is the base of the supsub group - group = assertNodeType(supSub.base, "accent"); // The character box is the base of the accent group + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, - base = group.base; // Stick the character box into the base of the supsub group + // Flow is unable to correctly infer the type of `group`, even though it's + // unambiguously determined from the passed-in `type` above. + htmlBuilder(group, options) { + var style = options.style; // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. - supSub.base = base; // Rerender the supsub group with its new base, and store that - // result. + var newOptions = options.havingStyle(style.sup()); + var upperGroup = buildCommon.wrapFragment(buildGroup$1(group.body, newOptions, options), options); + var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + var lowerGroup; - supSubGroup = assertSpan(buildGroup(supSub, options)); // reset original base + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = buildCommon.wrapFragment(buildGroup$1(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } - supSub.base = group; - } else { - group = assertNodeType(grp, "accent"); - base = group.base; - } // Build the base group + var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi - const body = buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu - const mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the - // nucleus is not a single character, let s = 0; otherwise set s to the - // kern amount for the nucleus followed by the \skewchar of its font." - // Note that our skew metrics are just the kern between each character - // and the skewchar. + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } // Generate the vlist - let skew = 0; - if (mustShift) { - // If the base is a character box, then we want the skew of the - // innermost character. To do that, we find the innermost character: - const baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it + var vlist; - const baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. + if (lowerGroup) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }] + }, options); + } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. - skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we - // removed with getBaseElem might contain things like \color which - // we can't get rid of. - // TODO(emily): Find a better way to get the skew - } // calculate the amount of space between the body and the accent + vlist.children[0].children[0].children[1].classes.push("svg-align"); + return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); + }, - let clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent + mathmlBuilder(group, options) { + var arrowNode = stretchy.mathMLnode(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + var node; - let accentBody; + if (group.body) { + var upperNode = paddedNode(buildGroup(group.body, options)); - if (!group.isStretchy) { - let accent; - let width; + if (group.below) { + var lowerNode = paddedNode(buildGroup(group.below, options)); + node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + var _lowerNode = paddedNode(buildGroup(group.below, options)); - if (group.label === "\\vec") { - // Before version 0.9, \vec used the combining font glyph U+20D7. - // But browsers, especially Safari, are not consistent in how they - // render combining characters when not preceded by a character. - // So now we use an SVG. - // If Safari reforms, we should consider reverting to the glyph. - accent = buildCommon.staticSvg("vec", options); - width = buildCommon.svgData.vec[1]; + node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]); } else { - accent = buildCommon.makeOrd({ - mode: group.mode, - text: group.label - }, options, "textord"); - accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to - // shift the accent over to a place we don't want. - - accent.italic = 0; - width = accent.width; + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new mathMLTree.MathNode("mover", [arrowNode, node]); } - accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be - // at least the width of the accent, and overlap directly onto the - // character without any vertical offset. + return node; + } - const accentFull = group.label === "\\textcircled"; +}); - if (accentFull) { - accentBody.classes.push('accent-full'); - clearance = body.height; - } // Shift the accent over by the skew. +var makeSpan = buildCommon.makeSpan; +function htmlBuilder$9(group, options) { + var elements = buildExpression$1(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} - let left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` - // so that the accent doesn't contribute to the bounding box. - // We need to shift the character by its width (effectively half - // its width) to compensate. +function mathmlBuilder$8(group, options) { + var node; + var inner = buildExpression(group.body, options); - if (!accentFull) { - left -= width / 2; + if (group.mclass === "minner") { + node = new mathMLTree.MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new mathMLTree.MathNode("mi", inner); } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new mathMLTree.MathNode("mo", inner); + } // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. - accentBody.style.left = left + "em"; // \textcircled uses the \bigcirc glyph, so it needs some - // vertical adjustment to match LaTeX. - if (group.label === "\\textcircled") { - accentBody.style.top = ".2em"; - } + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + + node.attributes.width = "+0.1111em"; + } // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo - accentBody = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: body - }, { - type: "kern", - size: -clearance - }, { - type: "elem", - elem: accentBody - }] - }, options); - } else { - accentBody = stretchy.svgSpan(group, options); - accentBody = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: body - }, { - type: "elem", - elem: accentBody, - wrapperClasses: ["svg-align"], - wrapperStyle: skew > 0 ? { - width: `calc(100% - ${2 * skew}em)`, - marginLeft: `${2 * skew}em` - } : undefined - }] - }, options); } - const accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); + return node; +} // Math class commands except \mathop - if (supSubGroup) { - // Here, we replace the "base" child of the supsub with our newly - // generated accent. - supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the - // accent, we manually recalculate height. - supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, - supSubGroup.classes[0] = "mord"; - return supSubGroup; - } else { - return accentWrap; - } -}; + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: utils.isCharacterBox(body) + }; + }, -const mathmlBuilder = (group, options) => { - const accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]); - const node = new mathMLTree.MathNode("mover", [buildGroup$1(group.base, options), accentNode]); - node.setAttribute("accent", "true"); - return node; -}; + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); +var binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; -const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => `\\${accent}`).join("|")); // Accents + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. defineFunction({ - type: "accent", - names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + type: "mclass", + names: ["\\@binrel"], props: { - numArgs: 1 + numArgs: 2 }, - handler: (context, args) => { - const base = args[0]; - const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); - const isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + + handler(_ref2, args) { + var { + parser + } = _ref2; return { - type: "accent", - mode: context.parser.mode, - label: context.funcName, - isStretchy: isStretchy, - isShifty: isShifty, - base: base + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: utils.isCharacterBox(args[1]) }; - }, - htmlBuilder, - mathmlBuilder -}); // Text-mode accents + } + +}); // Build a relation or stacked op by placing one symbol on top of another defineFunction({ - type: "accent", - names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v", "\\textcircled"], + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], props: { - numArgs: 1, - allowedInText: true, - allowedInMath: false + numArgs: 2 }, - handler: (context, args) => { - const base = args[0]; + + handler(_ref3, args) { + var { + parser, + funcName + } = _ref3; + var baseArg = args[1]; + var shiftedArg = args[0]; + var mclass; + + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + var baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + var supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; return { - type: "accent", - mode: context.parser.mode, - label: context.funcName, - isStretchy: false, - isShifty: true, - base: base + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: utils.isCharacterBox(supsub) }; }, - htmlBuilder, - mathmlBuilder + + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 }); -// Horizontal overlap functions +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. defineFunction({ - type: "accentUnder", - names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + type: "pmb", + names: ["\\pmb"], props: { - numArgs: 1 + numArgs: 1, + allowedInText: true }, - handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - const base = args[0]; + + handler(_ref, args) { + var { + parser + } = _ref; return { - type: "accentUnder", + type: "pmb", mode: parser.mode, - label: funcName, - base: base + mclass: binrelClass(args[0]), + body: ordargument(args[0]) }; }, - htmlBuilder: (group, options) => { - // Treat under accents much like underlines. - const innerGroup = buildGroup(group.base, options); - const accentBody = stretchy.svgSpan(group, options); - const kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns - const vlist = buildCommon.makeVList({ - positionType: "bottom", - positionData: accentBody.height + kern, - children: [{ - type: "elem", - elem: accentBody, - wrapperClasses: ["svg-align"] - }, { - type: "kern", - size: kern - }, { - type: "elem", - elem: innerGroup - }] - }, options); - return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, true); + var node = buildCommon.makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; }, - mathmlBuilder: (group, options) => { - const accentNode = stretchy.mathMLnode(group.label); - const node = new mathMLTree.MathNode("munder", [buildGroup$1(group.base, options), accentNode]); - node.setAttribute("accentunder", "true"); + + mathmlBuilder(group, style) { + var inner = buildExpression(group.body, style); // Wrap with an element. + + var node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); return node; } + }); -// Helper function -const paddedNode = group => { - const node = new mathMLTree.MathNode("mpadded", group ? [group] : []); - node.setAttribute("width", "+0.6em"); - node.setAttribute("lspace", "0.3em"); - return node; -}; // Stretchy arrows with an optional argument +var cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; + +var newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + // So these values are fixed and flow can do implicit typing. + return { + type: "styling", + body: [], + mode: "math", + style: "display" + }; +}; +var isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; -defineFunction({ - type: "xArrow", - names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. - // Direct use of these functions is discouraged and may break someday. - "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium"], - props: { - numArgs: 1, - numOptionalArgs: 1 - }, +var isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; - handler(_ref, args, optArgs) { - let parser = _ref.parser, - funcName = _ref.funcName; - return { - type: "xArrow", - mode: parser.mode, - label: funcName, - body: args[0], - below: optArgs[0] - }; - }, +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + var funcName = cdArrowFunctionName[arrowChar]; - // Flow is unable to correctly infer the type of `group`, even though it's - // unamibiguously determined from the passed-in `type` above. - htmlBuilder(group, options) { - const style = options.style; // Build the argument groups in the appropriate style. - // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% - // Some groups can return document fragments. Handle those by wrapping - // them in a span. + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); - let newOptions = options.havingStyle(style.sup()); - const upperGroup = buildCommon.wrapFragment(buildGroup(group.body, newOptions, options), options); - upperGroup.classes.push("x-arrow-pad"); - let lowerGroup; + case "\\uparrow": + case "\\downarrow": + { + var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + var bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + var sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + var arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } - if (group.below) { - // Build the lower group - newOptions = options.havingStyle(style.sub()); - lowerGroup = buildCommon.wrapFragment(buildGroup(group.below, newOptions, options), options); - lowerGroup.classes.push("x-arrow-pad"); + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + + case "\\Vert": + { + var arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} + +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + var parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + + while (true) { + // eslint-disable-line no-constant-condition + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var next = parser.fetch().text; + + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); } + } - const arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. - // The point we want on the math axis is at 0.5 * arrowBody.height. + var row = []; + var body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows. - const arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + for (var i = 0; i < parsedRows.length; i++) { + // Start a new row. + var rowNodes = parsedRows[i]; // Create the first cell. - let upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + var cell = newCell(); - if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { - upperShift -= upperGroup.depth; // shift up if depth encroaches - } // Generate the vlist + for (var j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + var arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them. - let vlist; + var labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; // Process the arrow. + + if ("=|.".indexOf(arrowChar) > -1) ; else if ("<>AV".indexOf(arrowChar) > -1) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (var labelNum = 0; labelNum < 2; labelNum++) { + var inLabel = true; + + for (var k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } - if (lowerGroup) { - const lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; - vlist = buildCommon.makeVList({ - positionType: "individualShift", - children: [{ - type: "elem", - elem: upperGroup, - shift: upperShift - }, { - type: "elem", - elem: arrowBody, - shift: arrowShift - }, { - type: "elem", - elem: lowerGroup, - shift: lowerShift - }] - }, options); + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } // Now join the arrow to its labels. + + + var arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + + var wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display" // CD is always displaystyle. + + }; + row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + + cell = newCell(); + } + } + + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); } else { - vlist = buildCommon.makeVList({ - positionType: "individualShift", - children: [{ - type: "elem", - elem: upperGroup, - shift: upperShift - }, { - type: "elem", - elem: arrowBody, - shift: arrowShift - }] - }, options); - } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + + row = []; + body.push(row); + } // End row group + + + parser.gullet.endGroup(); // End array group defining \\ + + parser.gullet.endGroup(); // define column separation. + + var cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} // The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, - vlist.children[0].children[0].children[1].classes.push("svg-align"); - return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); + htmlBuilder(group, options) { + var newOptions = options.havingStyle(options.style.sup()); + var label = buildCommon.wrapFragment(buildGroup$1(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + + label.height = 0; + label.depth = 0; + return label; }, mathmlBuilder(group, options) { - const arrowNode = stretchy.mathMLnode(group.label); - let node; + var label = new mathMLTree.MathNode("mrow", [buildGroup(group.label, options)]); + label = new mathMLTree.MathNode("mpadded", [label]); + label.setAttribute("width", "0"); - if (group.body) { - const upperNode = paddedNode(buildGroup$1(group.body, options)); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. - if (group.below) { - const lowerNode = paddedNode(buildGroup$1(group.below, options)); - node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); - } else { - node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); - } - } else if (group.below) { - const lowerNode = paddedNode(buildGroup$1(group.below, options)); - node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]); - } else { - // This should never happen. - // Parser.js throws an error if there is no argument. - node = paddedNode(); - node = new mathMLTree.MathNode("mover", [arrowNode, node]); - } - return node; + label.setAttribute("voffset", "0.7em"); + label = new mathMLTree.MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } + +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + var parent = buildCommon.wrapFragment(buildGroup$1(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", [buildGroup(group.fragment, options)]); } }); @@ -7946,33 +8479,45 @@ defineFunction({ }, handler(_ref, args) { - let parser = _ref.parser; - const arg = assertNodeType(args[0], "ordgroup"); - const group = arg.body; - let number = ""; - - for (let i = 0; i < group.length; i++) { - const node = assertNodeType(group[i], "textord"); + var { + parser + } = _ref; + var arg = assertNodeType(args[0], "ordgroup"); + var group = arg.body; + var number = ""; + + for (var i = 0; i < group.length; i++) { + var node = assertNodeType(group[i], "textord"); number += node.text; } - const code = parseInt(number); + var code = parseInt(number); + var text; if (isNaN(code)) { - throw new ParseError(`\\@char has non-numeric argument ${number}`); + throw new ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); } return { type: "textord", mode: parser.mode, - text: String.fromCharCode(code) + text: text }; } }); -const htmlBuilder$1 = (group, options) => { - const elements = buildExpression(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. +var htmlBuilder$8 = (group, options) => { + var elements = buildExpression$1(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. // To accomplish this, we wrap the results in a fragment, so the inner // elements will be able to directly interact with their neighbors. For // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` @@ -7980,9 +8525,9 @@ const htmlBuilder$1 = (group, options) => { return buildCommon.makeFragment(elements); }; -const mathmlBuilder$1 = (group, options) => { - const inner = buildExpression$1(group.body, options.withColor(group.color)); - const node = new mathMLTree.MathNode("mstyle", inner); +var mathmlBuilder$7 = (group, options) => { + var inner = buildExpression(group.body, options.withColor(group.color)); + var node = new mathMLTree.MathNode("mstyle", inner); node.setAttribute("mathcolor", group.color); return node; }; @@ -7993,14 +8538,15 @@ defineFunction({ props: { numArgs: 2, allowedInText: true, - greediness: 3, argTypes: ["color", "original"] }, handler(_ref, args) { - let parser = _ref.parser; - const color = assertNodeType(args[0], "color-token").color; - const body = args[1]; + var { + parser + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; return { type: "color", mode: parser.mode, @@ -8009,8 +8555,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$1, - mathmlBuilder: mathmlBuilder$1 + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 }); defineFunction({ type: "color", @@ -8018,21 +8564,22 @@ defineFunction({ props: { numArgs: 1, allowedInText: true, - greediness: 3, argTypes: ["color"] }, handler(_ref2, args) { - let parser = _ref2.parser, - breakOnTokenText = _ref2.breakOnTokenText; - const color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current + var { + parser, + breakOnTokenText + } = _ref2; + var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current // color, mimicking the behavior of color.sty. // This is currently used just to correctly color a \right // that follows a \color command. parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored. - const body = parser.parseExpression(true, breakOnTokenText); + var body = parser.parseExpression(true, breakOnTokenText); return { type: "color", mode: parser.mode, @@ -8041,45 +8588,31 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$1, - mathmlBuilder: mathmlBuilder$1 + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 }); // Row breaks within tabular environments, and line breaks at top level -// same signature, we implement them as one megafunction, with newRow -// indicating whether we're in the \cr case, and newLine indicating whether -// to break the line in the \newline case. defineFunction({ type: "cr", - names: ["\\cr", "\\newline"], + names: ["\\\\"], props: { numArgs: 0, - numOptionalArgs: 1, - argTypes: ["size"], + numOptionalArgs: 0, allowedInText: true }, handler(_ref, args, optArgs) { - let parser = _ref.parser, - funcName = _ref.funcName; - const size = optArgs[0]; - const newRow = funcName === "\\cr"; - let newLine = false; - - if (!newRow) { - if (parser.settings.displayMode && parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode")) { - newLine = false; - } else { - newLine = true; - } - } - + var { + parser + } = _ref; + var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); return { type: "cr", mode: parser.mode, newLine, - newRow, size: size && assertNodeType(size, "size").value }; }, @@ -8087,17 +8620,13 @@ defineFunction({ // The following builders are called only at the top level, // not within tabular/array environments. htmlBuilder(group, options) { - if (group.newRow) { - throw new ParseError("\\cr valid only within a tabular/array environment"); - } - - const span = buildCommon.makeSpan(["mspace"], [], options); + var span = buildCommon.makeSpan(["mspace"], [], options); if (group.newLine) { span.classes.push("newline"); if (group.size) { - span.style.marginTop = calculateSize(group.size, options) + "em"; + span.style.marginTop = makeEm(calculateSize(group.size, options)); } } @@ -8105,13 +8634,13 @@ defineFunction({ }, mathmlBuilder(group, options) { - const node = new mathMLTree.MathNode("mspace"); + var node = new mathMLTree.MathNode("mspace"); if (group.newLine) { node.setAttribute("linebreak", "newline"); if (group.size) { - node.setAttribute("height", calculateSize(group.size, options) + "em"); + node.setAttribute("height", makeEm(calculateSize(group.size, options))); } } @@ -8120,6 +8649,247 @@ defineFunction({ }); +var globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; + +var checkControlSequence = tok => { + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + return name; +}; + +var getRHS = parser => { + var tok = parser.gullet.popToken(); + + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + + return tok; +}; + +var letCommand = (parser, name, tok, global) => { + var macro = parser.gullet.macros.get(tok.text); + + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + + parser.gullet.macros.set(name, macro, global); +}; // -> | +// -> |\global +// -> | +// -> \global|\long|\outer + + +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + var token = parser.fetch(); + + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + + return assertNodeType(parser.parseFunction(), "internal"); + } + + throw new ParseError("Invalid token after macro prefix", token); + } + +}); // Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> + +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref2) { + var { + parser, + funcName + } = _ref2; + var tok = parser.gullet.popToken(); + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + var numArgs = 0; + var insert; + var delimiters = [[]]; // contains no braces + + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + + + tok = parser.gullet.popToken(); + + if (!/^[1-9]$/.test(tok.text)) { + throw new ParseError("Invalid argument number \"" + tok.text + "\""); + } + + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError("Argument number \"" + tok.text + "\" out of order"); + } + + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } // replacement text, enclosed in '{' and '}' and properly nested + + + var { + tokens + } = parser.gullet.consumeArg(); + + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } // Final arg is the expansion of the macro + + + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // -> +// -> \futurelet +// | \let +// -> |= + +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + var name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + var tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf + +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + var name = checkControlSequence(parser.gullet.popToken()); + var middle = parser.gullet.popToken(); + var tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } + +}); + /** * This file deals with creating delimiters of various sizes. The TeXbook * discusses these routines on page 441-442, in the "Another subroutine sets box @@ -8146,12 +8916,12 @@ defineFunction({ * Get the metrics for a given symbol and font, after transformation (i.e. * after following replacement from symbols.js) */ -const getMetrics = function getMetrics(symbol, font, mode) { - const replace = symbols.math[symbol] && symbols.math[symbol].replace; - const metrics = getCharacterMetrics(replace || symbol, font, mode); +var getMetrics = function getMetrics(symbol, font, mode) { + var replace = symbols.math[symbol] && symbols.math[symbol].replace; + var metrics = getCharacterMetrics(replace || symbol, font, mode); if (!metrics) { - throw new Error(`Unsupported symbol ${symbol} and font size ${font}.`); + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); } return metrics; @@ -8162,21 +8932,21 @@ const getMetrics = function getMetrics(symbol, font, mode) { */ -const styleWrap = function styleWrap(delim, toStyle, options, classes) { - const newOptions = options.havingBaseStyle(toStyle); - const span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); - const delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); + var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; span.height *= delimSizeMultiplier; span.depth *= delimSizeMultiplier; span.maxFontSize = newOptions.sizeMultiplier; return span; }; -const centerSpan = function centerSpan(span, options, style) { - const newOptions = options.havingBaseStyle(style); - const shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; span.classes.push("delimcenter"); - span.style.top = shift + "em"; + span.style.top = makeEm(shift); span.height -= shift; span.depth += shift; }; @@ -8187,9 +8957,9 @@ const centerSpan = function centerSpan(span, options, style) { */ -const makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { - const text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); - const span = styleWrap(text, style, options, classes); +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); if (center) { centerSpan(span, options, style); @@ -8202,7 +8972,7 @@ const makeSmallDelim = function makeSmallDelim(delim, style, center, options, mo */ -const mathrmSize = function mathrmSize(value, size, mode, options) { +var mathrmSize = function mathrmSize(value, size, mode, options) { return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options); }; /** @@ -8211,9 +8981,9 @@ const mathrmSize = function mathrmSize(value, size, mode, options) { */ -const makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { - const inner = mathrmSize(delim, size, mode, options); - const span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes); +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes); if (center) { centerSpan(span, options, Style$1.TEXT); @@ -8222,13 +8992,13 @@ const makeLargeDelim = function makeLargeDelim(delim, size, center, options, mod return span; }; /** - * Make an inner span with the given offset and in the given font. This is used - * in `makeStackedDelim` to make the stacking pieces for the delimiter. + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. */ -const makeInner = function makeInner(symbol, font, mode) { - let sizeClass; // Apply the correct CSS class to choose the right font. +var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { + var sizeClass; // Apply the correct CSS class to choose the right font. if (font === "Size1-Regular") { sizeClass = "delim-size1"; @@ -8238,36 +9008,63 @@ const makeInner = function makeInner(symbol, font, mode) { sizeClass = "delim-size4"; } - const inner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element + var corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element // in the appropriate tag that VList uses. return { type: "elem", - elem: inner + elem: corner + }; +}; + +var makeInner = function makeInner(ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + var span = buildCommon.makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span }; -}; // Helper for makeStackedDelim +}; // Helpers for makeStackedDelim -const lap = { +var lapInEms = 0.008; +var lap = { type: "kern", - size: -0.005 + size: -1 * lapInEms }; +var verts = ["|", "\\lvert", "\\rvert", "\\vert"]; +var doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"]; /** * Make a stacked delimiter out of a given delimiter, with the total height at * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. */ -const makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { // There are four parts, the top, an optional middle, a repeated part, and a // bottom. - let top; - let middle; - let repeat; - let bottom; + var top; + var middle; + var repeat; + var bottom; + var svgLabel = ""; + var viewBoxWidth = 0; top = repeat = bottom = delim; middle = null; // Also keep track of what font the delimiters are in - let font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use + var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the // repeats of the arrows @@ -8287,42 +9084,66 @@ const makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, o top = "\\Uparrow"; repeat = "\u2016"; bottom = "\\Downarrow"; + } else if (utils.contains(verts, delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (utils.contains(doubleVerts, delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; } else if (delim === "[" || delim === "\\lbrack") { top = "\u23a1"; repeat = "\u23a2"; bottom = "\u23a3"; font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; } else if (delim === "]" || delim === "\\rbrack") { top = "\u23a4"; repeat = "\u23a5"; bottom = "\u23a6"; font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; } else if (delim === "\\lfloor" || delim === "\u230a") { repeat = top = "\u23a2"; bottom = "\u23a3"; font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; } else if (delim === "\\lceil" || delim === "\u2308") { top = "\u23a1"; repeat = bottom = "\u23a2"; font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; } else if (delim === "\\rfloor" || delim === "\u230b") { repeat = top = "\u23a5"; bottom = "\u23a6"; font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; } else if (delim === "\\rceil" || delim === "\u2309") { top = "\u23a4"; repeat = bottom = "\u23a5"; font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; } else if (delim === "(" || delim === "\\lparen") { top = "\u239b"; repeat = "\u239c"; bottom = "\u239d"; font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; } else if (delim === ")" || delim === "\\rparen") { top = "\u239e"; repeat = "\u239f"; bottom = "\u23a0"; font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; } else if (delim === "\\{" || delim === "\\lbrace") { top = "\u23a7"; middle = "\u23a8"; @@ -8358,118 +9179,118 @@ const makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, o } // Get the metrics of the four sections - const topMetrics = getMetrics(top, font, mode); - const topHeightTotal = topMetrics.height + topMetrics.depth; - const repeatMetrics = getMetrics(repeat, font, mode); - const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; - const bottomMetrics = getMetrics(bottom, font, mode); - const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; - let middleHeightTotal = 0; - let middleFactor = 1; + var topMetrics = getMetrics(top, font, mode); + var topHeightTotal = topMetrics.height + topMetrics.depth; + var repeatMetrics = getMetrics(repeat, font, mode); + var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + var bottomMetrics = getMetrics(bottom, font, mode); + var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + var middleHeightTotal = 0; + var middleFactor = 1; if (middle !== null) { - const middleMetrics = getMetrics(middle, font, mode); + var middleMetrics = getMetrics(middle, font, mode); middleHeightTotal = middleMetrics.height + middleMetrics.depth; middleFactor = 2; // repeat symmetrically above and below middle - } // Calcuate the minimal height that the delimiter can have. + } // Calculate the minimal height that the delimiter can have. // It is at least the size of the top, bottom, and optional middle combined. - const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need + var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need - const repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols + var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols - const realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note // that in this context, "center" means that the delimiter should be // centered around the axis in the current style, while normally it is // centered around the axis in textstyle. - let axisHeight = options.fontMetrics().axisHeight; + var axisHeight = options.fontMetrics().axisHeight; if (center) { axisHeight *= options.sizeMultiplier; } // Calculate the depth - const depth = realHeightTotal / 2 - axisHeight; // This function differs from the TeX procedure in one way. - // We shift each repeat element downwards by 0.005em, to prevent a gap - // due to browser floating point rounding error. - // Then, at the last element-to element joint, we add one extra repeat - // element to cover the gap created by the shifts. - // Find the shift needed to align the upper end of the extra element at a point - // 0.005em above the lower end of the top element. - - const shiftOfExtraElement = (repeatCount + 1) * 0.005 - repeatHeightTotal; // Now, we start building the pieces that will go into the vlist - // Keep a list of the inner pieces - - const inners = []; // Add the bottom symbol - - inners.push(makeInner(bottom, font, mode)); - - if (middle === null) { - // Add that many symbols - for (let i = 0; i < repeatCount; i++) { - inners.push(lap); // overlap - - inners.push(makeInner(repeat, font, mode)); - } - } else { - // When there is a middle bit, we need the middle part and two repeated - // sections - for (let i = 0; i < repeatCount; i++) { - inners.push(lap); - inners.push(makeInner(repeat, font, mode)); - } // Insert one extra repeat element. - - - inners.push({ - type: "kern", - size: shiftOfExtraElement + var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + + var stack = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + var viewBoxHeight = Math.round(realHeightTotal * 1000); + var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + var path = new PathNode(svgLabel, pathStr); + var width = (viewBoxWidth / 1000).toFixed(3) + "em"; + var height = (viewBoxHeight / 1000).toFixed(3) + "em"; + var svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + var wrapper = buildCommon.makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper }); - inners.push(makeInner(repeat, font, mode)); - inners.push(lap); // Now insert the middle of the brace. + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; - inners.push(makeInner(middle, font, mode)); + stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace. - for (let i = 0; i < repeatCount; i++) { - inners.push(lap); - inners.push(makeInner(repeat, font, mode)); - } - } // To cover the gap create by the overlaps, insert one more repeat element, - // at a position that juts 0.005 above the bottom of the top element. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, _innerHeight, options)); + } // Add the top symbol - inners.push({ - type: "kern", - size: shiftOfExtraElement - }); - inners.push(makeInner(repeat, font, mode)); - inners.push(lap); // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } // Finally, build the vlist - inners.push(makeInner(top, font, mode)); // Finally, build the vlist - const newOptions = options.havingBaseStyle(Style$1.TEXT); - const inner = buildCommon.makeVList({ + var newOptions = options.havingBaseStyle(Style$1.TEXT); + var inner = buildCommon.makeVList({ positionType: "bottom", positionData: depth, - children: inners + children: stack }, newOptions); return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes); -}; // All surds have 0.08em padding above the viniculum inside the SVG. +}; // All surds have 0.08em padding above the vinculum inside the SVG. // That keeps browser span height rounding error from pinching the line. -const vbPad = 80; // padding above the surd, measured inside the viewBox. +var vbPad = 80; // padding above the surd, measured inside the viewBox. -const emPad = 0.08; // padding, in ems, measured in the document. +var emPad = 0.08; // padding, in ems, measured in the document. -const sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) { - const path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight); - const pathNode = new PathNode(sqrtName, path); - const svg = new SvgNode([pathNode], { +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) { + var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + var pathNode = new PathNode(sqrtName, path); + var svg = new SvgNode([pathNode], { // Note: 1000:1 ratio of viewBox to document em width. "width": "400em", - "height": height + "em", + "height": makeEm(height), "viewBox": "0 0 400000 " + viewBoxHeight, "preserveAspectRatio": "xMinYMin slice" }); @@ -8480,32 +9301,32 @@ const sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum */ -const makeSqrtImage = function makeSqrtImage(height, options) { +var makeSqrtImage = function makeSqrtImage(height, options) { // Define a newOptions that removes the effect of size changes such as \Huge. // We don't pick different a height surd for \Huge. For it, we scale up. - const newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. + var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. - const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); - let sizeMultiplier = newOptions.sizeMultiplier; // default - // The standard sqrt SVGs each have a 0.04em thick viniculum. - // If Settings.minRuleThickness is larger than that, we add extraViniculum. + var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + var sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. - const extraViniculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. + var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. - let span; - let spanHeight = 0; - let texHeight = 0; - let viewBoxHeight = 0; - let advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. + var span; + var spanHeight = 0; + var texHeight = 0; + var viewBoxHeight = 0; + var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. // Then browser rounding error on the parent span height will not - // encroach on the ink of the viniculum. But that padding is not + // encroach on the ink of the vinculum. But that padding is not // included in the TeX-like `height` used for calculation of // vertical alignment. So texHeight = span.height < span.style.height. if (delim.type === "small") { // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. // 1000 unit normal glyph height. - viewBoxHeight = 1000 + 1000 * extraViniculum + vbPad; + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; if (height < 1.0) { sizeMultiplier = 1.0; // mimic a \textfont radical @@ -8513,32 +9334,32 @@ const makeSqrtImage = function makeSqrtImage(height, options) { sizeMultiplier = 0.7; // mimic a \scriptfont radical } - spanHeight = (1.0 + extraViniculum + emPad) / sizeMultiplier; - texHeight = (1.00 + extraViniculum) / sizeMultiplier; - span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraViniculum, options); + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "0.853em"; advanceWidth = 0.833 / sizeMultiplier; // from the font. } else if (delim.type === "large") { // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; - texHeight = (sizeToMaxHeight[delim.size] + extraViniculum) / sizeMultiplier; - spanHeight = (sizeToMaxHeight[delim.size] + extraViniculum + emPad) / sizeMultiplier; - span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraViniculum, options); + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "1.02em"; advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. } else { // Tall sqrt. In TeX, this would be stacked using multiple glyphs. // We'll use a single SVG to accomplish the same thing. - spanHeight = height + extraViniculum + emPad; - texHeight = height + extraViniculum; - viewBoxHeight = Math.floor(1000 * height + extraViniculum) + vbPad; - span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraViniculum, options); + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); span.style.minWidth = "0.742em"; advanceWidth = 1.056; } span.height = texHeight; - span.style.height = spanHeight + "em"; + span.style.height = makeEm(spanHeight); return { span, advanceWidth, @@ -8546,26 +9367,26 @@ const makeSqrtImage = function makeSqrtImage(height, options) { // This actually should depend on the chosen font -- e.g. \boldmath // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and // have thicker rules. - ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraViniculum) * sizeMultiplier + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier }; }; // There are three kinds of delimiters, delimiters that stack when they become // too large -const stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack +var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack -const stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]; // and delimiters that never stack +var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]; // and delimiters that never stack -const stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of +var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ // Used to create stacked delimiters of appropriate sizes in makeSizedDelim. -const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; /** * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. */ -const makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { // < and > turn into \langle and \rangle in delimiters if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { delim = "\\langle"; @@ -8596,7 +9417,7 @@ const makeSizedDelim = function makeSizedDelim(delim, size, options, mode, class // Delimiters that never stack try small delimiters and large delimiters only -const stackNeverDelimiterSequence = [{ +var stackNeverDelimiterSequence = [{ type: "small", style: Style$1.SCRIPTSCRIPT }, { @@ -8619,7 +9440,7 @@ const stackNeverDelimiterSequence = [{ size: 4 }]; // Delimiters that always stack try the small delimiters first, then stack -const stackAlwaysDelimiterSequence = [{ +var stackAlwaysDelimiterSequence = [{ type: "small", style: Style$1.SCRIPTSCRIPT }, { @@ -8633,7 +9454,7 @@ const stackAlwaysDelimiterSequence = [{ }]; // Delimiters that stack when large try the small and then large delimiters, and // stack afterwards -const stackLargeDelimiterSequence = [{ +var stackLargeDelimiterSequence = [{ type: "small", style: Style$1.SCRIPTSCRIPT }, { @@ -8662,7 +9483,7 @@ const stackLargeDelimiterSequence = [{ * TODO(#963) Use more specific font family return type once that is introduced. */ -const delimTypeToFont = function delimTypeToFont(type) { +var delimTypeToFont = function delimTypeToFont(type) { if (type.type === "small") { return "Main-Regular"; } else if (type.type === "large") { @@ -8670,7 +9491,7 @@ const delimTypeToFont = function delimTypeToFont(type) { } else if (type.type === "stack") { return "Size4-Regular"; } else { - throw new Error(`Add support for delim type '${type.type}' here.`); + throw new Error("Add support for delim type '" + type.type + "' here."); } }; /** @@ -8679,25 +9500,25 @@ const delimTypeToFont = function delimTypeToFont(type) { */ -const traverseSequence = function traverseSequence(delim, height, sequence, options) { +var traverseSequence = function traverseSequence(delim, height, sequence, options) { // Here, we choose the index we should start at in the sequences. In smaller // sizes (which correspond to larger numbers in style.size) we start earlier // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 - const start = Math.min(2, 3 - options.style.size); + var start = Math.min(2, 3 - options.style.size); - for (let i = start; i < sequence.length; i++) { + for (var i = start; i < sequence.length; i++) { if (sequence[i].type === "stack") { // This is always the last delimiter, so we just break the loop now. break; } - const metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math"); - let heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we + var metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math"); + var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we // account for the style change size. if (sequence[i].type === "small") { - const newOptions = options.havingBaseStyle(sequence[i].style); + var newOptions = options.havingBaseStyle(sequence[i].style); heightDepth *= newOptions.sizeMultiplier; } // Check if the delimiter at this size works for the given height. @@ -8716,7 +9537,7 @@ const traverseSequence = function traverseSequence(delim, height, sequence, opti */ -const makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { delim = "\\langle"; } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { @@ -8724,7 +9545,7 @@ const makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center } // Decide what sequence to use - let sequence; + var sequence; if (utils.contains(stackNeverDelimiters, delim)) { sequence = stackNeverDelimiterSequence; @@ -8735,7 +9556,7 @@ const makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center } // Look through the sequence - const delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. + var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. // Depending on the sequence element we decided on, call the // appropriate function. @@ -8755,14 +9576,14 @@ const makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center */ -const makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { // We always center \left/\right delimiters, so the axis is always shifted - const axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right - const delimiterFactor = 901; - const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; - const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); - const totalHeight = Math.max( // In real TeX, calculations are done using integral values which are + var delimiterFactor = 901; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are // 65536 per pt, or 655360 per em. So, the division here truncates in // TeX but doesn't here, producing different results. If we wanted to // exactly match TeX's calculation, we could do @@ -8780,12 +9601,13 @@ const makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, opt var delimiter = { sqrtImage: makeSqrtImage, sizedDelim: makeSizedDelim, + sizeToMaxHeight: sizeToMaxHeight, customSizedDelim: makeCustomSizedDelim, leftRightDelim: makeLeftRightDelim }; // Extra data needed for the delimiter handler down below -const delimiterSizes = { +var delimiterSizes = { "\\bigl": { mclass: "mopen", size: 1 @@ -8851,16 +9673,18 @@ const delimiterSizes = { size: 4 } }; -const delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; +var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; // Delimiter functions function checkDelimiter(delim, context) { - const symDelim = checkSymbolNodeType(delim); + var symDelim = checkSymbolNodeType(delim); if (symDelim && utils.contains(delimiters, symDelim.text)) { return symDelim; + } else if (symDelim) { + throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); } else { - throw new ParseError("Invalid delimiter: '" + (symDelim ? symDelim.text : JSON.stringify(delim)) + "' after '" + context.funcName + "'", delim); + throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim); } } @@ -8868,10 +9692,11 @@ defineFunction({ type: "delimsizing", names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], props: { - numArgs: 1 + numArgs: 1, + argTypes: ["primitive"] }, handler: (context, args) => { - const delim = checkDelimiter(args[0], context); + var delim = checkDelimiter(args[0], context); return { type: "delimsizing", mode: context.parser.mode, @@ -8891,13 +9716,13 @@ defineFunction({ return delimiter.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); }, mathmlBuilder: group => { - const children = []; + var children = []; if (group.delim !== ".") { children.push(makeText(group.delim, group.mode)); } - const node = new mathMLTree.MathNode("mo", children); + var node = new mathMLTree.MathNode("mo", children); if (group.mclass === "mopen" || group.mclass === "mclose") { // Only some of the delimsizing functions act as fences, and they @@ -8909,6 +9734,10 @@ defineFunction({ node.setAttribute("fence", "false"); } + node.setAttribute("stretchy", "true"); + var size = makeEm(delimiter.sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); return node; } }); @@ -8923,13 +9752,14 @@ defineFunction({ type: "leftright-right", names: ["\\right"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, handler: (context, args) => { // \left case below triggers parsing of \right in // `const right = parser.parseFunction();` // uses this return value. - const color = context.parser.gullet.macros.get("\\current@color"); + var color = context.parser.gullet.macros.get("\\current@color"); if (color && typeof color !== "string") { throw new ParseError("\\current@color set to non-string in \\right"); @@ -8948,19 +9778,20 @@ defineFunction({ type: "leftright", names: ["\\left"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, handler: (context, args) => { - const delim = checkDelimiter(args[0], context); - const parser = context.parser; // Parse out the implicit body + var delim = checkDelimiter(args[0], context); + var parser = context.parser; // Parse out the implicit body ++parser.leftrightDepth; // parseExpression stops before '\\right' - const body = parser.parseExpression(false); + var body = parser.parseExpression(false); --parser.leftrightDepth; // Check the next token parser.expect("\\right", false); - const right = assertNodeType(parser.parseFunction(), "leftright-right"); + var right = assertNodeType(parser.parseFunction(), "leftright-right"); return { type: "leftright", mode: parser.mode, @@ -8973,12 +9804,12 @@ defineFunction({ htmlBuilder: (group, options) => { assertParsed(group); // Build the inner expression - const inner = buildExpression(group.body, options, true, ["mopen", "mclose"]); - let innerHeight = 0; - let innerDepth = 0; - let hadMiddle = false; // Calculate its height and depth + var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]); + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; // Calculate its height and depth - for (let i = 0; i < inner.length; i++) { + for (var i = 0; i < inner.length; i++) { // Property `isMiddle` not defined on `span`. See comment in // "middle"'s htmlBuilder. // $FlowFixMe @@ -8995,7 +9826,7 @@ defineFunction({ innerHeight *= options.sizeMultiplier; innerDepth *= options.sizeMultiplier; - let leftDelim; + var leftDelim; if (group.left === ".") { // Empty delimiters in \left and \right make null delimiter spaces. @@ -9010,26 +9841,26 @@ defineFunction({ inner.unshift(leftDelim); // Handle middle delimiters if (hadMiddle) { - for (let i = 1; i < inner.length; i++) { - const middleDelim = inner[i]; // Property `isMiddle` not defined on `span`. See comment in + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in // "middle"'s htmlBuilder. // $FlowFixMe - const isMiddle = middleDelim.isMiddle; + var isMiddle = middleDelim.isMiddle; if (isMiddle) { // Apply the options that were active when \middle was called - inner[i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + inner[_i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); } } } - let rightDelim; // Same for the right delimiter, but using color specified by \color + var rightDelim; // Same for the right delimiter, but using color specified by \color if (group.right === ".") { rightDelim = makeNullDelimiter(options, ["mclose"]); } else { - const colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); } // Add it to the end of the expression. @@ -9039,16 +9870,16 @@ defineFunction({ }, mathmlBuilder: (group, options) => { assertParsed(group); - const inner = buildExpression$1(group.body, options); + var inner = buildExpression(group.body, options); if (group.left !== ".") { - const leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]); + var leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]); leftNode.setAttribute("fence", "true"); inner.unshift(leftNode); } if (group.right !== ".") { - const rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]); + var rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]); rightNode.setAttribute("fence", "true"); if (group.rightColor) { @@ -9065,10 +9896,11 @@ defineFunction({ type: "middle", names: ["\\middle"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, handler: (context, args) => { - const delim = checkDelimiter(args[0], context); + var delim = checkDelimiter(args[0], context); if (!context.parser.leftrightDepth) { throw new ParseError("\\middle without preceding \\left", delim); @@ -9081,13 +9913,13 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - let middleDelim; + var middleDelim; if (group.delim === ".") { middleDelim = makeNullDelimiter(options, []); } else { middleDelim = delimiter.sizedDelim(group.delim, 1, options, group.mode, []); - const isMiddle = { + var isMiddle = { delim: group.delim, options }; // Property `isMiddle` not defined on `span`. It is only used in @@ -9102,12 +9934,12 @@ defineFunction({ return middleDelim; }, mathmlBuilder: (group, options) => { - // A Firefox \middle will strech a character vertically only if it + // A Firefox \middle will stretch a character vertically only if it // is in the fence part of the operator dictionary at: // https://www.w3.org/TR/MathML3/appendixc.html. // So we need to avoid U+2223 and use plain "|" instead. - const textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); - const middleNode = new mathMLTree.MathNode("mo", [textNode]); + var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + var middleNode = new mathMLTree.MathNode("mo", [textNode]); middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each element. // \middle should get delimiter spacing instead. @@ -9117,57 +9949,99 @@ defineFunction({ } }); -const htmlBuilder$2 = (group, options) => { - // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox +var htmlBuilder$7 = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase // Some groups can return document fragments. Handle those by wrapping // them in a span. - const inner = buildCommon.wrapFragment(buildGroup(group.body, options), options); - const label = group.label.substr(1); - const scale = options.sizeMultiplier; - let img; - let imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different + var inner = buildCommon.wrapFragment(buildGroup$1(group.body, options), options); + var label = group.label.slice(1); + var scale = options.sizeMultiplier; + var img; + var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different // depending on whether the subject is wider than it is tall, or vice versa. // We don't know the width of a group, so as a proxy, we test if // the subject is a single character. This captures most of the // subjects that should get the "tall" treatment. - const isSingleChar = utils.isCharacterBox(group.body); + var isSingleChar = utils.isCharacterBox(group.body); if (label === "sout") { img = buildCommon.makeSpan(["stretchy", "sout"]); img.height = options.fontMetrics().defaultRuleThickness / scale; imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + var lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + var clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); // Prevent size changes like \Huge from affecting line thickness + + var newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle. + + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG + + var viewBoxHeight = Math.floor(1000 * angleHeight * scale); + var path = phasePath(viewBoxHeight); + var svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); // Wrap it in a span with overflow: hidden. + + img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; } else { // Add horizontal padding if (/cancel/.test(label)) { if (!isSingleChar) { inner.classes.push("cancel-pad"); } + } else if (label === "angl") { + inner.classes.push("anglpad"); } else { inner.classes.push("boxpad"); } // Add vertical padding - let vertPad = 0; - let ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" + var topPad = 0; + var bottomPad = 0; + var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" if (/box/.test(label)) { ruleThickness = Math.max(options.fontMetrics().fboxrule, // default options.minRuleThickness // User override. ); - vertPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + + bottomPad = Math.max(0, 0.25 - inner.depth); } else { - vertPad = isSingleChar ? 0.2 : 0; + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; } - img = stretchy.encloseSpan(inner, label, vertPad, options); + img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options); if (/fbox|boxed|fcolorbox/.test(label)) { img.style.borderStyle = "solid"; - img.style.borderWidth = `${ruleThickness}em`; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); } - imgShift = inner.depth + vertPad; + imgShift = inner.depth + bottomPad; if (group.backgroundColor) { img.style.backgroundColor = group.backgroundColor; @@ -9178,7 +10052,7 @@ const htmlBuilder$2 = (group, options) => { } } - let vlist; + var vlist; if (group.backgroundColor) { vlist = buildCommon.makeVList({ @@ -9195,6 +10069,7 @@ const htmlBuilder$2 = (group, options) => { }] }, options); } else { + var classes = /cancel|phase/.test(label) ? ["svg-align"] : []; vlist = buildCommon.makeVList({ positionType: "individualShift", children: [// Write the \cancel stroke on top of inner. @@ -9206,7 +10081,7 @@ const htmlBuilder$2 = (group, options) => { type: "elem", elem: img, shift: imgShift, - wrapperClasses: /cancel/.test(label) ? ["svg-align"] : [] + wrapperClasses: classes }] }, options); } @@ -9226,9 +10101,9 @@ const htmlBuilder$2 = (group, options) => { } }; -const mathmlBuilder$2 = (group, options) => { - let fboxsep = 0; - const node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildGroup$1(group.body, options)]); +var mathmlBuilder$6 = (group, options) => { + var fboxsep = 0; + var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildGroup(group.body, options)]); switch (group.label) { case "\\cancel": @@ -9239,6 +10114,10 @@ const mathmlBuilder$2 = (group, options) => { node.setAttribute("notation", "downdiagonalstrike"); break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": node.setAttribute("notation", "horizontalstrike"); break; @@ -9247,19 +10126,23 @@ const mathmlBuilder$2 = (group, options) => { node.setAttribute("notation", "box"); break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": case "\\colorbox": // doesn't have a good notation option. So use // instead. Set some attributes that come included with . fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; - node.setAttribute("width", `+${2 * fboxsep}pt`); - node.setAttribute("height", `+${2 * fboxsep}pt`); - node.setAttribute("lspace", `${fboxsep}pt`); // + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // - node.setAttribute("voffset", `${fboxsep}pt`); + node.setAttribute("voffset", fboxsep + "pt"); if (group.label === "\\fcolorbox") { - const thk = Math.max(options.fontMetrics().fboxrule, // default + var thk = Math.max(options.fontMetrics().fboxrule, // default options.minRuleThickness // user override ); node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor)); @@ -9285,15 +10168,16 @@ defineFunction({ props: { numArgs: 2, allowedInText: true, - greediness: 3, argTypes: ["color", "text"] }, handler(_ref, args, optArgs) { - let parser = _ref.parser, - funcName = _ref.funcName; - const color = assertNodeType(args[0], "color-token").color; - const body = args[1]; + var { + parser, + funcName + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; return { type: "enclose", mode: parser.mode, @@ -9303,8 +10187,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$2, - mathmlBuilder: mathmlBuilder$2 + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 }); defineFunction({ type: "enclose", @@ -9312,16 +10196,17 @@ defineFunction({ props: { numArgs: 3, allowedInText: true, - greediness: 3, argTypes: ["color", "color", "text"] }, handler(_ref2, args, optArgs) { - let parser = _ref2.parser, - funcName = _ref2.funcName; - const borderColor = assertNodeType(args[0], "color-token").color; - const backgroundColor = assertNodeType(args[1], "color-token").color; - const body = args[2]; + var { + parser, + funcName + } = _ref2; + var borderColor = assertNodeType(args[0], "color-token").color; + var backgroundColor = assertNodeType(args[1], "color-token").color; + var body = args[2]; return { type: "enclose", mode: parser.mode, @@ -9332,8 +10217,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$2, - mathmlBuilder: mathmlBuilder$2 + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 }); defineFunction({ type: "enclose", @@ -9345,7 +10230,9 @@ defineFunction({ }, handler(_ref3, args) { - let parser = _ref3.parser; + var { + parser + } = _ref3; return { type: "enclose", mode: parser.mode, @@ -9357,15 +10244,17 @@ defineFunction({ }); defineFunction({ type: "enclose", - names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout"], + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"], props: { numArgs: 1 }, - handler(_ref4, args, optArgs) { - let parser = _ref4.parser, - funcName = _ref4.funcName; - const body = args[0]; + handler(_ref4, args) { + var { + parser, + funcName + } = _ref4; + var body = args[0]; return { type: "enclose", mode: parser.mode, @@ -9374,8 +10263,30 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$2, - mathmlBuilder: mathmlBuilder$2 + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + + handler(_ref5, args) { + var { + parser + } = _ref5; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } + }); /** @@ -9383,29 +10294,29 @@ defineFunction({ * `environments.js` exports this same dictionary again and makes it public. * `Parser.js` requires this dictionary via `environments.js`. */ -const _environments = {}; +var _environments = {}; function defineEnvironment(_ref) { - let type = _ref.type, - names = _ref.names, - props = _ref.props, - handler = _ref.handler, - htmlBuilder = _ref.htmlBuilder, - mathmlBuilder = _ref.mathmlBuilder; + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; // Set default values of environments. - const data = { + var data = { type, numArgs: props.numArgs || 0, - greediness: 1, allowedInText: false, numOptionalArgs: 0, handler }; - for (let i = 0; i < names.length; ++i) { + for (var i = 0; i < names.length; ++i) { // TODO: The value type of _environments should be a type union of all // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is // an existential type. - // $FlowFixMe _environments[names[i]] = data; } @@ -9418,12 +10329,31 @@ function defineEnvironment(_ref) { } } +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; // This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + _macros[name] = body; +} + +// Helper functions function getHLines(parser) { // Return an array. The array length = number of hlines. // Each element in the array tells if the line is dashed. - const hlineInfo = []; + var hlineInfo = []; parser.consumeSpaces(); - let nxt = parser.fetch().text; + var nxt = parser.fetch().text; + + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } while (nxt === "\\hline" || nxt === "\\hdashline") { parser.consume(); @@ -9434,6 +10364,26 @@ function getHLines(parser) { return hlineInfo; } + +var validateAmsEnvironmentContext = context => { + var settings = context.parser.settings; + + if (!settings.displayMode) { + throw new ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; // autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. + + +function getAutoTag(name) { + if (name.indexOf("ed") === -1) { + return name.indexOf("*") === -1; + } // return undefined; + +} /** * Parse the body of the environment, with rows delimited by \\ and * columns delimited by &, and create a nested list in row-major order @@ -9443,17 +10393,29 @@ function getHLines(parser) { function parseArray(parser, _ref, style) { - let hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, - addJot = _ref.addJot, - cols = _ref.cols, - arraystretch = _ref.arraystretch, - colSeparationType = _ref.colSeparationType; - // Parse body of array with \\ temporarily mapped to \cr + var { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; parser.gullet.beginGroup(); - parser.gullet.macros.set("\\\\", "\\cr"); // Get current arraystretch if it's not set by the environment + + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } // Get current arraystretch if it's not set by the environment + if (!arraystretch) { - const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); if (stretch == null) { // Default \arraystretch from lttab.dtx @@ -9462,24 +10424,46 @@ function parseArray(parser, _ref, style) { arraystretch = parseFloat(stretch); if (!arraystretch || arraystretch < 0) { - throw new ParseError(`Invalid \\arraystretch: ${stretch}`); + throw new ParseError("Invalid \\arraystretch: " + stretch); } } } // Start group for first cell - parser.gullet.beginGroup(); - let row = []; - const body = [row]; - const rowGaps = []; - const hLinesBeforeRow = []; // Test for \hline at the top of the array. + parser.gullet.beginGroup(); + var row = []; + var body = [row]; + var rowGaps = []; + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + + beginRow(); // Test for \hline at the top of the array. hLinesBeforeRow.push(getHLines(parser)); while (true) { // eslint-disable-line no-constant-condition // Parse each cell in its own group (namespace) - let cell = parser.parseExpression(false, "\\cr"); + var cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); parser.gullet.endGroup(); parser.gullet.beginGroup(); cell = { @@ -9498,15 +10482,27 @@ function parseArray(parser, _ref, style) { } row.push(cell); - const next = parser.fetch().text; + var next = parser.fetch().text; if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); } else if (next === "\\end") { - // Arrays terminate newlines with `\crcr` which consumes a `\cr` if - // the last line is empty. + endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. // NOTE: Currently, `cell` is the last item added into `row`. - if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0) { + + if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { body.pop(); } @@ -9515,20 +10511,32 @@ function parseArray(parser, _ref, style) { } break; - } else if (next === "\\cr") { - const cr = assertNodeType(parser.parseFunction(), "cr"); - rowGaps.push(cr.size); // check for \hline(s) following the row separator + } else if (next === "\\\\") { + parser.consume(); + var size = void 0; // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + + rowGaps.push(size ? size.value : null); + endRow(); // check for \hline(s) following the row separator hLinesBeforeRow.push(getHLines(parser)); row = []; body.push(row); + beginRow(); } else { throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); } } // End cell group - parser.gullet.endGroup(); // End array group defining \\ + parser.gullet.endGroup(); // End array group defining \cr parser.gullet.endGroup(); return { @@ -9541,34 +10549,36 @@ function parseArray(parser, _ref, style) { rowGaps, hskipBeforeAndAfter, hLinesBeforeRow, - colSeparationType + colSeparationType, + tags, + leqno }; } // Decides on a style for cells in an array according to whether the given // environment name starts with the letter 'd'. function dCellStyle(envName) { - if (envName.substr(0, 1) === "d") { + if (envName.slice(0, 1) === "d") { return "display"; } else { return "text"; } } -const htmlBuilder$3 = function htmlBuilder(group, options) { - let r; - let c; - const nr = group.body.length; - const hLinesBeforeRow = group.hLinesBeforeRow; - let nc = 0; - let body = new Array(nr); - const hlines = []; - const ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. +var htmlBuilder$6 = function htmlBuilder(group, options) { + var r; + var c; + var nr = group.body.length; + var hLinesBeforeRow = group.hLinesBeforeRow; + var nc = 0; + var body = new Array(nr); + var hlines = []; + var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. ); // Horizontal spacing - const pt = 1 / options.fontMetrics().ptPerEm; - let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls if (group.colSeparationType && group.colSeparationType === "small") { // We're in a {smallmatrix}. Default column space is \thickspace, @@ -9576,25 +10586,28 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { // But that needs adjustment because LaTeX applies \scriptstyle to the // entire array, including the colspace, but this function applies // \scriptstyle only inside each element. - const localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier; + var localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier; arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); } // Vertical spacing - const baselineskip = 12 * pt; // see size10.clo + var baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo // Default \jot from ltmath.dtx // TODO(edemaine): allow overriding \jot via \setlength (#687) - const jot = 3 * pt; - const arrayskip = group.arraystretch * baselineskip; - const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + var jot = 3 * pt; + var arrayskip = group.arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and - const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx - let totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. + var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. function setHLinePos(hlinesInGap) { - for (let i = 0; i < hlinesInGap.length; ++i) { + for (var i = 0; i < hlinesInGap.length; ++i) { if (i > 0) { totalHeight += 0.25; } @@ -9609,19 +10622,19 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { setHLinePos(hLinesBeforeRow[0]); for (r = 0; r < group.body.length; ++r) { - const inrow = group.body[r]; - let height = arstrutHeight; // \@array adds an \@arstrut + var inrow = group.body[r]; + var height = arstrutHeight; // \@array adds an \@arstrut - let depth = arstrutDepth; // to each tow (via the template) + var depth = arstrutDepth; // to each tow (via the template) if (nc < inrow.length) { nc = inrow.length; } - const outrow = new Array(inrow.length); + var outrow = new Array(inrow.length); for (c = 0; c < inrow.length; ++c) { - const elt = buildGroup(inrow[c], options); + var elt = buildGroup$1(inrow[c], options); if (depth < elt.depth) { depth = elt.depth; @@ -9634,8 +10647,8 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { outrow[c] = elt; } - const rowGap = group.rowGaps[r]; - let gap = 0; + var rowGap = group.rowGaps[r]; + var gap = 0; if (rowGap) { gap = calculateSize(rowGap, options); @@ -9670,35 +10683,72 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { setHLinePos(hLinesBeforeRow[r + 1]); } - const offset = totalHeight / 2 + options.fontMetrics().axisHeight; - const colDescriptions = group.cols || []; - const cols = []; - let colSep; - let colDescrNum; + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.cols || []; + var cols = []; + var colSep; + var colDescrNum; + var tagSpans = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + var rw = body[r]; + var shift = rw.pos - offset; + var tag = group.tags[r]; + var tagSpan = void 0; + + if (tag === true) { + // automatic numbering + tagSpan = buildCommon.makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = buildCommon.makeSpan([], [], options); + } else { + // manual \tag + tagSpan = buildCommon.makeSpan([], buildExpression$1(tag, options, true), options); + } + + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column // descriptions, so trailing separators don't get lost. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { - let colDescr = colDescriptions[colDescrNum] || {}; - let firstSeparator = true; + var colDescr = colDescriptions[colDescrNum] || {}; + var firstSeparator = true; while (colDescr.type === "separator") { // If there is more than one separator in a row, add a space // between them. if (!firstSeparator) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = options.fontMetrics().doubleRuleSep + "em"; + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); cols.push(colSep); } if (colDescr.separator === "|" || colDescr.separator === ":") { - const lineType = colDescr.separator === "|" ? "solid" : "dashed"; - const separator = buildCommon.makeSpan(["vertical-separator"], [], options); - separator.style.height = totalHeight + "em"; - separator.style.borderRightWidth = `${ruleThickness}em`; + var lineType = colDescr.separator === "|" ? "solid" : "dashed"; + var separator = buildCommon.makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); separator.style.borderRightStyle = lineType; - separator.style.margin = `0 -${ruleThickness / 2}em`; - separator.style.verticalAlign = -(totalHeight - offset) + "em"; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + + var _shift = totalHeight - offset; + + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + cols.push(separator); } else { throw new ParseError("Invalid separator type: " + colDescr.separator); @@ -9713,35 +10763,36 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { continue; } - let sepwidth; + var sepwidth = void 0; if (c > 0 || group.hskipBeforeAndAfter) { sepwidth = utils.deflt(colDescr.pregap, arraycolsep); if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } - let col = []; + var col = []; for (r = 0; r < nr; ++r) { - const row = body[r]; - const elem = row[c]; + var row = body[r]; + var elem = row[c]; if (!elem) { continue; } - const shift = row.pos - offset; + var _shift2 = row.pos - offset; + elem.depth = row.depth; elem.height = row.height; col.push({ type: "elem", elem: elem, - shift: shift + shift: _shift2 }); } @@ -9757,7 +10808,7 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } @@ -9766,17 +10817,17 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any. if (hlines.length > 0) { - const line = buildCommon.makeLineSpan("hline", options, ruleThickness); - const dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); - const vListElems = [{ + var line = buildCommon.makeLineSpan("hline", options, ruleThickness); + var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); + var vListElems = [{ type: "elem", elem: body, shift: 0 }]; while (hlines.length > 0) { - const hline = hlines.pop(); - const lineShift = hline.pos - offset; + var hline = hlines.pop(); + var lineShift = hline.pos - offset; if (hline.isDashed) { vListElems.push({ @@ -9799,21 +10850,52 @@ const htmlBuilder$3 = function htmlBuilder(group, options) { }, options); } - return buildCommon.makeSpan(["mord"], [body], options); + if (tagSpans.length === 0) { + return buildCommon.makeSpan(["mord"], [body], options); + } else { + var eqnNumCol = buildCommon.makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options); + return buildCommon.makeFragment([body, eqnNumCol]); + } }; -const alignMap = { +var alignMap = { c: "center ", l: "left ", r: "right " }; -const mathmlBuilder$3 = function mathmlBuilder(group, options) { - let table = new mathMLTree.MathNode("mtable", group.body.map(function (row) { - return new mathMLTree.MathNode("mtr", row.map(function (cell) { - return new mathMLTree.MathNode("mtd", [buildGroup$1(cell, options)]); - })); - })); // Set column alignment, row spacing, column spacing, and +var mathmlBuilder$5 = function mathmlBuilder(group, options) { + var tbl = []; + var glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]); + var tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]); + + for (var i = 0; i < group.body.length; i++) { + var rw = group.body[i]; + var row = []; + + for (var j = 0; j < rw.length; j++) { + row.push(new mathMLTree.MathNode("mtd", [buildGroup(rw[j], options)])); + } + + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + + tbl.push(new mathMLTree.MathNode("mtr", row)); + } + + var table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and // array lines by setting attributes on the table element. // Set the row spacing. In MathML, we specify a gap distance. // We do not use rowGap[] because MathML automatically increases @@ -9821,24 +10903,24 @@ const mathmlBuilder$3 = function mathmlBuilder(group, options) { // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. // We simulate this by adding (arraystretch - 1)em to the gap. This // does a reasonable job of adjusting arrays containing 1 em tall content. - // The 0.16 and 0.09 values are found emprically. They produce an array - // similar to LaTeX and in which content does not interfere with \hines. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. - const gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); - table.setAttribute("rowspacing", gap + "em"); // MathML table lines go only between cells. + table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells. // To place a line on an edge we'll use , if necessary. - let menclose = ""; - let align = ""; + var menclose = ""; + var align = ""; - if (group.cols) { + if (group.cols && group.cols.length > 0) { // Find column alignment, column spacing, and vertical lines. - const cols = group.cols; - let columnLines = ""; - let prevTypeWasAlign = false; - let iStart = 0; - let iEnd = cols.length; + var cols = group.cols; + var columnLines = ""; + var prevTypeWasAlign = false; + var iStart = 0; + var iEnd = cols.length; if (cols[0].type === "separator") { menclose += "top "; @@ -9850,20 +10932,20 @@ const mathmlBuilder$3 = function mathmlBuilder(group, options) { iEnd -= 1; } - for (let i = iStart; i < iEnd; i++) { - if (cols[i].type === "align") { - align += alignMap[cols[i].align]; + for (var _i = iStart; _i < iEnd; _i++) { + if (cols[_i].type === "align") { + align += alignMap[cols[_i].align]; if (prevTypeWasAlign) { columnLines += "none "; } prevTypeWasAlign = true; - } else if (cols[i].type === "separator") { + } else if (cols[_i].type === "separator") { // MathML accepts only single lines between cells. // So we read only the first of consecutive separators. if (prevTypeWasAlign) { - columnLines += cols[i].separator === "|" ? "solid " : "dashed "; + columnLines += cols[_i].separator === "|" ? "solid " : "dashed "; prevTypeWasAlign = false; } } @@ -9878,31 +10960,34 @@ const mathmlBuilder$3 = function mathmlBuilder(group, options) { if (group.colSeparationType === "align") { - const cols = group.cols || []; - let spacing = ""; + var _cols = group.cols || []; + + var spacing = ""; - for (let i = 1; i < cols.length; i++) { - spacing += i % 2 ? "0em " : "1em "; + for (var _i2 = 1; _i2 < _cols.length; _i2++) { + spacing += _i2 % 2 ? "0em " : "1em "; } table.setAttribute("columnspacing", spacing.trim()); - } else if (group.colSeparationType === "alignat") { + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { table.setAttribute("columnspacing", "0em"); } else if (group.colSeparationType === "small") { table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); } else { table.setAttribute("columnspacing", "1em"); } // Address \hline and \hdashline - let rowLines = ""; - const hlines = group.hLinesBeforeRow; + var rowLines = ""; + var hlines = group.hLinesBeforeRow; menclose += hlines[0].length > 0 ? "left " : ""; menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; - for (let i = 1; i < hlines.length - 1; i++) { - rowLines += hlines[i].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. - : hlines[i][0] ? "dashed " : "solid "; + for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) { + rowLines += hlines[_i3].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. + : hlines[_i3][0] ? "dashed " : "solid "; } if (/[sd]/.test(rowLines)) { @@ -9921,14 +11006,25 @@ const mathmlBuilder$3 = function mathmlBuilder(group, options) { } return table; -}; // Convenience function for aligned and alignedat environments. +}; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat. -const alignedHandler = function alignedHandler(context, args) { - const cols = []; - const res = parseArray(context.parser, { +var alignedHandler = function alignedHandler(context, args) { + if (context.envName.indexOf("ed") === -1) { + validateAmsEnvironmentContext(context); + } + + var cols = []; + var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align"; + var isSplit = context.envName === "split"; + var res = parseArray(context.parser, { cols, - addJot: true + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno }, "display"); // Determining number of columns. // 1. If the first argument is given, we use it as a number of columns, // and makes sure that each row doesn't exceed that number. @@ -9939,20 +11035,19 @@ const alignedHandler = function alignedHandler(context, args) { // cell in each row (starting with second cell) so that operators become // binary. This behavior is implemented in amsmath's \start@aligned. - let numMaths; - let numCols = 0; - const emptyGroup = { + var numMaths; + var numCols = 0; + var emptyGroup = { type: "ordgroup", mode: context.mode, body: [] }; - const ordgroup = checkNodeType(args[0], "ordgroup"); - if (ordgroup) { - let arg0 = ""; + if (args[0] && args[0].type === "ordgroup") { + var arg0 = ""; - for (let i = 0; i < ordgroup.body.length; i++) { - const textord = assertNodeType(ordgroup.body[i], "textord"); + for (var i = 0; i < args[0].body.length; i++) { + var textord = assertNodeType(args[0].body[i], "textord"); arg0 += textord.text; } @@ -9960,21 +11055,21 @@ const alignedHandler = function alignedHandler(context, args) { numCols = numMaths * 2; } - const isAligned = !numCols; + var isAligned = !numCols; res.body.forEach(function (row) { - for (let i = 1; i < row.length; i += 2) { + for (var _i4 = 1; _i4 < row.length; _i4 += 2) { // Modify ordgroup node within styling node - const styling = assertNodeType(row[i], "styling"); - const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + var styling = assertNodeType(row[_i4], "styling"); + var ordgroup = assertNodeType(styling.body[0], "ordgroup"); ordgroup.body.unshift(emptyGroup); } if (!isAligned) { // Case 1 - const curMaths = row.length / 2; + var curMaths = row.length / 2; if (numMaths < curMaths) { - throw new ParseError("Too many math in a row: " + `expected ${numMaths}, but got ${curMaths}`, row[0]); + throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); } } else if (numCols < row.length) { // Case 2 @@ -9984,18 +11079,18 @@ const alignedHandler = function alignedHandler(context, args) { // In aligned mode, we add one \qquad between columns; // otherwise we add nothing. - for (let i = 0; i < numCols; ++i) { - let align = "r"; - let pregap = 0; + for (var _i5 = 0; _i5 < numCols; ++_i5) { + var align = "r"; + var pregap = 0; - if (i % 2 === 1) { + if (_i5 % 2 === 1) { align = "l"; - } else if (i > 0 && isAligned) { + } else if (_i5 > 0 && isAligned) { // "aligned" mode. pregap = 1; // add one \quad } - cols[i] = { + cols[_i5] = { type: "align", align: align, pregap: pregap, @@ -10023,11 +11118,11 @@ defineEnvironment({ // - The argument is wrapped in {} or [], in which case Parser's // parseGroup() returns an "ordgroup" wrapping some symbol node. // - The argument is a bare symbol node. - const symNode = checkSymbolNodeType(args[0]); - const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; - const cols = colalign.map(function (nde) { - const node = assertSymbolNodeType(nde); - const ca = node.text; + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; if ("lcr".indexOf(ca) !== -1) { return { @@ -10048,40 +11143,81 @@ defineEnvironment({ throw new ParseError("Unknown column alignment: " + ca, nde); }); - const res = { + var res = { cols, - hskipBeforeAndAfter: true // \@preamble in lttab.dtx - + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length }; return parseArray(context.parser, res, dCellStyle(context.envName)); }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); // The matrix environments of amsmath builds on the array environment // of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. defineEnvironment({ type: "array", - names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"], + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], props: { numArgs: 0 }, handler(context) { - const delimiters = { + var delimiters = { "matrix": null, "pmatrix": ["(", ")"], "bmatrix": ["[", "]"], "Bmatrix": ["\\{", "\\}"], "vmatrix": ["|", "|"], "Vmatrix": ["\\Vert", "\\Vert"] - }[context.envName]; // \hskip -\arraycolsep in amsmath + }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath - const payload = { - hskipBeforeAndAfter: false + var colAlign = "c"; + var payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] }; - const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + var parser = context.parser; + parser.consumeSpaces(); + + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + + if ("lcr".indexOf(colAlign) === -1) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs. + + var numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); return delimiters ? { type: "leftright", mode: context.mode, @@ -10093,8 +11229,8 @@ defineEnvironment({ } : res; }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); defineEnvironment({ type: "array", @@ -10104,16 +11240,16 @@ defineEnvironment({ }, handler(context) { - const payload = { + var payload = { arraystretch: 0.5 }; - const res = parseArray(context.parser, payload, "script"); + var res = parseArray(context.parser, payload, "script"); res.colSeparationType = "small"; return res; }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); defineEnvironment({ type: "array", @@ -10124,11 +11260,11 @@ defineEnvironment({ handler(context, args) { // Parsing of {subarray} is similar to {array} - const symNode = checkSymbolNodeType(args[0]); - const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; - const cols = colalign.map(function (nde) { - const node = assertSymbolNodeType(nde); - const ca = node.text; // {subarray} only recognizes "l" & "c" + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; // {subarray} only recognizes "l" & "c" if ("lc".indexOf(ca) !== -1) { return { @@ -10144,37 +11280,38 @@ defineEnvironment({ throw new ParseError("{subarray} can contain only one column"); } - let res = { + var res = { cols, hskipBeforeAndAfter: false, arraystretch: 0.5 }; res = parseArray(context.parser, res, "script"); - if (res.body[0].length > 1) { + if (res.body.length > 0 && res.body[0].length > 1) { throw new ParseError("{subarray} can contain only one column"); } return res; }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); // A cases environment (in amsmath.sty) is almost equivalent to // \def\arraystretch{1.2}% // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. // {dcases} is a {cases} environment where cells are set in \displaystyle, // as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. defineEnvironment({ type: "array", - names: ["cases", "dcases"], + names: ["cases", "dcases", "rcases", "drcases"], props: { numArgs: 0 }, handler(context) { - const payload = { + var payload = { arraystretch: 1.2, cols: [{ type: "align", @@ -10194,334 +11331,222 @@ defineEnvironment({ postgap: 0 }] }; - const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); return { type: "leftright", mode: context.mode, body: [res], - left: "\\{", - right: ".", + left: context.envName.indexOf("r") > -1 ? "." : "\\{", + right: context.envName.indexOf("r") > -1 ? "\\}" : ".", rightColor: undefined }; }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 -}); // An aligned environment is like the align* environment -// except it operates within math mode. + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. // Note that we assume \nomallineskiplimit to be zero, // so that \strut@ is the same as \strut. defineEnvironment({ type: "array", - names: ["aligned"], + names: ["align", "align*", "aligned", "split"], props: { numArgs: 0 }, handler: alignedHandler, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); // A gathered environment is like an array environment with one centered // column, but where rows are considered lines so get \jot line spacing // and contents are set in \displaystyle. defineEnvironment({ type: "array", - names: ["gathered"], + names: ["gathered", "gather", "gather*"], props: { numArgs: 0 }, handler(context) { - const res = { + if (utils.contains(["gather", "gather*"], context.envName)) { + validateAmsEnvironmentContext(context); + } + + var res = { cols: [{ type: "align", align: "c" }], - addJot: true + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno }; return parseArray(context.parser, res, "display"); }, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); // alignat environment is like an align environment, but one must explicitly // specify maximum number of columns in each row, and can adjust spacing between // each columns. defineEnvironment({ type: "array", - names: ["alignedat"], - // One for numbered and for unnumbered; - // but, KaTeX doesn't supports math numbering yet, - // they make no difference for now. + names: ["alignat", "alignat*", "alignedat"], props: { numArgs: 1 }, handler: alignedHandler, - htmlBuilder: htmlBuilder$3, - mathmlBuilder: mathmlBuilder$3 -}); // Catch \hline outside array environment - -defineFunction({ - type: "text", - // Doesn't matter what this is. - names: ["\\hline", "\\hdashline"], - props: { - numArgs: 0, - allowedInText: true, - allowedInMath: true - }, - - handler(context, args) { - throw new ParseError(`${context.funcName} valid only within array environment`); - } - + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); - -const environments = _environments; - -// defineEnvironment definitions. -// $FlowFixMe, "environment" handler returns an environment ParseNode - -defineFunction({ - type: "environment", - names: ["\\begin", "\\end"], +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], props: { - numArgs: 1, - argTypes: ["text"] + numArgs: 0 }, - handler(_ref, args) { - let parser = _ref.parser, - funcName = _ref.funcName; - const nameGroup = args[0]; - - if (nameGroup.type !== "ordgroup") { - throw new ParseError("Invalid environment name", nameGroup); - } - - let envName = ""; - - for (let i = 0; i < nameGroup.body.length; ++i) { - envName += assertNodeType(nameGroup.body[i], "textord").text; - } - - if (funcName === "\\begin") { - // begin...end is similar to left...right - if (!environments.hasOwnProperty(envName)) { - throw new ParseError("No such environment: " + envName, nameGroup); - } // Build the environment object. Arguments and other information will - // be made available to the begin and end methods using properties. - - - const env = environments[envName]; - - const _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env), - args = _parser$parseArgument.args, - optArgs = _parser$parseArgument.optArgs; - - const context = { - mode: parser.mode, - envName, - parser - }; - const result = env.handler(context, args, optArgs); - parser.expect("\\end", false); - const endNameToken = parser.nextToken; - const end = assertNodeType(parser.parseFunction(), "environment"); - - if (end.name !== envName) { - throw new ParseError(`Mismatch: \\begin{${envName}} matched by \\end{${end.name}}`, endNameToken); - } - - return result; - } - - return { - type: "environment", - mode: parser.mode, - name: envName, - nameGroup + handler(context) { + validateAmsEnvironmentContext(context); + var res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno }; - } + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); - -const makeSpan$2 = buildCommon.makeSpan; - -function htmlBuilder$4(group, options) { - const elements = buildExpression(group.body, options, true); - return makeSpan$2([group.mclass], elements, options); -} - -function mathmlBuilder$4(group, options) { - let node; - const inner = buildExpression$1(group.body, options); - - if (group.mclass === "minner") { - return mathMLTree.newDocumentFragment(inner); - } else if (group.mclass === "mord") { - if (group.isCharacterBox) { - node = inner[0]; - node.type = "mi"; - } else { - node = new mathMLTree.MathNode("mi", inner); - } - } else { - if (group.isCharacterBox) { - node = inner[0]; - node.type = "mo"; - } else { - node = new mathMLTree.MathNode("mo", inner); - } // Set spacing based on what is the most likely adjacent atom type. - // See TeXbook p170. - - - if (group.mclass === "mbin") { - node.attributes.lspace = "0.22em"; // medium space - - node.attributes.rspace = "0.22em"; - } else if (group.mclass === "mpunct") { - node.attributes.lspace = "0em"; - node.attributes.rspace = "0.17em"; // thinspace - } else if (group.mclass === "mopen" || group.mclass === "mclose") { - node.attributes.lspace = "0em"; - node.attributes.rspace = "0em"; - } // MathML default space is 5/18 em, so needs no action. - // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo - - } - - return node; -} // Math class commands except \mathop - - -defineFunction({ - type: "mclass", - names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], +defineEnvironment({ + type: "array", + names: ["CD"], props: { - numArgs: 1 + numArgs: 0 }, - handler(_ref, args) { - let parser = _ref.parser, - funcName = _ref.funcName; - const body = args[0]; - return { - type: "mclass", - mode: parser.mode, - mclass: "m" + funcName.substr(5), - // TODO(kevinb): don't prefix with 'm' - body: ordargument(body), - isCharacterBox: utils.isCharacterBox(body) - }; + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); }, - htmlBuilder: htmlBuilder$4, - mathmlBuilder: mathmlBuilder$4 + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 }); -const binrelClass = arg => { - // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. - // (by rendering separately and with {}s before and after, and measuring - // the change in spacing). We'll do roughly the same by detecting the - // atom type directly. - const atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; - - if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { - return "m" + atom.family; - } else { - return "mord"; - } -}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. -// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment defineFunction({ - type: "mclass", - names: ["\\@binrel"], + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], props: { - numArgs: 2 + numArgs: 0, + allowedInText: true, + allowedInMath: true }, - handler(_ref2, args) { - let parser = _ref2.parser; - return { - type: "mclass", - mode: parser.mode, - mclass: binrelClass(args[0]), - body: [args[1]], - isCharacterBox: utils.isCharacterBox(args[1]) - }; + handler(context, args) { + throw new ParseError(context.funcName + " valid only within array environment"); } -}); // Build a relation or stacked op by placing one symbol on top of another +}); + +var environments = _environments; + +// defineEnvironment definitions. defineFunction({ - type: "mclass", - names: ["\\stackrel", "\\overset", "\\underset"], + type: "environment", + names: ["\\begin", "\\end"], props: { - numArgs: 2 + numArgs: 1, + argTypes: ["text"] }, - handler(_ref3, args) { - let parser = _ref3.parser, - funcName = _ref3.funcName; - const baseArg = args[1]; - const shiftedArg = args[0]; - let mclass; + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var nameGroup = args[0]; - if (funcName !== "\\stackrel") { - // LaTeX applies \binrel spacing to \overset and \underset. - mclass = binrelClass(baseArg); - } else { - mclass = "mrel"; // for \stackrel + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + + var envName = ""; + + for (var i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError("No such environment: " + envName, nameGroup); + } // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + + + var env = environments[envName]; + var { + args: _args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + var context = { + mode: parser.mode, + envName, + parser + }; + var result = env.handler(context, _args, optArgs); + parser.expect("\\end", false); + var endNameToken = parser.nextToken; + var end = assertNodeType(parser.parseFunction(), "environment"); + + if (end.name !== envName) { + throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } // $FlowFixMe, "environment" handler returns an environment ParseNode + + + return result; } - const baseOp = { - type: "op", - mode: baseArg.mode, - limits: true, - alwaysHandleSupSub: true, - parentIsSupSub: false, - symbol: false, - suppressBaseShift: funcName !== "\\stackrel", - body: ordargument(baseArg) - }; - const supsub = { - type: "supsub", - mode: shiftedArg.mode, - base: baseOp, - sup: funcName === "\\underset" ? null : shiftedArg, - sub: funcName === "\\underset" ? shiftedArg : null - }; return { - type: "mclass", + type: "environment", mode: parser.mode, - mclass, - body: [supsub], - isCharacterBox: utils.isCharacterBox(supsub) + name: envName, + nameGroup }; - }, + } - htmlBuilder: htmlBuilder$4, - mathmlBuilder: mathmlBuilder$4 }); // TODO(kevinb): implement \\sl and \\sc -const htmlBuilder$5 = (group, options) => { - const font = group.font; - const newOptions = options.withFont(font); - return buildGroup(group.body, newOptions); +var htmlBuilder$5 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup$1(group.body, newOptions); }; -const mathmlBuilder$5 = (group, options) => { - const font = group.font; - const newOptions = options.withFont(font); - return buildGroup$1(group.body, newOptions); +var mathmlBuilder$4 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); }; -const fontAliases = { +var fontAliases = { "\\Bbb": "\\mathbb", "\\bold": "\\mathbf", "\\frak": "\\mathfrak", @@ -10535,13 +11560,15 @@ defineFunction({ "\\Bbb", "\\bold", "\\frak"], props: { numArgs: 1, - greediness: 2 + allowedInArgument: true }, handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - const body = args[0]; - let func = funcName; + var { + parser, + funcName + } = _ref; + var body = normalizeArgument(args[0]); + var func = funcName; if (func in fontAliases) { func = fontAliases[func]; @@ -10555,19 +11582,20 @@ defineFunction({ }; }, htmlBuilder: htmlBuilder$5, - mathmlBuilder: mathmlBuilder$5 + mathmlBuilder: mathmlBuilder$4 }); defineFunction({ type: "mclass", names: ["\\boldsymbol", "\\bm"], props: { - numArgs: 1, - greediness: 2 + numArgs: 1 }, handler: (_ref2, args) => { - let parser = _ref2.parser; - const body = args[0]; - const isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + var { + parser + } = _ref2; + var body = args[0]; + var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the // argument's bin|rel|ord status return { @@ -10587,18 +11615,22 @@ defineFunction({ defineFunction({ type: "font", - names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it"], + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], props: { numArgs: 0, allowedInText: true }, handler: (_ref3, args) => { - let parser = _ref3.parser, - funcName = _ref3.funcName, - breakOnTokenText = _ref3.breakOnTokenText; - const mode = parser.mode; - const body = parser.parseExpression(true, breakOnTokenText); - const style = `math${funcName.slice(1)}`; + var { + parser, + funcName, + breakOnTokenText + } = _ref3; + var { + mode + } = parser; + var body = parser.parseExpression(true, breakOnTokenText); + var style = "math" + funcName.slice(1); return { type: "font", mode: mode, @@ -10611,13 +11643,13 @@ defineFunction({ }; }, htmlBuilder: htmlBuilder$5, - mathmlBuilder: mathmlBuilder$5 + mathmlBuilder: mathmlBuilder$4 }); -const adjustStyle = (size, originalStyle) => { +var adjustStyle = (size, originalStyle) => { // Figure out what style this fraction should be in based on the // function used - let style = originalStyle; + var style = originalStyle; if (size === "display") { // Get display style as a default. @@ -10635,29 +11667,29 @@ const adjustStyle = (size, originalStyle) => { return style; }; -const htmlBuilder$6 = (group, options) => { +var htmlBuilder$4 = (group, options) => { // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). - const style = adjustStyle(group.size, options.style); - const nstyle = style.fracNum(); - const dstyle = style.fracDen(); - let newOptions; + var style = adjustStyle(group.size, options.style); + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions; newOptions = options.havingStyle(nstyle); - const numerm = buildGroup(group.numer, newOptions, options); + var numerm = buildGroup$1(group.numer, newOptions, options); if (group.continued) { // \cfrac inserts a \strut into the numerator. // Get \strut dimensions from TeXbook page 353. - const hStrut = 8.5 / options.fontMetrics().ptPerEm; - const dStrut = 3.5 / options.fontMetrics().ptPerEm; + var hStrut = 8.5 / options.fontMetrics().ptPerEm; + var dStrut = 3.5 / options.fontMetrics().ptPerEm; numerm.height = numerm.height < hStrut ? hStrut : numerm.height; numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; } newOptions = options.havingStyle(dstyle); - const denomm = buildGroup(group.denom, newOptions, options); - let rule; - let ruleWidth; - let ruleSpacing; + var denomm = buildGroup$1(group.denom, newOptions, options); + var rule; + var ruleWidth; + var ruleSpacing; if (group.hasBarLine) { if (group.barSize) { @@ -10676,9 +11708,9 @@ const htmlBuilder$6 = (group, options) => { } // Rule 15b - let numShift; - let clearance; - let denomShift; + var numShift; + var clearance; + var denomShift; if (style.size === Style$1.DISPLAY.size || group.size === "display") { numShift = options.fontMetrics().num1; @@ -10702,11 +11734,11 @@ const htmlBuilder$6 = (group, options) => { denomShift = options.fontMetrics().denom2; } - let frac; + var frac; if (!rule) { // Rule 15c - const candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); if (candidateClearance < clearance) { numShift += 0.5 * (clearance - candidateClearance); @@ -10727,7 +11759,7 @@ const htmlBuilder$6 = (group, options) => { }, options); } else { // Rule 15d - const axisHeight = options.fontMetrics().axisHeight; + var axisHeight = options.fontMetrics().axisHeight; if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); @@ -10737,7 +11769,7 @@ const htmlBuilder$6 = (group, options) => { denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); } - const midShift = -(axisHeight - 0.5 * ruleWidth); + var midShift = -(axisHeight - 0.5 * ruleWidth); frac = buildCommon.makeVList({ positionType: "individualShift", children: [{ @@ -10762,16 +11794,18 @@ const htmlBuilder$6 = (group, options) => { frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e - let delimSize; + var delimSize; if (style.size === Style$1.DISPLAY.size) { delimSize = options.fontMetrics().delim1; + } else if (style.size === Style$1.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style$1.SCRIPT).fontMetrics().delim2; } else { delimSize = options.fontMetrics().delim2; } - let leftDelim; - let rightDelim; + var leftDelim; + var rightDelim; if (group.leftDelim == null) { leftDelim = makeNullDelimiter(options, ["mopen"]); @@ -10790,30 +11824,30 @@ const htmlBuilder$6 = (group, options) => { return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options); }; -const mathmlBuilder$6 = (group, options) => { - let node = new mathMLTree.MathNode("mfrac", [buildGroup$1(group.numer, options), buildGroup$1(group.denom, options)]); +var mathmlBuilder$3 = (group, options) => { + var node = new mathMLTree.MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]); if (!group.hasBarLine) { node.setAttribute("linethickness", "0px"); } else if (group.barSize) { - const ruleWidth = calculateSize(group.barSize, options); - node.setAttribute("linethickness", ruleWidth + "em"); + var ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); } - const style = adjustStyle(group.size, options.style); + var style = adjustStyle(group.size, options.style); if (style.size !== options.style.size) { node = new mathMLTree.MathNode("mstyle", [node]); - const isDisplay = style.size === Style$1.DISPLAY.size ? "true" : "false"; + var isDisplay = style.size === Style$1.DISPLAY.size ? "true" : "false"; node.setAttribute("displaystyle", isDisplay); node.setAttribute("scriptlevel", "0"); } if (group.leftDelim != null || group.rightDelim != null) { - const withDelims = []; + var withDelims = []; if (group.leftDelim != null) { - const leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); + var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); leftOp.setAttribute("fence", "true"); withDelims.push(leftOp); } @@ -10821,7 +11855,7 @@ const mathmlBuilder$6 = (group, options) => { withDelims.push(node); if (group.rightDelim != null) { - const rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); + var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); rightOp.setAttribute("fence", "true"); withDelims.push(rightOp); } @@ -10834,24 +11868,26 @@ const mathmlBuilder$6 = (group, options) => { defineFunction({ type: "genfrac", - names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly - "\\\\bracefrac", "\\\\brackfrac"], + names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], props: { numArgs: 2, - greediness: 2 + allowedInArgument: true }, handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - const numer = args[0]; - const denom = args[1]; - let hasBarLine; - let leftDelim = null; - let rightDelim = null; - let size = "auto"; + var { + parser, + funcName + } = _ref; + var numer = args[0]; + var denom = args[1]; + var hasBarLine; + var leftDelim = null; + var rightDelim = null; + var size = "auto"; switch (funcName) { - case "\\cfrac": case "\\dfrac": case "\\frac": case "\\tfrac": @@ -10887,7 +11923,6 @@ defineFunction({ } switch (funcName) { - case "\\cfrac": case "\\dfrac": case "\\dbinom": size = "display"; @@ -10902,7 +11937,7 @@ defineFunction({ return { type: "genfrac", mode: parser.mode, - continued: funcName === "\\cfrac", + continued: false, numer, denom, hasBarLine, @@ -10912,8 +11947,35 @@ defineFunction({ barSize: null }; }, - htmlBuilder: htmlBuilder$6, - mathmlBuilder: mathmlBuilder$6 + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); +defineFunction({ + type: "genfrac", + names: ["\\cfrac"], + props: { + numArgs: 2 + }, + handler: (_ref2, args) => { + var { + parser, + funcName + } = _ref2; + var numer = args[0]; + var denom = args[1]; + return { + type: "genfrac", + mode: parser.mode, + continued: true, + numer, + denom, + hasBarLine: true, + leftDelim: null, + rightDelim: null, + size: "display", + barSize: null + }; + } }); // Infix generalized fractions -- these are not rendered directly, but replaced // immediately by one of the variants above. @@ -10925,11 +11987,13 @@ defineFunction({ infix: true }, - handler(_ref2) { - let parser = _ref2.parser, - funcName = _ref2.funcName, - token = _ref2.token; - let replaceWith; + handler(_ref3) { + var { + parser, + funcName, + token + } = _ref3; + var replaceWith; switch (funcName) { case "\\over": @@ -10965,10 +12029,10 @@ defineFunction({ } }); -const stylArray = ["display", "text", "script", "scriptscript"]; +var stylArray = ["display", "text", "script", "scriptscript"]; -const delimFromValue = function delimFromValue(delimString) { - let delim = null; +var delimFromValue = function delimFromValue(delimString) { + var delim = null; if (delimString.length > 0) { delim = delimString; @@ -10983,32 +12047,24 @@ defineFunction({ names: ["\\genfrac"], props: { numArgs: 6, - greediness: 6, + allowedInArgument: true, argTypes: ["math", "math", "size", "text", "math", "math"] }, - handler(_ref3, args) { - let parser = _ref3.parser; - const numer = args[4]; - const denom = args[5]; // Look into the parse nodes to get the desired delimiters. - - let leftNode = checkNodeType(args[0], "atom"); - - if (leftNode) { - leftNode = assertAtomFamily(args[0], "open"); - } - - const leftDelim = leftNode ? delimFromValue(leftNode.text) : null; - let rightNode = checkNodeType(args[1], "atom"); - - if (rightNode) { - rightNode = assertAtomFamily(args[1], "close"); - } - - const rightDelim = rightNode ? delimFromValue(rightNode.text) : null; - const barNode = assertNodeType(args[2], "size"); - let hasBarLine; - let barSize = null; + handler(_ref4, args) { + var { + parser + } = _ref4; + var numer = args[4]; + var denom = args[5]; // Look into the parse nodes to get the desired delimiters. + + var leftNode = normalizeArgument(args[0]); + var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + var rightNode = normalizeArgument(args[1]); + var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + var barNode = assertNodeType(args[2], "size"); + var hasBarLine; + var barSize = null; if (barNode.isBlank) { // \genfrac acts differently than \above. @@ -11021,16 +12077,16 @@ defineFunction({ } // Find out if we want displaystyle, textstyle, etc. - let size = "auto"; - let styl = checkNodeType(args[3], "ordgroup"); + var size = "auto"; + var styl = args[3]; - if (styl) { + if (styl.type === "ordgroup") { if (styl.body.length > 0) { - const textOrd = assertNodeType(styl.body[0], "textord"); + var textOrd = assertNodeType(styl.body[0], "textord"); size = stylArray[Number(textOrd.text)]; } } else { - styl = assertNodeType(args[3], "textord"); + styl = assertNodeType(styl, "textord"); size = stylArray[Number(styl.text)]; } @@ -11048,8 +12104,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$6, - mathmlBuilder: mathmlBuilder$6 + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 }); // \above is an infix fraction that also defines a fraction bar size. defineFunction({ @@ -11061,10 +12117,12 @@ defineFunction({ infix: true }, - handler(_ref4, args) { - let parser = _ref4.parser, - funcName = _ref4.funcName, - token = _ref4.token; + handler(_ref5, args) { + var { + parser, + funcName, + token + } = _ref5; return { type: "infix", mode: parser.mode, @@ -11082,13 +12140,15 @@ defineFunction({ numArgs: 3, argTypes: ["math", "size", "math"] }, - handler: (_ref5, args) => { - let parser = _ref5.parser, - funcName = _ref5.funcName; - const numer = args[0]; - const barSize = assert(assertNodeType(args[1], "infix").size); - const denom = args[2]; - const hasBarLine = barSize.number > 0; + handler: (_ref6, args) => { + var { + parser, + funcName + } = _ref6; + var numer = args[0]; + var barSize = assert(assertNodeType(args[1], "infix").size); + var denom = args[2]; + var hasBarLine = barSize.number > 0; return { type: "genfrac", mode: parser.mode, @@ -11102,35 +12162,35 @@ defineFunction({ size: "auto" }; }, - htmlBuilder: htmlBuilder$6, - mathmlBuilder: mathmlBuilder$6 + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 }); // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but -const htmlBuilder$7 = (grp, options) => { - const style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. +// also "supsub" since an over/underbrace can affect super/subscripting. +var htmlBuilder$3 = (grp, options) => { + var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. - let supSubGroup; - let group; - const supSub = checkNodeType(grp, "supsub"); + var supSubGroup; + var group; - if (supSub) { + if (grp.type === "supsub") { // Ref: LaTeX source2e: }}}}\limits} // i.e. LaTeX treats the brace similar to an op and passes it // with \limits, so we need to assign supsub style. - supSubGroup = supSub.sup ? buildGroup(supSub.sup, options.havingStyle(style.sup()), options) : buildGroup(supSub.sub, options.havingStyle(style.sub()), options); - group = assertNodeType(supSub.base, "horizBrace"); + supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); } else { group = assertNodeType(grp, "horizBrace"); } // Build the base group - const body = buildGroup(group.base, options.havingBaseStyle(Style$1.DISPLAY)); // Create the stretchy element + var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1.DISPLAY)); // Create the stretchy element - const braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ // This first vlist contains the content and the brace: equation - let vlist; + var vlist; if (group.isOver) { vlist = buildCommon.makeVList({ @@ -11175,7 +12235,7 @@ const htmlBuilder$7 = (grp, options) => { // note long note long note // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ // equation eqn eqn - const vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); + var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); if (group.isOver) { vlist = buildCommon.makeVList({ @@ -11212,9 +12272,9 @@ const htmlBuilder$7 = (grp, options) => { return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); }; -const mathmlBuilder$7 = (group, options) => { - const accentNode = stretchy.mathMLnode(group.label); - return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildGroup$1(group.base, options), accentNode]); +var mathmlBuilder$2 = (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]); }; // Horizontal stretchy braces @@ -11226,8 +12286,10 @@ defineFunction({ }, handler(_ref, args) { - let parser = _ref.parser, - funcName = _ref.funcName; + var { + parser, + funcName + } = _ref; return { type: "horizBrace", mode: parser.mode, @@ -11237,8 +12299,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$7, - mathmlBuilder: mathmlBuilder$7 + htmlBuilder: htmlBuilder$3, + mathmlBuilder: mathmlBuilder$2 }); defineFunction({ @@ -11250,86 +12312,234 @@ defineFunction({ allowedInText: true }, handler: (_ref, args) => { - let parser = _ref.parser; - const body = args[1]; - const href = assertNodeType(args[0], "url").url; + var { + parser + } = _ref; + var body = args[1]; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + var math = buildExpressionRow(group.body, options); + + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + + var chars = []; + + for (var i = 0; i < href.length; i++) { + var c = href[i]; + + if (c === "~") { + c = "\\textasciitilde"; + } + + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + + var body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); + +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeFragment(elements); + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", buildExpression(group.body, options)); + } + +}); + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName, + token + } = _ref; + var value = assertNodeType(args[0], "raw").string; + var body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + + var trustContext; + var attributes = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + + case "\\htmlData": + { + var data = value.split(","); + + for (var i = 0; i < data.length; i++) { + var keyVal = data[i].split("="); + + if (keyVal.length !== 2) { + throw new ParseError("Error parsing key-value for \\htmlData"); + } + + attributes["data-" + keyVal[0].trim()] = keyVal[1].trim(); + } + + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } - if (!parser.settings.isTrusted({ - command: "\\href", - url: href - })) { - return parser.formatUnsupportedCmd("\\href"); + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); } return { - type: "href", + type: "html", mode: parser.mode, - href, + attributes, body: ordargument(body) }; }, htmlBuilder: (group, options) => { - const elements = buildExpression(group.body, options, false); - return buildCommon.makeAnchor(group.href, [], elements, options); - }, - mathmlBuilder: (group, options) => { - let math = buildExpressionRow(group.body, options); - - if (!(math instanceof MathNode)) { - math = new MathNode("mrow", [math]); - } - - math.setAttribute("href", group.href); - return math; - } -}); -defineFunction({ - type: "href", - names: ["\\url"], - props: { - numArgs: 1, - argTypes: ["url"], - allowedInText: true - }, - handler: (_ref2, args) => { - let parser = _ref2.parser; - const href = assertNodeType(args[0], "url").url; + var elements = buildExpression$1(group.body, options, false); + var classes = ["enclosing"]; - if (!parser.settings.isTrusted({ - command: "\\url", - url: href - })) { - return parser.formatUnsupportedCmd("\\url"); + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); } - const chars = []; + var span = buildCommon.makeSpan(classes, elements, options); - for (let i = 0; i < href.length; i++) { - let c = href[i]; - - if (c === "~") { - c = "\\textasciitilde"; + for (var attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); } - - chars.push({ - type: "textord", - mode: "text", - text: c - }); } - const body = { - type: "text", - mode: parser.mode, - font: "\\texttt", - body: chars - }; - return { - type: "href", - mode: parser.mode, - href, - body: ordargument(body) - }; + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); } }); @@ -11341,7 +12551,9 @@ defineFunction({ allowedInText: true }, handler: (_ref, args) => { - let parser = _ref.parser; + var { + parser + } = _ref; return { type: "htmlmathml", mode: parser.mode, @@ -11350,7 +12562,7 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const elements = buildExpression(group.html, options, false); + var elements = buildExpression$1(group.html, options, false); return buildCommon.makeFragment(elements); }, mathmlBuilder: (group, options) => { @@ -11358,7 +12570,7 @@ defineFunction({ } }); -const sizeData = function sizeData(str) { +var sizeData = function sizeData(str) { if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { // str is a number with no unit specified. // default unit is bp, per graphix package. @@ -11367,13 +12579,13 @@ const sizeData = function sizeData(str) { unit: "bp" }; } else { - const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); if (!match) { throw new ParseError("Invalid size: '" + str + "' in \\includegraphics"); } - const data = { + var data = { number: +(match[1] + match[2]), // sign + magnitude, cast to number unit: match[3] @@ -11397,32 +12609,34 @@ defineFunction({ allowedInText: false }, handler: (_ref, args, optArgs) => { - let parser = _ref.parser; - let width = { + var { + parser + } = _ref; + var width = { number: 0, unit: "em" }; - let height = { + var height = { number: 0.9, unit: "em" }; // sorta character sized. - let totalheight = { + var totalheight = { number: 0, unit: "em" }; - let alt = ""; + var alt = ""; if (optArgs[0]) { - const attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. + var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. - const attributes = attributeStr.split(","); + var attributes = attributeStr.split(","); - for (let i = 0; i < attributes.length; i++) { - const keyVal = attributes[i].split("="); + for (var i = 0; i < attributes.length; i++) { + var keyVal = attributes[i].split("="); if (keyVal.length === 2) { - const str = keyVal[1].trim(); + var str = keyVal[1].trim(); switch (keyVal[0].trim()) { case "alt": @@ -11448,7 +12662,7 @@ defineFunction({ } } - const src = assertNodeType(args[0], "url").url; + var src = assertNodeType(args[0], "url").url; if (alt === "") { // No alt given. Use the file name. Strip away the path. @@ -11475,54 +12689,52 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const height = calculateSize(group.height, options); - let depth = 0; + var height = calculateSize(group.height, options); + var depth = 0; if (group.totalheight.number > 0) { depth = calculateSize(group.totalheight, options) - height; - depth = Number(depth.toFixed(2)); } - let width = 0; + var width = 0; if (group.width.number > 0) { width = calculateSize(group.width, options); } - const style = { - height: height + depth + "em" + var style = { + height: makeEm(height + depth) }; if (width > 0) { - style.width = width + "em"; + style.width = makeEm(width); } if (depth > 0) { - style.verticalAlign = -depth + "em"; + style.verticalAlign = makeEm(-depth); } - const node = new Img(group.src, group.alt, style); + var node = new Img(group.src, group.alt, style); node.height = height; node.depth = depth; return node; }, mathmlBuilder: (group, options) => { - const node = new mathMLTree.MathNode("mglyph", []); + var node = new mathMLTree.MathNode("mglyph", []); node.setAttribute("alt", group.alt); - const height = calculateSize(group.height, options); - let depth = 0; + var height = calculateSize(group.height, options); + var depth = 0; if (group.totalheight.number > 0) { depth = calculateSize(group.totalheight, options) - height; - depth = depth.toFixed(2); - node.setAttribute("valign", "-" + depth + "em"); + node.setAttribute("valign", makeEm(-depth)); } - node.setAttribute("height", height + depth + "em"); + node.setAttribute("height", makeEm(height + depth)); if (group.width.number > 0) { - const width = calculateSize(group.width, options); - node.setAttribute("width", width + "em"); + var width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); } node.setAttribute("src", group.src); @@ -11538,31 +12750,34 @@ defineFunction({ props: { numArgs: 1, argTypes: ["size"], + primitive: true, allowedInText: true }, handler(_ref, args) { - let parser = _ref.parser, - funcName = _ref.funcName; - const size = assertNodeType(args[0], "size"); + var { + parser, + funcName + } = _ref; + var size = assertNodeType(args[0], "size"); if (parser.settings.strict) { - const mathFunction = funcName[1] === 'm'; // \mkern, \mskip + var mathFunction = funcName[1] === 'm'; // \mkern, \mskip - const muUnit = size.value.unit === 'mu'; + var muUnit = size.value.unit === 'mu'; if (mathFunction) { if (!muUnit) { - parser.settings.reportNonstrict("mathVsTextUnits", `LaTeX's ${funcName} supports only mu units, ` + `not ${size.value.unit} units`); + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); } if (parser.mode !== "math") { - parser.settings.reportNonstrict("mathVsTextUnits", `LaTeX's ${funcName} works only in math mode`); + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); } } else { // !mathFunction if (muUnit) { - parser.settings.reportNonstrict("mathVsTextUnits", `LaTeX's ${funcName} doesn't support mu units`); + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); } } } @@ -11579,7 +12794,7 @@ defineFunction({ }, mathmlBuilder(group, options) { - const dimension = calculateSize(group.dimension, options); + var dimension = calculateSize(group.dimension, options); return new mathMLTree.SpaceNode(dimension); } @@ -11594,9 +12809,11 @@ defineFunction({ allowedInText: true }, handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - const body = args[0]; + var { + parser, + funcName + } = _ref; + var body = args[0]; return { type: "lap", mode: parser.mode, @@ -11606,44 +12823,43 @@ defineFunction({ }, htmlBuilder: (group, options) => { // mathllap, mathrlap, mathclap - let inner; + var inner; if (group.alignment === "clap") { // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ - inner = buildCommon.makeSpan([], [buildGroup(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span + inner = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span inner = buildCommon.makeSpan(["inner"], [inner], options); } else { - inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options)]); + inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options)]); } - const fix = buildCommon.makeSpan(["fix"], []); - let node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the + var fix = buildCommon.makeSpan(["fix"], []); + var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the // two items involved in the lap. // Next, use a strut to set the height of the HTML bounding box. // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 - const strut = buildCommon.makeSpan(["strut"]); - strut.style.height = node.height + node.depth + "em"; - strut.style.verticalAlign = -node.depth + "em"; - node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + var strut = buildCommon.makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); - node = buildCommon.makeVList({ - positionType: "firstBaseline", - children: [{ - type: "elem", - elem: node - }] - }, options); // Get the horizontal spacing correct relative to adjacent items. + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } - return buildCommon.makeSpan(["mord"], [node], options); + node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + + node = buildCommon.makeSpan(["thinbox"], [node], options); + return buildCommon.makeSpan(["mord", "vbox"], [node], options); }, mathmlBuilder: (group, options) => { // mathllap, mathrlap, mathclap - const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, options)]); + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); if (group.alignment !== "rlap") { - const offset = group.alignment === "llap" ? "-1" : "-0.5"; + var offset = group.alignment === "llap" ? "-1" : "-0.5"; node.setAttribute("lspace", offset + "width"); } @@ -11662,12 +12878,14 @@ defineFunction({ }, handler(_ref, args) { - let funcName = _ref.funcName, - parser = _ref.parser; - const outerMode = parser.mode; + var { + funcName, + parser + } = _ref; + var outerMode = parser.mode; parser.switchMode("math"); - const close = funcName === "\\(" ? "\\)" : "$"; - const body = parser.parseExpression(false, close); + var close = funcName === "\\(" ? "\\)" : "$"; + var body = parser.parseExpression(false, close); parser.expect(close); parser.switchMode(outerMode); return { @@ -11691,12 +12909,12 @@ defineFunction({ }, handler(context, args) { - throw new ParseError(`Mismatched ${context.funcName}`); + throw new ParseError("Mismatched " + context.funcName); } }); -const chooseMathStyle = (group, options) => { +var chooseMathStyle = (group, options) => { switch (options.style.size) { case Style$1.DISPLAY.size: return group.display; @@ -11719,10 +12937,13 @@ defineFunction({ type: "mathchoice", names: ["\\mathchoice"], props: { - numArgs: 4 + numArgs: 4, + primitive: true }, handler: (_ref, args) => { - let parser = _ref.parser; + var { + parser + } = _ref; return { type: "mathchoice", mode: parser.mode, @@ -11733,27 +12954,25 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const body = chooseMathStyle(group, options); - const elements = buildExpression(body, options, false); + var body = chooseMathStyle(group, options); + var elements = buildExpression$1(body, options, false); return buildCommon.makeFragment(elements); }, mathmlBuilder: (group, options) => { - const body = chooseMathStyle(group, options); + var body = chooseMathStyle(group, options); return buildExpressionRow(body, options); } }); -// For an operator with limits, assemble the base, sup, and sub into a span. -const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { - // IE 8 clips \int if it is in a display: inline-block. We wrap it - // in a new span so it is an inline, and works. +var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { base = buildCommon.makeSpan([], [base]); - let sub; - let sup; // We manually have to handle the superscripts and subscripts. This, + var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup); + var sub; + var sup; // We manually have to handle the superscripts and subscripts. This, // aside from the kern calculations, is copied from supsub. if (supGroup) { - const elem = buildGroup(supGroup, options.havingStyle(style.sup()), options); + var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options); sup = { elem, kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) @@ -11761,19 +12980,20 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi } if (subGroup) { - const elem = buildGroup(subGroup, options.havingStyle(style.sub()), options); + var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options); + sub = { - elem, - kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - elem.height) + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) }; } // Build the final group as a vlist of the possible subscript, base, // and possible superscript. - let finalGroup; + var finalGroup; if (sup && sub) { - const bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; finalGroup = buildCommon.makeVList({ positionType: "bottom", positionData: bottom, @@ -11783,7 +13003,7 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -11796,14 +13016,14 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }] }, options); } else if (sub) { - const top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note + var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note // that we are supposed to shift the limits by 1/2 of the slant, // but since we are centering the limits adding a full slant of // margin will shift by 1/2 that. @@ -11817,7 +13037,7 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -11827,10 +13047,11 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi }] }, options); } else if (sup) { - const bottom = base.depth + baseShift; + var _bottom = base.depth + baseShift; + finalGroup = buildCommon.makeVList({ positionType: "bottom", - positionData: bottom, + positionData: _bottom, children: [{ type: "elem", elem: base @@ -11840,7 +13061,7 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 @@ -11853,54 +13074,62 @@ const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShi return base; } - return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options); + var parts = [finalGroup]; + + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = buildCommon.makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + + return buildCommon.makeSpan(["mop", "op-limits"], parts, options); }; // Limits, symbols // Most operators have a large successor symbol, but these don't. -const noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also // "supsub" since some of them (like \int) can affect super/subscripting. -const htmlBuilder$8 = (grp, options) => { +var htmlBuilder$2 = (grp, options) => { // Operators are handled in the TeXbook pg. 443-444, rule 13(a). - let supGroup; - let subGroup; - let hasLimits = false; - let group; - const supSub = checkNodeType(grp, "supsub"); + var supGroup; + var subGroup; + var hasLimits = false; + var group; - if (supSub) { + if (grp.type === "supsub") { // If we have limits, supsub will pass us its group to handle. Pull // out the superscript and subscript and set the group to the op in // its base. - supGroup = supSub.sup; - subGroup = supSub.sub; - group = assertNodeType(supSub.base, "op"); + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); hasLimits = true; } else { group = assertNodeType(grp, "op"); } - const style = options.style; - let large = false; + var style = options.style; + var large = false; if (style.size === Style$1.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) { // Most symbol operators get larger in displaystyle (rule 13) large = true; } - let base; + var base; if (group.symbol) { // If this is a symbol, create the symbol. - const fontName = large ? "Size2-Regular" : "Size1-Regular"; - let stash = ""; + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + var stash = ""; if (group.name === "\\oiint" || group.name === "\\oiiint") { // No font glyphs yet, so use a glyph w/o the oval. // TODO: When font glyphs are available, delete this code. - stash = group.name.substr(1); // $FlowFixMe - + stash = group.name.slice(1); group.name = stash === "oiint" ? "\\iint" : "\\iiint"; } @@ -11909,8 +13138,8 @@ const htmlBuilder$8 = (grp, options) => { if (stash.length > 0) { // We're in \oiint or \oiiint. Overlay the oval. // TODO: When font glyphs are available, delete this code. - const italic = base.italic; - const oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); + var italic = base.italic; + var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); base = buildCommon.makeVList({ positionType: "individualShift", children: [{ @@ -11922,8 +13151,7 @@ const htmlBuilder$8 = (grp, options) => { elem: oval, shift: large ? 0.08 : 0 }] - }, options); // $FlowFixMe - + }, options); group.name = "\\" + stash; base.classes.unshift("mop"); // $FlowFixMe @@ -11931,22 +13159,20 @@ const htmlBuilder$8 = (grp, options) => { } } else if (group.body) { // If this is a list, compose that list. - const inner = buildExpression(group.body, options, true); + var inner = buildExpression$1(group.body, options, true); if (inner.length === 1 && inner[0] instanceof SymbolNode) { base = inner[0]; base.classes[0] = "mop"; // replace old mclass } else { - base = buildCommon.makeSpan(["mop"], buildCommon.tryCombineChars(inner), options); + base = buildCommon.makeSpan(["mop"], inner, options); } } else { // Otherwise, this is a text operator. Build the text from the // operator's name. - // TODO(emily): Add a space in the middle of some of these - // operators, like \limsup - const output = []; + var output = []; - for (let i = 1; i < group.name.length; i++) { + for (var i = 1; i < group.name.length; i++) { output.push(buildCommon.mathsym(group.name[i], group.mode, options)); } @@ -11954,8 +13180,8 @@ const htmlBuilder$8 = (grp, options) => { } // If content of op is a single symbol, shift it vertically. - let baseShift = 0; - let slant = 0; + var baseShift = 0; + var slant = 0; if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { // We suppress the shift of the base of \overset and \underset. Otherwise, @@ -11975,15 +13201,15 @@ const htmlBuilder$8 = (grp, options) => { } else { if (baseShift) { base.style.position = "relative"; - base.style.top = baseShift + "em"; + base.style.top = makeEm(baseShift); } return base; } }; -const mathmlBuilder$8 = (group, options) => { - let node; +var mathmlBuilder$1 = (group, options) => { + var node; if (group.symbol) { // This is a symbol. Just add the symbol. @@ -11994,17 +13220,17 @@ const mathmlBuilder$8 = (group, options) => { } } else if (group.body) { // This is an operator with children. Add them. - node = new MathNode("mo", buildExpression$1(group.body, options)); + node = new MathNode("mo", buildExpression(group.body, options)); } else { // This is a text operator. Add all of the characters from the // operator's name. node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an . // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 - const operator = new MathNode("mo", [makeText("\u2061", "text")]); + var operator = new MathNode("mo", [makeText("\u2061", "text")]); if (group.parentIsSupSub) { - node = new MathNode("mo", [node, operator]); + node = new MathNode("mrow", [node, operator]); } else { node = newDocumentFragment([node, operator]); } @@ -12013,7 +13239,7 @@ const mathmlBuilder$8 = (group, options) => { return node; }; -const singleCharBigOps = { +var singleCharBigOps = { "\u220F": "\\prod", "\u2210": "\\coprod", "\u2211": "\\sum", @@ -12034,9 +13260,11 @@ defineFunction({ numArgs: 0 }, handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - let fName = funcName; + var { + parser, + funcName + } = _ref; + var fName = funcName; if (fName.length === 1) { fName = singleCharBigOps[fName]; @@ -12051,8 +13279,8 @@ defineFunction({ name: fName }; }, - htmlBuilder: htmlBuilder$8, - mathmlBuilder: mathmlBuilder$8 + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 }); // Note: calling defineFunction with a type that's already been defined only // works because the same htmlBuilder and mathmlBuilder are being used. @@ -12060,11 +13288,14 @@ defineFunction({ type: "op", names: ["\\mathop"], props: { - numArgs: 1 + numArgs: 1, + primitive: true }, handler: (_ref2, args) => { - let parser = _ref2.parser; - const body = args[0]; + var { + parser + } = _ref2; + var body = args[0]; return { type: "op", mode: parser.mode, @@ -12074,13 +13305,13 @@ defineFunction({ body: ordargument(body) }; }, - htmlBuilder: htmlBuilder$8, - mathmlBuilder: mathmlBuilder$8 + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 }); // There are 2 flags for operators; whether they produce limits in // displaystyle, and whether they are symbols and should grow in // displaystyle. These four groups cover the four possible choices. -const singleCharIntegrals = { +var singleCharIntegrals = { "\u222b": "\\int", "\u222c": "\\iint", "\u222d": "\\iiint", @@ -12097,8 +13328,10 @@ defineFunction({ }, handler(_ref3) { - let parser = _ref3.parser, - funcName = _ref3.funcName; + var { + parser, + funcName + } = _ref3; return { type: "op", mode: parser.mode, @@ -12109,8 +13342,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$8, - mathmlBuilder: mathmlBuilder$8 + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 }); // Limits, not symbols defineFunction({ @@ -12121,8 +13354,10 @@ defineFunction({ }, handler(_ref4) { - let parser = _ref4.parser, - funcName = _ref4.funcName; + var { + parser, + funcName + } = _ref4; return { type: "op", mode: parser.mode, @@ -12133,8 +13368,8 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$8, - mathmlBuilder: mathmlBuilder$8 + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 }); // No limits, symbols defineFunction({ @@ -12145,9 +13380,11 @@ defineFunction({ }, handler(_ref5) { - let parser = _ref5.parser, - funcName = _ref5.funcName; - let fName = funcName; + var { + parser, + funcName + } = _ref5; + var fName = funcName; if (fName.length === 1) { fName = singleCharIntegrals[fName]; @@ -12163,38 +13400,38 @@ defineFunction({ }; }, - htmlBuilder: htmlBuilder$8, - mathmlBuilder: mathmlBuilder$8 + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 }); // NOTE: Unlike most `htmlBuilder`s, this one handles not only // "operatorname", but also "supsub" since \operatorname* can -const htmlBuilder$9 = (grp, options) => { +// affect super/subscripting. +var htmlBuilder$1 = (grp, options) => { // Operators are handled in the TeXbook pg. 443-444, rule 13(a). - let supGroup; - let subGroup; - let hasLimits = false; - let group; - const supSub = checkNodeType(grp, "supsub"); + var supGroup; + var subGroup; + var hasLimits = false; + var group; - if (supSub) { + if (grp.type === "supsub") { // If we have limits, supsub will pass us its group to handle. Pull // out the superscript and subscript and set the group to the op in // its base. - supGroup = supSub.sup; - subGroup = supSub.sub; - group = assertNodeType(supSub.base, "operatorname"); + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); hasLimits = true; } else { group = assertNodeType(grp, "operatorname"); } - let base; + var base; if (group.body.length > 0) { - const body = group.body.map(child => { + var body = group.body.map(child => { // $FlowFixMe: Check if the node has a string `text` property. - const childText = child.text; + var childText = child.text; if (typeof childText === "string") { return { @@ -12207,10 +13444,10 @@ const htmlBuilder$9 = (grp, options) => { } }); // Consolidate function names into symbol characters. - const expression = buildExpression(body, options.withFont("mathrm"), true); + var expression = buildExpression$1(body, options.withFont("mathrm"), true); - for (let i = 0; i < expression.length; i++) { - const child = expression[i]; + for (var i = 0; i < expression.length; i++) { + var child = expression[i]; if (child instanceof SymbolNode) { // Per amsopn package, @@ -12231,14 +13468,14 @@ const htmlBuilder$9 = (grp, options) => { } }; -const mathmlBuilder$9 = (group, options) => { +var mathmlBuilder = (group, options) => { // The steps taken here are similar to the html version. - let expression = buildExpression$1(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? + var expression = buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? - let isAllString = true; // default + var isAllString = true; // default - for (let i = 0; i < expression.length; i++) { - const node = expression[i]; + for (var i = 0; i < expression.length; i++) { + var node = expression[i]; if (node instanceof mathMLTree.SpaceNode) ; else if (node instanceof mathMLTree.MathNode) { switch (node.type) { @@ -12252,7 +13489,7 @@ const mathmlBuilder$9 = (group, options) => { case "mo": { - const child = node.children[0]; + var child = node.children[0]; if (node.children.length === 1 && child instanceof mathMLTree.TextNode) { child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); @@ -12273,18 +13510,18 @@ const mathmlBuilder$9 = (group, options) => { if (isAllString) { // Write a single TextNode instead of multiple nested tags. - const word = expression.map(node => node.toText()).join(""); + var word = expression.map(node => node.toText()).join(""); expression = [new mathMLTree.TextNode(word)]; } - const identifier = new mathMLTree.MathNode("mi", expression); + var identifier = new mathMLTree.MathNode("mi", expression); identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as ⁡ // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp - const operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]); + var operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]); if (group.parentIsSupSub) { - return new mathMLTree.MathNode("mo", [identifier, operator]); + return new mathMLTree.MathNode("mrow", [identifier, operator]); } else { return mathMLTree.newDocumentFragment([identifier, operator]); } @@ -12294,36 +13531,39 @@ const mathmlBuilder$9 = (group, options) => { defineFunction({ type: "operatorname", - names: ["\\operatorname", "\\operatorname*"], + names: ["\\operatorname@", "\\operatornamewithlimits"], props: { numArgs: 1 }, handler: (_ref, args) => { - let parser = _ref.parser, - funcName = _ref.funcName; - const body = args[0]; + var { + parser, + funcName + } = _ref; + var body = args[0]; return { type: "operatorname", mode: parser.mode, body: ordargument(body), - alwaysHandleSupSub: funcName === "\\operatorname*", + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", limits: false, parentIsSupSub: false }; }, - htmlBuilder: htmlBuilder$9, - mathmlBuilder: mathmlBuilder$9 + htmlBuilder: htmlBuilder$1, + mathmlBuilder }); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); defineFunctionBuilders({ type: "ordgroup", htmlBuilder(group, options) { if (group.semisimple) { - return buildCommon.makeFragment(buildExpression(group.body, options, false)); + return buildCommon.makeFragment(buildExpression$1(group.body, options, false)); } - return buildCommon.makeSpan(["mord"], buildExpression(group.body, options, true), options); + return buildCommon.makeSpan(["mord"], buildExpression$1(group.body, options, true), options); }, mathmlBuilder(group, options) { @@ -12340,8 +13580,10 @@ defineFunction({ }, handler(_ref, args) { - let parser = _ref.parser; - const body = args[0]; + var { + parser + } = _ref; + var body = args[0]; return { type: "overline", mode: parser.mode, @@ -12352,12 +13594,12 @@ defineFunction({ htmlBuilder(group, options) { // Overlines are handled in the TeXbook pg 443, Rule 9. // Build the inner group in the cramped style. - const innerGroup = buildGroup(group.body, options.havingCrampedStyle()); // Create the line above the body + var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle()); // Create the line above the body - const line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns + var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns - const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; - const vlist = buildCommon.makeVList({ + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -12377,9 +13619,9 @@ defineFunction({ }, mathmlBuilder(group, options) { - const operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); operator.setAttribute("stretchy", "true"); - const node = new mathMLTree.MathNode("mover", [buildGroup$1(group.body, options), operator]); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.body, options), operator]); node.setAttribute("accent", "true"); return node; } @@ -12394,8 +13636,10 @@ defineFunction({ allowedInText: true }, handler: (_ref, args) => { - let parser = _ref.parser; - const body = args[0]; + var { + parser + } = _ref; + var body = args[0]; return { type: "phantom", mode: parser.mode, @@ -12403,13 +13647,13 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const elements = buildExpression(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. + var elements = buildExpression$1(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. // See "color" for more details. return buildCommon.makeFragment(elements); }, mathmlBuilder: (group, options) => { - const inner = buildExpression$1(group.body, options); + var inner = buildExpression(group.body, options); return new mathMLTree.MathNode("mphantom", inner); } }); @@ -12421,8 +13665,10 @@ defineFunction({ allowedInText: true }, handler: (_ref2, args) => { - let parser = _ref2.parser; - const body = args[0]; + var { + parser + } = _ref2; + var body = args[0]; return { type: "hphantom", mode: parser.mode, @@ -12430,12 +13676,12 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - let node = buildCommon.makeSpan([], [buildGroup(group.body, options.withPhantom())]); + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options.withPhantom())]); node.height = 0; node.depth = 0; if (node.children) { - for (let i = 0; i < node.children.length; i++) { + for (var i = 0; i < node.children.length; i++) { node.children[i].height = 0; node.children[i].depth = 0; } @@ -12453,9 +13699,9 @@ defineFunction({ return buildCommon.makeSpan(["mord"], [node], options); }, mathmlBuilder: (group, options) => { - const inner = buildExpression$1(ordargument(group.body), options); - const phantom = new mathMLTree.MathNode("mphantom", inner); - const node = new mathMLTree.MathNode("mpadded", [phantom]); + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); node.setAttribute("height", "0px"); node.setAttribute("depth", "0px"); return node; @@ -12469,8 +13715,10 @@ defineFunction({ allowedInText: true }, handler: (_ref3, args) => { - let parser = _ref3.parser; - const body = args[0]; + var { + parser + } = _ref3; + var body = args[0]; return { type: "vphantom", mode: parser.mode, @@ -12478,14 +13726,14 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]); - const fix = buildCommon.makeSpan(["fix"], []); + var inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]); + var fix = buildCommon.makeSpan(["fix"], []); return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options); }, mathmlBuilder: (group, options) => { - const inner = buildExpression$1(ordargument(group.body), options); - const phantom = new mathMLTree.MathNode("mphantom", inner); - const node = new mathMLTree.MathNode("mpadded", [phantom]); + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); node.setAttribute("width", "0px"); return node; } @@ -12501,9 +13749,11 @@ defineFunction({ }, handler(_ref, args) { - let parser = _ref.parser; - const amount = assertNodeType(args[0], "size").value; - const body = args[1]; + var { + parser + } = _ref; + var amount = assertNodeType(args[0], "size").value; + var body = args[1]; return { type: "raisebox", mode: parser.mode, @@ -12513,8 +13763,8 @@ defineFunction({ }, htmlBuilder(group, options) { - const body = buildGroup(group.body, options); - const dy = calculateSize(group.dy, options); + var body = buildGroup$1(group.body, options); + var dy = calculateSize(group.dy, options); return buildCommon.makeVList({ positionType: "shift", positionData: -dy, @@ -12526,14 +13776,34 @@ defineFunction({ }, mathmlBuilder(group, options) { - const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, options)]); - const dy = group.dy.number + group.dy.unit; + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + var dy = group.dy.number + group.dy.unit; node.setAttribute("voffset", dy); return node; } }); +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } + +}); + defineFunction({ type: "rule", names: ["\\rule"], @@ -12544,10 +13814,12 @@ defineFunction({ }, handler(_ref, args, optArgs) { - let parser = _ref.parser; - const shift = optArgs[0]; - const width = assertNodeType(args[0], "size"); - const height = assertNodeType(args[1], "size"); + var { + parser + } = _ref; + var shift = optArgs[0]; + var width = assertNodeType(args[0], "size"); + var height = assertNodeType(args[1], "size"); return { type: "rule", mode: parser.mode, @@ -12559,15 +13831,15 @@ defineFunction({ htmlBuilder(group, options) { // Make an empty span for the rule - const rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units + var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units - const width = calculateSize(group.width, options); - const height = calculateSize(group.height, options); - const shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size - rule.style.borderRightWidth = width + "em"; - rule.style.borderTopWidth = height + "em"; - rule.style.bottom = shift + "em"; // Record the height and width + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); // Record the height and width rule.width = width; rule.height = height + shift; @@ -12580,36 +13852,36 @@ defineFunction({ }, mathmlBuilder(group, options) { - const width = calculateSize(group.width, options); - const height = calculateSize(group.height, options); - const shift = group.shift ? calculateSize(group.shift, options) : 0; - const color = options.color && options.getColor() || "black"; - const rule = new mathMLTree.MathNode("mspace"); + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + var color = options.color && options.getColor() || "black"; + var rule = new mathMLTree.MathNode("mspace"); rule.setAttribute("mathbackground", color); - rule.setAttribute("width", width + "em"); - rule.setAttribute("height", height + "em"); - const wrapper = new mathMLTree.MathNode("mpadded", [rule]); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + var wrapper = new mathMLTree.MathNode("mpadded", [rule]); if (shift >= 0) { - wrapper.setAttribute("height", "+" + shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); } else { - wrapper.setAttribute("height", shift + "em"); - wrapper.setAttribute("depth", "+" + -shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); } - wrapper.setAttribute("voffset", shift + "em"); + wrapper.setAttribute("voffset", makeEm(shift)); return wrapper; } }); function sizingGroup(value, options, baseOptions) { - const inner = buildExpression(value, options, false); - const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize + var inner = buildExpression$1(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize // manually. Handle nested size changes. - for (let i = 0; i < inner.length; i++) { - const pos = inner[i].classes.indexOf("sizing"); + for (var i = 0; i < inner.length; i++) { + var pos = inner[i].classes.indexOf("sizing"); if (pos < 0) { Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); @@ -12626,12 +13898,12 @@ function sizingGroup(value, options, baseOptions) { return buildCommon.makeFragment(inner); } -const sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; -const htmlBuilder$a = (group, options) => { +var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +var htmlBuilder = (group, options) => { // Handle sizing operators like \Huge. Real TeX doesn't actually allow // these functions inside of math expressions, so we do some special // handling. - const newOptions = options.havingSize(group.size); + var newOptions = options.havingSize(group.size); return sizingGroup(group.body, newOptions, options); }; defineFunction({ @@ -12642,10 +13914,12 @@ defineFunction({ allowedInText: true }, handler: (_ref, args) => { - let breakOnTokenText = _ref.breakOnTokenText, - funcName = _ref.funcName, - parser = _ref.parser; - const body = parser.parseExpression(false, breakOnTokenText); + var { + breakOnTokenText, + funcName, + parser + } = _ref; + var body = parser.parseExpression(false, breakOnTokenText); return { type: "sizing", mode: parser.mode, @@ -12654,17 +13928,17 @@ defineFunction({ body }; }, - htmlBuilder: htmlBuilder$a, + htmlBuilder, mathmlBuilder: (group, options) => { - const newOptions = options.havingSize(group.size); - const inner = buildExpression$1(group.body, newOptions); - const node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size + var newOptions = options.havingSize(group.size); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size // changes, because we don't keep state of what style we're currently // in, so we can't reset the size to normal before changing it. Now // that we're passing an options parameter we should be able to fix // this. - node.setAttribute("mathsize", newOptions.sizeMultiplier + "em"); + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); return node; } }); @@ -12679,19 +13953,21 @@ defineFunction({ allowedInText: true }, handler: (_ref, args, optArgs) => { - let parser = _ref.parser; - let smashHeight = false; - let smashDepth = false; - const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + var { + parser + } = _ref; + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); if (tbArg) { // Optional [tb] argument is engaged. // ref: amsmath: \renewcommand{\smash}[1][tb]{% // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% - let letter = ""; + var letter = ""; - for (let i = 0; i < tbArg.body.length; ++i) { - const node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. + for (var i = 0; i < tbArg.body.length; ++i) { + var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. letter = node.text; @@ -12710,7 +13986,7 @@ defineFunction({ smashDepth = true; } - const body = args[0]; + var body = args[0]; return { type: "smash", mode: parser.mode, @@ -12720,7 +13996,7 @@ defineFunction({ }; }, htmlBuilder: (group, options) => { - const node = buildCommon.makeSpan([], [buildGroup(group.body, options)]); + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); if (!group.smashHeight && !group.smashDepth) { return node; @@ -12730,7 +14006,7 @@ defineFunction({ node.height = 0; // In order to influence makeVList, we have to reset the children. if (node.children) { - for (let i = 0; i < node.children.length; i++) { + for (var i = 0; i < node.children.length; i++) { node.children[i].height = 0; } } @@ -12740,8 +14016,8 @@ defineFunction({ node.depth = 0; if (node.children) { - for (let i = 0; i < node.children.length; i++) { - node.children[i].depth = 0; + for (var _i = 0; _i < node.children.length; _i++) { + node.children[_i].depth = 0; } } } // At this point, we've reset the TeX-like height and depth values. @@ -12750,7 +14026,7 @@ defineFunction({ // from acting on that line height. So we'll call makeVList now. - const smashedNode = buildCommon.makeVList({ + var smashedNode = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -12761,7 +14037,7 @@ defineFunction({ return buildCommon.makeSpan(["mord"], [smashedNode], options); }, mathmlBuilder: (group, options) => { - const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, options)]); + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); if (group.smashHeight) { node.setAttribute("height", "0px"); @@ -12784,9 +14060,11 @@ defineFunction({ }, handler(_ref, args, optArgs) { - let parser = _ref.parser; - const index = optArgs[0]; - const body = args[0]; + var { + parser + } = _ref; + var index = optArgs[0]; + var body = args[0]; return { type: "sqrt", mode: parser.mode, @@ -12799,7 +14077,7 @@ defineFunction({ // Square roots are handled in the TeXbook pg. 443, Rule 11. // First, we do the same steps as in overline to build the inner group // and line - let inner = buildGroup(group.body, options.havingCrampedStyle()); + var inner = buildGroup$1(group.body, options.havingCrampedStyle()); if (inner.height === 0) { // Render a small surd. @@ -12810,34 +14088,34 @@ defineFunction({ inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter - const metrics = options.fontMetrics(); - const theta = metrics.defaultRuleThickness; - let phi = theta; + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; + var phi = theta; if (options.style.id < Style$1.TEXT.id) { phi = options.fontMetrics().xHeight; } // Calculate the clearance between the body and line - let lineClearance = theta + phi / 4; - const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size + var lineClearance = theta + phi / 4; + var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size - const _delimiter$sqrtImage = delimiter.sqrtImage(minDelimiterHeight, options), - img = _delimiter$sqrtImage.span, - ruleWidth = _delimiter$sqrtImage.ruleWidth, - advanceWidth = _delimiter$sqrtImage.advanceWidth; - - const delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size + var { + span: img, + ruleWidth, + advanceWidth + } = delimiter.sqrtImage(minDelimiterHeight, options); + var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size if (delimDepth > inner.height + inner.depth + lineClearance) { lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; } // Shift the sqrt image - const imgShift = img.height - inner.height - lineClearance - ruleWidth; - inner.style.paddingLeft = advanceWidth + "em"; // Overlay the image and the argument. + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument. - const body = buildCommon.makeVList({ + var body = buildCommon.makeVList({ positionType: "firstBaseline", children: [{ type: "elem", @@ -12860,13 +14138,13 @@ defineFunction({ } else { // Handle the optional root index // The index is always in scriptscript style - const newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT); - const rootm = buildGroup(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX + var newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT); + var rootm = buildGroup$1(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX // source, in the definition of `\r@@t`. - const toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly + var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly - const rootVList = buildCommon.makeVList({ + var rootVList = buildCommon.makeVList({ positionType: "shift", positionData: -toShift, children: [{ @@ -12876,20 +14154,22 @@ defineFunction({ }, options); // Add a class surrounding it so we can add on the appropriate // kerning - const rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); + var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); } }, mathmlBuilder(group, options) { - const body = group.body, - index = group.index; - return index ? new mathMLTree.MathNode("mroot", [buildGroup$1(body, options), buildGroup$1(index, options)]) : new mathMLTree.MathNode("msqrt", [buildGroup$1(body, options)]); + var { + body, + index + } = group; + return index ? new mathMLTree.MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildGroup(body, options)]); } }); -const styleMap$1 = { +var styleMap = { "display": Style$1.DISPLAY, "text": Style$1.TEXT, "script": Style$1.SCRIPT, @@ -12900,19 +14180,22 @@ defineFunction({ names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], props: { numArgs: 0, - allowedInText: true + allowedInText: true, + primitive: true }, handler(_ref, args) { - let breakOnTokenText = _ref.breakOnTokenText, - funcName = _ref.funcName, - parser = _ref.parser; + var { + breakOnTokenText, + funcName, + parser + } = _ref; // parse out the implicit body - const body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. // here and in buildHTML and de-dupe the enumeration of all the styles). // $FlowFixMe: The names above exactly match the styles. - const style = funcName.slice(1, funcName.length - 5); + var style = funcName.slice(1, funcName.length - 5); return { type: "styling", mode: parser.mode, @@ -12925,24 +14208,24 @@ defineFunction({ htmlBuilder(group, options) { // Style changes are handled in the TeXbook on pg. 442, Rule 3. - const newStyle = styleMap$1[group.style]; - const newOptions = options.havingStyle(newStyle).withFont(''); + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle).withFont(''); return sizingGroup(group.body, newOptions, options); }, mathmlBuilder(group, options) { // Figure out what style we're changing to. - const newStyle = styleMap$1[group.style]; - const newOptions = options.havingStyle(newStyle); - const inner = buildExpression$1(group.body, newOptions); - const node = new mathMLTree.MathNode("mstyle", inner); - const styleAttributes = { + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); + var styleAttributes = { "display": ["0", "true"], "text": ["0", "false"], "script": ["1", "false"], "scriptscript": ["2", "false"] }; - const attr = styleAttributes[group.style]; + var attr = styleAttributes[group.style]; node.setAttribute("scriptlevel", attr[0]); node.setAttribute("displaystyle", attr[1]); return node; @@ -12957,24 +14240,25 @@ defineFunction({ * its inner element should handle the superscripts and subscripts instead of * handling them itself. */ -const htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { - const base = group.base; +var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { + var base = group.base; if (!base) { return null; } else if (base.type === "op") { // Operators handle supsubs differently when they have limits // (e.g. `\displaystyle\sum_2^3`) - const delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub); - return delegate ? htmlBuilder$8 : null; + var delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? htmlBuilder$2 : null; } else if (base.type === "operatorname") { - const delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits); - return delegate ? htmlBuilder$9 : null; + var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits); + + return _delegate ? htmlBuilder$1 : null; } else if (base.type === "accent") { - return utils.isCharacterBox(base.base) ? htmlBuilder : null; + return utils.isCharacterBox(base.base) ? htmlBuilder$a : null; } else if (base.type === "horizBrace") { - const isSup = !group.sub; - return isSup === base.isOver ? htmlBuilder$7 : null; + var isSup = !group.sub; + return isSup === base.isOver ? htmlBuilder$3 : null; } else { return null; } @@ -12990,27 +14274,29 @@ defineFunctionBuilders({ // 445-446, rules 18(a-f). // Here is where we defer to the inner group if it should handle // superscripts and subscripts itself. - const builderDelegate = htmlBuilderDelegate(group, options); + var builderDelegate = htmlBuilderDelegate(group, options); if (builderDelegate) { return builderDelegate(group, options); } - const valueBase = group.base, - valueSup = group.sup, - valueSub = group.sub; - const base = buildGroup(valueBase, options); - let supm; - let subm; - const metrics = options.fontMetrics(); // Rule 18a + var { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + var base = buildGroup$1(valueBase, options); + var supm; + var subm; + var metrics = options.fontMetrics(); // Rule 18a - let supShift = 0; - let subShift = 0; - const isCharacterBox = valueBase && utils.isCharacterBox(valueBase); + var supShift = 0; + var subShift = 0; + var isCharacterBox = valueBase && utils.isCharacterBox(valueBase); if (valueSup) { - const newOptions = options.havingStyle(options.style.sup()); - supm = buildGroup(valueSup, newOptions, options); + var newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup$1(valueSup, newOptions, options); if (!isCharacterBox) { supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; @@ -13018,16 +14304,17 @@ defineFunctionBuilders({ } if (valueSub) { - const newOptions = options.havingStyle(options.style.sub()); - subm = buildGroup(valueSub, newOptions, options); + var _newOptions = options.havingStyle(options.style.sub()); + + subm = buildGroup$1(valueSub, _newOptions, options); if (!isCharacterBox) { - subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; } } // Rule 18c - let minSupShift; + var minSupShift; if (options.style === Style$1.DISPLAY) { minSupShift = metrics.sup1; @@ -13039,34 +14326,34 @@ defineFunctionBuilders({ // appropriately for use as the marginRight. - const multiplier = options.sizeMultiplier; - const marginRight = 0.5 / metrics.ptPerEm / multiplier + "em"; - let marginLeft = null; + var multiplier = options.sizeMultiplier; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + var marginLeft = null; if (subm) { // Subscripts shouldn't be shifted by the base's italic correction. // Account for that by shifting the subscript back the appropriate // amount. Note we only do this when the base is a single symbol. - const isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); if (base instanceof SymbolNode || isOiint) { // $FlowFixMe - marginLeft = -base.italic + "em"; + marginLeft = makeEm(-base.italic); } } - let supsub; + var supsub; if (supm && subm) { supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); subShift = Math.max(subShift, metrics.sub2); - const ruleWidth = metrics.defaultRuleThickness; // Rule 18e + var ruleWidth = metrics.defaultRuleThickness; // Rule 18e - const maxWidth = 4 * ruleWidth; + var maxWidth = 4 * ruleWidth; if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { subShift = maxWidth - (supShift - supm.depth) + subm.height; - const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); if (psi > 0) { supShift += psi; @@ -13074,7 +14361,7 @@ defineFunctionBuilders({ } } - const vlistElem = [{ + var vlistElem = [{ type: "elem", elem: subm, shift: subShift, @@ -13093,7 +14380,7 @@ defineFunctionBuilders({ } else if (subm) { // Rule 18b subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); - const vlistElem = [{ + var _vlistElem = [{ type: "elem", elem: subm, marginLeft, @@ -13102,7 +14389,7 @@ defineFunctionBuilders({ supsub = buildCommon.makeVList({ positionType: "shift", positionData: subShift, - children: vlistElem + children: _vlistElem }, options); } else if (supm) { // Rule 18c, d @@ -13121,23 +14408,22 @@ defineFunctionBuilders({ } // Wrap the supsub vlist in a span.msupsub to reset text-align. - const mclass = getTypeOfDomTree(base, "right") || "mord"; + var mclass = getTypeOfDomTree(base, "right") || "mord"; return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options); }, mathmlBuilder(group, options) { // Is the inner group a relevant horizonal brace? - let isBrace = false; - let isOver; - let isSup; - const horizBrace = checkNodeType(group.base, "horizBrace"); + var isBrace = false; + var isOver; + var isSup; - if (horizBrace) { + if (group.base && group.base.type === "horizBrace") { isSup = !!group.sup; - if (isSup === horizBrace.isOver) { + if (isSup === group.base.isOver) { isBrace = true; - isOver = horizBrace.isOver; + isOver = group.base.isOver; } } @@ -13145,22 +14431,22 @@ defineFunctionBuilders({ group.base.parentIsSupSub = true; } - const children = [buildGroup$1(group.base, options)]; + var children = [buildGroup(group.base, options)]; if (group.sub) { - children.push(buildGroup$1(group.sub, options)); + children.push(buildGroup(group.sub, options)); } if (group.sup) { - children.push(buildGroup$1(group.sup, options)); + children.push(buildGroup(group.sup, options)); } - let nodeType; + var nodeType; if (isBrace) { nodeType = isOver ? "mover" : "munder"; } else if (!group.sub) { - const base = group.base; + var base = group.base; if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) { nodeType = "mover"; @@ -13170,29 +14456,28 @@ defineFunctionBuilders({ nodeType = "msup"; } } else if (!group.sup) { - const base = group.base; + var _base = group.base; - if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) { + if (_base && _base.type === "op" && _base.limits && (options.style === Style$1.DISPLAY || _base.alwaysHandleSupSub)) { nodeType = "munder"; - } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1.DISPLAY)) { + } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1.DISPLAY)) { nodeType = "munder"; } else { nodeType = "msub"; } } else { - const base = group.base; + var _base2 = group.base; - if (base && base.type === "op" && base.limits && options.style === Style$1.DISPLAY) { + if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1.DISPLAY) { nodeType = "munderover"; - } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || base.limits)) { + } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || _base2.limits)) { nodeType = "munderover"; } else { nodeType = "msubsup"; } } - const node = new mathMLTree.MathNode(nodeType, children); - return node; + return new mathMLTree.MathNode(nodeType, children); } }); @@ -13205,10 +14490,10 @@ defineFunctionBuilders({ }, mathmlBuilder(group, options) { - const node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]); + var node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]); if (group.family === "bin") { - const variant = getVariant(group, options); + var variant = getVariant(group, options); if (variant === "bold-italic") { node.setAttribute("mathvariant", variant); @@ -13227,7 +14512,8 @@ defineFunctionBuilders({ }); // "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in -const defaultVariant = { +// src/symbols.js. +var defaultVariant = { "mi": "italic", "mn": "normal", "mtext": "normal" @@ -13240,8 +14526,8 @@ defineFunctionBuilders({ }, mathmlBuilder(group, options) { - const node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]); - const variant = getVariant(group, options) || "italic"; + var node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]); + var variant = getVariant(group, options) || "italic"; if (variant !== defaultVariant[node.type]) { node.setAttribute("mathvariant", variant); @@ -13259,15 +14545,13 @@ defineFunctionBuilders({ }, mathmlBuilder(group, options) { - const text = makeText(group.text, group.mode, options); - const variant = getVariant(group, options) || "normal"; - let node; + var text = makeText(group.text, group.mode, options); + var variant = getVariant(group, options) || "normal"; + var node; if (group.mode === 'text') { node = new mathMLTree.MathNode("mtext", [text]); } else if (/[0-9]/.test(group.text)) { - // TODO(kevinb) merge adjacent nodes - // do it as a post processing step node = new mathMLTree.MathNode("mn", [text]); } else if (group.text === "\\prime") { node = new mathMLTree.MathNode("mo", [text]); @@ -13284,7 +14568,7 @@ defineFunctionBuilders({ }); -const cssSpace = { +var cssSpace = { "\\nobreak": "nobreak", "\\allowbreak": "allowbreak" }; // A lookup table to determine whether a spacing function/symbol should be @@ -13293,7 +14577,7 @@ const cssSpace = { // the associated value may have a `className` specifying an extra CSS class // to add to the created `span`. -const regularSpace = { +var regularSpace = { " ": {}, "\\ ": {}, "~": { @@ -13311,12 +14595,12 @@ defineFunctionBuilders({ htmlBuilder(group, options) { if (regularSpace.hasOwnProperty(group.text)) { - const className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these + var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these // things has an entry in the symbols table, so these will be turned // into appropriate outputs. if (group.mode === "text") { - const ord = buildCommon.makeOrd(group, options, "textord"); + var ord = buildCommon.makeOrd(group, options, "textord"); ord.classes.push(className); return ord; } else { @@ -13326,12 +14610,12 @@ defineFunctionBuilders({ // Spaces based on just a CSS class. return buildCommon.makeSpan(["mspace", cssSpace[group.text]], [], options); } else { - throw new ParseError(`Unknown type of space "${group.text}"`); + throw new ParseError("Unknown type of space \"" + group.text + "\""); } }, mathmlBuilder(group, options) { - let node; + var node; if (regularSpace.hasOwnProperty(group.text)) { node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\u00a0")]); @@ -13339,7 +14623,7 @@ defineFunctionBuilders({ // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored return new mathMLTree.MathNode("mspace"); } else { - throw new ParseError(`Unknown type of space "${group.text}"`); + throw new ParseError("Unknown type of space \"" + group.text + "\""); } return node; @@ -13347,8 +14631,8 @@ defineFunctionBuilders({ }); -const pad = () => { - const padNode = new mathMLTree.MathNode("mtd", []); +var pad = () => { + var padNode = new mathMLTree.MathNode("mtd", []); padNode.setAttribute("width", "50%"); return padNode; }; @@ -13357,7 +14641,7 @@ defineFunctionBuilders({ type: "tag", mathmlBuilder(group, options) { - const table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); table.setAttribute("width", "100%"); return table; // TODO: Left-aligned tags. // Currently, the group and options passed here do not contain @@ -13370,24 +14654,24 @@ defineFunctionBuilders({ }); -const textFontFamilies = { +var textFontFamilies = { "\\text": undefined, "\\textrm": "textrm", "\\textsf": "textsf", "\\texttt": "texttt", "\\textnormal": "textrm" }; -const textFontWeights = { +var textFontWeights = { "\\textbf": "textbf", "\\textmd": "textmd" }; -const textFontShapes = { +var textFontShapes = { "\\textit": "textit", "\\textup": "textup" }; -const optionsWithFont = (group, options) => { - const font = group.font; // Checks if the argument is a font family or a font style. +var optionsWithFont = (group, options) => { + var font = group.font; // Checks if the argument is a font family or a font style. if (!font) { return options; @@ -13409,14 +14693,16 @@ defineFunction({ props: { numArgs: 1, argTypes: ["text"], - greediness: 2, + allowedInArgument: true, allowedInText: true }, handler(_ref, args) { - let parser = _ref.parser, - funcName = _ref.funcName; - const body = args[0]; + var { + parser, + funcName + } = _ref; + var body = args[0]; return { type: "text", mode: parser.mode, @@ -13426,13 +14712,13 @@ defineFunction({ }, htmlBuilder(group, options) { - const newOptions = optionsWithFont(group, options); - const inner = buildExpression(group.body, newOptions, true); - return buildCommon.makeSpan(["mord", "text"], buildCommon.tryCombineChars(inner), newOptions); + var newOptions = optionsWithFont(group, options); + var inner = buildExpression$1(group.body, newOptions, true); + return buildCommon.makeSpan(["mord", "text"], inner, newOptions); }, mathmlBuilder(group, options) { - const newOptions = optionsWithFont(group, options); + var newOptions = optionsWithFont(group, options); return buildExpressionRow(group.body, newOptions); } @@ -13447,7 +14733,9 @@ defineFunction({ }, handler(_ref, args) { - let parser = _ref.parser; + var { + parser + } = _ref; return { type: "underline", mode: parser.mode, @@ -13458,12 +14746,12 @@ defineFunction({ htmlBuilder(group, options) { // Underlines are handled in the TeXbook pg 443, Rule 10. // Build the inner group. - const innerGroup = buildGroup(group.body, options); // Create the line to go below the body + var innerGroup = buildGroup$1(group.body, options); // Create the line to go below the body - const line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns + var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns - const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; - const vlist = buildCommon.makeVList({ + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ positionType: "top", positionData: innerGroup.height, children: [{ @@ -13484,15 +14772,59 @@ defineFunction({ }, mathmlBuilder(group, options) { - const operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); operator.setAttribute("stretchy", "true"); - const node = new mathMLTree.MathNode("munder", [buildGroup$1(group.body, options), operator]); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.body, options), operator]); node.setAttribute("accentunder", "true"); return node; } }); +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var axisHeight = options.fontMetrics().axisHeight; + var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return buildCommon.makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + return new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]); + } + +}); + defineFunction({ type: "verb", names: ["\\verb"], @@ -13510,13 +14842,13 @@ defineFunction({ }, htmlBuilder(group, options) { - const text = makeVerb(group); - const body = []; // \verb enters text mode and therefore is sized like \textstyle + var text = makeVerb(group); + var body = []; // \verb enters text mode and therefore is sized like \textstyle - const newOptions = options.havingStyle(options.style.text()); + var newOptions = options.havingStyle(options.style.text()); - for (let i = 0; i < text.length; i++) { - let c = text[i]; + for (var i = 0; i < text.length; i++) { + var c = text[i]; if (c === '~') { c = '\\textasciitilde'; @@ -13529,8 +14861,8 @@ defineFunction({ }, mathmlBuilder(group, options) { - const text = new mathMLTree.TextNode(makeVerb(group)); - const node = new mathMLTree.MathNode("mtext", [text]); + var text = new mathMLTree.TextNode(makeVerb(group)); + var node = new mathMLTree.MathNode("mtext", [text]); node.setAttribute("mathvariant", "monospace"); return node; } @@ -13543,10 +14875,10 @@ defineFunction({ * \verb replaces each space with a no-break space \xA0 */ -const makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); +var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); /** Include this to ensure that all functions are defined. */ -const functions = _functions; +var functions = _functions; /** * The Lexer class handles tokenizing the input in various ways. Since our @@ -13570,34 +14902,43 @@ const functions = _functions; * - does not match bare surrogate code units * - matches any BMP character except for those just described * - matches any valid Unicode surrogate pair - * - matches a backslash followed by one or more letters - * - matches a backslash followed by any BMP character, including newline + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace * Just because the Lexer matches something doesn't mean it's valid input: * If there is no matching function or symbol definition, the Parser will * still reject the input. */ -const spaceRegexString = "[ \r\n\t]"; -const controlWordRegexString = "\\\\[a-zA-Z@]+"; -const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; -const controlWordWhitespaceRegexString = `${controlWordRegexString}${spaceRegexString}*`; -const controlWordWhitespaceRegex = new RegExp(`^(${controlWordRegexString})${spaceRegexString}*$`); -const combiningDiacriticalMarkString = "[\u0300-\u036f]"; -const combiningDiacriticalMarksEndRegex = new RegExp(`${combiningDiacriticalMarkString}+$`); -const tokenRegexString = `(${spaceRegexString}+)|` + // whitespace -"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint -`${combiningDiacriticalMarkString}*` + // ...plus accents -"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair -`${combiningDiacriticalMarkString}*` + // ...plus accents -"|\\\\verb\\*([^]).*?\\3" + // \verb* -"|\\\\verb([^*a-zA-Z]).*?\\4" + // \verb unstarred -"|\\\\operatorname\\*" + // \operatorname* -`|${controlWordWhitespaceRegexString}` + // \macroName + spaces -`|${controlSymbolRegexString})`; // \\, \', etc. +var spaceRegexString = "[ \r\n\t]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +var combiningDiacriticalMarkString = "[\u0300-\u036f]"; +var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace +controlSpaceRegexString + "|") + // \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint +combiningDiacriticalMarkString + "*") + // ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair +combiningDiacriticalMarkString + "*") + // ...plus accents +"|\\\\verb\\*([^]).*?\\4" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred +"|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. /** Main Lexer class */ class Lexer { - // category codes, only supports comment characters (14) for now + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). constructor(input, settings) { this.input = void 0; this.settings = void 0; @@ -13608,7 +14949,9 @@ class Lexer { this.settings = settings; this.tokenRegex = new RegExp(tokenRegexString, 'g'); this.catcodes = { - "%": 14 // comment character + "%": 14, + // comment character + "~": 13 // active character }; } @@ -13622,24 +14965,24 @@ class Lexer { lex() { - const input = this.input; - const pos = this.tokenRegex.lastIndex; + var input = this.input; + var pos = this.tokenRegex.lastIndex; if (pos === input.length) { return new Token("EOF", new SourceLocation(this, pos, pos)); } - const match = this.tokenRegex.exec(input); + var match = this.tokenRegex.exec(input); if (match === null || match.index !== pos) { - throw new ParseError(`Unexpected character: '${input[pos]}'`, new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); } - let text = match[2] || " "; + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); if (this.catcodes[text] === 14) { // comment character - const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); if (nlIndex === -1) { this.tokenRegex.lastIndex = input.length; // EOF @@ -13650,13 +14993,6 @@ class Lexer { } return this.lex(); - } // Trim any trailing whitespace from control word match - - - const controlMatch = text.match(controlWordWhitespaceRegex); - - if (controlMatch) { - text = controlMatch[1]; } return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); @@ -13712,11 +15048,11 @@ class Namespace { throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); } - const undefs = this.undefStack.pop(); + var undefs = this.undefStack.pop(); - for (const undef in undefs) { + for (var undef in undefs) { if (undefs.hasOwnProperty(undef)) { - if (undefs[undef] === undefined) { + if (undefs[undef] == null) { delete this.current[undef]; } else { this.current[undef] = undefs[undef]; @@ -13724,6 +15060,17 @@ class Namespace { } } } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } /** * Detect whether `name` has a definition. Equivalent to * `get(name) != null`. @@ -13755,6 +15102,7 @@ class Namespace { * Local set() sets the current value and (when appropriate) adds an undo * operation to the undo stack. Global set() may change the undo * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. */ @@ -13768,7 +15116,7 @@ class Namespace { // by destroying any undos currently scheduled for this name, // and adding an undo with the *new* value (in case it later gets // locally reset within this environment). - for (let i = 0; i < this.undefStack.length; i++) { + for (var i = 0; i < this.undefStack.length; i++) { delete this.undefStack[i][name]; } @@ -13779,14 +15127,18 @@ class Namespace { // Undo this set at end of this group (possibly to `undefined`), // unless an undo is already in place, in which case that older // value is the correct one. - const top = this.undefStack[this.undefStack.length - 1]; + var top = this.undefStack[this.undefStack.length - 1]; if (top && !top.hasOwnProperty(name)) { top[name] = this.current[name]; } } - this.current[name] = value; + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } } } @@ -13795,17 +15147,43 @@ class Namespace { * Predefined macros for KaTeX. * This can be used to define some commands in terms of others. */ -const builtinMacros = {}; - -function defineMacro(name, body) { - builtinMacros[name] = body; -} ////////////////////////////////////////////////////////////////////// +var macros = _macros; // macro tools -// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + var t = context.popToken(); + + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + var t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + + return { + tokens: [t], + numArgs: 0 + }; +}); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 // TeX source: \long\def\@firstoftwo#1#2{#1} defineMacro("\\@firstoftwo", function (context) { - const args = context.consumeArgs(2); + var args = context.consumeArgs(2); return { tokens: args[0], numArgs: 0 @@ -13814,19 +15192,21 @@ defineMacro("\\@firstoftwo", function (context) { // TeX source: \long\def\@secondoftwo#1#2{#2} defineMacro("\\@secondoftwo", function (context) { - const args = context.consumeArgs(2); + var args = context.consumeArgs(2); return { tokens: args[1], numArgs: 0 }; }); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) -// symbol. If it matches #1, then the macro expands to #2; otherwise, #3. -// Note, however, that it does not consume the next symbol in either case. +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. defineMacro("\\@ifnextchar", function (context) { - const args = context.consumeArgs(3); // symbol, if, else + var args = context.consumeArgs(3); // symbol, if, else - const nextToken = context.future(); + context.consumeSpaces(); + var nextToken = context.future(); if (args[0].length === 1 && args[0][0].text === nextToken.text) { return { @@ -13847,7 +15227,7 @@ defineMacro("\\@ifnextchar", function (context) { defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode defineMacro("\\TextOrMath", function (context) { - const args = context.consumeArgs(2); + var args = context.consumeArgs(2); if (context.mode === 'text') { return { @@ -13862,7 +15242,7 @@ defineMacro("\\TextOrMath", function (context) { } }); // Lookup table for parsing numbers in base 8 through 16 -const digitToNumber = { +var digitToNumber = { "0": 0, "1": 1, "2": 2, @@ -13896,9 +15276,9 @@ const digitToNumber = { // calls to a function \@char dealt with in the Parser. defineMacro("\\char", function (context) { - let token = context.popToken(); - let base; - let number = ''; + var token = context.popToken(); + var base; + var number = ''; if (token.text === "'") { base = 8; @@ -13925,10 +15305,10 @@ defineMacro("\\char", function (context) { number = digitToNumber[token.text]; if (number == null || number >= base) { - throw new ParseError(`Invalid base-${base} digit ${token.text}`); + throw new ParseError("Invalid base-" + base + " digit " + token.text); } - let digit; + var digit; while ((digit = digitToNumber[context.future().text]) != null && digit < base) { number *= base; @@ -13937,99 +15317,35 @@ defineMacro("\\char", function (context) { } } - return `\\@char{${number}}`; -}); // Basic support for macro definitions: -// \def\macro{expansion} -// \def\macro#1{expansion} -// \def\macro#1#2{expansion} -// \def\macro#1#2#3#4#5#6#7#8#9{expansion} -// Also the \gdef and \global\def equivalents - -const def = (context, global) => { - let arg = context.consumeArgs(1)[0]; - - if (arg.length !== 1) { - throw new ParseError("\\gdef's first argument must be a macro name"); - } - - const name = arg[0].text; // Count argument specifiers, and check they are in the order #1 #2 ... - - let numArgs = 0; - arg = context.consumeArgs(1)[0]; - - while (arg.length === 1 && arg[0].text === "#") { - arg = context.consumeArgs(1)[0]; - - if (arg.length !== 1) { - throw new ParseError(`Invalid argument number length "${arg.length}"`); - } - - if (!/^[1-9]$/.test(arg[0].text)) { - throw new ParseError(`Invalid argument number "${arg[0].text}"`); - } - - numArgs++; - - if (parseInt(arg[0].text) !== numArgs) { - throw new ParseError(`Argument number "${arg[0].text}" out of order`); - } - - arg = context.consumeArgs(1)[0]; - } // Final arg is the expansion of the macro - - - context.macros.set(name, { - tokens: arg, - numArgs - }, global); - return ''; -}; - -defineMacro("\\gdef", context => def(context, true)); -defineMacro("\\def", context => def(context, false)); -defineMacro("\\global", context => { - const next = context.consumeArgs(1)[0]; - - if (next.length !== 1) { - throw new ParseError("Invalid command after \\global"); - } - - const command = next[0].text; // TODO: Should expand command - - if (command === "\\def") { - // \global\def is equivalent to \gdef - return def(context, true); - } else { - throw new ParseError(`Invalid command '${command}' after \\global`); - } + return "\\@char{" + number + "}"; }); // \newcommand{\macro}[args]{definition} // \renewcommand{\macro}[args]{definition} // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} -const newcommand = (context, existsOK, nonexistsOK) => { - let arg = context.consumeArgs(1)[0]; +var newcommand = (context, existsOK, nonexistsOK) => { + var arg = context.consumeArg().tokens; if (arg.length !== 1) { throw new ParseError("\\newcommand's first argument must be a macro name"); } - const name = arg[0].text; - const exists = context.isDefined(name); + var name = arg[0].text; + var exists = context.isDefined(name); if (exists && !existsOK) { - throw new ParseError(`\\newcommand{${name}} attempting to redefine ` + `${name}; use \\renewcommand`); + throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); } if (!exists && !nonexistsOK) { - throw new ParseError(`\\renewcommand{${name}} when command ${name} ` + `does not yet exist; use \\newcommand`); + throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); } - let numArgs = 0; - arg = context.consumeArgs(1)[0]; + var numArgs = 0; + arg = context.consumeArg().tokens; if (arg.length === 1 && arg[0].text === "[") { - let argText = ''; - let token = context.expandNextToken(); + var argText = ''; + var token = context.expandNextToken(); while (token.text !== "]" && token.text !== "EOF") { // TODO: Should properly expand arg, e.g., ignore {}s @@ -14038,11 +15354,11 @@ const newcommand = (context, existsOK, nonexistsOK) => { } if (!argText.match(/^\s*[0-9]+\s*$/)) { - throw new ParseError(`Invalid number of arguments: ${argText}`); + throw new ParseError("Invalid number of arguments: " + argText); } numArgs = parseInt(argText); - arg = context.consumeArgs(1)[0]; + arg = context.consumeArg().tokens; } // Final arg is the expansion of the macro @@ -14055,17 +15371,39 @@ const newcommand = (context, existsOK, nonexistsOK) => { defineMacro("\\newcommand", context => newcommand(context, false, true)); defineMacro("\\renewcommand", context => newcommand(context, true, false)); -defineMacro("\\providecommand", context => newcommand(context, true, true)); ////////////////////////////////////////////////////////////////////// +defineMacro("\\providecommand", context => newcommand(context, true, true)); // terminal (console) tools + +defineMacro("\\message", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + var tok = context.popToken(); + var name = tok.text; // eslint-disable-next-line no-console + + console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]); + return ''; +}); ////////////////////////////////////////////////////////////////////// // Grouping // \let\bgroup={ \let\egroup=} defineMacro("\\bgroup", "{"); defineMacro("\\egroup", "}"); // Symbols from latex.ltx: +// \def~{\nobreakspace{}} // \def\lq{`} // \def\rq{'} // \def \aa {\r a} // \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); defineMacro("\\lq", "`"); defineMacro("\\rq", "'"); defineMacro("\\aa", "\\r a"); @@ -14102,7 +15440,11 @@ defineMacro("\u00b7", "\\cdotp"); // \llap and \rlap render their contents in te defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); -defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \not is defined by base/fontmath.ltx via +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360 + +defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353 + +defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} // It's thus treated like a \mathrel, but defined by a symbol that has zero // width but extends to the right. We use \rlap to get that spacing. @@ -14137,7 +15479,13 @@ defineMacro("\u231E", "\\llcorner"); defineMacro("\u231F", "\\lrcorner"); defineMacro("\u00A9", "\\copyright"); defineMacro("\u00AE", "\\textregistered"); -defineMacro("\uFE0F", "\\textregistered"); ////////////////////////////////////////////////////////////////////// +defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. + +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); ////////////////////////////////////////////////////////////////////// // LaTeX_2ε // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} @@ -14166,7 +15514,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} -defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;} // \def\implies{\DOTSB\;\Longrightarrow\;} @@ -14176,7 +15524,7 @@ defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro. -const dotsByToken = { +var dotsByToken = { ',': '\\dotsc', '\\not': '\\dotsb', // \keybin@ checks for the following: @@ -14237,12 +15585,12 @@ defineMacro("\\dots", function (context) { // (in text mode), and it's unlikely we'd see any of the math commands // that affect the behavior of \dots when in text mode. So fine for now // (until we support \ifmmode ... \else ... \fi). - let thedots = '\\dotso'; - const next = context.expandAfterFuture().text; + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; if (next in dotsByToken) { thedots = dotsByToken[next]; - } else if (next.substr(0, 4) === '\\not') { + } else if (next.slice(0, 4) === '\\not') { thedots = '\\dotsb'; } else if (next in symbols.math) { if (utils.contains(['bin', 'rel'], symbols.math[next].group)) { @@ -14252,7 +15600,7 @@ defineMacro("\\dots", function (context) { return thedots; }); -const spaceAfterDots = { +var spaceAfterDots = { // \rightdelim@ checks for the following: ')': true, ']': true, @@ -14277,7 +15625,7 @@ const spaceAfterDots = { ',': true }; defineMacro("\\dotso", function (context) { - const next = context.future().text; + var next = context.future().text; if (next in spaceAfterDots) { return "\\ldots\\,"; @@ -14286,7 +15634,7 @@ defineMacro("\\dotso", function (context) { } }); defineMacro("\\dotsc", function (context) { - const next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for + var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for // ';' and '.', but doesn't check for ','. if (next in spaceAfterDots && next !== ',') { @@ -14296,7 +15644,7 @@ defineMacro("\\dotsc", function (context) { } }); defineMacro("\\cdots", function (context) { - const next = context.future().text; + var next = context.future().text; if (next in spaceAfterDots) { return "\\@cdots\\,"; @@ -14379,16 +15727,13 @@ defineMacro("\\tag@literal", context => { defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); -defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); // \pmb -- A simulation of bold. -// The version in ambsy.sty works by typesetting three copies of the argument -// with small offsets. We use two copies. We omit the vertical offset because -// of rendering problems that makeVList encounters in Safari. - -defineMacro("\\pmb", "\\html@mathml{" + "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + "{\\mathbf{#1}}"); ////////////////////////////////////////////////////////////////////// +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); ////////////////////////////////////////////////////////////////////// // LaTeX source2e -// \\ defaults to \newline, but changes to \cr within array environment +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} -defineMacro("\\\\", "\\newline"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} // TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't // support \@ yet, so that's omitted, and we add \text so that the result // doesn't look funny in math mode. @@ -14408,10 +15753,10 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e // We compute the corresponding \raisebox when A is rendered in \normalsize // \scriptstyle, which has a scale factor of 0.7 (see Options.js). -const latexRaiseA = metricMap['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * metricMap['Main-Regular']["A".charCodeAt(0)][1] + "em"; -defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + `L\\kern-.36em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo +var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo -defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + `K\\kern-.17em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} // \def\@hspace#1{\hskip #1\relax} // \def\@hspacer#1{\vrule \@width\z@\nobreak // \hskip #1\hskip \z@skip} @@ -14491,6 +15836,14 @@ defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\d defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); ////////////////////////////////////////////////////////////////////// +// From amsopn.sty + +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); ////////////////////////////////////////////////////////////////////// // MathML alternates for KaTeX glyphs in the Unicode private area defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); @@ -14506,7 +15859,9 @@ defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); -defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); ////////////////////////////////////////////////////////////////////// +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); ////////////////////////////////////////////////////////////////////// // stmaryrd and semantic // The stmaryrd and semantic packages render the next four items by calling a // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. @@ -14524,7 +15879,11 @@ defineMacro("\u2983", "\\lBrace"); // blackboard bold { defineMacro("\u2984", "\\rBrace"); // blackboard bold } // TODO: Create variable sized versions of the last two items. I believe that // will require new font glyphs. -////////////////////////////////////////////////////////////////////// +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. + +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); ////////////////////////////////////////////////////////////////////// // texvc.sty // The texvc package contains macros available in mediawiki pages. // We omit the functions deprecated at @@ -14593,14 +15952,85 @@ defineMacro("\\supe", "\\supseteq"); defineMacro("\\Tau", "\\mathrm{T}"); defineMacro("\\thetasym", "\\vartheta"); // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); -defineMacro("\\weierp", "\\wp"); -defineMacro("\\Zeta", "\\mathrm{Z}"); ////////////////////////////////////////////////////////////////////// -// statmath.sty -// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); ////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); ////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); + +var braketHelper = one => context => { + var left = context.consumeArg().tokens; + var middle = context.consumeArg().tokens; + var middleDouble = context.consumeArg().tokens; + var right = context.consumeArg().tokens; + var oldMiddle = context.macros.get("|"); + var oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + + var midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + + var doubled = double; + + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + var nextToken = context.future(); + + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + + context.macros.set("|", midMacro(false)); + + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + + var arg = context.consumeArg().tokens; + var expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; + +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); // has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx -defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); -defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); -defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); // Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); @@ -14665,9 +16095,7 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); */ // List of commands that act like macros but aren't defined as a macro, // function, or symbol. Used in `isDefined`. -const implicitCommands = { - "\\relax": true, - // MacroExpander.js +var implicitCommands = { "^": true, // Parser.js "_": true, @@ -14689,7 +16117,7 @@ class MacroExpander { this.expansionCount = 0; this.feed(input); // Make new global namespace - this.macros = new Namespace(builtinMacros, settings.macros); + this.macros = new Namespace(macros, settings.macros); this.mode = mode; this.stack = []; // contains tokens in REVERSE order } @@ -14726,6 +16154,15 @@ class MacroExpander { endGroup() { this.macros.endGroup(); } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + this.macros.endGroups(); + } /** * Returns the topmost token on the stack, without expanding it. * Similar in behavior to TeX's `\futurelet`. @@ -14766,6 +16203,43 @@ class MacroExpander { pushTokens(tokens) { this.stack.push(...tokens); } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + + + scanArgument(isOptional) { + var start; + var end; + var tokens; + + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + + if (this.future().text !== "[") { + return null; + } + + start = this.popToken(); // don't include [ in tokens + + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } // indicate the end of an argument + + + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return start.range(end, ""); + } /** * Consume all following space tokens, without expansion. */ @@ -14773,7 +16247,7 @@ class MacroExpander { consumeSpaces() { for (;;) { - const token = this.future(); + var token = this.future(); if (token.text === " ") { this.stack.pop(); @@ -14783,100 +16257,169 @@ class MacroExpander { } } /** - * Consume the specified number of arguments from the token stream, - * and return the resulting array of arguments. + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. */ - consumeArgs(numArgs) { - const args = []; // obtain arguments, either single token or balanced {…} group + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + var tokens = []; + var isDelimited = delims && delims.length > 0; - for (let i = 0; i < numArgs; ++i) { - this.consumeSpaces(); // ignore spaces before each argument + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + + var start = this.future(); + var tok; + var depth = 0; + var match = 0; - const startOfArg = this.popToken(); + do { + tok = this.popToken(); + tokens.push(tok); - if (startOfArg.text === "{") { - const arg = []; - let depth = 1; + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } - while (depth !== 0) { - const tok = this.popToken(); - arg.push(tok); + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; - if (tok.text === "{") { - ++depth; - } else if (tok.text === "}") { - --depth; - } else if (tok.text === "EOF") { - throw new ParseError("End of input in macro argument", startOfArg); + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; } + } else { + match = 0; } + } + } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed - arg.pop(); // remove last } - arg.reverse(); // like above, to fit in with stack order + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } - args[i] = arg; - } else if (startOfArg.text === "EOF") { - throw new ParseError("End of input expecting macro argument"); - } else { - args[i] = [startOfArg]; + tokens.reverse(); // to fit in with stack order + + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + + + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError("The length of delimiters doesn't match the number of args!"); + } + + var delims = delimiters[0]; + + for (var i = 0; i < delims.length; i++) { + var tok = this.popToken(); + + if (delims[i] !== tok.text) { + throw new ParseError("Use of the macro doesn't match its definition", tok); + } } } + var args = []; + + for (var _i = 0; _i < numArgs; _i++) { + args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens); + } + return args; } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + + + countExpansion(amount) { + this.expansionCount += amount; + + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } /** * Expand the next token only once if possible. * * If the token is expanded, the resulting tokens will be pushed onto - * the stack in reverse order and will be returned as an array, - * also in reverse order. + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. * - * If not, the next token will be returned without removing it - * from the stack. This case can be detected by a `Token` return value - * instead of an `Array` return value. + * If not, the return value is `false`, and the next token remains at the + * top of the stack. * * In either case, the next token will be on the top of the stack, - * or the stack will be empty. + * or the stack will be empty (in case of empty expansion + * and no other tokens). * * Used to implement `expandAfterFuture` and `expandNextToken`. * - * At the moment, macro expansion doesn't handle delimited macros, - * i.e. things like those defined by \def\foo#1\end{…}. - * See the TeX book page 202ff. for details on how those should behave. + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. */ - expandOnce() { - const topToken = this.popToken(); - const name = topToken.text; + expandOnce(expandableOnly) { + var topToken = this.popToken(); + var name = topToken.text; + var expansion = !topToken.noexpand ? this._getExpansion(name) : null; - const expansion = this._getExpansion(name); + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } - if (expansion == null) { - // mainly checking for undefined here - // Fully expanded this.pushToken(topToken); - return topToken; - } - - this.expansionCount++; - - if (this.expansionCount > this.settings.maxExpand) { - throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + return false; } - let tokens = expansion.tokens; + this.countExpansion(1); + var tokens = expansion.tokens; + var args = this.consumeArgs(expansion.numArgs, expansion.delimiters); if (expansion.numArgs) { - const args = this.consumeArgs(expansion.numArgs); // paste arguments in place of the placeholders - + // paste arguments in place of the placeholders tokens = tokens.slice(); // make a shallow copy - for (let i = tokens.length - 1; i >= 0; --i) { - let tok = tokens[i]; + for (var i = tokens.length - 1; i >= 0; --i) { + var tok = tokens[i]; if (tok.text === "#") { if (i === 0) { @@ -14900,7 +16443,7 @@ class MacroExpander { this.pushTokens(tokens); - return tokens; + return tokens.length; } /** * Expand the next token only once (if possible), and return the resulting @@ -14921,16 +16464,16 @@ class MacroExpander { expandNextToken() { for (;;) { - const expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. + if (this.expandOnce() === false) { + // fully expanded + var token = this.stack.pop(); // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ - if (expanded instanceof Token) { - // \relax stops the expansion, but shouldn't get returned (a - // null return value couldn't get implemented as a function). - if (expanded.text === "\\relax") { - this.stack.pop(); - } else { - return this.stack.pop(); // === expanded + if (token.treatAsRelax) { + token.text = "\\relax"; } + + return token; } } // Flow unable to figure out that this pathway is impossible. // https://github.com/facebook/flow/issues/4808 @@ -14945,22 +16488,39 @@ class MacroExpander { expandMacro(name) { - if (!this.macros.get(name)) { - return undefined; - } + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ - const output = []; - const oldStackLength = this.stack.length; - this.pushToken(new Token(name)); + + expandTokens(tokens) { + var output = []; + var oldStackLength = this.stack.length; + this.pushTokens(tokens); while (this.stack.length > oldStackLength) { - const expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + var token = this.stack.pop(); + + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } - if (expanded instanceof Token) { - output.push(this.stack.pop()); + output.push(token); } - } + } // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + + this.countExpansion(output.length); return output; } /** @@ -14970,7 +16530,7 @@ class MacroExpander { expandMacroAsText(name) { - const tokens = this.expandMacro(name); + var tokens = this.expandMacro(name); if (tokens) { return tokens.map(token => token.text).join(""); @@ -14985,29 +16545,39 @@ class MacroExpander { _getExpansion(name) { - const definition = this.macros.get(name); + var definition = this.macros.get(name); if (definition == null) { // mainly checking for undefined here return definition; + } // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + + + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + + if (catcode != null && catcode !== 13) { + return; + } } - const expansion = typeof definition === "function" ? definition(this) : definition; + var expansion = typeof definition === "function" ? definition(this) : definition; if (typeof expansion === "string") { - let numArgs = 0; + var numArgs = 0; if (expansion.indexOf("#") !== -1) { - const stripped = expansion.replace(/##/g, ""); + var stripped = expansion.replace(/##/g, ""); while (stripped.indexOf("#" + (numArgs + 1)) !== -1) { ++numArgs; } } - const bodyLexer = new Lexer(expansion, this.settings); - const tokens = []; - let tok = bodyLexer.lex(); + var bodyLexer = new Lexer(expansion, this.settings); + var tokens = []; + var tok = bodyLexer.lex(); while (tok.text !== "EOF") { tokens.push(tok); @@ -15016,7 +16586,7 @@ class MacroExpander { tokens.reverse(); // to fit in with stack using push and pop - const expanded = { + var expanded = { tokens, numArgs }; @@ -15036,699 +16606,522 @@ class MacroExpander { isDefined(name) { return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); } + /** + * Determine whether a command is expandable. + */ + + + isExpandable(name) { + var macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive; + } } -// Mapping of Unicode accent characters to their LaTeX equivalent in text and -// math mode (when they exist). +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +var uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); + +/* eslint no-constant-condition:0 */ + var unicodeAccents = { - '\u0301': { - text: "\\'", - math: '\\acute' + "́": { + "text": "\\'", + "math": "\\acute" }, - '\u0300': { - text: '\\`', - math: '\\grave' + "̀": { + "text": "\\`", + "math": "\\grave" }, - '\u0308': { - text: '\\"', - math: '\\ddot' + "̈": { + "text": "\\\"", + "math": "\\ddot" }, - '\u0303': { - text: '\\~', - math: '\\tilde' + "̃": { + "text": "\\~", + "math": "\\tilde" }, - '\u0304': { - text: '\\=', - math: '\\bar' + "̄": { + "text": "\\=", + "math": "\\bar" }, - '\u0306': { - text: '\\u', - math: '\\breve' + "̆": { + "text": "\\u", + "math": "\\breve" }, - '\u030c': { - text: '\\v', - math: '\\check' + "̌": { + "text": "\\v", + "math": "\\check" }, - '\u0302': { - text: '\\^', - math: '\\hat' + "̂": { + "text": "\\^", + "math": "\\hat" }, - '\u0307': { - text: '\\.', - math: '\\dot' + "̇": { + "text": "\\.", + "math": "\\dot" }, - '\u030a': { - text: '\\r', - math: '\\mathring' + "̊": { + "text": "\\r", + "math": "\\mathring" }, - '\u030b': { - text: '\\H' + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" } }; - -// This file is GENERATED by unicodeMake.js. DO NOT MODIFY. var unicodeSymbols = { - "\u00e1": "\u0061\u0301", - // á = \'{a} - "\u00e0": "\u0061\u0300", - // à = \`{a} - "\u00e4": "\u0061\u0308", - // ä = \"{a} - "\u01df": "\u0061\u0308\u0304", - // ǟ = \"\={a} - "\u00e3": "\u0061\u0303", - // ã = \~{a} - "\u0101": "\u0061\u0304", - // ā = \={a} - "\u0103": "\u0061\u0306", - // ă = \u{a} - "\u1eaf": "\u0061\u0306\u0301", - // ắ = \u\'{a} - "\u1eb1": "\u0061\u0306\u0300", - // ằ = \u\`{a} - "\u1eb5": "\u0061\u0306\u0303", - // ẵ = \u\~{a} - "\u01ce": "\u0061\u030c", - // ǎ = \v{a} - "\u00e2": "\u0061\u0302", - // â = \^{a} - "\u1ea5": "\u0061\u0302\u0301", - // ấ = \^\'{a} - "\u1ea7": "\u0061\u0302\u0300", - // ầ = \^\`{a} - "\u1eab": "\u0061\u0302\u0303", - // ẫ = \^\~{a} - "\u0227": "\u0061\u0307", - // ȧ = \.{a} - "\u01e1": "\u0061\u0307\u0304", - // ǡ = \.\={a} - "\u00e5": "\u0061\u030a", - // å = \r{a} - "\u01fb": "\u0061\u030a\u0301", - // ǻ = \r\'{a} - "\u1e03": "\u0062\u0307", - // ḃ = \.{b} - "\u0107": "\u0063\u0301", - // ć = \'{c} - "\u010d": "\u0063\u030c", - // č = \v{c} - "\u0109": "\u0063\u0302", - // ĉ = \^{c} - "\u010b": "\u0063\u0307", - // ċ = \.{c} - "\u010f": "\u0064\u030c", - // ď = \v{d} - "\u1e0b": "\u0064\u0307", - // ḋ = \.{d} - "\u00e9": "\u0065\u0301", - // é = \'{e} - "\u00e8": "\u0065\u0300", - // è = \`{e} - "\u00eb": "\u0065\u0308", - // ë = \"{e} - "\u1ebd": "\u0065\u0303", - // ẽ = \~{e} - "\u0113": "\u0065\u0304", - // ē = \={e} - "\u1e17": "\u0065\u0304\u0301", - // ḗ = \=\'{e} - "\u1e15": "\u0065\u0304\u0300", - // ḕ = \=\`{e} - "\u0115": "\u0065\u0306", - // ĕ = \u{e} - "\u011b": "\u0065\u030c", - // ě = \v{e} - "\u00ea": "\u0065\u0302", - // ê = \^{e} - "\u1ebf": "\u0065\u0302\u0301", - // ế = \^\'{e} - "\u1ec1": "\u0065\u0302\u0300", - // ề = \^\`{e} - "\u1ec5": "\u0065\u0302\u0303", - // ễ = \^\~{e} - "\u0117": "\u0065\u0307", - // ė = \.{e} - "\u1e1f": "\u0066\u0307", - // ḟ = \.{f} - "\u01f5": "\u0067\u0301", - // ǵ = \'{g} - "\u1e21": "\u0067\u0304", - // ḡ = \={g} - "\u011f": "\u0067\u0306", - // ğ = \u{g} - "\u01e7": "\u0067\u030c", - // ǧ = \v{g} - "\u011d": "\u0067\u0302", - // ĝ = \^{g} - "\u0121": "\u0067\u0307", - // ġ = \.{g} - "\u1e27": "\u0068\u0308", - // ḧ = \"{h} - "\u021f": "\u0068\u030c", - // ȟ = \v{h} - "\u0125": "\u0068\u0302", - // ĥ = \^{h} - "\u1e23": "\u0068\u0307", - // ḣ = \.{h} - "\u00ed": "\u0069\u0301", - // í = \'{i} - "\u00ec": "\u0069\u0300", - // ì = \`{i} - "\u00ef": "\u0069\u0308", - // ï = \"{i} - "\u1e2f": "\u0069\u0308\u0301", - // ḯ = \"\'{i} - "\u0129": "\u0069\u0303", - // ĩ = \~{i} - "\u012b": "\u0069\u0304", - // ī = \={i} - "\u012d": "\u0069\u0306", - // ĭ = \u{i} - "\u01d0": "\u0069\u030c", - // ǐ = \v{i} - "\u00ee": "\u0069\u0302", - // î = \^{i} - "\u01f0": "\u006a\u030c", - // ǰ = \v{j} - "\u0135": "\u006a\u0302", - // ĵ = \^{j} - "\u1e31": "\u006b\u0301", - // ḱ = \'{k} - "\u01e9": "\u006b\u030c", - // ǩ = \v{k} - "\u013a": "\u006c\u0301", - // ĺ = \'{l} - "\u013e": "\u006c\u030c", - // ľ = \v{l} - "\u1e3f": "\u006d\u0301", - // ḿ = \'{m} - "\u1e41": "\u006d\u0307", - // ṁ = \.{m} - "\u0144": "\u006e\u0301", - // ń = \'{n} - "\u01f9": "\u006e\u0300", - // ǹ = \`{n} - "\u00f1": "\u006e\u0303", - // ñ = \~{n} - "\u0148": "\u006e\u030c", - // ň = \v{n} - "\u1e45": "\u006e\u0307", - // ṅ = \.{n} - "\u00f3": "\u006f\u0301", - // ó = \'{o} - "\u00f2": "\u006f\u0300", - // ò = \`{o} - "\u00f6": "\u006f\u0308", - // ö = \"{o} - "\u022b": "\u006f\u0308\u0304", - // ȫ = \"\={o} - "\u00f5": "\u006f\u0303", - // õ = \~{o} - "\u1e4d": "\u006f\u0303\u0301", - // ṍ = \~\'{o} - "\u1e4f": "\u006f\u0303\u0308", - // ṏ = \~\"{o} - "\u022d": "\u006f\u0303\u0304", - // ȭ = \~\={o} - "\u014d": "\u006f\u0304", - // ō = \={o} - "\u1e53": "\u006f\u0304\u0301", - // ṓ = \=\'{o} - "\u1e51": "\u006f\u0304\u0300", - // ṑ = \=\`{o} - "\u014f": "\u006f\u0306", - // ŏ = \u{o} - "\u01d2": "\u006f\u030c", - // ǒ = \v{o} - "\u00f4": "\u006f\u0302", - // ô = \^{o} - "\u1ed1": "\u006f\u0302\u0301", - // ố = \^\'{o} - "\u1ed3": "\u006f\u0302\u0300", - // ồ = \^\`{o} - "\u1ed7": "\u006f\u0302\u0303", - // ỗ = \^\~{o} - "\u022f": "\u006f\u0307", - // ȯ = \.{o} - "\u0231": "\u006f\u0307\u0304", - // ȱ = \.\={o} - "\u0151": "\u006f\u030b", - // ő = \H{o} - "\u1e55": "\u0070\u0301", - // ṕ = \'{p} - "\u1e57": "\u0070\u0307", - // ṗ = \.{p} - "\u0155": "\u0072\u0301", - // ŕ = \'{r} - "\u0159": "\u0072\u030c", - // ř = \v{r} - "\u1e59": "\u0072\u0307", - // ṙ = \.{r} - "\u015b": "\u0073\u0301", - // ś = \'{s} - "\u1e65": "\u0073\u0301\u0307", - // ṥ = \'\.{s} - "\u0161": "\u0073\u030c", - // š = \v{s} - "\u1e67": "\u0073\u030c\u0307", - // ṧ = \v\.{s} - "\u015d": "\u0073\u0302", - // ŝ = \^{s} - "\u1e61": "\u0073\u0307", - // ṡ = \.{s} - "\u1e97": "\u0074\u0308", - // ẗ = \"{t} - "\u0165": "\u0074\u030c", - // ť = \v{t} - "\u1e6b": "\u0074\u0307", - // ṫ = \.{t} - "\u00fa": "\u0075\u0301", - // ú = \'{u} - "\u00f9": "\u0075\u0300", - // ù = \`{u} - "\u00fc": "\u0075\u0308", - // ü = \"{u} - "\u01d8": "\u0075\u0308\u0301", - // ǘ = \"\'{u} - "\u01dc": "\u0075\u0308\u0300", - // ǜ = \"\`{u} - "\u01d6": "\u0075\u0308\u0304", - // ǖ = \"\={u} - "\u01da": "\u0075\u0308\u030c", - // ǚ = \"\v{u} - "\u0169": "\u0075\u0303", - // ũ = \~{u} - "\u1e79": "\u0075\u0303\u0301", - // ṹ = \~\'{u} - "\u016b": "\u0075\u0304", - // ū = \={u} - "\u1e7b": "\u0075\u0304\u0308", - // ṻ = \=\"{u} - "\u016d": "\u0075\u0306", - // ŭ = \u{u} - "\u01d4": "\u0075\u030c", - // ǔ = \v{u} - "\u00fb": "\u0075\u0302", - // û = \^{u} - "\u016f": "\u0075\u030a", - // ů = \r{u} - "\u0171": "\u0075\u030b", - // ű = \H{u} - "\u1e7d": "\u0076\u0303", - // ṽ = \~{v} - "\u1e83": "\u0077\u0301", - // ẃ = \'{w} - "\u1e81": "\u0077\u0300", - // ẁ = \`{w} - "\u1e85": "\u0077\u0308", - // ẅ = \"{w} - "\u0175": "\u0077\u0302", - // ŵ = \^{w} - "\u1e87": "\u0077\u0307", - // ẇ = \.{w} - "\u1e98": "\u0077\u030a", - // ẘ = \r{w} - "\u1e8d": "\u0078\u0308", - // ẍ = \"{x} - "\u1e8b": "\u0078\u0307", - // ẋ = \.{x} - "\u00fd": "\u0079\u0301", - // ý = \'{y} - "\u1ef3": "\u0079\u0300", - // ỳ = \`{y} - "\u00ff": "\u0079\u0308", - // ÿ = \"{y} - "\u1ef9": "\u0079\u0303", - // ỹ = \~{y} - "\u0233": "\u0079\u0304", - // ȳ = \={y} - "\u0177": "\u0079\u0302", - // ŷ = \^{y} - "\u1e8f": "\u0079\u0307", - // ẏ = \.{y} - "\u1e99": "\u0079\u030a", - // ẙ = \r{y} - "\u017a": "\u007a\u0301", - // ź = \'{z} - "\u017e": "\u007a\u030c", - // ž = \v{z} - "\u1e91": "\u007a\u0302", - // ẑ = \^{z} - "\u017c": "\u007a\u0307", - // ż = \.{z} - "\u00c1": "\u0041\u0301", - // Á = \'{A} - "\u00c0": "\u0041\u0300", - // À = \`{A} - "\u00c4": "\u0041\u0308", - // Ä = \"{A} - "\u01de": "\u0041\u0308\u0304", - // Ǟ = \"\={A} - "\u00c3": "\u0041\u0303", - // Ã = \~{A} - "\u0100": "\u0041\u0304", - // Ā = \={A} - "\u0102": "\u0041\u0306", - // Ă = \u{A} - "\u1eae": "\u0041\u0306\u0301", - // Ắ = \u\'{A} - "\u1eb0": "\u0041\u0306\u0300", - // Ằ = \u\`{A} - "\u1eb4": "\u0041\u0306\u0303", - // Ẵ = \u\~{A} - "\u01cd": "\u0041\u030c", - // Ǎ = \v{A} - "\u00c2": "\u0041\u0302", - // Â = \^{A} - "\u1ea4": "\u0041\u0302\u0301", - // Ấ = \^\'{A} - "\u1ea6": "\u0041\u0302\u0300", - // Ầ = \^\`{A} - "\u1eaa": "\u0041\u0302\u0303", - // Ẫ = \^\~{A} - "\u0226": "\u0041\u0307", - // Ȧ = \.{A} - "\u01e0": "\u0041\u0307\u0304", - // Ǡ = \.\={A} - "\u00c5": "\u0041\u030a", - // Å = \r{A} - "\u01fa": "\u0041\u030a\u0301", - // Ǻ = \r\'{A} - "\u1e02": "\u0042\u0307", - // Ḃ = \.{B} - "\u0106": "\u0043\u0301", - // Ć = \'{C} - "\u010c": "\u0043\u030c", - // Č = \v{C} - "\u0108": "\u0043\u0302", - // Ĉ = \^{C} - "\u010a": "\u0043\u0307", - // Ċ = \.{C} - "\u010e": "\u0044\u030c", - // Ď = \v{D} - "\u1e0a": "\u0044\u0307", - // Ḋ = \.{D} - "\u00c9": "\u0045\u0301", - // É = \'{E} - "\u00c8": "\u0045\u0300", - // È = \`{E} - "\u00cb": "\u0045\u0308", - // Ë = \"{E} - "\u1ebc": "\u0045\u0303", - // Ẽ = \~{E} - "\u0112": "\u0045\u0304", - // Ē = \={E} - "\u1e16": "\u0045\u0304\u0301", - // Ḗ = \=\'{E} - "\u1e14": "\u0045\u0304\u0300", - // Ḕ = \=\`{E} - "\u0114": "\u0045\u0306", - // Ĕ = \u{E} - "\u011a": "\u0045\u030c", - // Ě = \v{E} - "\u00ca": "\u0045\u0302", - // Ê = \^{E} - "\u1ebe": "\u0045\u0302\u0301", - // Ế = \^\'{E} - "\u1ec0": "\u0045\u0302\u0300", - // Ề = \^\`{E} - "\u1ec4": "\u0045\u0302\u0303", - // Ễ = \^\~{E} - "\u0116": "\u0045\u0307", - // Ė = \.{E} - "\u1e1e": "\u0046\u0307", - // Ḟ = \.{F} - "\u01f4": "\u0047\u0301", - // Ǵ = \'{G} - "\u1e20": "\u0047\u0304", - // Ḡ = \={G} - "\u011e": "\u0047\u0306", - // Ğ = \u{G} - "\u01e6": "\u0047\u030c", - // Ǧ = \v{G} - "\u011c": "\u0047\u0302", - // Ĝ = \^{G} - "\u0120": "\u0047\u0307", - // Ġ = \.{G} - "\u1e26": "\u0048\u0308", - // Ḧ = \"{H} - "\u021e": "\u0048\u030c", - // Ȟ = \v{H} - "\u0124": "\u0048\u0302", - // Ĥ = \^{H} - "\u1e22": "\u0048\u0307", - // Ḣ = \.{H} - "\u00cd": "\u0049\u0301", - // Í = \'{I} - "\u00cc": "\u0049\u0300", - // Ì = \`{I} - "\u00cf": "\u0049\u0308", - // Ï = \"{I} - "\u1e2e": "\u0049\u0308\u0301", - // Ḯ = \"\'{I} - "\u0128": "\u0049\u0303", - // Ĩ = \~{I} - "\u012a": "\u0049\u0304", - // Ī = \={I} - "\u012c": "\u0049\u0306", - // Ĭ = \u{I} - "\u01cf": "\u0049\u030c", - // Ǐ = \v{I} - "\u00ce": "\u0049\u0302", - // Î = \^{I} - "\u0130": "\u0049\u0307", - // İ = \.{I} - "\u0134": "\u004a\u0302", - // Ĵ = \^{J} - "\u1e30": "\u004b\u0301", - // Ḱ = \'{K} - "\u01e8": "\u004b\u030c", - // Ǩ = \v{K} - "\u0139": "\u004c\u0301", - // Ĺ = \'{L} - "\u013d": "\u004c\u030c", - // Ľ = \v{L} - "\u1e3e": "\u004d\u0301", - // Ḿ = \'{M} - "\u1e40": "\u004d\u0307", - // Ṁ = \.{M} - "\u0143": "\u004e\u0301", - // Ń = \'{N} - "\u01f8": "\u004e\u0300", - // Ǹ = \`{N} - "\u00d1": "\u004e\u0303", - // Ñ = \~{N} - "\u0147": "\u004e\u030c", - // Ň = \v{N} - "\u1e44": "\u004e\u0307", - // Ṅ = \.{N} - "\u00d3": "\u004f\u0301", - // Ó = \'{O} - "\u00d2": "\u004f\u0300", - // Ò = \`{O} - "\u00d6": "\u004f\u0308", - // Ö = \"{O} - "\u022a": "\u004f\u0308\u0304", - // Ȫ = \"\={O} - "\u00d5": "\u004f\u0303", - // Õ = \~{O} - "\u1e4c": "\u004f\u0303\u0301", - // Ṍ = \~\'{O} - "\u1e4e": "\u004f\u0303\u0308", - // Ṏ = \~\"{O} - "\u022c": "\u004f\u0303\u0304", - // Ȭ = \~\={O} - "\u014c": "\u004f\u0304", - // Ō = \={O} - "\u1e52": "\u004f\u0304\u0301", - // Ṓ = \=\'{O} - "\u1e50": "\u004f\u0304\u0300", - // Ṑ = \=\`{O} - "\u014e": "\u004f\u0306", - // Ŏ = \u{O} - "\u01d1": "\u004f\u030c", - // Ǒ = \v{O} - "\u00d4": "\u004f\u0302", - // Ô = \^{O} - "\u1ed0": "\u004f\u0302\u0301", - // Ố = \^\'{O} - "\u1ed2": "\u004f\u0302\u0300", - // Ồ = \^\`{O} - "\u1ed6": "\u004f\u0302\u0303", - // Ỗ = \^\~{O} - "\u022e": "\u004f\u0307", - // Ȯ = \.{O} - "\u0230": "\u004f\u0307\u0304", - // Ȱ = \.\={O} - "\u0150": "\u004f\u030b", - // Ő = \H{O} - "\u1e54": "\u0050\u0301", - // Ṕ = \'{P} - "\u1e56": "\u0050\u0307", - // Ṗ = \.{P} - "\u0154": "\u0052\u0301", - // Ŕ = \'{R} - "\u0158": "\u0052\u030c", - // Ř = \v{R} - "\u1e58": "\u0052\u0307", - // Ṙ = \.{R} - "\u015a": "\u0053\u0301", - // Ś = \'{S} - "\u1e64": "\u0053\u0301\u0307", - // Ṥ = \'\.{S} - "\u0160": "\u0053\u030c", - // Š = \v{S} - "\u1e66": "\u0053\u030c\u0307", - // Ṧ = \v\.{S} - "\u015c": "\u0053\u0302", - // Ŝ = \^{S} - "\u1e60": "\u0053\u0307", - // Ṡ = \.{S} - "\u0164": "\u0054\u030c", - // Ť = \v{T} - "\u1e6a": "\u0054\u0307", - // Ṫ = \.{T} - "\u00da": "\u0055\u0301", - // Ú = \'{U} - "\u00d9": "\u0055\u0300", - // Ù = \`{U} - "\u00dc": "\u0055\u0308", - // Ü = \"{U} - "\u01d7": "\u0055\u0308\u0301", - // Ǘ = \"\'{U} - "\u01db": "\u0055\u0308\u0300", - // Ǜ = \"\`{U} - "\u01d5": "\u0055\u0308\u0304", - // Ǖ = \"\={U} - "\u01d9": "\u0055\u0308\u030c", - // Ǚ = \"\v{U} - "\u0168": "\u0055\u0303", - // Ũ = \~{U} - "\u1e78": "\u0055\u0303\u0301", - // Ṹ = \~\'{U} - "\u016a": "\u0055\u0304", - // Ū = \={U} - "\u1e7a": "\u0055\u0304\u0308", - // Ṻ = \=\"{U} - "\u016c": "\u0055\u0306", - // Ŭ = \u{U} - "\u01d3": "\u0055\u030c", - // Ǔ = \v{U} - "\u00db": "\u0055\u0302", - // Û = \^{U} - "\u016e": "\u0055\u030a", - // Ů = \r{U} - "\u0170": "\u0055\u030b", - // Ű = \H{U} - "\u1e7c": "\u0056\u0303", - // Ṽ = \~{V} - "\u1e82": "\u0057\u0301", - // Ẃ = \'{W} - "\u1e80": "\u0057\u0300", - // Ẁ = \`{W} - "\u1e84": "\u0057\u0308", - // Ẅ = \"{W} - "\u0174": "\u0057\u0302", - // Ŵ = \^{W} - "\u1e86": "\u0057\u0307", - // Ẇ = \.{W} - "\u1e8c": "\u0058\u0308", - // Ẍ = \"{X} - "\u1e8a": "\u0058\u0307", - // Ẋ = \.{X} - "\u00dd": "\u0059\u0301", - // Ý = \'{Y} - "\u1ef2": "\u0059\u0300", - // Ỳ = \`{Y} - "\u0178": "\u0059\u0308", - // Ÿ = \"{Y} - "\u1ef8": "\u0059\u0303", - // Ỹ = \~{Y} - "\u0232": "\u0059\u0304", - // Ȳ = \={Y} - "\u0176": "\u0059\u0302", - // Ŷ = \^{Y} - "\u1e8e": "\u0059\u0307", - // Ẏ = \.{Y} - "\u0179": "\u005a\u0301", - // Ź = \'{Z} - "\u017d": "\u005a\u030c", - // Ž = \v{Z} - "\u1e90": "\u005a\u0302", - // Ẑ = \^{Z} - "\u017b": "\u005a\u0307", - // Ż = \.{Z} - "\u03ac": "\u03b1\u0301", - // ά = \'{α} - "\u1f70": "\u03b1\u0300", - // ὰ = \`{α} - "\u1fb1": "\u03b1\u0304", - // ᾱ = \={α} - "\u1fb0": "\u03b1\u0306", - // ᾰ = \u{α} - "\u03ad": "\u03b5\u0301", - // έ = \'{ε} - "\u1f72": "\u03b5\u0300", - // ὲ = \`{ε} - "\u03ae": "\u03b7\u0301", - // ή = \'{η} - "\u1f74": "\u03b7\u0300", - // ὴ = \`{η} - "\u03af": "\u03b9\u0301", - // ί = \'{ι} - "\u1f76": "\u03b9\u0300", - // ὶ = \`{ι} - "\u03ca": "\u03b9\u0308", - // ϊ = \"{ι} - "\u0390": "\u03b9\u0308\u0301", - // ΐ = \"\'{ι} - "\u1fd2": "\u03b9\u0308\u0300", - // ῒ = \"\`{ι} - "\u1fd1": "\u03b9\u0304", - // ῑ = \={ι} - "\u1fd0": "\u03b9\u0306", - // ῐ = \u{ι} - "\u03cc": "\u03bf\u0301", - // ό = \'{ο} - "\u1f78": "\u03bf\u0300", - // ὸ = \`{ο} - "\u03cd": "\u03c5\u0301", - // ύ = \'{υ} - "\u1f7a": "\u03c5\u0300", - // ὺ = \`{υ} - "\u03cb": "\u03c5\u0308", - // ϋ = \"{υ} - "\u03b0": "\u03c5\u0308\u0301", - // ΰ = \"\'{υ} - "\u1fe2": "\u03c5\u0308\u0300", - // ῢ = \"\`{υ} - "\u1fe1": "\u03c5\u0304", - // ῡ = \={υ} - "\u1fe0": "\u03c5\u0306", - // ῠ = \u{υ} - "\u03ce": "\u03c9\u0301", - // ώ = \'{ω} - "\u1f7c": "\u03c9\u0300", - // ὼ = \`{ω} - "\u038e": "\u03a5\u0301", - // Ύ = \'{Υ} - "\u1fea": "\u03a5\u0300", - // Ὺ = \`{Υ} - "\u03ab": "\u03a5\u0308", - // Ϋ = \"{Υ} - "\u1fe9": "\u03a5\u0304", - // Ῡ = \={Υ} - "\u1fe8": "\u03a5\u0306", - // Ῠ = \u{Υ} - "\u038f": "\u03a9\u0301", - // Ώ = \'{Ω} - "\u1ffa": "\u03a9\u0300" // Ὼ = \`{Ω} - + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" }; -/* eslint no-constant-condition:0 */ - /** * This file contains the parser used to parse out a TeX expression from the * input. Since TeX isn't context-free, standard parsers don't work particularly @@ -15787,7 +17180,7 @@ class Parser { } if (this.fetch().text !== text) { - throw new ParseError(`Expected '${text}', got '${this.fetch().text}'`, this.fetch()); + throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); } if (consume) { @@ -15831,27 +17224,67 @@ class Parser { parse() { - // Create a group namespace for the math expression. - // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) - this.gullet.beginGroup(); // Use old \color behavior (same as LaTeX's \textcolor) if requested. + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } // Use old \color behavior (same as LaTeX's \textcolor) if requested. // We do this within the group for the math expression, so it doesn't // pollute settings.macros. + if (this.settings.colorIsTextColor) { this.gullet.macros.set("\\color", "\\textcolor"); - } // Try to parse the input + } + + try { + // Try to parse the input + var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); // End the group namespace for the expression - const parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + + return parse; // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ - this.expect("EOF"); // End the group namespace for the expression - this.gullet.endGroup(); + subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); // Run the new job, terminating it with an excess '}' + + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); // Restore the next token from the current job. + + this.nextToken = oldToken; return parse; } + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence han infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ parseExpression(breakOnInfix, breakOnTokenText) { - const body = []; // Keep adding atoms to the body until we can't parse any more atoms (either + var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either // we reached the end, a }, or a \right) while (true) { @@ -15860,7 +17293,7 @@ class Parser { this.consumeSpaces(); } - const lex = this.fetch(); + var lex = this.fetch(); if (Parser.endOfExpression.indexOf(lex.text) !== -1) { break; @@ -15874,10 +17307,12 @@ class Parser { break; } - const atom = this.parseAtom(breakOnTokenText); + var atom = this.parseAtom(breakOnTokenText); if (!atom) { break; + } else if (atom.type === "internal") { + continue; } body.push(atom); @@ -15899,27 +17334,25 @@ class Parser { handleInfixNodes(body) { - let overIndex = -1; - let funcName; + var overIndex = -1; + var funcName; - for (let i = 0; i < body.length; i++) { - const node = checkNodeType(body[i], "infix"); - - if (node) { + for (var i = 0; i < body.length; i++) { + if (body[i].type === "infix") { if (overIndex !== -1) { - throw new ParseError("only one infix operator per group", node.token); + throw new ParseError("only one infix operator per group", body[i].token); } overIndex = i; - funcName = node.replaceWith; + funcName = body[i].replaceWith; } } if (overIndex !== -1 && funcName) { - let numerNode; - let denomNode; - const numerBody = body.slice(0, overIndex); - const denomBody = body.slice(overIndex + 1); + var numerNode; + var denomNode; + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { numerNode = numerBody[0]; @@ -15941,7 +17374,7 @@ class Parser { }; } - let node; + var node; if (funcName === "\\\\abovefrac") { node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); @@ -15953,17 +17386,20 @@ class Parser { } else { return body; } - } // The greediness of a superscript or subscript - - + } /** * Handle a subscript or superscript with nice errors. */ - handleSupSubscript(name) { - const symbolToken = this.fetch(); - const symbol = symbolToken.text; + + + handleSupSubscript(name // For error reporting. + ) { + var symbolToken = this.fetch(); + var symbol = symbolToken.text; this.consume(); - const group = this.parseGroup(name, false, Parser.SUPSUB_GREEDINESS, undefined, undefined, true); // ignore spaces before sup/subscript argument + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + var group = this.parseGroup(name); if (!group) { throw new ParseError("Expected group after '" + symbol + "'", symbolToken); @@ -15978,9 +17414,9 @@ class Parser { formatUnsupportedCmd(text) { - const textordArray = []; + var textordArray = []; - for (let i = 0; i < text.length; i++) { + for (var i = 0; i < text.length; i++) { textordArray.push({ type: "textord", mode: "text", @@ -15988,12 +17424,12 @@ class Parser { }); } - const textNode = { + var textNode = { type: "text", mode: this.mode, body: textordArray }; - const colorNode = { + var colorNode = { type: "color", mode: this.mode, color: this.settings.errorColor, @@ -16009,39 +17445,34 @@ class Parser { parseAtom(breakOnTokenText) { // The body of an atom is an implicit group, so that things like // \left(x\right)^2 work correctly. - const base = this.parseGroup("atom", false, null, breakOnTokenText); // In text mode, we don't have superscripts or subscripts + var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts if (this.mode === "text") { return base; } // Note that base may be empty (i.e. null) at this point. - let superscript; - let subscript; + var superscript; + var subscript; while (true) { // Guaranteed in math mode, so eat any spaces first. this.consumeSpaces(); // Lex the first token - const lex = this.fetch(); + var lex = this.fetch(); if (lex.text === "\\limits" || lex.text === "\\nolimits") { // We got a limit control - let opNode = checkNodeType(base, "op"); - - if (opNode) { - const limits = lex.text === "\\limits"; - opNode.limits = limits; - opNode.alwaysHandleSupSub = true; - } else { - opNode = checkNodeType(base, "operatorname"); - - if (opNode && opNode.alwaysHandleSupSub) { - const limits = lex.text === "\\limits"; - opNode.limits = limits; - } else { - throw new ParseError("Limit controls must follow a math operator", lex); + if (base && base.type === "op") { + var limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; } + } else { + throw new ParseError("Limit controls must follow a math operator", lex); } this.consume(); @@ -16065,13 +17496,13 @@ class Parser { throw new ParseError("Double superscript", lex); } - const prime = { + var prime = { type: "textord", mode: this.mode, text: "\\prime" }; // Many primes can be grouped together, so we handle this here - const primes = [prime]; + var primes = [prime]; this.consume(); // Keep lexing tokens until we get something that's not a prime while (this.fetch().text === "'") { @@ -16092,6 +17523,47 @@ class Parser { mode: this.mode, body: primes }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + var isSub = unicodeSubRegEx.test(lex.text); + var subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); // Continue fetching tokens to fill out the string. + + while (true) { + var token = this.fetch().text; + + if (!uSubsAndSups[token]) { + break; + } + + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } // Now create a (sub|super)script. + + + var body = this.subparse(subsupTokens); + + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } } else { // If it wasn't ^, _, or ', stop parsing super/subscripts break; @@ -16119,11 +17591,11 @@ class Parser { */ - parseFunction(breakOnTokenText, name, // For error reporting. - greediness) { - const token = this.fetch(); - const func = token.text; - const funcData = functions[func]; + parseFunction(breakOnTokenText, name // For determining its context + ) { + var token = this.fetch(); + var func = token.text; + var funcData = functions[func]; if (!funcData) { return null; @@ -16131,7 +17603,7 @@ class Parser { this.consume(); // consume command token - if (greediness != null && funcData.greediness <= greediness) { + if (name && name !== "atom" && !funcData.allowedInArgument) { throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); } else if (this.mode === "text" && !funcData.allowedInText) { throw new ParseError("Can't use function '" + func + "' in text mode", token); @@ -16139,10 +17611,10 @@ class Parser { throw new ParseError("Can't use function '" + func + "' in math mode", token); } - const _this$parseArguments = this.parseArguments(func, funcData), - args = _this$parseArguments.args, - optArgs = _this$parseArguments.optArgs; - + var { + args, + optArgs + } = this.parseArguments(func, funcData); return this.callFunction(func, args, optArgs, token, breakOnTokenText); } /** @@ -16151,18 +17623,18 @@ class Parser { callFunction(name, args, optArgs, token, breakOnTokenText) { - const context = { + var context = { funcName: name, parser: this, token, breakOnTokenText }; - const func = functions[name]; + var func = functions[name]; if (func && func.handler) { return func.handler(context, args, optArgs); } else { - throw new ParseError(`No function handler for ${name}`); + throw new ParseError("No function handler for " + name); } } /** @@ -16172,7 +17644,7 @@ class Parser { parseArguments(func, // Should look like "\name" or "\begin{name}". funcData) { - const totalArgs = funcData.numArgs + funcData.numOptionalArgs; + var totalArgs = funcData.numArgs + funcData.numOptionalArgs; if (totalArgs === 0) { return { @@ -16181,36 +17653,28 @@ class Parser { }; } - const baseGreediness = funcData.greediness; - const args = []; - const optArgs = []; - - for (let i = 0; i < totalArgs; i++) { - const argType = funcData.argTypes && funcData.argTypes[i]; - const isOptional = i < funcData.numOptionalArgs; // Ignore spaces between arguments. As the TeXbook says: - // "After you have said ‘\def\row#1#2{...}’, you are allowed to - // put spaces between the arguments (e.g., ‘\row x n’), because - // TeX doesn’t use single spaces as undelimited arguments." + var args = []; + var optArgs = []; - const consumeSpaces = i > 0 && !isOptional || // Also consume leading spaces in math mode, as parseSymbol - // won't know what to do with them. This can only happen with - // macros, e.g. \frac\foo\foo where \foo expands to a space symbol. - // In LaTeX, the \foo's get treated as (blank) arguments. - // In KaTeX, for now, both spaces will get consumed. - // TODO(edemaine) - i === 0 && !isOptional && this.mode === "math"; - const arg = this.parseGroupOfType(`argument to '${func}'`, argType, isOptional, baseGreediness, consumeSpaces); - - if (!arg) { - if (isOptional) { - optArgs.push(null); - continue; - } + for (var i = 0; i < totalArgs; i++) { + var argType = funcData.argTypes && funcData.argTypes[i]; + var isOptional = i < funcData.numOptionalArgs; - throw new ParseError(`Expected group after '${func}'`, this.fetch()); + if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; } - (isOptional ? optArgs : args).push(arg); + var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } } return { @@ -16223,76 +17687,64 @@ class Parser { */ - parseGroupOfType(name, type, optional, greediness, consumeSpaces) { + parseGroupOfType(name, type, optional) { switch (type) { case "color": - if (consumeSpaces) { - this.consumeSpaces(); - } - return this.parseColorGroup(optional); case "size": - if (consumeSpaces) { - this.consumeSpaces(); - } - return this.parseSizeGroup(optional); case "url": - return this.parseUrlGroup(optional, consumeSpaces); + return this.parseUrlGroup(optional); case "math": case "text": - return this.parseGroup(name, optional, greediness, undefined, type, consumeSpaces); + return this.parseArgumentGroup(optional, type); case "hbox": { // hbox argument type wraps the argument in the equivalent of // \hbox, which is like \text but switching to \textstyle size. - const group = this.parseGroup(name, optional, greediness, undefined, "text", consumeSpaces); - - if (!group) { - return group; - } - - const styledGroup = { + var group = this.parseArgumentGroup(optional, "text"); + return group != null ? { type: "styling", mode: group.mode, body: [group], style: "text" // simulate \textstyle - }; - return styledGroup; + } : null; } case "raw": { - if (consumeSpaces) { - this.consumeSpaces(); - } + var token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } - if (optional && this.fetch().text === "{") { - return null; + case "primitive": + { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); } - const token = this.parseStringGroup("raw", optional, true); + var _group = this.parseGroup(name); - if (token) { - return { - type: "raw", - mode: "text", - string: token.text - }; - } else { - throw new ParseError("Expected raw group", this.fetch()); + if (_group == null) { + throw new ParseError("Expected group as " + name, this.fetch()); } + + return _group; } case "original": case null: case undefined: - return this.parseGroup(name, optional, greediness, undefined, undefined, consumeSpaces); + return this.parseArgumentGroup(optional); default: throw new ParseError("Unknown group type as " + name, this.fetch()); @@ -16315,52 +17767,25 @@ class Parser { parseStringGroup(modeName, // Used to describe the mode in error messages. - optional, raw) { - const groupBegin = optional ? "[" : "{"; - const groupEnd = optional ? "]" : "}"; - const beginToken = this.fetch(); + optional) { + var argToken = this.gullet.scanArgument(optional); - if (beginToken.text !== groupBegin) { - if (optional) { - return null; - } else if (raw && beginToken.text !== "EOF" && /[^{}[\]]/.test(beginToken.text)) { - this.consume(); - return beginToken; - } + if (argToken == null) { + return null; } - const outerMode = this.mode; - this.mode = "text"; - this.expect(groupBegin); - let str = ""; - const firstToken = this.fetch(); - let nested = 0; // allow nested braces in raw string group - - let lastToken = firstToken; - let nextToken; - - while ((nextToken = this.fetch()).text !== groupEnd || raw && nested > 0) { - switch (nextToken.text) { - case "EOF": - throw new ParseError("Unexpected end of input in " + modeName, firstToken.range(lastToken, str)); - - case groupBegin: - nested++; - break; - - case groupEnd: - nested--; - break; - } + var str = ""; + var nextToken; - lastToken = nextToken; - str += lastToken.text; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; this.consume(); } - this.expect(groupEnd); - this.mode = outerMode; - return firstToken.range(lastToken, str); + this.consume(); // consume the end of the argument + + argToken.text = str; + return argToken; } /** * Parses a regex-delimited group: the largest sequence of tokens @@ -16369,13 +17794,12 @@ class Parser { */ - parseRegexGroup(regex, modeName) { - const outerMode = this.mode; - this.mode = "text"; - const firstToken = this.fetch(); - let lastToken = firstToken; - let str = ""; - let nextToken; + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + var firstToken = this.fetch(); + var lastToken = firstToken; + var str = ""; + var nextToken; while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { lastToken = nextToken; @@ -16387,7 +17811,6 @@ class Parser { throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); } - this.mode = outerMode; return firstToken.range(lastToken, str); } /** @@ -16396,19 +17819,19 @@ class Parser { parseColorGroup(optional) { - const res = this.parseStringGroup("color", optional); + var res = this.parseStringGroup("color", optional); - if (!res) { + if (res == null) { return null; } - const match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); if (!match) { throw new ParseError("Invalid color: '" + res.text + "'", res); } - let color = match[0]; + var color = match[0]; if (/^[0-9a-f]{6}$/i.test(color)) { // We allow a 6-digit HTML color spec without a leading "#". @@ -16429,10 +17852,12 @@ class Parser { parseSizeGroup(optional) { - let res; - let isBlank = false; + var res; + var isBlank = false; // don't expand before parseStringGroup - if (!optional && this.fetch().text !== "{") { + this.gullet.consumeSpaces(); + + if (!optional && this.gullet.future().text !== "{") { res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); } else { res = this.parseStringGroup("size", optional); @@ -16451,13 +17876,13 @@ class Parser { isBlank = true; // This is here specifically for \genfrac } - const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); if (!match) { throw new ParseError("Invalid size: '" + res.text + "'", res); } - const data = { + var data = { number: +(match[1] + match[2]), // sign + magnitude, cast to number unit: match[3] @@ -16480,14 +17905,17 @@ class Parser { */ - parseUrlGroup(optional, consumeSpaces) { + parseUrlGroup(optional) { this.gullet.lexer.setCatcode("%", 13); // active character - const res = this.parseStringGroup("url", optional, true); // get raw string + this.gullet.lexer.setCatcode("~", 12); // other character + var res = this.parseStringGroup("url", optional); this.gullet.lexer.setCatcode("%", 14); // comment character - if (!res) { + this.gullet.lexer.setCatcode("~", 13); // active character + + if (res == null) { return null; } // hyperref package allows backslashes alone in href, but doesn't // generate valid links in such cases; we interpret this as @@ -16495,7 +17923,7 @@ class Parser { // replace backslashes with forward slashes. - const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); return { type: "url", mode: this.mode, @@ -16503,49 +17931,66 @@ class Parser { }; } /** - * If `optional` is false or absent, this parses an ordinary group, - * which is either a single nucleus (like "x") or an expression - * in braces (like "{x+y}") or an implicit group, a group that starts - * at the current position, and ends right before a higher explicit - * group ends, or at EOF. - * If `optional` is true, it parses either a bracket-delimited expression - * (like "[x+y]") or returns null to indicate the absence of a - * bracket-enclosed group. - * If `mode` is present, switches to that mode while parsing the group, - * and switches back after. + * Parses an argument with the mode specified. */ - parseGroup(name, // For error reporting. - optional, greediness, breakOnTokenText, mode, consumeSpaces) { - // Switch to specified mode - const outerMode = this.mode; + parseArgumentGroup(optional, mode) { + var argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + var outerMode = this.mode; if (mode) { + // Switch to specified mode this.switchMode(mode); - } // Consume spaces if requested, crucially *after* we switch modes, - // so that the next non-space token is parsed in the correct mode. + } + this.gullet.beginGroup(); + var expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end - if (consumeSpaces) { - this.consumeSpaces(); - } // Get first token + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + var result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; - const firstToken = this.fetch(); - const text = firstToken.text; - let result; // Try to parse an open brace or \begingroup + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } - if (optional ? text === "[" : text === "{" || text === "\\begingroup") { - this.consume(); - const groupEnd = Parser.endOfGroup[text]; // Start a new group namespace + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ - this.gullet.beginGroup(); // If we get a brace, parse an expression - const expression = this.parseExpression(false, groupEnd); - const lastToken = this.fetch(); // Check that we got a matching closing brace + parseGroup(name, // For error reporting. + breakOnTokenText) { + var firstToken = this.fetch(); + var text = firstToken.text; + var result; // Try to parse an open brace or \begingroup + + if (text === "{" || text === "\\begingroup") { + this.consume(); + var groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); // If we get a brace, parse an expression - this.expect(groupEnd); // End group namespace + var expression = this.parseExpression(false, groupEnd); + var lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace this.gullet.endGroup(); result = { @@ -16559,13 +18004,10 @@ class Parser { // use-begingroup-instead-of-bgroup semisimple: text === "\\begingroup" || undefined }; - } else if (optional) { - // Return nothing for an optional group - result = null; } else { // If there exists a function with this name, parse the function. // Otherwise, just return a nucleus - result = this.parseFunction(breakOnTokenText, name, greediness) || this.parseSymbol(); + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { if (this.settings.throwOnError) { @@ -16575,11 +18017,6 @@ class Parser { result = this.formatUnsupportedCmd(text); this.consume(); } - } // Switch mode back - - - if (mode) { - this.switchMode(outerMode); } return result; @@ -16595,12 +18032,12 @@ class Parser { formLigatures(group) { - let n = group.length - 1; + var n = group.length - 1; - for (let i = 0; i < n; ++i) { - const a = group[i]; // $FlowFixMe: Not every node type has a `text` property. + for (var i = 0; i < n; ++i) { + var a = group[i]; // $FlowFixMe: Not every node type has a `text` property. - const v = a.text; + var v = a.text; if (v === "-" && group[i + 1].text === "-") { if (i + 1 < n && group[i + 2].text === "-") { @@ -16640,13 +18077,13 @@ class Parser { parseSymbol() { - const nucleus = this.fetch(); - let text = nucleus.text; + var nucleus = this.fetch(); + var text = nucleus.text; if (/^\\verb[^a-zA-Z]/.test(text)) { this.consume(); - let arg = text.slice(5); - const star = arg.charAt(0) === "*"; + var arg = text.slice(5); + var star = arg.charAt(0) === "*"; if (star) { arg = arg.slice(1); @@ -16655,8 +18092,7 @@ class Parser { if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { - throw new ParseError(`\\verb assertion failed -- - please report what input caused this bug`); + throw new ParseError("\\verb assertion failed --\n please report what input caused this bug"); } arg = arg.slice(1, -1); // remove first and last char @@ -16674,14 +18110,14 @@ class Parser { if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) { // This behavior is not strict (XeTeX-compatible) in math mode. if (this.settings.strict && this.mode === "math") { - this.settings.reportNonstrict("unicodeTextInMathMode", `Accented Unicode text character "${text[0]}" used in ` + `math mode`, nucleus); + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); } - text = unicodeSymbols[text[0]] + text.substr(1); + text = unicodeSymbols[text[0]] + text.slice(1); } // Strip off any combining characters - const match = combiningDiacriticalMarksEndRegex.exec(text); + var match = combiningDiacriticalMarksEndRegex.exec(text); if (match) { text = text.substring(0, match.index); @@ -16694,20 +18130,20 @@ class Parser { } // Recognize base symbol - let symbol; + var symbol; if (symbols[this.mode][text]) { if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) { - this.settings.reportNonstrict("unicodeTextInMathMode", `Latin-1/Unicode text character "${text[0]}" used in ` + `math mode`, nucleus); + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); } - const group = symbols[this.mode][text].group; - const loc = SourceLocation.range(nucleus); - let s; + var group = symbols[this.mode][text].group; + var loc = SourceLocation.range(nucleus); + var s; if (ATOMS.hasOwnProperty(group)) { // $FlowFixMe - const family = group; + var family = group; s = { type: "atom", mode: this.mode, @@ -16723,16 +18159,17 @@ class Parser { loc, text }; - } + } // $FlowFixMe + symbol = s; } else if (text.charCodeAt(0) >= 0x80) { // no symbol for e.g. ^ if (this.settings.strict) { if (!supportedCodepoint(text.charCodeAt(0))) { - this.settings.reportNonstrict("unknownSymbol", `Unrecognized Unicode character "${text[0]}"` + ` (${text.charCodeAt(0)})`, nucleus); + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); } else if (this.mode === "math") { - this.settings.reportNonstrict("unicodeTextInMathMode", `Unicode text character "${text[0]}" used in math mode`, nucleus); + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); } } // All nonmathematical Unicode characters are rendered as if they // are in text mode (wrapped in \text) because that's what it @@ -16756,17 +18193,17 @@ class Parser { this.consume(); // Transform combining characters into accents if (match) { - for (let i = 0; i < match[0].length; i++) { - const accent = match[0][i]; + for (var i = 0; i < match[0].length; i++) { + var accent = match[0][i]; if (!unicodeAccents[accent]) { - throw new ParseError(`Unknown accent ' ${accent}'`, nucleus); + throw new ParseError("Unknown accent ' " + accent + "'", nucleus); } - const command = unicodeAccents[accent][this.mode]; + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; if (!command) { - throw new ParseError(`Accent ${accent} unsupported in ${this.mode} mode`, nucleus); + throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); } symbol = { @@ -16776,34 +18213,18 @@ class Parser { label: command, isStretchy: false, isShifty: true, + // $FlowFixMe base: symbol }; } - } + } // $FlowFixMe + return symbol; } } Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; -Parser.endOfGroup = { - "[": "]", - "{": "}", - "\\begingroup": "\\endgroup" - /** - * Parses an "expression", which is a list of atoms. - * - * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This - * happens when functions have higher precendence han infix - * nodes in implicit parses. - * - * `breakOnTokenText`: The text of the token that the expression should end - * with, or `null` if something else should end the - * expression. - */ - -}; -Parser.SUPSUB_GREEDINESS = 1; /** * Provides a single function for parsing an expression using a Parser @@ -16813,15 +18234,18 @@ Parser.SUPSUB_GREEDINESS = 1; /** * Parses an expression using a Parser, then returns the parsed result. */ -const parseTree = function parseTree(toParse, settings) { +var parseTree = function parseTree(toParse, settings) { if (!(typeof toParse === 'string' || toParse instanceof String)) { throw new TypeError('KaTeX can only parse string typed expression'); } - const parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + var parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors delete parser.gullet.macros.current["\\df@tag"]; - let tree = parser.parse(); // If the input used \tag, it will set the \df@tag macro to the tag. + var tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render(). + + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag. // In this case, we separately parse the tag and wrap the tree. if (parser.gullet.macros.get("\\df@tag")) { @@ -16829,12 +18253,11 @@ const parseTree = function parseTree(toParse, settings) { throw new ParseError("\\tag works only in display equations"); } - parser.gullet.feed("\\df@tag"); tree = [{ type: "tag", mode: "text", body: tree, - tag: parser.parse() + tag: parser.subparse([new Token("\\df@tag")]) }]; } @@ -16847,9 +18270,9 @@ const parseTree = function parseTree(toParse, settings) { * Parse and build an expression, and place that expression in the DOM node * given. */ -let render = function render(expression, baseNode, options) { +var render = function render(expression, baseNode, options) { baseNode.textContent = ""; - const node = renderToDomTree(expression, options).toNode(); + var node = renderToDomTree(expression, options).toNode(); baseNode.appendChild(node); }; // KaTeX's styles don't work properly in quirks mode. Print out an error, and // disable rendering. @@ -16869,8 +18292,8 @@ if (typeof document !== "undefined") { */ -const renderToString = function renderToString(expression, options) { - const markup = renderToDomTree(expression, options).toMarkup(); +var renderToString = function renderToString(expression, options) { + var markup = renderToDomTree(expression, options).toMarkup(); return markup; }; /** @@ -16878,8 +18301,8 @@ const renderToString = function renderToString(expression, options) { */ -const generateParseTree = function generateParseTree(expression, options) { - const settings = new Settings(options); +var generateParseTree = function generateParseTree(expression, options) { + var settings = new Settings(options); return parseTree(expression, settings); }; /** @@ -16889,14 +18312,14 @@ const generateParseTree = function generateParseTree(expression, options) { */ -const renderError = function renderError(error, expression, options) { +var renderError = function renderError(error, expression, options) { if (options.throwOnError || !(error instanceof ParseError)) { throw error; } - const node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]); + var node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]); node.setAttribute("title", error.toString()); - node.setAttribute("style", `color:${options.errorColor}`); + node.setAttribute("style", "color:" + options.errorColor); return node; }; /** @@ -16905,11 +18328,11 @@ const renderError = function renderError(error, expression, options) { */ -const renderToDomTree = function renderToDomTree(expression, options) { - const settings = new Settings(options); +var renderToDomTree = function renderToDomTree(expression, options) { + var settings = new Settings(options); try { - const tree = parseTree(expression, settings); + var tree = parseTree(expression, settings); return buildTree(tree, expression, settings); } catch (error) { return renderError(error, expression, settings); @@ -16921,11 +18344,11 @@ const renderToDomTree = function renderToDomTree(expression, options) { */ -const renderToHTMLTree = function renderToHTMLTree(expression, options) { - const settings = new Settings(options); +var renderToHTMLTree = function renderToHTMLTree(expression, options) { + var settings = new Settings(options); try { - const tree = parseTree(expression, settings); + var tree = parseTree(expression, settings); return buildHTMLTree(tree, expression, settings); } catch (error) { return renderError(error, expression, settings); @@ -16936,7 +18359,7 @@ var katex = { /** * Current KaTeX version */ - version: "0.11.1", + version: "0.16.10", /** * Renders the given LaTeX into an HTML+MathML combination, and adds @@ -16955,6 +18378,11 @@ var katex = { */ ParseError, + /** + * The shema of Settings + */ + SETTINGS_SCHEMA, + /** * Parses the given LaTeX into KaTeX's internal parse tree structure, * without rendering to HTML or MathML. @@ -16996,6 +18424,13 @@ var katex = { */ __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** * adds a new macro to builtin macro list */ @@ -17018,4 +18453,4 @@ var katex = { } }; -export default katex; +export { katex as default }; diff --git a/proposals/VK_KHR_maintenance7.adoc b/proposals/VK_KHR_maintenance7.adoc new file mode 100644 index 0000000000..53c05068ad --- /dev/null +++ b/proposals/VK_KHR_maintenance7.adoc @@ -0,0 +1,283 @@ +// Copyright 2024 The Khronos Group Inc. +// SPDX-License-Identifier: CC-BY-4.0 + += VK_KHR_maintenance7 +:toc: left +:refpage: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/ +:sectnums: + +This proposal details and addresses the issues solved by the `VK_KHR_maintenance7` extension. + +== Problem Statement + +Over time, a collection of minor features, none of which would warrant an +entire extension of their own, requires the creation of a maintenance +extension. + +The following is a list of issues considered in this proposal: + + * Require no access overlap between depth and stencil aspects when + rendering + * Add a way to query information regarding the underlying devices in + environments where the Vulkan implementation is provided through layered + implementations. + * Promote ename:VK_RENDERING_CONTENTS_INLINE_BIT_EXT and + ename:VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT to + KHR + * Add a limit to report the maximum total count of dynamic uniform buffers + and dynamic storage buffers that can be included in a pipeline layout. + * Add a method for determining whether an implementation wraps or saturates + on 32bit timestamp query overflow + * Require that FSR attachment access is consistent with other image + accesses for robustness. Perhaps also make sure array access is robust - + not just width/height. + +=== Separate Depth/Stencil Access + +Some implementations treat writes to a single aspect of mixed depth/stencil attachments as writes +to both aspects, while some implementations treat these writes as single-aspect writes in isolation. +It is important for applications to know which behavior is in use by an implementation. + +=== Query Properties of Underlying Layered Implementations + +When the Vulkan driver is provided by a layered implementation, it may be necessary to query the details of the underlying device. +For example, running on Mesa/Venus, driver ID is returned as ename:VK_DRIVER_ID_MESA_VENUS, but it may be necessary to know what the real driver under the hood is. + +=== Mixed Inline and Secondary Command Buffer Recording in Render Passes + +Vulkan 1.0 required that the contents of a render pass subpass are either entirely inlined or are provided in a single secondary command buffer. +In some situations, it may be beneficial to be able to mix inline and secondary command buffers inside the same render pass subpass, or executed multiple secondary command buffers. + +=== Relax Count of Dynamic Uniform/Storage Buffers + +The maximum count of dynamic uniform buffers and dynamic storage buffers that can +be included in a pipeline layout are reported separately. While some implementations +treat dynamic offsets of uniform buffers and storage buffers the same way, reporting +the total count along with maximum count of dynamic uniform and storage buffers could +relax the limitation and expose device capabilities more accurately. + +=== Fragment Shading Rate Attachment Size Mismatch + +The https://microsoft.github.io/DirectX-Specs/d3d/VariableRateShading.html[DirectX 12 Variable Shading Rate] feature allows applications to specify a shading rate image that is smaller than would be required to provide shading rates for all rendered texels. +When a fragment is rendered outside of the area covered by the shading rate image, default values are returned, in line with the usual out of bounds values for images that it guarantees. + +In Vulkan however, this is currently outright banned, making it difficult to guarantee portability for apps relying on this or for emulation layers. + +== Issue Details and Solution Space + +=== Separate Depth/Stencil Access + +A property that indicates whether single-aspect writes to a depth/stencil attachment will +result in writes to both aspects. + +=== Query Properties of Underlying Layered Implementations + +A new set of structures are included, accessible through link:{refpage}VkPhysicalDeviceLayeredApiPropertiesListKHR.html[VkPhysicalDeviceLayeredApiPropertiesListKHR] when chained to link:{refpage}VkPhysicalDeviceProperties2.html[VkPhysicalDeviceProperties2]. + +=== Mixed Inline and Secondary Command Buffer Recording in Render Passes + +Flags from the `VK_EXT_nested_command_buffer` extension provide this functionality, and are promoted to this extension. + +=== Relax Count of Dynamic Uniform/Storage Buffers + +A limit that indicates the maximum total count of dynamic uniform buffers and +storage buffers that can be included in a pipeline layout is added. + +=== Fragment Shading Rate Attachment Size Mismatch + +At the basic level, the first hurdle is allowing applications to specify fragment shading rate attachments that are too small for the render area, and giving it some sense of defined behavior. +The second challenge is ensuring that implementations all return the expected values. + +This could be achieved by using new language to describe the specifics of these lookups, but notably image reads with robust access already have the desired behavior. +As such, this proposal retools fragment shading rate attachment reads as general image reads, and guarantees the values match DirectX 12's guarantees when the link:{refpage}VkPhysicalDeviceRobustness2FeaturesEXT.html[VkPhysicalDeviceRobustness2FeaturesEXT::robustImageAccess2] feature is enabled. + +=== Determine 32-Bit Query Overflow Behavior + +Previously when the 32-bit unsigned integer query result overflows, the implementation may either +wrap or saturate. However, MESA Virtio-GPU Venus layered implementation needs determined behavior +to implement `vkGetQueryPoolResults` based on `vkCmdCopyQueryPoolResults` in an efficient way. +This is solved by requiring that for an unsigned integer query, the 32-bit result value must be +equal to the 32 least significant bits of the equivalent 64-bit result value. + + +== Proposal + +=== New features + +The following features are exposed: + +[source,c] +---- +typedef struct VkPhysicalDeviceMaintenance7FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 maintenance7; +} VkPhysicalDeviceMaintenance7FeaturesKHR; +---- + + * The `maintenance7` feature indicates support for the `VK_KHR_maintenance7` extension. + + +=== New properties + +The following properties are added by this extension: + +[source,c] +---- +typedef struct VkPhysicalDeviceMaintenance7PropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 robustFragmentShadingRateAttachmentAccess; + VkBool32 separateDepthStencilAttachmentAccess; + uint32_t maxDescriptorSetTotalUniformBuffersDynamic; + uint32_t maxDescriptorSetTotalStorageBuffersDynamic; + uint32_t maxDescriptorSetTotalBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindTotalBuffersDynamic; +} VkPhysicalDeviceMaintenance7PropertiesKHR; +---- + + * `robustFragmentShadingRateAttachmentAccess` indicates whether a + fragment shading rate attachment created with + slink:VkImageSubresourceRange::pname:baseMipLevel equal to 0 can + have a size that is too small to cover a specified render area. + * `separateDepthStencilAttachmentAccess` indicates whether + read-modify-write operations to a depth/stencil attachment are considered a write to the sibling + stencil or depth attachment in an image which contains both depth and stencil aspects. + * `maxDescriptorSetTotalUniformBuffersDynamic` indicates the maximum total count of dynamic uniform buffers + that can be included in a pipeline layout. + * `maxDescriptorSetTotalStorageBuffersDynamic` indicates the maximum total count of dynamic storage buffers + that can be included in a pipeline layout. + * `maxDescriptorSetTotalBuffersDynamic` indicates the maximum total count of dynamic uniform buffers + and storage buffers that can be included in a pipeline layout. + * `maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic` is similar to +`maxDescriptorSetUniformBuffersDynamic` + but counts descriptors from descriptor sets created with or without the + `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set. + * `maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic` is similar to `maxDescriptorSetStorageBuffersDynamic` + but counts descriptors from descriptor sets created with or without the + `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set. + * `maxDescriptorSetUpdateAfterBindTotalBuffersDynamic` is similar to `maxDescriptorSetBuffersDynamic` + but counts descriptors from descriptor sets created with or without the + `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set. + +=== New flags + +The `VK_RENDERING_CONTENTS_INLINE_BIT_KHR` flag promoted from +the `VK_EXT_nested_command_buffer` extension allows the render pass instance to be recorded +inline within the current command buffer. +Combined with the `VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT` bit, +the contents of the render pass instance can be recorded both inline and in +secondary command buffers executed with `vkCmdExecuteCommands`. + +The `VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_KHR` flag +promoted from the `VK_EXT_nested_command_buffer` extension allows the contents +of a render pass subpass to be recorded both inline and in secondary command +buffers executed with `vkCmdExecuteCommands`. + +=== New structs + +To query information regarding layered implementations, chain the following to `vkGetPhysicalDeviceProperties2`. + +[source,c] +---- +typedef struct VkPhysicalDeviceLayeredApiPropertiesListKHR { + VkStructureType sType; + void* pNext; + uint32_t layeredApiCount; + VkPhysicalDeviceLayeredApiPropertiesKHR* pLayeredApis; +} VkPhysicalDeviceLayeredApiPropertiesListKHR; +---- + +Where: + +[source,c] +---- +typedef struct VkPhysicalDeviceLayeredApiPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t vendorID; + uint32_t deviceID; + VkPhysicalDeviceLayeredApiKHR layeredAPI; + char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; +} VkPhysicalDeviceLayeredApiPropertiesKHR; +---- + +In the above, `vendorID`, `deviceID`, and `deviceName` are similar to members of the same name in `VkPhysicalDeviceProperties`. +`layeredAPI` is an enum that identifies the underlying API of the layered implementation, for example `VK_PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR` if the layer implements the D3D12 API. + +In the presence of multiple layers, the contents of `pLayeredApis[0]` corresponds to the bottom-most layer, with the following indices (if any) ordered by layer order. +This allows applications who are purely interested in the ultimate vendor ID or API that is executing the commands to avoid querying the layer count, always provide a `layeredApiCount` of 1, and inspect only `pLayeredApis[0]`. + +To query API-specific details of the layered implementation, an API-specific struct can be chained to `VkPhysicalDeviceLayeredApiPropertiesKHR`. +For layered Vulkan implementations (i.e. `VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR`) this extension introduces `VkPhysicalDeviceLayeredApiVulkanPropertiesKHR` to be chained, with structs for other APIs potentially added in future extensions. +The implementation will fill in the chained struct that corresponds to the layered API, and leave structs for other APIs untouched. +This allows the application to chain structs for multiple APIs and retrieve all necessary information in a single query. + +[source,c] +---- +typedef struct VkPhysicalDeviceLayeredApiVulkanPropertiesKHR { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceProperties2 properties; +} VkPhysicalDeviceLayeredApiVulkanPropertiesKHR; +---- + +In the above struct, the application may additionally chain `VkPhysicalDeviceDriverProperties` and `VkPhysicalDeviceIDProperties` to `properties` to extract further information from the underlying Vulkan device. +`properties.properties.limits` and `properties.properties.sparseProperties` will however be 0-initialized and will not contain meaningful values. + +For example, an application running through Mesa's Venus, atop Mesa's Dozen, atop the Nvidia proprietary D3D12 implementation would receive: + +[source,c] +---- +layers->pLayeredApis[0].layeredAPI = VK_PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR; +// other fields + +layers->pLayeredApis[1].layeredAPI = VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR; +// other fields + +// If driverProperties is a VkPhysicalDeviceDriverProperties chained to +// VkPhysicalDeviceLayeredApiVulkanPropertiesKHR::properties that is in turn +// chained to layers->pLayeredApis[1].pNext: +driverProperties->driverID = VK_DRIVER_ID_MESA_DOZEN; +// other fields +---- + +In the above example, the properties of the top layer (Mesa's Venus) will be returned as usual in `VkPhysicalDeviceProperties2`. +Note: if there are layers underneath a non-Vulkan implementation, they may not be visible in this query. +For example, if the application is running through Mesa's Dozen, atop VKD3D-proton and so on, the query may return layered implementations only up to Mesa's Dozen as other APIs may lack such a query. + +The `VkPhysicalDeviceLayeredApiKHR` enum is defined as: + +[source,c] +---- +typedef enum VkPhysicalDeviceLayeredApiKHR { + VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR = 1, + VK_PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR = 2, + VK_PHYSICAL_DEVICE_LAYERED_API_METAL_KHR = 3, + VK_PHYSICAL_DEVICE_LAYERED_API_OPENGL_KHR = 4, + VK_PHYSICAL_DEVICE_LAYERED_API_OPENGLES_KHR = 5, +} VkPhysicalDeviceLayeredApiKHR; +---- + +== Issues + +=== RESOLVED: When running on a layered implementation, how should the properties of an underlying layered Vulkan device be queries? + +A dedicated struct `VkPhysicalDeviceLayeredApiVulkanPropertiesKHR` should be used, with a `VkPhysicalDeviceProperties2` member. +Additional information can be queried by chaining `VkPhysicalDeviceDriverProperties` and `VkPhysicalDeviceIDProperties` structs to that member. + +Chaining `VkPhysicalDeviceProperties2`, `VkPhysicalDeviceDriverProperties` and `VkPhysicalDeviceIDProperties` directly to `VkPhysicalDeviceLayeredApiPropertiesKHR` can be confusing for a number of reasons. +In particular, `VkPhysicalDeviceProperties2` is a "root" structure which can accept `VkPhysicalDeviceDriverProperties` and `VkPhysicalDeviceIDProperties` in its chain; allowing those structs to be chained to `VkPhysicalDeviceLayeredApiPropertiesKHR` means that it would be valid for an application to create a chain such as `VkPhysicalDeviceLayeredApiPropertiesKHR` -> `VkPhysicalDeviceDriverProperties` -> `VkPhysicalDeviceProperties2` which can be confusing. + +A future extension could also provide functionality to query properties of another layered API, such as D3D. +This extension allows the API-specific structs to be chained to `VkPhysicalDeviceLayeredApiPropertiesKHR` to facilitate querying all information at once, which means the `pNext` chain of `VkPhysicalDeviceLayeredApiPropertiesKHR` could include property structs for both Vulkan and D3D for example. +Allowing multiple structs per API, potentially interleaved would just add to the confusion. + +By wrapping `VkPhysicalDeviceProperties2` in a `VkPhysicalDeviceLayeredApiVulkanPropertiesKHR` struct, the `pNext` chain of `VkPhysicalDeviceLayeredApiPropertiesKHR` would contain only one struct per API, and avoid confusion in drivers, applications and validation layers. + + +== Further Functionality + +None. diff --git a/proposals/VK_KHR_shader_relaxed_extended_instruction.asciidoc b/proposals/VK_KHR_shader_relaxed_extended_instruction.adoc similarity index 100% rename from proposals/VK_KHR_shader_relaxed_extended_instruction.asciidoc rename to proposals/VK_KHR_shader_relaxed_extended_instruction.adoc diff --git a/scripts/interfacedocgenerator.py b/scripts/interfacedocgenerator.py index 0c35f695fa..3f4099bf96 100644 --- a/scripts/interfacedocgenerator.py +++ b/scripts/interfacedocgenerator.py @@ -51,24 +51,22 @@ def writeNewInterfaces(self, feature, key, title, markup, fp): write('',file=fp) # Loop through required blocks, sorted so they start with "core" features + # 'required', if not None, is a boolean expression of + # extension names (the 'depends' XML attribute). + # The expression may not be valid asciidoc conditional + # syntax, since the 'depends' XML syntax is more powerful. + # Consequently we no longer surround these interfaces with + # asciidoc ifdef markup (per vulkan/vulkan#3907), instead + # relying on the API name macros to render correctly. + # An alternative is to actually evaluate the expression + # here. for required in sorted(dict, key = interfaceDocSortKey): - # 'required' may be a boolean expression of extension - # names. - # Currently this syntax is the same as asciidoc conditional - # syntax, but will eventually become more complex. if required is not None: # Rewrite with spec macros and xrefs applied to names requiredlink = dependencyLanguageSpecMacros(required) - # @@ A better approach would be to actually evaluate the - # logical expression at generation time. - # If the extensions required are not in the spec build, - # then do not include these requirements. - # This would support arbitrarily complex expressions, - # unlike asciidoc ifdef syntax. - write('ifdef::' + required + '[]', file=fp) write(f'If {requiredlink} is supported:', file=fp) - write('',file=fp) + write('', file=fp) # Commands are relatively straightforward if key == 'command': @@ -88,9 +86,7 @@ def writeNewInterfaces(self, feature, key, title, markup, fp): for api in sorted(dict[required][parent]): write(' * ' + markup + api, file=fp) - if required is not None: - write('endif::' + required + '[]', file=fp) - write('',file=fp) + write('', file=fp) def makeInterfaceFile(self, feature): """Generate a file containing feature interface documentation in diff --git a/scripts/json_parser.py b/scripts/json_parser.py index ba4d4418dc..ad9c45b3dd 100644 --- a/scripts/json_parser.py +++ b/scripts/json_parser.py @@ -17,7 +17,7 @@ copyright = """ /* - * Copyright 2021 The Khronos Group Inc. + * Copyright 2024 The Khronos Group Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,8 @@ #include #include #include -#include +#include +#include #include namespace vk_json_parser { @@ -129,24 +130,24 @@ class GlobalMem { // To make sure the generated data is consistent across platforms, // we typecast to 32-bit. -static void parse_size_t(const char* s, Json::Value& obj, size_t& o) +static void parse_size_t(const Json::Value& obj, size_t& o) { %s _res = static_cast<%s>(obj.asUInt()); o = _res; } -static void parse_char(const char* s, Json::Value& obj, char o[]) +static void parse_char(const Json::Value& obj, char o[]) { - std::string _res = obj.asString(); + const std::string& _res = obj.asString(); memcpy((void*)o, _res.c_str(), static_cast<%s>(_res.size())); o[_res.size()] = \'\\0\'; } -static void parse_char(const char* s, Json::Value& obj, const char* const*) +static void parse_char(const Json::Value& obj, const char* const*) { } -static void parse_char(const char* s, Json::Value& obj, const char** o) +static void parse_char(const Json::Value& obj, const char** o) { - std::string _res = obj.asString(); + const std::string& _res = obj.asString(); char *writePtr = (char *)s_globalMem.allocate(static_cast<%s>(_res.size()) + 1); memcpy((void*)writePtr, _res.c_str(), _res.size()); writePtr[_res.size()] = \'\\0\'; @@ -159,7 +160,7 @@ class GlobalMem { // base64 encoder taken from executor/xeTestResultParser.cpp static -std::vector base64decode(const std::string encoded) +std::vector base64decode(const std::string& encoded) { int base64DecodeOffset = 0; std::vector result; @@ -206,7 +207,7 @@ class GlobalMem { return result; } -static void parse_void_data(const void* s, Json::Value& obj, void* o, int oSize) +static void parse_void_data(const Json::Value& obj, void* o, int oSize) { std::vector data; if (obj.isString()) @@ -218,7 +219,7 @@ class GlobalMem { data.resize(oSize); for (int i = 0; i < std::min(oSize, (int)obj.size()); i++) { - parse_uint8_t("pData", obj[i], const_cast(data[i])); + parse_uint8_t(obj[i], const_cast(data[i])); } } memcpy(o, data.data(), oSize); @@ -230,7 +231,7 @@ class GlobalMem { // base64 encoder taken from executor/xeTestResultParser.cpp static -std::vector base64decode(const std::string encoded) +std::vector base64decode(const std::string& encoded) { int base64DecodeOffset = 0; std::vector result; @@ -277,7 +278,7 @@ class GlobalMem { return result; } -static void parse_void_data(const void* s, Json::Value& obj, void* o, int oSize) +static void parse_void_data(const Json::Value& obj, void* o, int oSize) { std::vector data; if (obj.isString()) @@ -289,7 +290,7 @@ class GlobalMem { data.resize(oSize); for (int i = 0; i < std::min(oSize, (int)obj.size()); i++) { - parse_uint8_t("pData", obj[i], const_cast(data[i])); + parse_uint8_t(obj[i], const_cast(data[i])); } } memcpy(o, data.data(), oSize); @@ -301,7 +302,7 @@ class GlobalMem { #define _VULKAN_JSON_PARSER_HPP """ -headerGuardBottom = """#endif // _VULKAN_JSON_PARSER_HPP""" +headerGuardBottom = """#endif // _VULKAN_JSON_PARSER_HPP\n""" class JSONParserOptions(GeneratorOptions): """JSONParserOptions - subclass of GeneratorOptions. @@ -326,17 +327,24 @@ def __init__(self, genEnumBeginEndRange=False, genAliasMacro=False, aliasMacro='', + versions='', + defaultExtensions='', + addExtensions='', **kwargs ): GeneratorOptions.__init__(self, **kwargs) self.isCTS = isCTS + self.versions = versions + self.defaultExtensions = defaultExtensions + self.addExtensions = addExtensions class JSONParserGenerator(OutputGenerator): # This is an ordered list of sections in the header file. TYPE_SECTIONS = ['basetype', 'handle', 'enum', - 'group', 'bitmask', 'struct'] + 'group', 'bitmask', 'struct', + 'pNext'] ALL_SECTIONS = TYPE_SECTIONS def __init__(self, *args, **kwargs): @@ -345,8 +353,7 @@ def __init__(self, *args, **kwargs): self.sections = {section: [] for section in self.ALL_SECTIONS} self.feature_not_empty = False self.may_alias = None - self.featureDict = {} - self.vkscFeatureList = [] + self.pNextCases = "" self.constDict = {} self.baseTypeDict = { "int32_t" : "obj.asInt()", @@ -357,26 +364,35 @@ def __init__(self, *args, **kwargs): "int" : "obj.asInt()", "double" : "obj.asDouble()", "int64_t" : "obj.asInt64()", - "uint16_t" : "obj.asUInt()", + "uint16_t" : "obj.asUInt()" + } + self.nvSciTypeDict = { "NvSciBufAttrList" : "obj.asInt()", "NvSciBufObj" : "obj.asInt()", "NvSciSyncAttrList" : "obj.asInt()", "NvSciSyncObj" : "obj.asInt()" } - def parseBaseTypes(self): - for baseType in self.baseTypeDict: - printStr = self.baseTypeDict[baseType] - if baseType == "uint8_t" or baseType == "uint16_t" or baseType.startswith('NvSci'): - write("static void parse_%s(const char* s, Json::Value& obj, %s& o)\n" %(baseType, self.baseTypeListMap[baseType]) + + def parseBaseTypes(self, dict): + for baseType in dict: + printStr = dict[baseType] + if baseType == "uint8_t" or baseType == "uint16_t": + write("static void parse_%s(const Json::Value& obj, %s& o)\n" %(baseType, self.baseTypeListMap[baseType]) + "{\n" " o = static_cast<%s>(%s);\n" %(self.baseTypeListMap[baseType],printStr) + "}\n" , file=self.outFile ) + elif baseType.startswith('NvSci'): + write("static void parse_%s(const Json::Value& obj, %s& o)\n" %(baseType, self.nvSciTypeListMap[baseType]) + + "{\n" + " o = static_cast<%s>(%s);\n" %(self.nvSciTypeListMap[baseType],printStr) + + "}\n" + , file=self.outFile + ) else: code = "" - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o)\n" %(baseType, self.baseTypeListMap[baseType]) + code += "static void parse_%s(const Json::Value& obj, %s& o)\n" %(baseType, self.baseTypeListMap[baseType]) code += "{\n" if baseType in self.constDict: code += " if (obj.isString())\n" @@ -395,39 +411,8 @@ def parseBaseTypes(self): code += "}\n" write(code, file=self.outFile) - def createvkscFeatureList(self): - for feature in self.registry.reg.findall('feature'): - if feature.get('api').find('vulkansc') != -1: - # Remove entries that are removed in features in VKSC profile. - requiredList = feature.findall("require") - - for requiredItem in requiredList: - typeList = requiredItem.findall("type") - for typeName in typeList: - if typeName.get("name") != "": - self.featureDict[typeName.get("name")] = feature.get("name") - self.vkscFeatureList.append(typeName.get("name")) - - removeItemList = feature.findall("remove") - for removeItem in removeItemList: - removeTypes = removeItem.findall("type") - for item in removeTypes: - if self.vkscFeatureList.count(item.get("name")) > 0: - self.vkscFeatureList.remove(item.get("name")) - - allExtensions = self.registry.reg.findall('extensions') - for extensions in allExtensions: - extensionList = extensions.findall("extension") - for extension in extensionList: - if extension.get("supported").find("vulkansc") != -1: - requiredList = extension.findall("require") - for requiredItem in requiredList: - typeList = requiredItem.findall("type") - for typeName in typeList: - self.featureDict[typeName.get("name")] = extension.get("name") - self.vkscFeatureList.append(typeName.get("name")) - def createConstDict(self): + # This dictionary is used to convert string constants like 'VK_TRUE' and 'VK_WHOLE_SIZE' when reading integer base types for enums in self.registry.reg.findall('enums'): if enums.get("name") == "API Constants": for enum in enums.findall('enum'): @@ -440,90 +425,30 @@ def createConstDict(self): else: self.constDict[type].append((name, value)) - def printPrototypes(self): - code = "" - - code += "/*************************************** Begin prototypes ***********************************/\n" - typesList = self.registry.reg.findall('types') - currentExtension = "VK_VERSION_1_0" - for types in typesList: - typeList = types.findall("type") - - for type in typeList: - if type.get("name") != "": - cat = type.get("category") - name = type.get("name") - - if cat in {"handle", "bitmask", "basetype", "enum", "struct"} and name in self.vkscFeatureList: - if name in self.featureDict and currentExtension != self.featureDict[name]: - if not self.isCTS and currentExtension != "VK_VERSION_1_0": - code += "#endif\n" - currentExtension = self.featureDict[name] - if self.featureDict[name] != "VK_VERSION_1_0": - if not self.isCTS: - code += "#ifdef %s\n" %(currentExtension) - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o);\n" %(name, name) - - if currentExtension != "VK_VERSION_1_0": - if not self.isCTS: - code += "#endif\n" - code += "/*************************************** End prototypes ***********************************/\n\n" - - return code - def genStructExtensionCode(self): - code = "" - code += "static\n" - code += "void* parsePNextChain(Json::Value& obj) {\n" - code += " VkBaseInStructure o;\n" - code += " Json::Value& pNextObj = obj[\"pNext\"];\n" - code += " if (pNextObj.empty() || (pNextObj.isString() && pNextObj.asString() == \"NULL\")) return nullptr;\n\n" - code += " parse_VkStructureType(\"sType\", pNextObj[\"sType\"], (o.sType));\n" - code += " void* p = nullptr;\n" - code += " switch (o.sType) {\n" - - typesList = self.registry.reg.findall('types') - currentExtension = "VK_VERSION_1_0" - for types in typesList: - typeList = types.findall("type") - for type in typeList: - if type.get('category') == 'struct' and type.get('structextends') is not None and type.get('name') in self.vkscFeatureList: - members = type.findall('member') - for m in members: - n = type.get('name') - if m.get('values'): - if n in self.featureDict and currentExtension != self.featureDict[n]: - if not self.isCTS and currentExtension != "VK_VERSION_1_0": - code += "#endif\n" - currentExtension = self.featureDict[n] - if self.featureDict[n] != "VK_VERSION_1_0": - if not self.isCTS: - code += "#ifdef %s\n" %(currentExtension) - code += " case %s:\n" %(m.get('values')) - code += " {\n" - code += " p = s_globalMem.allocate(sizeof(%s));\n" %(n) - code += " parse_%s(\"\", pNextObj, *((%s*)p));\n" %(n, n) - code += " }\n" - #code += "print_%s(((%s *)pNext), \"%s\", 1);\n" %(n, n, n) - code += " break;\n" - - if currentExtension != "VK_VERSION_1_0": - if not self.isCTS: - code += "#endif\n" - code += " default: {/** **/}\n" - code += " }\n" - code += " return p;\n" - code += " }\n" - + code = "static void* parsePNextChain(const Json::Value& obj) {\n" + code += " VkBaseInStructure o;\n" + code += " const Json::Value& pNextObj = obj[\"pNext\"];\n" + code += " if (pNextObj.empty() || (pNextObj.isString() && pNextObj.asString() == \"NULL\")) return nullptr;\n\n" + code += " parse_VkStructureType(pNextObj[\"sType\"], (o.sType));\n" + code += " void* p = nullptr;\n" + code += " switch (o.sType) {\n" + code += self.pNextCases + code += " default:\n" + code += " break;\n" + code += " }\n" + code += " return p;\n" + code += "}\n" return code def beginFile(self, genOpts): OutputGenerator.beginFile(self, genOpts) - self.createvkscFeatureList() - self.createConstDict() - self.isCTS = genOpts.isCTS + self.versions = genOpts.versions + self.defaultExtensions = genOpts.defaultExtensions + self.addExtensions = genOpts.addExtensions + self.createConstDict() self.baseTypeListMap = { "int32_t" : "deInt32" if self.isCTS else "int32_t", @@ -534,7 +459,9 @@ def beginFile(self, genOpts): "int" : "int", "double" : "double", "int64_t" : "deInt64" if self.isCTS else "int64_t", - "uint16_t" : "deUint16" if self.isCTS else "uint16_t", + "uint16_t" : "deUint16" if self.isCTS else "uint16_t" + } + self.nvSciTypeListMap = { "NvSciBufAttrList" : "vk::pt::NvSciBufAttrList" if self.isCTS else "NvSciBufAttrList", "NvSciBufObj" : "vk::pt::NvSciBufObj" if self.isCTS else "NvSciBufObj", "NvSciSyncAttrList" : "vk::pt::NvSciSyncAttrList" if self.isCTS else "NvSciSyncAttrList", @@ -551,17 +478,20 @@ def beginFile(self, genOpts): self.baseTypeListMap["uint32_t"], self.baseTypeListMap["uint32_t"]), file=self.outFile) - self.parseBaseTypes() + self.parseBaseTypes(self.baseTypeDict) + nvSciExtensions = ('VK_NV_external_sci_sync', 'VK_NV_external_sci_sync2', 'VK_NV_external_memory_sci_buf') + if any(item in self.addExtensions for item in nvSciExtensions) or (self.defaultExtensions == 'vulkansc'): + self.parseBaseTypes(self.nvSciTypeDict) + + write("static void* parsePNextChain(const Json::Value& obj);\n", file=self.outFile) + if self.isCTS: write(base64DecodeCodeCTS, file=self.outFile) else: write(base64DecodeCode, file=self.outFile) - write(self.printPrototypes(), file=self.outFile) - - write(self.genStructExtensionCode(), file=self.outFile) - def endFile(self): + write(self.genStructExtensionCode(), file=self.outFile) write("}//End of namespace vk_json_parser\n", file=self.outFile) # end of namespace write(headerGuardBottom, file=self.outFile, end='') # end of _VULKAN_JSON_PARSER_HPP OutputGenerator.endFile(self) @@ -575,11 +505,13 @@ def endFeature(self): if self.emit: if self.feature_not_empty: if self.genOpts.conventions.writeFeature(self.featureName, self.featureExtraProtect, self.genOpts.filename): - for section in self.TYPE_SECTIONS: contents = self.sections[section] if contents: - write('\n'.join(contents), file=self.outFile) + if section == 'pNext': + self.pNextCases += ''.join(contents) + else: + write('\n'.join(contents), file=self.outFile) # Finish processing in superclass OutputGenerator.endFeature(self) @@ -588,96 +520,74 @@ def appendSection(self, section, text): self.sections[section].append(text) self.feature_not_empty = True - def genEnumCode(self, name, endIfdef): + def genEnumCode(self, name): code = "" - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(name, name) - code += " std::string _res = obj.asString();\n" - code += " o = (%s)%s_map[std::string(_res)];\n" %(name, name) + code += "static void parse_%s(const Json::Value& obj, %s& o) {\n" %(name, name) + code += " const std::string& _res = obj.asString();\n" + code += " o = (%s)%s_map[std::string(_res)];\n" %(name, name) code += "}\n" - if not self.isCTS and endIfdef: - code += "#endif\n" return code def genBasetypeCode(self, str1, str2, name): - code = "" - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(name, name) - code += " std::string _res = obj.asString();\n" + code = "static void parse_%s(const Json::Value& obj, %s& o) {\n" %(name, name) + code += " const std::string& _res = obj.asString();\n" if name == "VkBool32": - code += " //VkBool is represented as VK_TRUE and VK_FALSE in the json\n" - code += " o = (_res == \"VK_TRUE\") ? (1) : (0);\n" + code += " //VkBool is represented as VK_TRUE and VK_FALSE in the json\n" + code += " o = (_res == \"VK_TRUE\") ? (1) : (0);\n" elif name == "VkDeviceAddress": - code += " sscanf(_res.c_str(), \"%\" SCNu64, &o);\n" + code += " sscanf(_res.c_str(), \"%\" SCNu64, &o);\n" elif name == "VkDeviceSize": - code += " if (_res == \"VK_WHOLE_SIZE\")\n" - code += " o = (~0ULL);\n" - code += " else\n" - code += " sscanf(_res.c_str(), \"%\" SCNu64, &o);\n" - elif name in ["VkFlags64", "VkPipelineStageFlags2KHR", "VkAccessFlags2KHR", "VkFormatFeatureFlags2KHR"]: - code += " sscanf(_res.c_str(), \"%\" SCNd64, &o);\n" + code += " if (_res == \"VK_WHOLE_SIZE\")\n" + code += " o = (~0ULL);\n" + code += " else\n" + code += " sscanf(_res.c_str(), \"%\" SCNu64, &o);\n" + elif name == "VkFlags64": + code += " sscanf(_res.c_str(), \"%\" SCNd64, &o);\n" else: - code += " sscanf(_res.c_str(), \"%u\", &o);\n" + code += " sscanf(_res.c_str(), \"%u\", &o);\n" code += "}\n" return code def genHandleCode(self, str1, str2, name): - code = "" - ifdefName = "" - if name in self.featureDict and self.featureDict[name] != "VK_VERSION_1_0": - ifdefName = self.featureDict[name] - if not self.isCTS and ifdefName != "": - code += "#ifdef %s\n" %(ifdefName) - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(name, name) - code += "// std::string _res = obj.asString();\n" + code = "static void parse_%s(const Json::Value& obj, %s& o) {\n" %(name, name) + code += "// const std::string& _res = obj.asString();\n" code += "}\n" - if not self.isCTS and ifdefName != "": - code += "#endif\n" return code - def genBitmaskCode(self, str1, str2, name, mapName): + def genBitmaskCode(self, str1, str2, name, mapName, baseType): code = "" - ifdefName = "" - if mapName in self.featureDict and self.featureDict[mapName] != "VK_VERSION_1_0": - ifdefName = self.featureDict[mapName] - elif name in self.featureDict and self.featureDict[name] != "VK_VERSION_1_0": - ifdefName = self.featureDict[name] - if ifdefName != "": - if not self.isCTS: - code += "#ifdef %s\n" %(ifdefName) if mapName is not None: - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(name, name) - code += " o = (%s)0;\n" %(name) - code += " std::string _res = obj.asString();\n" - code += " std::vector bitmasks;\n" - code += " std::istringstream inputStream(_res);\n" - code += " std::string tempStr;\n" - code += " while (getline(inputStream, tempStr, '|')) {\n" - code += " tempStr.erase(std::remove_if(tempStr.begin(), tempStr.end(), isspace), tempStr.end());\n" - code += " bitmasks.push_back(tempStr);\n" - code += " }\n" - code += " for (auto& it : bitmasks) {\n" - code += " o |= (%s)%s_map[it];\n" %(mapName, mapName) - code += " }\n" + code += "static void parse_%s(const Json::Value& obj, %s& o) {\n" %(name, name) + code += " o = (%s)0;\n" %(name) + code += " const std::string& _res = obj.asString();\n" + code += " std::vector bitmasks;\n" + code += " std::istringstream inputStream(_res);\n" + code += " std::string tempStr;\n" + code += " while (getline(inputStream, tempStr, '|')) {\n" + code += " tempStr.erase(std::remove_if(tempStr.begin(), tempStr.end(), isspace), tempStr.end());\n" + code += " bitmasks.push_back(tempStr);\n" + code += " }\n" + code += " for (auto& it : bitmasks) {\n" + code += " o |= (%s)%s_map[it];\n" %(mapName, mapName) + code += " }\n" code += "}\n" else: - code += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(name, name) - code += " if (obj.isString()) {\n" - code += " std::string _res = obj.asString();\n" - if name in ["VkFlags64", "VkPipelineStageFlags2KHR", "VkAccessFlags2KHR", "VkFormatFeatureFlags2KHR"]: - code += " sscanf(_res.c_str(), \"%\" SCNd64, &o);\n" + code += "static void parse_%s(const Json::Value& obj, %s& o) {\n" %(name, name) + code += " if (obj.isString()) {\n" + code += " const std::string& _res = obj.asString();\n" + if baseType == "VkFlags64": + code += " sscanf(_res.c_str(), \"%\" SCNd64, &o);\n" else: - code += " sscanf(_res.c_str(), \"%u\", &o);\n" - code += " }\n" - code += " else {\n" - code += " o = obj.asUInt();\n" - code += " }\n" + code += " sscanf(_res.c_str(), \"%u\", &o);\n" + code += " }\n" + code += " else {\n" + code += " o = obj.asUInt();\n" + code += " }\n" code += "}\n" - if not self.isCTS and ifdefName != "": - code += "#endif\n" - return code def genType(self, typeinfo, name, alias): @@ -695,9 +605,15 @@ def genType(self, typeinfo, name, alias): self.genStruct(typeinfo, name, alias) else: if typeElem.get('category') == 'bitmask': + baseType = '' + typeName = '' for elem in typeElem: - if elem.tag == 'name': - body += self.genBitmaskCode("(", " obj,", elem.text, typeElem.get('requires')) + if elem.tag == 'type': + baseType = elem.text + elif elem.tag == 'name': + typeName = elem.text + if typeName != '': + body += self.genBitmaskCode("(", " obj,", typeName, typeElem.get('requires'), baseType) elif typeElem.get('category') == 'basetype': for elem in typeElem: @@ -764,36 +680,35 @@ def generateStructMembercode(self, param, str1, str2, str3, str4, memberName, ty length = str2 + param.get('len') + ")" if self.paramIsPointer(param) is True and isArr is True: - code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, memberName, typeName, length, typeName) - code += " Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) - code += " if (obj_%s.size() == 0) %s%s) = nullptr;\n" %(memberName, str2, memberName) - code += " else {\n" - code += " for (unsigned int i = 0; i < %s; i++) {\n" %(length) - code += " parse_%s(\"%s\", obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, memberName, memberName, typeName, str2, memberName) - code += " }\n" - code += " }\n" + code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, memberName, typeName, length, typeName) + code += " const Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) + code += " if (obj_%s.size() == 0) %s%s) = nullptr;\n" %(memberName, str2, memberName) + code += " else {\n" + code += " for (unsigned int i = 0; i < %s; i++) {\n" %(length) + code += " parse_%s(obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, memberName, typeName, str2, memberName) + code += " }\n" + code += " }\n" return code elif self.paramIsPointer(param) is True: - code += " {\n" - code += " Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) - code += " const int sz = obj_%s.size();\n" %(memberName) - code += " if (obj_%s.size() == 0) {\n" %(memberName) - code += " %s%s) = nullptr;\n"%(str2, memberName) - code += " } else {\n" - code += " %s%s) = (%s*)s_globalMem.allocate(1, sizeof(%s));\n" %(str2, memberName, typeName, typeName) - code += " parse_%s(\"%s\", obj_%s, const_cast<%s&>(*%s%s)));\n" %(typeName, memberName, memberName, typeName, str2, memberName) - code += " }\n" - code += " }\n" + code += " {\n" + code += " const Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) + code += " if (obj_%s.size() == 0) {\n" %(memberName) + code += " %s%s) = nullptr;\n"%(str2, memberName) + code += " } else {\n" + code += " %s%s) = (%s*)s_globalMem.allocate(1, sizeof(%s));\n" %(str2, memberName, typeName, typeName) + code += " parse_%s(obj_%s, const_cast<%s&>(*%s%s)));\n" %(typeName, memberName, typeName, str2, memberName) + code += " }\n" + code += " }\n" return code # TODO: With some tweak, we can use the genArrayCode() here. if isArr is True: - code += " Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) - code += " for (unsigned int i = 0; i < obj_%s.size(); i++) {\n" %(memberName) - code += " parse_%s(\"%s\", obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, memberName, memberName, typeName, str2, memberName) - code += " }\n" + code += " const Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) + code += " for (unsigned int i = 0; i < obj_%s.size(); i++) {\n" %(memberName) + code += " parse_%s(obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, memberName, typeName, str2, memberName) + code += " }\n" else: - code += " parse_%s(\"%s\", obj[\"%s\"], %s%s));\n" %(typeName, memberName, memberName, str2, memberName) + code += " parse_%s(obj[\"%s\"], %s%s));\n" %(typeName, memberName, str2, memberName) return code @@ -802,21 +717,21 @@ def genArrayCode(self, structName, name, typeName, str2, arraySize, needStrPrint mappedType = self.baseTypeListMap[typeName] if self.baseTypeListMap.get(typeName) != None else typeName if structName == "VkPipelineLayoutCreateInfo" and self.isCTS: if isMallocNeeded: - code += " %s* %sTab = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(mappedType, name, mappedType, arraySize, mappedType) - code += " Json::Value& obj_%s_arr = obj[\"%s\"];\n" %(name, name) - code += " for (unsigned int i = 0; i < obj_%s_arr.size(); i++) {\n" %(name) - code += " deUint64 %sInternal = 0;\n" %(name) - code += " parse_uint64_t(\"%s\", obj_%s_arr[i], %sInternal);\n" %(name, name, name) - code += " %sTab[i] = %s(%sInternal);\n" %(name, mappedType, name) - code += " }\n" - code += " %s%s = %sTab;\n" %(str2[1:], name, name) + code += " %s* %sTab = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(mappedType, name, mappedType, arraySize, mappedType) + code += " const Json::Value& obj_%s_arr = obj[\"%s\"];\n" %(name, name) + code += " for (unsigned int i = 0; i < obj_%s_arr.size(); i++) {\n" %(name) + code += " deUint64 %sInternal = 0;\n" %(name) + code += " parse_uint64_t(obj_%s_arr[i], %sInternal);\n" %(name, name) + code += " %sTab[i] = %s(%sInternal);\n" %(name, mappedType, name) + code += " }\n" + code += " %s%s = %sTab;\n" %(str2[1:], name, name) else: if isMallocNeeded: - code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, name, mappedType, arraySize, mappedType) - code += " Json::Value& obj_%s_arr = obj[\"%s\"];\n" %(name, name) - code += " for (unsigned int i = 0; i < obj_%s_arr.size(); i++) {\n" %(name) - code += " parse_%s(\"%s\", obj_%s_arr[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, name, name, mappedType, str2, name) - code += " }\n" + code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, name, mappedType, arraySize, mappedType) + code += " const Json::Value& obj_%s_arr = obj[\"%s\"];\n" %(name, name) + code += " for (unsigned int i = 0; i < obj_%s_arr.size(); i++) {\n" %(name) + code += " parse_%s(obj_%s_arr[i], const_cast<%s&>(%s%s[i])));\n" %(typeName, name, mappedType, str2, name) + code += " }\n" return code @@ -827,9 +742,9 @@ def genEmptyCode(self, memberName, isCommaNeeded): def genCTSHandleCode(self, memberName, typeName): code = "" - code += " deUint64 %sInternal = 0;\n" %(memberName) - code += " parse_uint64_t(\"%s\", obj[\"%s\"], %sInternal);\n" %(memberName, memberName, memberName) - code += " o.%s = %s(%sInternal);\n" %(memberName, typeName, memberName) + code += " deUint64 %sInternal = 0;\n" %(memberName) + code += " parse_uint64_t(obj[\"%s\"], %sInternal);\n" %(memberName, memberName) + code += " o.%s = %s(%sInternal);\n" %(memberName, typeName, memberName) return code def genStructCode(self, param, str1, str2, str3, str4, structName, isCommaNeeded): @@ -839,10 +754,10 @@ def genStructCode(self, param, str1, str2, str3, str4, structName, isCommaNeeded for elem in param: if elem.text.find('PFN_') != -1: - return " /** Note: Ignoring function pointer (%s). **/\n" %(elem.text) + return " /** Note: Ignoring function pointer (%s). **/\n" %(elem.text) if elem.text == 'pNext': - return " o.pNext = (%s*)parsePNextChain(obj);\n" %(structName) + return " o.pNext = (%s*)parsePNextChain(obj);\n" %(structName) if elem.tag == 'name': memberName = elem.text @@ -865,27 +780,27 @@ def genStructCode(self, param, str1, str2, str3, str4, structName, isCommaNeeded elif self.paramIsPointer(param) and typeName == 'void': code = "" if structName == "VkSpecializationInfo": - code += " if (o.dataSize > 0U)\n" - code += " {\n" - code += " void* data = s_globalMem.allocate(%s(%sdataSize));\n" %(self.baseTypeListMap["uint32_t"] ,str2[1:]) - code += " parse_void_data(\"%s\", obj[\"%s\"], data, int(%sdataSize));\n" %(memberName, memberName, str2[1:]) - code += " %s%s = data;\n" %(str2[1:], memberName) - code += " }\n" - code += " else\n" - code += " %s%s = NULL;\n" %(str2[1:], memberName) + code += " if (o.dataSize > 0U)\n" + code += " {\n" + code += " void* data = s_globalMem.allocate(%s(%sdataSize));\n" %(self.baseTypeListMap["uint32_t"] ,str2[1:]) + code += " parse_void_data(obj[\"%s\"], data, int(%sdataSize));\n" %(memberName, str2[1:]) + code += " %s%s = data;\n" %(str2[1:], memberName) + code += " }\n" + code += " else\n" + code += " %s%s = NULL;\n" %(str2[1:], memberName) return code if self.isCTS: if structName == "VkPipelineCacheCreateInfo": - code += " if (o.initialDataSize > 0U)\n" - code += " {\n" - code += " void* data = s_globalMem.allocate(%s(%sinitialDataSize));\n" %(self.baseTypeListMap["uint32_t"], str2[1:]) - code += " parse_void_data(\"%s\", obj[\"%s\"], data, int(%sinitialDataSize));\n" %(memberName, memberName, str2[1:]) - code += " %s%s = data;\n" %(str2[1:], memberName) - code += " }\n" - code += " else\n" - code += " %s%s = NULL;\n" %(str2[1:], memberName) + code += " if (o.initialDataSize > 0U)\n" + code += " {\n" + code += " void* data = s_globalMem.allocate(%s(%sinitialDataSize));\n" %(self.baseTypeListMap["uint32_t"], str2[1:]) + code += " parse_void_data(obj[\"%s\"], data, int(%sinitialDataSize));\n" %(memberName, str2[1:]) + code += " %s%s = data;\n" %(str2[1:], memberName) + code += " }\n" + code += " else\n" + code += " %s%s = NULL;\n" %(str2[1:], memberName) return code - return " /** Note: Ignoring void* data. **/\n" + return " /** Note: Ignoring void* data. **/\n" # For pointers where we have the 'len' field, dump them as arrays. elif self.paramIsPointer(param) and param.get('len') is not None and param.get('len').find('null-terminated') == -1 and param.get('len').find('latexmath') == -1: @@ -894,36 +809,35 @@ def genStructCode(self, param, str1, str2, str3, str4, structName, isCommaNeeded return self.genArrayCode(structName, memberName, typeName, str2, str2+param.get('len')+")", False, True) else: if structName == "VkDescriptorSetLayoutBinding" and self.isCTS: - code = "" - code += " Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) - code += " if (obj_%s.empty() || (obj_%s.isString() && obj_%s.asString() == \"NULL\"))\n" %(memberName, memberName, memberName) - code += " o.%s = nullptr;\n" %(memberName) - code += " else\n" - code += " {\n" - code += " %s* samplers = (%s*)s_globalMem.allocate((o.descriptorCount), sizeof(%s));\n" %(typeName, typeName, typeName) - code += " for (unsigned int i = 0; i < obj_%s.size(); i++)\n" %(memberName) - code += " {\n" - code += " deUint64 sInternal = 0;\n" - code += " parse_uint64_t(\"%s\", obj_%s[i], sInternal);\n" %(memberName, memberName) - code += " samplers[i] = %s(sInternal);\n" %(typeName) - code += " }\n" - code += " o.%s = samplers;\n" %(memberName) - code += " }" + code = " const Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) + code += " if (obj_%s.empty() || (obj_%s.isString() && obj_%s.asString() == \"NULL\"))\n" %(memberName, memberName, memberName) + code += " o.%s = nullptr;\n" %(memberName) + code += " else\n" + code += " {\n" + code += " %s* samplers = (%s*)s_globalMem.allocate((o.descriptorCount), sizeof(%s));\n" %(typeName, typeName, typeName) + code += " for (unsigned int i = 0; i < obj_%s.size(); i++)\n" %(memberName) + code += " {\n" + code += " deUint64 sInternal = 0;\n" + code += " parse_uint64_t(obj_%s[i], sInternal);\n" %(memberName) + code += " samplers[i] = %s(sInternal);\n" %(typeName) + code += " }\n" + code += " o.%s = samplers;\n" %(memberName) + code += " }" return code return self.genEmptyCode(memberName, isCommaNeeded) # Special handling for VkPipelineMultisampleStateCreateInfo::pSampleMask elif typeName in "VkSampleMask": arraySize = "(%s(o.rasterizationSamples + 31) / 32)" %(self.baseTypeListMap["uint32_t"]) - code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, memberName, typeName, arraySize, typeName) - code += " Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) - code += " if (o.rasterizationSamples == 0 || obj_%s.size() == 0) {\n" %(memberName) - code += " %s%s) = nullptr;\n" %(str2, memberName) - code += " } else {\n" - code += " for (%s i = 0; i < %s; i++) {\n" %(self.baseTypeListMap["uint32_t"], arraySize) - code += " parse_uint32_t(\"%s\", obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(memberName, memberName, typeName, str2, memberName) - code += " }\n" - code += " }\n" + code += " %s%s) = (%s*)s_globalMem.allocate(%s, sizeof(%s));\n" %(str2, memberName, typeName, arraySize, typeName) + code += " const Json::Value& obj_%s = obj[\"%s\"];\n" %(memberName, memberName) + code += " if (o.rasterizationSamples == 0 || obj_%s.size() == 0) {\n" %(memberName) + code += " %s%s) = nullptr;\n" %(str2, memberName) + code += " } else {\n" + code += " for (%s i = 0; i < %s; i++) {\n" %(self.baseTypeListMap["uint32_t"], arraySize) + code += " parse_uint32_t(obj_%s[i], const_cast<%s&>(%s%s[i])));\n" %(memberName, typeName, str2, memberName) + code += " }\n" + code += " }\n" # If a struct member is just a handle. elif str(self.getTypeCategory(typeName)) == 'handle': @@ -933,16 +847,20 @@ def genStructCode(self, param, str1, str2, str3, str4, structName, isCommaNeeded elif typeName in "char": if self.paramIsCharStaticArrayWithMacroSize(param) == 0: - code += " %s%s) = (const char*)s_globalMem.allocate(255);\n" %(str2, memberName) - code += " parse_%s(\"%s\", obj[\"%s\"], &%s%s));\n" %(typeName, memberName, memberName, str2, memberName) + code += " %s%s) = (const char*)s_globalMem.allocate(255);\n" %(str2, memberName) + code += " parse_%s(obj[\"%s\"], &%s%s));\n" %(typeName, memberName, str2, memberName) else: - code += " /** TODO: Handle this - %s **/\n" %(memberName) + code += " /** TODO: Handle this - %s **/\n" %(memberName) elif typeName in "NvSciSyncFence": - code += " /** TODO: Handle this - %s **/\n" %(memberName) + code += " /** TODO: Handle this - %s **/\n" %(memberName) + # Ignore other pointer data members + elif self.paramIsPointer(param): + code += " /** Note: Ignoring %s* data from %s **/\n" %(typeName, memberName) + else: - code += " parse_%s(\"%s\", obj[\"%s\"], %s%s));\n" %(typeName, memberName, memberName, str2, memberName) + code += " parse_%s(obj[\"%s\"], %s%s));\n" %(typeName, memberName, str2, memberName) return code @@ -950,24 +868,15 @@ def genStruct(self, typeinfo, typeName, alias): OutputGenerator.genStruct(self, typeinfo, typeName, alias) body = "" typeElem = typeinfo.elem - ifdefNeeded = False - - if typeName in self.featureDict and self.featureDict[typeName] != "VK_VERSION_1_0": - ifdefNeeded = True - if not self.isCTS: - body = "#ifdef %s\n" %(self.featureDict[typeName]) - if alias: - body += 'typedef ' + alias + ' ' + typeName + ';\n' - else: + if alias is None: genStr1 = ["("] genStr2 = ["(o."] genStr3 = [" o, const const char* s, bool commaNeeded) {"] - genStr4 = [" if (obj."] + genStr4 = [" if (obj."] index = 0 - body += "static void parse_%s(const char* s, Json::Value& obj, %s& o) {\n" %(typeName, typeName) - body += "\n" + body += "static void parse_%s(const Json::Value& obj, %s& o) {\n\n" %(typeName, typeName) for member in typeElem.findall('.//member'): body += self.genStructCode(member, genStr1[index], genStr2[index], genStr3[index], genStr4[index], typeName, 0) @@ -975,46 +884,71 @@ def genStruct(self, typeinfo, typeName, alias): body += "}\n" - if not self.isCTS and ifdefNeeded: - body += "#endif\n" + self.appendSection('struct', body) - self.appendSection('struct', body) + if typeElem.get('category') == 'struct' and typeElem.get('structextends') is not None: + members = typeElem.findall('member') + for m in members: + n = typeElem.get('name') + if m.get('values'): + pNext = " case %s:\n" %(m.get('values')) + pNext += " p = s_globalMem.allocate(sizeof(%s));\n" %(n) + pNext += " parse_%s(pNextObj, *((%s*)p));\n" %(n, n) + pNext += " break;\n\n" + self.appendSection('pNext', pNext) def genGroup(self, groupinfo, groupName, alias=None): OutputGenerator.genGroup(self, groupinfo, groupName, alias) groupElem = groupinfo.elem body = "" section = 'enum' - ifdefNeeded = False + if (groupElem.get('bitwidth')): + bitwidth = int(groupElem.get('bitwidth')) + else: + bitwidth = 32 - if groupName in self.featureDict and self.featureDict[groupName] != "VK_VERSION_1_0": - ifdefNeeded = True - if not self.isCTS: - body += "#ifdef %s\n" %(self.featureDict[groupName]) - - if groupName == "VkPipelineStageFlagBits2KHR" or groupName == "VkAccessFlagBits2KHR" or groupName == "VkFormatFeatureFlagBits2KHR": + if bitwidth == 64: body += "static std::map %s_map = {\n" %(self.baseTypeListMap["uint64_t"],groupName) else: body += "static std::map %s_map = {\n" %(groupName) enums = groupElem.findall('enum') for enum in enums: - if enum.get('value'): - body += " std::make_pair(\"%s\", %s),\n" %(enum.get('name'), enum.get('value')) - - elif enum.get('bitpos'): - if groupName == "VkPipelineStageFlagBits2KHR" or groupName == "VkAccessFlagBits2KHR" or groupName == "VkFormatFeatureFlagBits2KHR": - body += " std::make_pair(\"%s\", 1ULL << %s),\n" %(enum.get('name'), enum.get('bitpos')) + enumName = enum.get('name') + enumValue = enum.get('value') + enumBit = enum.get('bitpos') + enumExtends = enum.get('extends') + enumExtension = enum.get('extnumber') + enumOffset = enum.get('offset') + + # Handle aliases by looking up their aliased type + if enum.get('alias'): + for allEnums in self.registry.reg.findall('enums'): + if allEnums.get("name") == groupName: + for baseEnum in allEnums.findall('enum'): + if (enum.get('alias') == baseEnum.get('name')): + enumBit = baseEnum.get('bitpos') + enumValue = baseEnum.get('value') + enumExtends = baseEnum.get('extends') + enumExtension = baseEnum.get('extnumber') + enumOffset = baseEnum.get('offset') + + if enumValue: + body += " std::make_pair(\"%s\", %s),\n" %(enumName, enumValue) + + elif enumBit: + if bitwidth == 64: + body += " std::make_pair(\"%s\", 1ULL << %s),\n" %(enumName, enumBit) else: - body += " std::make_pair(\"%s\", 1UL << %s),\n" %(enum.get('name'), enum.get('bitpos')) + body += " std::make_pair(\"%s\", 1UL << %s),\n" %(enumName, enumBit) - elif enum.get('extends') and enum.get("extnumber") and enum.get("offset"): - extNumber = int(enum.get("extnumber")) - offset = int(enum.get("offset")) + elif enumExtends and enumExtension and enumOffset: + extNumber = int(enumExtension) + offset = int(enumOffset) enumVal = self.extBase + (extNumber - 1) * self.extBlockSize + offset - body += " std::make_pair(\"%s\", %s),\n" %(enum.get('name'), str(enumVal)) + body += " std::make_pair(\"%s\", %s),\n" %(enumName, str(enumVal)) body += "};\n" - body += self.genEnumCode(groupName, ifdefNeeded) + body += self.genEnumCode(groupName) self.appendSection(section, body) diff --git a/scripts/vksc_extensions.py b/scripts/vksc_extensions.py new file mode 100755 index 0000000000..08c8f8f48c --- /dev/null +++ b/scripts/vksc_extensions.py @@ -0,0 +1,257 @@ +#!/usr/bin/python3 +# +# Copyright 2023-2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 + +import argparse +import xml.etree.ElementTree as etree +import pdb + +def extensionInfoByName(name, extensionInfoList): + + for ext in extensionInfoList: + if ext.get('name') == name: + return ext + + return None + + +XMLFields = ['name', 'number', 'type', 'supported', 'depends', 'platform', 'ratified', 'author', 'contact', 'specialuse', 'promotedto', 'deprecatedby', 'obsoletedby', 'sortorder', 'provisional', 'comment'] + +def printHeader(): + sep = ";" + for f in XMLFields: + print(f, end=sep) + print("") + +def printExtXML(ext): + sep = ";" + for f in XMLFields: + print(ext.get(f), end=sep), + print("") + + +def printRatifiedHeader(): + print("name;number;xmlfield;vulkan;vulkansc;promotedto;deprecatedby") + +def printRatified(ext): + name = ext.get('name') + number = ext.get('number') + ratified = ext.get('ratified') + vkrat = ratified is not None and 'vulkan' in ratified.split(',') + vkscrat = ratified is not None and 'vulkansc' in ratified.split(',') + + promotedto = ext.get('promotedto') + deprecatedby = ext.get('deprecatedby') + if deprecatedby is None: + deprecatedby = ext.get('obsoletedby') + + print(f'{name};{number};{ratified};{vkrat};{vkscrat};{promotedto};{deprecatedby}') + +def dprint(*argv): + if args.verbose: + for arg in argv: + print(arg, end=" ") + print("") + +def printExtnSorted(extnSet, printFunc=printExtXML): + + # dictionary of extensions, indexed by vendor prefix + extnDict = {} + + for ext in extnSet: + (vk, vendor) = ext.split('_')[0:2] + + if not vendor in extnDict: + extnDict[vendor] = [] + extnDict[vendor].append(ext) + + # print KHR and EXT extensions first (sorted) + for vendor in ['KHR', 'EXT']: + if vendor in extnDict: + for ext in sorted(extnDict[vendor]): + printFunc(extensionInfoByName(ext, all_extensions)) + del extnDict[vendor] + + # print remaining extensions by vendor (sorted) + for vendor in sorted(extnDict.keys()): + for ext in sorted(extnDict[vendor]): + printFunc(extensionInfoByName(ext, all_extensions)) + del extnDict[vendor] + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(prog='vksc_extensions', + formatter_class=argparse.RawDescriptionHelpFormatter, + description='''\ +Loads VK/VKSC extensions from the API XML. +Filters out elements with non-matching explicit 'api' attributes from API XML. +Print various lists of extensions with attributes in semicolon separated lists. + ''') + + parser.add_argument('-input', action='store', + required=True, + help='Specify input registry XML') + parser.add_argument('-verbose', '-v', action='count', default=0, + help='print debug output') + parser.add_argument('-candidates', action='store_true', + help="Print Vulkan SC candidate extension lists") + parser.add_argument('-list-vksc', action='store_true', + help="Print Vulkan SC current extension list") + parser.add_argument('-ratify', action='store_true', + help="Print Vulkan SC ratification status lists") +# parser.add_argument('-output', action='store', +# required=True, +# help='Specify output registry XML') +# parser.add_argument('-keepAPI', action='store', +# default=None, +# help='Specify API name whose \'api\' tags are kept') + + args = parser.parse_args() +# print(args) + + tree = etree.parse(args.input) + + root = tree.getroot() + all_extensions = list() + vk_extensions = list() + vksc_extensions = list() + candidate_set = set() + already_in_set = set() + platform_set = set() + + for extension in root.find('extensions'): + #print(extension.tag, extension.attrib) + supported = extension.attrib.get('supported') + #print(supported) + + all_extensions.append(extension.attrib) + + if 'vulkan' in supported.split(','): + vk_extensions.append(extension.attrib) + candidate_set.add(extension.attrib.get('name')) + if 'vulkansc' in supported.split(','): + vksc_extensions.append(extension.attrib) + already_in_set.add(extension.attrib.get('name')) + + platform = extension.attrib.get('platform') + if platform is not None: + #print(platform) + platform_set.add(platform) + + for field in extension.attrib.items(): + if field[0] not in XMLFields: + print("WARNING unhandled XML extension attribute field:", field[0]) + + print("all vulkan extensions:", len(vk_extensions)) + print("all vulkan sc extensions:", len(vksc_extensions)) + print("platforms", platform_set) + + #for ext in vk_extensions: print(ext) + + # generate set of extensions that are in Vulkan but not in Vulkan SC + vksc_candidates = candidate_set - already_in_set + if args.verbose: + print("initial candidate list", len(vksc_candidates)) + print("-----------------") + for ext in vksc_candidates: print(ext) + print("-----------------") + + promoted_cores = ['VK_VERSION_1_0', 'VK_VERSION_1_1', 'VK_VERSION_1_2'] + future_cores = ['VK_VERSION_1_3'] + unsupported_platforms = ['xlib', 'xcb', 'wayland', 'win32', 'xlib_xrandr', + 'android', 'ggp', 'vi', 'fuchsia', 'directfb', + 'provisional', 'macos', 'ios', 'metal'] + removals = set() + future_core = set() + for ext in vksc_candidates: + info = extensionInfoByName(ext, vk_extensions) + promotedto = info.get('promotedto') + deprecatedby = info.get('deprecatedby') + if deprecatedby is None: + deprecatedby = info.get('obsoletedby') + platform = info.get('platform') + + # remove any that are promoted to a core version included in VKSC + if promotedto in promoted_cores: + removals.add(ext) + dprint("removing promoted core extension:", ext) + # remove any that are promoted to another candidate + elif promotedto in vksc_candidates: + removals.add(ext) + dprint("removing promoted to another candidate", ext) + # separate list for any promoted to a future core + elif promotedto in future_cores: + future_core.add(ext) + dprint("promoted to future core", ext) + # exceptional promotions + elif promotedto is not None: + # remove any that are promoted to an existing VKSC extension + vksc_info = extensionInfoByName(promotedto, vksc_extensions) + if vksc_info is not None: + removals.add(ext) + dprint("removing promoted to other VKSC extn", ext) + else: + print("unhandled promotedto", ext) + + # remove any that are deprecated by a core version included in VKSC + elif deprecatedby in promoted_cores: + removals.add(ext) + dprint("removing deprecated by core extension:", ext) + # remove any that are deprecated by another candidate + elif deprecatedby in vksc_candidates: + removals.add(ext) + dprint("removing deprecated by another candidate", ext) + # remove any that are deprecated without replacement + elif deprecatedby == '': + removals.add(ext) + dprint("removing deprecated without replacement", ext) + # exceptional deprecations + elif deprecatedby is not None: + vksc_info = extensionInfoByName(deprecatedby, vksc_extensions) + # remove any that are deprecated by an existing VKSC extension + if vksc_info is not None: + removals.add(ext) + dprint("removing deprecated by other VKSC extn", ext) + else: + print("unhandled deprecated", ext) + + # remove any that require a platform that is not supported for VKSC + elif platform in unsupported_platforms: + removals.add(ext) + dprint("removing due to unsupported platform:", ext, platform) + + #else: + #print("keeping candidate:", ext, info) + + vksc_candidates -= removals + vksc_candidates -= future_core + + if args.candidates: + print("-----------------") + print("future core promotion candidates", len(future_core)) + print("-----------------") + printHeader() + printExtnSorted(future_core) + + print("-----------------") + print("vulkansc extension candidates", len(vksc_candidates)) + print("-----------------") + printExtnSorted(vksc_candidates) + + if args.ratify: + print("-----------------") + print("ratification status for all vulkansc extensions:", len(vksc_extensions)) + print("-----------------") + printRatifiedHeader() + printExtnSorted(already_in_set, printRatified) + + if args.list_vksc: + print("-----------------") + print("all vulkansc extensions:", len(vksc_extensions)) + print("-----------------") + printHeader() + printExtnSorted(already_in_set) + + diff --git a/scripts/xml_consistency.py b/scripts/xml_consistency.py index b573bd4f2f..7073bcd56f 100755 --- a/scripts/xml_consistency.py +++ b/scripts/xml_consistency.py @@ -219,6 +219,7 @@ def __init__(self, args): 'VkQueueFamilyProperties2', 'VkSparseImageFormatProperties', 'VkSparseImageFormatProperties2', + 'VkPhysicalDeviceLayeredApiPropertiesKHR', )) # Substructures of allowed structures. This can be found by looking @@ -239,6 +240,7 @@ def __init__(self, args): 'VkPhysicalDeviceLimits', 'VkSparseImageFormatProperties', 'VkSparseImageFormatProperties2', + 'VkPhysicalDeviceLayeredApiPropertiesKHR', )) # Structures which have already have their limittype attributes validated diff --git a/style/extensions.adoc b/style/extensions.adoc index 679cbbc89c..dbe72d0d44 100644 --- a/style/extensions.adoc +++ b/style/extensions.adoc @@ -93,7 +93,7 @@ These names are used in a variety of places: * When specifying extensions and layers to enable in the API. * As a preprocessor symbol in the `vulkan_*.h` header files indicating that an extension interface is defined at compile time. - * To control building the Vulkan Specification from asciidoctor source + * To control building the Vulkan Specification from asciidoc source containing multiple versions and extensions, by explicitly enabling their inclusion. @@ -400,7 +400,7 @@ extension number assignment prior to extension publication: Changes to both the specification source, and to `vk.xml` will be needed. ** Extension changes to the specification source must be protected by - asciidoctor conditionals as described in the + asciidoc conditionals as described in the <> section. ** Changes to `vk.xml` must define the extension interfaces in the `` block, and must also change the `supported` attribute @@ -428,10 +428,10 @@ extension number assignment prior to extension publication: API versions and extensions are documented as modifications to the Vulkan specification. -Changes specific to a version or extension are protected by asciidoctor +Changes specific to a version or extension are protected by asciidoc conditionals. The changes are only visible in generated documentation when the -Specification is built with an asciidoctor attribute of that name defined. +Specification is built with an asciidoc attribute of that name defined. Khronos publishes three forms of the Vulkan Specification: the core API (e.g. versions 1.x) only; core API with all registered `KHR` and `EXT` extensions; and core API with all registered extensions. @@ -442,8 +442,8 @@ extensions; and core API with all registered extensions. If an new extension, or a related group of them is of sufficient scope to require a new chapter of the specification, localize such changes into a -small number of asciidoctor include files located under a subdirectory with -the name of the extension. +small number of asciidoc include files located under a subdirectory with the +name of the extension. An example can be found in `chapters/VK_KHR_surface/wsi.adoc`. Most extensions are not entirely self-contained, and also require changes in existing parts of the specification to document new interactions. @@ -482,7 +482,7 @@ Changes for extensions include (but may not be limited to) the following: removed as required). ** When creating references to the extension appendix from elsewhere in the Specification, use the custom macro `apiext:`, instead of an - explicit asciidoctor link. + explicit asciidoc pass:[link:] macro. This allows more easily checking for invalid extensions, and changing the link target for generated reference pages and other alternate output forms. @@ -508,8 +508,8 @@ sed -i -E 's/`?<<(VK_[A-Za-z0-9_]*)>>`?/`apiext:\1`/g' chapters/{*.adoc,*/*.adoc ---- ==== -- - * In the preamble to the appendix, start with an asciidoctor `include` of - the automatically generated meta information. + * In the preamble to the appendix, start with an asciidoc `include` of the + automatically generated meta information. This information includes the extension name string, type, number, revision, and contact information from `vk.xml`. * Following the `include`, add an *Other Extension Metadata* subsection @@ -544,8 +544,8 @@ sed -i -E 's/`?<<(VK_[A-Za-z0-9_]*)>>`?/`apiext:\1`/g' chapters/{*.adoc,*/*.adoc For example, see `appendices/VK_EXT_descriptor_indexing.adoc for language used when promoting to Vulkan core, with some features made optional in the promoted version. - * Next, add an asciidoctor `include` of the automatically generated - interface information. + * Next, add an asciidoc `include` of the automatically generated interface + information. This information includes API entities defined by the extension in `vk.xml`, such as new commands, structures, enumerants, and so on. * Following the `include`, add subsections describing interface @@ -583,7 +583,7 @@ sed -i -E 's/`?<<(VK_[A-Za-z0-9_]*)>>`?/`apiext:\1`/g' chapters/{*.adoc,*/*.adoc ---- * In every other place where the extension alters the behavior of the core Specification, make such changes and protect the modifications with the - same asciidoctor conditionals. + same asciidoc conditionals. For example, `VK_KHR_surface` adds new error codes to Vulkan. These are added to `chapters/fundamentals.adoc` in the "`Return Codes`" section as follows: @@ -596,8 +596,8 @@ sed -i -E 's/`?<<(VK_[A-Za-z0-9_]*)>>`?/`apiext:\1`/g' chapters/{*.adoc,*/*.adoc \include::{chapters}/VK_KHR_surface/VkResultErrorDescriptions_surface.adoc[] \endif::VK_KHR_surface[] ---- - * If two extensions interact, the asciidoctor conditionals must be - carefully structured so as to properly document the interactions if the + * If two extensions interact, the asciidoc conditionals must be carefully + structured so as to properly document the interactions if the specification is built with both extensions. Asciidoc conditionals allow link:{docguide}/directives/ifdef-ifndef/#checking-multiple-attributes[AND @@ -690,7 +690,7 @@ the version too: ---- When writing language dependent on the interaction of multiple extensions, -asciidoctor conditional syntax is very restricted and only supports a single +asciidoc conditional syntax is very restricted and only supports a single level of logical AND (`+`) or OR (`,`) operators. For example, if a section of text only applies when one extensions is enabled and another is not, the following markup will not work: @@ -753,7 +753,7 @@ Group. other specification source files. Other changes and additions are included inline in existing chapters. * All changes that are specific to the new version must be protected by - the asciidoctor conditional (e.g. the version name). + the asciidoc conditional (e.g. the version name). For example, in the case of Vulkan 1.1: + [source,asciidoc] diff --git a/style/introduction.adoc b/style/introduction.adoc index 50359cf6fa..979de6f3af 100644 --- a/style/introduction.adoc +++ b/style/introduction.adoc @@ -16,10 +16,10 @@ of this document is equally applicable to other documentation. [NOTE] .Note ==== -The custom Asciidoctor macros described in the <> section are only available in the actual Vulkan Specification, not in proposals and other documents. -For those documents only pure Asciidoctor markup may be used, in order that +For those documents only pure asciidoc markup may be used, in order that they be renderable in the web view provided by GitHub and Gitlab. ==== @@ -54,9 +54,9 @@ The style guide is broken into four sections: * <> - the required procedures for creating formal Vulkan extensions and layers. * <> - the required and recommended markup style for - writing asciidoctor and XML source that follows consistent formatting - and layout guidelines, tags special terms and phrases for proper - processing by the spec generation tools, etc. + writing asciidoc and XML source that follows consistent formatting and + layout guidelines, tags special terms and phrases for proper processing + by the spec generation tools, etc. * <> - the required and recommended writing style for overall and fine-grained structure and conventions, normative language use, API naming conventions, common words and phrases to use @@ -69,27 +69,28 @@ The style guide is broken into four sections: Vulkan Documentation is primarily written in link:https://docs.asciidoctor.org/asciidoctor/latest/[Asciidoc], a text markup language. -We process Asciidoc using the command-line +We process asciidoc using the command-line link:https://docs.asciidoctor.org/asciidoctor/latest/[`asciidoctor`] -application. +application, as well as with +link:https://github.com/asciidoctor/asciidoctor.js[`asciidoctor.js`\ when +building the integrated Vulkan documentation site. Asciidoctor is implemented in Ruby (https://www.ruby-lang.org/), which is available for Linux, MacOS, and Microsoft Windows. +Asciidoctor.js is a Javascript implementation transpiled from asciidoctor. [NOTE] .Note ==== -There are other implementations of asciidoctor, such as AsciidoctorJ -(https://github.com/asciidoctor/asciidoctorj) and asciidoctor.js -(https://github.com/asciidoctor/asciidoctor.js). -In particular, GitHub and GitLab both have preview renderers for .adoc or -.asciidoc files in repositories, and live preview extensions exist for -Chrome and Firefox. - -However, because of the use of custom Ruby macros in the Vulkan -Specification toolchain, and the high complexity of the documents and -toolchain used to generate it, these web tools cannot currently render the -Specification from source. +Additional implementations of asciidoc exist including +link:https://github.com/asciidoctor/asciidoctorj[AsciidoctorJ`) and the +builtin GitHub and GitLab preview renderers. +Live preview extensions exist for Chrome and Firefox. + +However, because of the use of custom macros in the Vulkan Specification +toolchain, and the high complexity of the documents and toolchain used to +generate it, these web tools cannot currently render the Specification from +source. Instead, we generate HTML and PDF versions of the Specification and publish them on the Khronos website. diff --git a/style/markup.adoc b/style/markup.adoc index 2e0000544a..886ba14214 100644 --- a/style/markup.adoc +++ b/style/markup.adoc @@ -5,14 +5,32 @@ [[markup]] = Markup Style -This chapter demonstrates Asciidoc and Specification structure, including +This chapter demonstrates asciidoc and Specification structure, including text layout and markup style. +[[markup-filenames]] +== Directory Structure and File Names + +All asciidoc markup files in the Specification must have a filename ending +in `.adoc`. + +Specification markup files must go in one of the top-level directories +`appendices` or `chapters`. + +When a file defining a new chapters or appendix is added, it must be +included from the top-level `vkspec.adoc` file, appropriately protected by +asciidoc conditionals if the file is specific to an extension or core +version. +The file must also be included from the Antora navigation file +`antora/spec/modules/ROOT/nav.adoc`, but without any asciidoc conditionals, +since the Antora build always includes all extensions and core versions. + + [[markup-copyrights]] == Copyrights and Licenses -The asciidoctor source for the Vulkan Specification and related documents is +The asciidoc source for the Vulkan Specification and related documents is under an open source license. When creating a *new* file, add the following copyright and license @@ -77,7 +95,7 @@ replaced by dashes. Always use the one-line title form, with one to four `=` signs preceding the chapter/section title. The two-line title form cannot be easily searched for, and often looks like -other types of asciidoctor delimiters. +other types of asciidoc delimiters. Using a mix of one-line and two-line titles causes compatibility issues, and using the two-line title form may implicitly set a backwards-compatibility syntax mode we do not want. @@ -100,7 +118,7 @@ file), and follow the title by a blank line, to set off sections visibly. [[markup-include-file-paths]] === Include File Paths -When using the asciidoctor `include::` directive anywhere other than the +When using the asciidoc `include::` directive anywhere other than the top-level file of the document, always use a full (absolute) path to the file being included. To make this easier, the specification build process defines several @@ -136,11 +154,11 @@ Each sentence in a paragraph ends with a newline to minimize git diff conflicts. Except when necessary for lists or other markup, text should begin at the first column of each line (leading spaces are often semantically meaningful -in asciidoctor markup). +in asciidoc markup). UTF-8 characters outside the ASCII subset should be used sparingly, only when needed for non-English names. -Instead use asciidoctor markup for special characters, if required. +Instead use asciidoc markup for special characters, if required. For example, two hyphens produces an em-dash: [NOTE] @@ -152,18 +170,17 @@ For example, two hyphens produces an em-dash: As an exception, multiplication should be marked with the unicode multiplication symbol "`×`" (and *not* an asterisk) when used in plain text. -You may also use the `\{times}` asciidoctor attribute for this symbol. +You may also use the `\{times}` asciidoc attribute for this symbol. In math sections, the same symbol should be referred to as `\times`. In code sections, a conventional asterisk (`*`) should be used instead. -The trailing `+` character causes a hard break in asciidoctor markup, and +The trailing `+` character causes a hard break in asciidoc markup, and should not be used except for this purpose. -Markup addition with the \{plus} asciidoctor attribute, except in +Markup addition with the \{plus} asciidoc attribute, except in <> and <>. -See the Asciidoctor docs for -link:{docguide}/subs/special-characters[supported special characters], as -well as use of entity references. +See the asciidoc link:{docguide}/subs/special-characters[supported special +characters], as well as use of entity references. Quotation marks should use the 66/99 convention. That is, double asymmetric quotation marks, indicated by a quotation mark @@ -172,8 +189,8 @@ closing marks (pass:["`like this`"]), which renders "`like this`". _Never_ use hard tabs or trailing blanks. -* In some cases, limitations of asciidoctor markup may result in lines that - are longer than 76 characters and cannot easily be shortened without +* In some cases, limitations of asciidoc markup may result in lines that are + longer than 76 characters and cannot easily be shortened without compromising the output documents. @@ -182,10 +199,10 @@ _Never_ use hard tabs or trailing blanks. Indentation (leading whitespace) for markup should not be used, except for <> as described below. -Leading whitespace can affect asciidoctor processing. +Leading whitespace can affect asciidoc processing. -When presenting unformatted text, use asciidoctor source blocks as described -in the next section. +When presenting unformatted text, use asciidoc source blocks as described in +the next section. Source blocks do allow leading whitespace, for example when including sample code in C. @@ -193,7 +210,7 @@ code in C. [[markup-blocks]] === Blocks -There are a variety of asciidoctor _block_ constructs. +There are a variety of asciidoc _block_ constructs. With the exception of <> and of _open blocks_ used to group markup together, blocks should be delimited by exactly four repeated characters indicating the block type, for consistency. @@ -241,11 +258,11 @@ from a regular listing block using the same delimiter. [[markup-footnotes]] === Footnotes -Use manually marked-up footnotes (the asciidoctor footnote construct is OK -for PDF outputs, but does not work well with long HTML documents since it -places all footnotes at the end of the document). +Use manually marked-up footnotes (the asciidoc footnote construct is OK for +PDF outputs, but does not work well with long HTML documents since it places +all footnotes at the end of the document). -Refer to footnotes with asciidoctor superscript notation^1^, and mark up the +Refer to footnotes with asciidoc superscript notation^1^, and mark up the footnotes below, but near the references as labeled lists. Manually assigned footnote numbers will inevitably be reused, which is OK as long as the colliding numbers are not in the same section. @@ -290,7 +307,7 @@ cannot be indented, only the first paragraph. + In general, successive list items should not be separated by white space. However, list continuation blocks should be followed by a `+` on a line by -itself, or by a blank line, due to limitations of the asciidoctor parser. +itself, or by a blank line, due to limitations of the asciidoc parser. + * Indent bullet lists two spaces (to the bullet), 4 spaces (to the text, if it extends over multiple lines). @@ -364,7 +381,7 @@ Whenever labeled lists are used the label and its terminating double colon must be alone on a line, followed by the contents of that list entry. For consistency do not use labels ending in three or four colons, or two -semicolons, even though these forms are allowed in asciidoctor markup. +semicolons, even though these forms are allowed in asciidoc markup. [source,asciidoc] .Example Markup @@ -499,9 +516,9 @@ The `opts=` attribute defaults to `inline`, which decreases output image size in the generated HTML. However, the `inline` option interferes with generating HTML diffs between two specifications with the script we currently use. -By using an asciidoctor attribute, this behavior can be controlled. +By using an asciidoc attribute, this behavior can be controlled. -Asciidoctor restricts captions in figures to be a single line in the source +Asciidoc restricts captions in figures to be a single line in the source document. If a longer caption is required, follow the figure directive with a sidebar block including the full caption preceded by a link to the figure: @@ -520,15 +537,14 @@ In the <> diagram, the diagram represents [[markup-indentation-equations]] === Indentation of Equations -Asciidoctor separates structural markup in asciidoctor source from -formatting, in HTML CSS stylesheets and invoked via asciidoctor "`role`" -attributes on blocks. +Asciidoc separates structural markup in asciidoc source from formatting, in +HTML CSS stylesheets and invoked via asciidoc "`role`" attributes on blocks. However, the flexibility of CSS stylesheets is not available in PDF layout using the existing PDF toolchain and YML stylesheets. Explicit indentation should be used sparingly in the specification, but one place it is useful is with equations. -Using <>, the easiest way to produce +Using <>, the easiest way to produce indentation is with a list where the leading bullet or descriptive text is suppressed @@ -597,7 +613,7 @@ formatting markup is used instead. [[markup-macros]] == Markup Macros and Normative Terminology -This section discusses Asciidoc macros used in the document. +This section discusses macros used in the document. In addition to the macros defined by asciidoctor itself, additional macros are defined by the <> and Reference Page configuration files. @@ -757,7 +773,7 @@ pname:pAllocateInfo->memoryTypeIndex ==== In the macros, "```\->```" is correct markup for the C arrow operator. But in any other context (including a "```````" delimited inline literal) it -would be subject to link:{docguide}/subs/replacements/[Asciidoctor character +would be subject to asciidoc link:{docguide}/subs/replacements/[character replacement substitutions], resulting in a unicode arrow: ->. ==== @@ -798,7 +814,7 @@ with common prefixes or suffixes, or common subsets of API names. Occasionally we want to use mathematical prime symbols as markup in regular text, outside of <>. While it is easy to write the single quote character for this, since that is -what LaTeX uses, asciidoctor will turn this into a curved quote character +what LaTeX uses, asciidoc will turn this into a curved quote character whenever it is followed by an alphabetic character. For example, when writing the {YCbCr} term widely used to describe a color encoding, the obvious markup does not look quite right: @@ -813,7 +829,7 @@ encoding, the obvious markup does not look quite right: Using a backslash to escape the apostrophe works in body text, but not places such as section titles, captions, and link text. When prime symbols are needed, use the Unicode ``prime'' symbol. -Several predefined asciidoctor variables are available to help with this, +Several predefined asciidoc attributes are available to help with this, including symbols for {YCbCr} and {RGBprime} because they are frequently used in the specification. @@ -931,9 +947,9 @@ There are several possible types of notes. Depending on the type of output, they are rendered in different styles, but always include a note title, and are usually set off in a box or with an icon. -While asciidoctor supports a wide set of _admonition paragraphs_ such as -TIP, IMPORTANT, WARNING, and CAUTION, we always use the NOTE form, augmented -by a note title. +While asciidoc supports a wide set of _admonition paragraphs_ such as TIP, +IMPORTANT, WARNING, and CAUTION, we always use the NOTE form, augmented by a +note title. Each type of note is discussed below. @@ -981,7 +997,7 @@ note. === Editing Notes Editing notes usually only appear in internal (non-published) versions of -documents, via asciidoctor conditionals. +documents, via asciidoc conditionals. If they are not resolved, or are internal issues that should not be visible in public, they should be removed from the source before pushing content to the canonical GitHub repository. @@ -1016,7 +1032,7 @@ issue, in the editing note. === Implementor's Notes Implementor's notes may or may not appear in published versions of -documents, via asciidoctor conditionals. +documents, via asciidoc conditionals. They describe suggested approaches or guidelines for people writing Vulkan implementations, and are rare because the hardware being targeted varies so widely. diff --git a/style/misc.adoc b/style/misc.adoc index 124b5c3c77..f52895ba47 100644 --- a/style/misc.adoc +++ b/style/misc.adoc @@ -17,7 +17,7 @@ image editors have been observed to produce images incompatible with the PDF image pipeline used by the Specification. Images must be authored at their actual image size in the HTML and PDF -output documents, and must not be scaled with asciidoctor options. +output documents, and must not be scaled with asciidoc options. In most cases, images are included as standalone figures and should occupy the full width of the document - do not leave unnecessary whitespace on either side of the image. @@ -34,7 +34,7 @@ limits. ==== According to the documentation available, the PDF output *should* have dimensions of roughly 184mm x 271mm - or equivalently 697px x 1026px (A4 -size [asciidoctor default] with a 0.5in margin [prawn-pdf default] on each +size [asciidoc default] with a 0.5in margin [prawn-pdf default] on each side). However for reasons currently unknown, at least the available width before images are scaled down lies is about 30-something pixels lower than that; diff --git a/style/revisions.adoc b/style/revisions.adoc index 46302d3241..cc75d58ae6 100644 --- a/style/revisions.adoc +++ b/style/revisions.adoc @@ -5,6 +5,11 @@ [[revisions]] = Revision History +* 2024-06-19 - Add the <> section. + Use `asciidoc` consistently when referring to the markup language, and + `asciidoctor` when referring to the asciidoc processing tool. + * 2024-06-12 - Specify where "`client`" and "`user`" terminology is allowed in the <> section (internal issue 3898). diff --git a/style/vuid.adoc b/style/vuid.adoc index ade7ad1304..aee38f50a5 100644 --- a/style/vuid.adoc +++ b/style/vuid.adoc @@ -8,10 +8,9 @@ Valid usage statements in the published Vulkan Specification must all be given _Valid Usage ID_ or _VUID_ tags. -These tags are asciidoctor anchors, intended for use by the validation layer -to provide unique names for each validation condition, and a way to link -from validation layer reports into the corresponding parts of the -Specification. +These tags are asciidoc anchors, intended for use by the validation layer to +provide unique names for each validation condition, and a way to link from +validation layer reports into the corresponding parts of the Specification. [[vuid-format]] diff --git a/style/writing.adoc b/style/writing.adoc index c07b6869ba..a5f60e3c9e 100644 --- a/style/writing.adoc +++ b/style/writing.adoc @@ -86,7 +86,7 @@ For example, if you wanted to say: A ename:VK_ERROR_DEVICE_LOST error -the correct way to mark this up in asciidoctor would be: +the correct way to mark this up in asciidoc would be: [source,asciidoc] ---- @@ -447,7 +447,7 @@ existing language. This constraint does not apply to enumerated types. Language for new enumerants defined by extensions should be added to the existing enumerant definition, <> for the new extension. +protected by asciidoc conditionals>> for the new extension. [NOTE] .Guideline @@ -467,10 +467,10 @@ There are two ways of marking up math expressions, described below. === Asciidoc Math Markup -Where possible, math is marked up using straight asciidoctor features. +Where possible, math is marked up using straight asciidoc features. For commonality with LaTeX math (see below), some common LaTeX operators and -names are defined as asciidoctor attributes using the same names, expanding -to the corresponding Unicode entities. +names are defined as asciidoc attributes using the same names, expanding to +the corresponding Unicode entities. The complete set of these attributes is found in `config/attribs.adoc`. .Spelling @@ -538,18 +538,18 @@ The complete set of these attributes is found in `config/attribs.adoc`. [[writing-math-latexmath]] === LaTeX Math Markup -Math markup more complex than easily supported in straight asciidoctor -markup (examples found in the Vulkan Specification include matrices, -tensors, summation notation, conditional assignments, and division of -complex expressions) are marked up using LaTeX math notation, which is -either passed through to the KaTeX in-browser rendering script for HTML -outputs, or passed through asciidoctor-mathematical for PDF outputs. +Math markup more complex than easily supported in straight asciidoc markup +(examples found in the Vulkan Specification include matrices, tensors, +summation notation, conditional assignments, and division of complex +expressions) is marked up using LaTeX math notation, which is either passed +through to the KaTeX in-browser rendering script for HTML outputs, or passed +through asciidoctor-mathematical for PDF outputs. [NOTE] .Note ==== -There are font and style differences between LaTeX and asciidoctor math -markup which lead to minor visual inconsistencies. +There are font and style differences between LaTeX and asciidoc math markup +which lead to minor visual inconsistencies. We will try to make this better over time, but it is not significant enough to be a big priority. ==== @@ -573,7 +573,7 @@ For example: ---- Note the escaped bracket in markup for the first expression, which is -necessary to work around asciidoctor macro parsing. +necessary to work around asciidoc macro parsing. _Block math_ is used for more complex equations. This example uses the `aligned` environment to delimit the expression. @@ -788,8 +788,8 @@ To create a command pool, call: ---- Note that each autogenerated command, enumeration, flag, or structure -definition include file also defines a corresponding asciidoctor anchor -which is the base name of the file. +definition include file also defines a corresponding asciidoc anchor which +is the base name of the file. In this case, the anchor is named `vkCreateCommandPool`. ==== @@ -884,7 +884,7 @@ All content within the block will be extracted for the corresponding reference page. Open blocks delimiting reference page content should not themselves contain -section headers, as asciidoctor cannot render such nested content correctly. +section headers, as asciidoc cannot render such nested content correctly. Reference pages should in general be relatively short, so this limitation is not severe. @@ -971,11 +971,11 @@ based on. These entries should be short and functional, without describing details of e.g. new enumerant values, function of individual parameter settings, etc. They can refer to other types using the appropriate *link: macros or to -related sections of the specification using asciidoctor xrefs. +related sections of the specification using asciidoc `xref` macros. In rare cases, a member description will cover multiple paragraphs. In these cases the normal list nesting and indentation guidelines cannot be -applied due to limitations of the asciidoctor parser. +applied due to limitations of the asciidoc parser. It is usually best to append a continuation block following the first paragraph of such a list item, as shown for pname:pNext above. @@ -1065,7 +1065,7 @@ endif::VK_VERSION_1_1[] Each enumerant in the enumerated type is described in a separate bullet list item. Make sure to protect enumerants added to the type by extensions or future -core versions with asciidoctor conditionals. +core versions with asciidoc conditionals. Close the open block after all enumerants are described. [source,asciidoc,subs=attributes+] @@ -1116,14 +1116,14 @@ See the "`Valid Usage`" section of the Vulkan Specification, and particularly the "`Valid Usage for Pointers`" section. When clauses in valid usage statements apply only when specific extensions -and/or core API versions are enabled at runtime, use appropriate asciidoctor +and/or core API versions are enabled at runtime, use appropriate asciidoc conditionals around such clauses. [NOTE] ==== Prior to specification update 1.3.255, there were stronger restrictions on -placement of asciidoctor conditionals that have been relaxed, allowing -writing such valid usage statements in a more natural manner and with less +placement of asciidoc conditionals that have been relaxed, allowing writing +such valid usage statements in a more natural manner and with less duplication of language. ==== @@ -1213,7 +1213,7 @@ usage statement), the original VUs can be left intact. == Markup for Empty Enumerated Types Sometimes an enumerated type has all values defined by extensions, and each -enumerated value defined by the type will be surrounded by an asciidoctor +enumerated value defined by the type will be surrounded by an asciidoc conditional for the corresponding extension. When a specification is built without any of those extensions enabled, the type should still be included, even though it is empty. @@ -1254,10 +1254,10 @@ sections of the API Specification. This requires that the markup and writing conventions described above be adhered to rigidly. -The extraction scripts for a given page rely on the existence of an -asciidoctor `open` block surrounding markup describing that page, with -attributes used to specify properties of the reference page. -Additional heuristics and non-asciidoctor tags, described below, are used to +The extraction scripts for a given page rely on the existence of an asciidoc +`open` block surrounding markup describing that page, with attributes used +to specify properties of the reference page. +Additional heuristics and non-asciidoc tags, described below, are used to identify subsections of a reference page in some cases. In general the open block introduction will look like: @@ -1299,7 +1299,7 @@ Attributes which can be set on the block are: This attribute is optional. Attributes of the open block must be written in this format, using single -quotes as delimiters (even though asciidoctor markup also allows double +quotes as delimiters (even though asciidoc markup also allows double quotes), and escape single quotes in e.g. the *desc* attribute value with backquotes. @@ -1320,7 +1320,7 @@ After the open block is started, the following markup should be provided: parameters. * Paragraphs of text making up the `Description` section of the ref page. This section is optional. - If it is necessary due to constraints of asciidoctor markup to have an + If it is necessary due to constraints of asciidoc markup to have an empty line in the bullet list section, add a `// refBody` comment immediately following the bullet list and preceding this section: + @@ -1339,7 +1339,7 @@ but it has been needed in the past and may again in the future. This line is required for commands and structures, but not for interfaces such as enumerated types, which do not have implicit valid usage blocks. - * Finally, a two-dash asciidoctor delimiter closing the open block: + * Finally, a two-dash asciidoc delimiter closing the open block: + [source,asciidoc] ---- diff --git a/xml/vk.xml b/xml/vk.xml index adb80de104..3ec9111554 100755 --- a/xml/vk.xml +++ b/xml/vk.xml @@ -175,11 +175,11 @@ branch of the member gitlab server. #define VKSC_API_VERSION_1_0 VK_MAKE_API_VERSION(VKSC_API_VARIANT, 1, 0, 0)// Patch version should always be set to 0 // Version of this file -#define VK_HEADER_VERSION 288 +#define VK_HEADER_VERSION 289 // Complete version of this file #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION) // Version of this file -#define VK_HEADER_VERSION 14 +#define VK_HEADER_VERSION 15 // Complete version of this file #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(VKSC_API_VARIANT, 1, 0, VK_HEADER_VERSION) @@ -796,6 +796,7 @@ typedef void* MTLSharedEvent_id; + WSI extensions @@ -3734,6 +3735,42 @@ typedef void* MTLSharedEvent_id; uint32_t maxCombinedImageSamplerDescriptorCount VkBool32 fragmentShadingRateClampCombinerInputs + + VkStructureType sType + void* pNext + VkBool32 maintenance7 + + + VkStructureType sType + void* pNext + VkBool32 robustFragmentShadingRateAttachmentAccess + VkBool32 separateDepthStencilAttachmentAccess + uint32_t maxDescriptorSetTotalUniformBuffersDynamic + uint32_t maxDescriptorSetTotalStorageBuffersDynamic + uint32_t maxDescriptorSetTotalBuffersDynamic + uint32_t maxDescriptorSetUpdateAfterBindTotalUniformBuffersDynamic + uint32_t maxDescriptorSetUpdateAfterBindTotalStorageBuffersDynamic + uint32_t maxDescriptorSetUpdateAfterBindTotalBuffersDynamic + + + VkStructureType sType + void* pNext + uint32_t layeredApiCount + VkPhysicalDeviceLayeredApiPropertiesKHR* pLayeredApisOutput list of layered implementations underneath the physical device + + + VkStructureType sType + void* pNext + uint32_t vendorID + uint32_t deviceID + VkPhysicalDeviceLayeredApiKHR layeredAPI + char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE] + + + VkStructureType sType + void* pNext + VkPhysicalDeviceProperties2 properties + VkStructureType sType const void* pNext @@ -11265,6 +11302,13 @@ typedef void* MTLSharedEvent_id; + + + + + + + @@ -12919,35 +12963,35 @@ typedef void* MTLSharedEvent_id; VkDevice device const VkImportFenceFdInfoKHR* pImportFenceFdInfo - + VkResult vkGetFenceSciSyncFenceNV VkDevice device const VkFenceGetSciSyncInfoNV* pGetSciSyncHandleInfo void* pHandle - + VkResult vkGetFenceSciSyncObjNV VkDevice device const VkFenceGetSciSyncInfoNV* pGetSciSyncHandleInfo void* pHandle - + VkResult vkImportFenceSciSyncFenceNV VkDevice device const VkImportFenceSciSyncInfoNV* pImportFenceSciSyncInfo - + VkResult vkImportFenceSciSyncObjNV VkDevice device const VkImportFenceSciSyncInfoNV* pImportFenceSciSyncInfo - + VkResult vkGetSemaphoreSciSyncObjNV VkDevice device const VkSemaphoreGetSciSyncInfoNV* pGetSciSyncInfo void* pHandle - + VkResult vkImportSemaphoreSciSyncObjNV VkDevice device const VkImportSemaphoreSciSyncInfoNV* pImportSemaphoreSciSyncInfo @@ -17079,7 +17123,7 @@ typedef void* MTLSharedEvent_id; - + @@ -17861,7 +17905,7 @@ typedef void* MTLSharedEvent_id; - + @@ -18302,7 +18346,7 @@ typedef void* MTLSharedEvent_id; - + @@ -18338,7 +18382,7 @@ typedef void* MTLSharedEvent_id; - + @@ -18377,7 +18421,7 @@ typedef void* MTLSharedEvent_id; - + @@ -18659,14 +18703,14 @@ typedef void* MTLSharedEvent_id; - + - + @@ -18858,7 +18902,7 @@ typedef void* MTLSharedEvent_id; - + @@ -18876,7 +18920,7 @@ typedef void* MTLSharedEvent_id; - + @@ -19577,7 +19621,7 @@ typedef void* MTLSharedEvent_id; - + @@ -19609,7 +19653,7 @@ typedef void* MTLSharedEvent_id; - + @@ -19663,7 +19707,7 @@ typedef void* MTLSharedEvent_id; - + @@ -19713,7 +19757,7 @@ typedef void* MTLSharedEvent_id; - + @@ -19737,7 +19781,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20010,7 +20054,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20130,7 +20174,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20261,7 +20305,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20435,7 +20479,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20548,7 +20592,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20598,7 +20642,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20782,7 +20826,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20864,7 +20908,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20922,7 +20966,7 @@ typedef void* MTLSharedEvent_id; - + @@ -20932,7 +20976,7 @@ typedef void* MTLSharedEvent_id; - + @@ -21635,7 +21679,7 @@ typedef void* MTLSharedEvent_id; - + VkPhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT and @@ -21683,7 +21727,7 @@ typedef void* MTLSharedEvent_id; - + @@ -21768,7 +21812,7 @@ typedef void* MTLSharedEvent_id; - + VkPhysicalDevice4444FormatsFeaturesEXT and @@ -21829,7 +21873,7 @@ typedef void* MTLSharedEvent_id; - + @@ -22194,7 +22238,7 @@ typedef void* MTLSharedEvent_id; - + @@ -22235,7 +22279,7 @@ typedef void* MTLSharedEvent_id; - + @@ -22695,7 +22739,7 @@ typedef void* MTLSharedEvent_id; - + @@ -22926,8 +22970,8 @@ typedef void* MTLSharedEvent_id; - - + + @@ -23714,7 +23758,7 @@ typedef void* MTLSharedEvent_id; - + @@ -23788,6 +23832,7 @@ typedef void* MTLSharedEvent_id; + @@ -24000,7 +24045,7 @@ typedef void* MTLSharedEvent_id; - + @@ -24074,7 +24119,7 @@ typedef void* MTLSharedEvent_id; - + @@ -24083,7 +24128,7 @@ typedef void* MTLSharedEvent_id; - + @@ -24146,7 +24191,7 @@ typedef void* MTLSharedEvent_id; - + @@ -24292,7 +24337,7 @@ typedef void* MTLSharedEvent_id; - + @@ -24318,10 +24363,23 @@ typedef void* MTLSharedEvent_id; - + - - + + + + + + + + + + + + + + + @@ -24535,6 +24593,31 @@ typedef void* MTLSharedEvent_id; + + + + + + + + + + + + + + + + + + + + + + + + +