@oneuptime/common 14.0.109 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/SecurityEvent.js +1 -1
- package/Models/DatabaseModels/AIInsight.js +2 -2
- package/Models/DatabaseModels/AIRunRecording.d.mts +12 -0
- package/Models/DatabaseModels/AIRunRecording.d.ts +12 -0
- package/Models/DatabaseModels/AIRunRecording.js +181 -0
- package/Models/DatabaseModels/AIRunRecording.mjs +2 -0
- package/Models/DatabaseModels/Alert.js +20 -4
- package/Models/DatabaseModels/AlertEpisode.js +2 -2
- package/Models/DatabaseModels/AlertEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.js +48 -2
- package/Models/DatabaseModels/AlertOnCallRule.js +3 -3
- package/Models/DatabaseModels/AlertSeverity.js +13 -4
- package/Models/DatabaseModels/AlertState.js +1 -1
- package/Models/DatabaseModels/CallLog.js +12 -12
- package/Models/DatabaseModels/DataStore.js +9 -0
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.mts +2 -0
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.ts +2 -0
- package/Models/DatabaseModels/EmailLog.js +14 -14
- package/Models/DatabaseModels/Form.js +3 -3
- package/Models/DatabaseModels/FormSubmission.js +6 -6
- package/Models/DatabaseModels/GlobalConfig.d.mts +1 -0
- package/Models/DatabaseModels/GlobalConfig.d.ts +1 -0
- package/Models/DatabaseModels/GlobalConfig.js +74 -45
- package/Models/DatabaseModels/Incident.js +20 -4
- package/Models/DatabaseModels/IncidentEpisode.js +2 -2
- package/Models/DatabaseModels/IncidentEpisodeOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentGroupingRule.d.mts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.d.ts +1 -0
- package/Models/DatabaseModels/IncidentGroupingRule.js +48 -2
- package/Models/DatabaseModels/IncidentOnCallRule.js +3 -3
- package/Models/DatabaseModels/IncidentSeverity.js +13 -4
- package/Models/DatabaseModels/IncidentSlaRule.js +2 -2
- package/Models/DatabaseModels/IncidentState.js +1 -1
- package/Models/DatabaseModels/IncidentTemplate.js +2 -2
- package/Models/DatabaseModels/Index.js +4 -0
- package/Models/DatabaseModels/InventoryItem.js +11 -0
- package/Models/DatabaseModels/Monitor.js +54 -20
- package/Models/DatabaseModels/MonitorNetworkDevice.d.mts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.d.ts +11 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.js +189 -0
- package/Models/DatabaseModels/MonitorNetworkDevice.mjs +2 -0
- package/Models/DatabaseModels/MonitorProbe.js +22 -5
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +64 -7
- package/Models/DatabaseModels/NetworkEndpoint.d.mts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.d.ts +1 -0
- package/Models/DatabaseModels/NetworkEndpoint.js +39 -7
- package/Models/DatabaseModels/NetworkInterface.js +5 -5
- package/Models/DatabaseModels/OnCallDutyPolicy.js +4 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRule.js +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +8 -5
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +5 -2
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +28 -11
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +10 -7
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.mts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.d.ts +1 -0
- package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +16 -11
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerTeam.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicyOwnerUser.js +7 -4
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +6 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +4 -4
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +3 -3
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -6
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +9 -6
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +35 -7
- package/Models/DatabaseModels/OpenStackCloudCheck.js +8 -1
- package/Models/DatabaseModels/Project.d.mts +3 -0
- package/Models/DatabaseModels/Project.d.ts +3 -0
- package/Models/DatabaseModels/Project.js +142 -5
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +3 -1
- package/Models/DatabaseModels/ProjectSmtpConfig.js +2 -0
- package/Models/DatabaseModels/ProxmoxCluster.d.mts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.d.ts +1 -0
- package/Models/DatabaseModels/ProxmoxCluster.js +52 -3
- package/Models/DatabaseModels/PublicNoteApprovalRequest.js +3 -3
- package/Models/DatabaseModels/PublicNoteApprovalStep.js +1 -1
- package/Models/DatabaseModels/PushNotificationLog.js +12 -12
- package/Models/DatabaseModels/Reseller.js +8 -2
- package/Models/DatabaseModels/ResellerPlan.js +8 -2
- package/Models/DatabaseModels/RunbookExecution.js +2 -2
- package/Models/DatabaseModels/RunbookRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenance.js +9 -6
- package/Models/DatabaseModels/ScheduledMaintenanceCalendarFeed.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +7 -4
- package/Models/DatabaseModels/ScheduledMaintenanceLabelRule.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurement.js +7 -7
- package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +3 -3
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerRule.js +6 -6
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceOwnerUser.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +10 -7
- package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +4 -4
- package/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +5 -5
- package/Models/DatabaseModels/Service.js +1 -1
- package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +4 -4
- package/Models/DatabaseModels/ServiceLevelObjectiveErrorBudgetPolicyTier.js +4 -4
- package/Models/DatabaseModels/SmsLog.js +12 -12
- package/Models/DatabaseModels/StatusPage.js +5 -5
- package/Models/DatabaseModels/StatusPageSubscriber.js +2 -2
- package/Models/DatabaseModels/TeamMember.js +10 -1
- package/Models/DatabaseModels/TelegramLog.js +12 -12
- package/Models/DatabaseModels/TelemetryIngestionKey.js +8 -5
- package/Models/DatabaseModels/TelemetryIngestionKeyRefusal.js +7 -4
- package/Models/DatabaseModels/User.d.mts +4 -0
- package/Models/DatabaseModels/User.d.ts +4 -0
- package/Models/DatabaseModels/User.js +100 -0
- package/Models/DatabaseModels/UserOnCallLog.js +6 -6
- package/Models/DatabaseModels/UserOnCallLogTimeline.js +3 -3
- package/Models/DatabaseModels/UserOnCallShiftReminderLog.js +2 -2
- package/Models/DatabaseModels/WebhookLog.js +12 -12
- package/Models/DatabaseModels/WhatsAppLog.js +12 -12
- package/Models/DatabaseModels/WorkspaceNotificationLog.js +12 -12
- package/Models/DatabaseModels/WorkspaceNotificationRule.js +36 -1
- package/Models/DatabaseModels/WorkspaceNotificationSummary.js +1 -1
- package/Models/DatabaseModels/WorkspacePublicNoteApprovalMessage.js +3 -3
- package/Server/Services/DatabaseService.d.mts +4 -1
- package/Server/Services/DatabaseService.d.ts +4 -1
- package/Server/Types/Database/CountBy.d.mts +1 -0
- package/Server/Types/Database/CountBy.d.ts +1 -0
- package/Server/Types/Database/UpdateLimit.d.mts +6 -0
- package/Server/Types/Database/UpdateLimit.d.ts +6 -0
- package/Types/AI/AIActionWords.d.mts +25 -1
- package/Types/AI/AIActionWords.d.ts +25 -1
- package/Types/AI/AIActionWords.js +166 -3
- package/Types/AI/AIActionWords.mjs +6 -0
- package/Types/AI/AIChatTypes.d.mts +4 -2
- package/Types/AI/AIChatTypes.d.ts +4 -2
- package/Types/AI/AIChatTypes.js +5 -0
- package/Types/AI/AiOutcomes.d.mts +57 -0
- package/Types/AI/AiOutcomes.d.ts +57 -0
- package/Types/AI/AiOutcomes.js +67 -0
- package/Types/AI/AiOutcomes.mjs +10 -0
- package/Types/AI/AiRunRefusal.d.mts +45 -0
- package/Types/AI/AiRunRefusal.d.ts +45 -0
- package/Types/AI/AiRunRefusal.js +187 -0
- package/Types/AI/AiRunRefusal.mjs +12 -0
- package/Types/AI/InvestigationRecording.d.mts +46 -0
- package/Types/AI/InvestigationRecording.d.ts +46 -0
- package/Types/AI/InvestigationRecording.js +42 -0
- package/Types/AI/InvestigationRecording.mjs +7 -0
- package/Types/API/HTTPResponse.d.mts +3 -0
- package/Types/API/HTTPResponse.d.ts +3 -0
- package/Types/API/HTTPResponse.js +15 -0
- package/Types/Analytics/ProductEvent.d.mts +6 -1
- package/Types/Analytics/ProductEvent.d.ts +6 -1
- package/Types/Analytics/ProductEvent.js +41 -0
- package/Types/AuditLog/AuditLogCoverage.d.mts +1 -0
- package/Types/AuditLog/AuditLogCoverage.d.ts +1 -0
- package/Types/AuditLog/AuditLogCoverage.js +4 -2
- package/Types/BaseDatabase/AggregateBy.d.mts +16 -0
- package/Types/BaseDatabase/AggregateBy.d.ts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -1
- package/Types/BaseDatabase/AggregationIntervalUtil.js +92 -2
- package/Types/BaseDatabase/ListResult.d.mts +1 -0
- package/Types/BaseDatabase/ListResult.d.ts +1 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.mts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.d.ts +47 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.js +282 -0
- package/Types/CallAndSMS/ServerTwilioEnvironment.mjs +7 -0
- package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
- package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
- package/Types/Cloud/CloudResourceCatalog.js +33 -3
- package/Types/Cloud/CloudResourceCatalog.mjs +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.mts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.d.ts +1 -0
- package/Types/Dashboard/DashboardAutoRefresh.js +21 -0
- package/Types/Dashboard/DashboardAutoRefresh.mjs +1 -0
- package/Types/DataObservability/DataCheckSuggestions.d.mts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.d.ts +25 -0
- package/Types/DataObservability/DataCheckSuggestions.js +102 -65
- package/Types/DataObservability/DataCheckSuggestions.mjs +1 -0
- package/Types/Database/TableMetadata.d.mts +2 -0
- package/Types/Database/TableMetadata.d.ts +2 -0
- package/Types/Database/TableMetadata.js +6 -0
- package/Types/Date.d.mts +26 -2
- package/Types/Date.d.ts +26 -2
- package/Types/Date.js +81 -9
- package/Types/Date.mjs +1 -0
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +44 -2
- package/Types/DateLanguage.mjs +2 -0
- package/Types/DirectionArrow.d.mts +7 -0
- package/Types/DirectionArrow.d.ts +7 -0
- package/Types/DirectionArrow.js +88 -0
- package/Types/DirectionArrow.mjs +7 -0
- package/Types/Docs/GlossaryTerm.d.mts +1 -0
- package/Types/Docs/GlossaryTerm.d.ts +1 -0
- package/Types/Docs/GlossaryTerm.js +2 -0
- package/Types/Docs/RetiredNames.d.mts +11 -0
- package/Types/Docs/RetiredNames.d.ts +11 -0
- package/Types/Docs/RetiredNames.js +139 -0
- package/Types/Docs/RetiredNames.mjs +3 -0
- package/Types/Email/ServerEmailEnvironment.d.mts +85 -0
- package/Types/Email/ServerEmailEnvironment.d.ts +85 -0
- package/Types/Email/ServerEmailEnvironment.js +793 -0
- package/Types/Email/ServerEmailEnvironment.mjs +14 -0
- package/Types/Exception/AiRunRefusalException.d.mts +6 -0
- package/Types/Exception/AiRunRefusalException.d.ts +6 -0
- package/Types/Exception/AiRunRefusalException.js +23 -0
- package/Types/Exception/AiRunRefusalException.mjs +2 -0
- package/Types/Exception/RefusalWithValues.d.mts +7 -0
- package/Types/Exception/RefusalWithValues.d.ts +7 -0
- package/Types/Exception/RefusalWithValues.js +76 -0
- package/Types/Exception/RefusalWithValues.mjs +3 -0
- package/Types/Exception/UnexplainedError.d.mts +13 -0
- package/Types/Exception/UnexplainedError.d.ts +13 -0
- package/Types/Exception/UnexplainedError.js +53 -1
- package/Types/Exception/UnexplainedError.mjs +1 -0
- package/Types/File/FileSize.d.mts +4 -1
- package/Types/File/FileSize.d.ts +4 -1
- package/Types/File/FileSize.js +18 -17
- package/Types/Form/FormTargetCatalog.js +2 -2
- package/Types/Form/FormTargetType.js +2 -2
- package/Types/HostCollector/HostCollector.d.mts +1 -0
- package/Types/HostCollector/HostCollector.d.ts +1 -0
- package/Types/HostCollector/HostCollector.js +26 -10
- package/Types/HostCollector/HostCollector.mjs +1 -0
- package/Types/ListData.d.mts +2 -0
- package/Types/ListData.d.ts +2 -0
- package/Types/ListData.js +4 -0
- package/Types/Monitor/MonitorCriteria.js +2 -2
- package/Types/Monitor/MonitorCriteriaInstance.js +9 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.mts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.d.ts +7 -0
- package/Types/Monitor/MonitorNotCheckedReason.js +36 -0
- package/Types/Monitor/MonitorNotCheckedReason.mjs +4 -0
- package/Types/Monitor/MonitorStep.js +1 -1
- package/Types/Monitor/MonitorTemplateSyncField.d.mts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.d.ts +6 -0
- package/Types/Monitor/MonitorTemplateSyncField.js +106 -64
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.mts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.ts +1 -0
- package/Types/Monitor/NtpMonitor/NtpMonitorUtil.js +11 -3
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.mts +6 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.d.ts +6 -0
- package/Types/Monitor/UptimeHistoryLabels.js +2 -2
- package/Types/Monitor/WhoIsTold.d.mts +3 -1
- package/Types/Monitor/WhoIsTold.d.ts +3 -1
- package/Types/Monitor/WhoIsTold.js +2 -1
- package/Types/NotificationRule/PagingLadder.d.mts +137 -0
- package/Types/NotificationRule/PagingLadder.d.ts +137 -0
- package/Types/NotificationRule/PagingLadder.js +682 -0
- package/Types/NotificationRule/PagingLadder.mjs +28 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.js +1 -1
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.mts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.d.ts +1 -0
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.js +12 -9
- package/Types/OnCallDutyPolicy/GlobalUserOverrideAccess.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.mts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.d.ts +3 -1
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.js +24 -6
- package/Types/OnCallDutyPolicy/OnCallAcknowledgePage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.mts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.d.ts +26 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.js +136 -0
- package/Types/OnCallDutyPolicy/OnCallPageLine.mjs +18 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.mts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPagePassOn.d.ts +1 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.mts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.d.ts +12 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.js +38 -0
- package/Types/OnCallDutyPolicy/OnCallPolicyStartedByHand.mjs +3 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +44 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.js +96 -5
- package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.mts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.ts +19 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.js +222 -0
- package/Types/OnCallDutyPolicy/OnCallTestPageLine.mjs +6 -0
- package/Types/OnCallDutyPolicy/ScheduleLayerDefaults.js +5 -2
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.mts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.d.ts +92 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.js +512 -0
- package/Types/OnCallDutyPolicy/ScheduleLayersSave.mjs +7 -0
- package/Types/OnCallDutyPolicy/UserOverrideCoverRequest.js +9 -1
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.mts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.d.ts +23 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.js +105 -0
- package/Types/OnCallDutyPolicy/UserOverrideEdit.mjs +6 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.mts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.d.ts +64 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.js +237 -0
- package/Types/OnCallDutyPolicy/UserOverrideOverlap.mjs +14 -0
- package/Types/Permission.d.mts +2 -2
- package/Types/Permission.d.ts +2 -2
- package/Types/Permission.js +196 -195
- package/Types/Probe/ProbeCapability.d.mts +2 -1
- package/Types/Probe/ProbeCapability.d.ts +2 -1
- package/Types/Probe/ProbeCapability.js +10 -0
- package/Types/Product/ProductCatalog.d.mts +10 -0
- package/Types/Product/ProductCatalog.d.ts +10 -0
- package/Types/Product/ProductCatalog.js +208 -0
- package/Types/Product/ProductCatalog.mjs +6 -0
- package/Types/Product/ProductOfTable.d.mts +3 -0
- package/Types/Product/ProductOfTable.d.ts +3 -0
- package/Types/Product/ProductOfTable.js +68 -0
- package/Types/Product/ProductOfTable.mjs +3 -0
- package/Types/Product/ProjectProductsAnswer.d.mts +3 -0
- package/Types/Product/ProjectProductsAnswer.d.ts +3 -0
- package/Types/Product/ProjectProductsAnswer.js +35 -2
- package/Types/Product/ProjectProductsAnswer.mjs +1 -0
- package/Types/Product/ServerProducts.d.mts +65 -0
- package/Types/Product/ServerProducts.d.ts +65 -0
- package/Types/Product/ServerProducts.js +383 -0
- package/Types/Product/ServerProducts.mjs +26 -0
- package/Types/Product/ServerProductsAnswer.d.mts +21 -0
- package/Types/Product/ServerProductsAnswer.d.ts +21 -0
- package/Types/Product/ServerProductsAnswer.js +78 -0
- package/Types/Product/ServerProductsAnswer.mjs +5 -0
- package/Types/ProductFeedback/ProductFeedback.d.mts +3 -1
- package/Types/ProductFeedback/ProductFeedback.d.ts +3 -1
- package/Types/ProductFeedback/ProductFeedback.js +8 -0
- package/Types/ReaderLanguage.d.mts +1 -0
- package/Types/ReaderLanguage.d.ts +1 -0
- package/Types/ReaderLanguage.js +13 -1
- package/Types/ReaderLanguage.mjs +1 -0
- package/Types/Rules/RuleRun.js +2 -2
- package/Types/Rum/SessionReplayCustomEvents.d.mts +1 -0
- package/Types/Rum/SessionReplayCustomEvents.d.ts +1 -0
- package/Types/SampleProject/SampleProject.d.mts +54 -0
- package/Types/SampleProject/SampleProject.d.ts +54 -0
- package/Types/SampleProject/SampleProject.js +177 -0
- package/Types/SampleProject/SampleProject.mjs +22 -0
- package/Types/SampleProject/SampleProjectContent.d.mts +127 -0
- package/Types/SampleProject/SampleProjectContent.d.ts +127 -0
- package/Types/SampleProject/SampleProjectContent.js +397 -0
- package/Types/SampleProject/SampleProjectContent.mjs +18 -0
- package/Types/ScheduledMaintenance/MaintenanceCalendar.js +1 -1
- package/Types/ServerSending/ServerSendingStatus.d.mts +7 -0
- package/Types/ServerSending/ServerSendingStatus.d.ts +7 -0
- package/Types/ServerSending/ServerSendingStatus.js +49 -2
- package/Types/ServerSetup/ServerSetupChecklist.js +3 -3
- package/Types/StateTimeline/RowsKeptOnDelete.js +1 -1
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.mts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.d.ts +8 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.js +50 -0
- package/Types/StatusPage/NewIncidentSubscriberNotificationDefault.mjs +3 -0
- package/Types/StatusPage/PublicNoteSubscriberNotificationDefault.js +1 -1
- package/Types/Telemetry/CompatibleIngest.d.mts +20 -0
- package/Types/Telemetry/CompatibleIngest.d.ts +20 -0
- package/Types/Telemetry/CompatibleIngest.js +123 -0
- package/Types/Telemetry/CompatibleIngest.mjs +21 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.mts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.d.ts +5 -0
- package/Types/Telemetry/TelemetryIngestSurface.js +54 -12
- package/Types/TimezoneAlias.d.mts +1 -0
- package/Types/TimezoneAlias.d.ts +1 -0
- package/Types/TimezoneAlias.js +13 -0
- package/Types/Translator.d.mts +1 -0
- package/Types/Translator.d.ts +1 -0
- package/Types/Translator.js +414 -50
- package/Types/Translator.mjs +1 -0
- package/Types/UsedBy/UsedBy.d.mts +103 -0
- package/Types/UsedBy/UsedBy.d.ts +103 -0
- package/Types/UsedBy/UsedBy.js +389 -0
- package/Types/UsedBy/UsedBy.mjs +20 -0
- package/Types/UsedBy/UsedByServerProducts.d.mts +4 -0
- package/Types/UsedBy/UsedByServerProducts.d.ts +4 -0
- package/Types/UsedBy/UsedByServerProducts.js +48 -0
- package/Types/UsedBy/UsedByServerProducts.mjs +3 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +6 -0
- package/Types/WelcomeChecklist/WelcomeChecklist.js +54 -2
- package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +1 -0
- package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +3 -0
- package/Types/Workflow/PassedOnFields.js +2 -1
- package/Types/Workflow/RunRecord.js +1 -1
- package/Types/Workflow/Templates.js +3 -3
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.mts +2 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.d.ts +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +28 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +28 -1
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.mts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.d.ts +84 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.js +456 -0
- package/Types/Workspace/NotificationRules/NotificationRuleUpdates.mjs +5 -0
- package/Utils/AI/MeaningMatch.d.mts +36 -0
- package/Utils/AI/MeaningMatch.d.ts +36 -0
- package/Utils/AI/MeaningMatch.js +535 -0
- package/Utils/AI/MeaningMatch.mjs +7 -0
- package/Utils/ArchivableValues.js +1 -1
- package/Utils/AuditLog/AuditLogValues.js +2 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.mts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.d.ts +14 -2
- package/Utils/Dashboard/ClockWidgetFormat.js +105 -2
- package/Utils/Dashboard/DashboardViewConfigSignature.d.mts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.d.ts +3 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.js +45 -0
- package/Utils/Dashboard/DashboardViewConfigSignature.mjs +3 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.mts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.d.ts +2 -0
- package/Utils/Dashboard/ValueWidgetSeries.js +75 -0
- package/Utils/DataSecurity/TextScanner.js +2 -2
- package/Utils/DeveloperDocs/AiAssistantExamples.js +4 -4
- package/Utils/DeveloperDocs/CliCommands.d.mts +1 -0
- package/Utils/DeveloperDocs/CliCommands.d.ts +1 -0
- package/Utils/DeveloperDocs/CliCommands.js +2 -1
- package/Utils/DeveloperDocs/CliResources.js +2 -1
- package/Utils/DeveloperDocs/ExampleBuilder.js +1 -1
- package/Utils/DeveloperDocs/ResourceProfiles.js +2 -2
- package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
- package/Utils/GuidedSetup/StatusPageRecords.d.mts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.d.ts +5 -0
- package/Utils/GuidedSetup/StatusPageRecords.js +27 -2
- package/Utils/GuidedSetup/StatusPageRecords.mjs +1 -0
- package/Utils/GuidedSetup/WebsiteMonitorRecords.js +6 -0
- package/Utils/HostAddressUtil.d.mts +1 -0
- package/Utils/HostAddressUtil.d.ts +1 -0
- package/Utils/HostAddressUtil.js +30 -0
- package/Utils/LinearRegExp/LinearRegExp.js +5 -1
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +8 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +1493 -131
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
- package/Utils/Markdown/MarkdownTableCell.js +2 -1
- package/Utils/Markdown/OverLongText.js +523 -5
- package/Utils/Markdown/SlowMarkdown.d.mts +14 -0
- package/Utils/Markdown/SlowMarkdown.d.ts +14 -0
- package/Utils/Markdown/SlowMarkdown.js +595 -11
- package/Utils/Markdown/SlowMarkdown.mjs +6 -0
- package/Utils/Milliseconds.d.mts +7 -0
- package/Utils/Milliseconds.d.ts +7 -0
- package/Utils/Milliseconds.js +60 -0
- package/Utils/Milliseconds.mjs +4 -0
- package/Utils/ModelApiName.d.mts +11 -0
- package/Utils/ModelApiName.d.ts +11 -0
- package/Utils/ModelApiName.js +72 -0
- package/Utils/ModelApiName.mjs +5 -0
- package/Utils/Monitor/DeviceMacLearningUtil.d.mts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.d.ts +2 -1
- package/Utils/Monitor/DeviceMacLearningUtil.js +26 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.mts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.d.ts +8 -0
- package/Utils/Monitor/EndpointAttachmentUtil.js +97 -22
- package/Utils/Monitor/EndpointAttachmentUtil.mjs +4 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.mts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.d.ts +3 -0
- package/Utils/Monitor/ExternalStatusPageReading.js +35 -1
- package/Utils/Monitor/ExternalStatusPageReading.mjs +2 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.mts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.d.ts +40 -0
- package/Utils/Monitor/InterfaceInventoryUtil.js +217 -5
- package/Utils/Monitor/InterfaceInventoryUtil.mjs +8 -0
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +63 -29
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +13 -2
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +2 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +58 -4
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.mts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.d.ts +9 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.js +45 -0
- package/Utils/Monitor/MonitorTemplateLinkRefusal.mjs +6 -0
- package/Utils/Monitor/MonitoringOff.d.mts +2 -0
- package/Utils/Monitor/MonitoringOff.d.ts +2 -0
- package/Utils/Monitor/MonitoringOff.js +21 -0
- package/Utils/Monitor/NetworkTopologyUtil.d.mts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.d.ts +2 -1
- package/Utils/Monitor/NetworkTopologyUtil.js +10 -0
- package/Utils/Monitor/NotOperationalMonitorQuery.d.mts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.d.ts +2 -1
- package/Utils/Monitor/NotOperationalMonitorQuery.js +23 -4
- package/Utils/Monitor/ProbeFailureReading.d.mts +14 -0
- package/Utils/Monitor/ProbeFailureReading.d.ts +14 -0
- package/Utils/Monitor/ProbeFailureReading.js +137 -0
- package/Utils/Monitor/ProbeFailureReading.mjs +7 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.mts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.d.ts +9 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.js +15 -0
- package/Utils/NetworkDevice/BoundMonitorNotChecked.mjs +2 -0
- package/Utils/OpenStack/OpenStackCheckName.js +2 -1
- package/Utils/OpenStack/OpenStackLogScrub.js +1 -1
- package/Utils/OpenStack/OpenStackLogs.js +3 -2
- package/Utils/OpenStack/OpenStackTraces.js +2 -1
- package/Utils/Project/NextNumber.js +1 -1
- package/Utils/Project/NotificationChannels.js +5 -5
- package/Utils/Project/ProjectBalance.js +2 -2
- package/Utils/Project/TwilioAccount.js +2 -2
- package/Utils/PromQL/PromQLAst.d.mts +159 -0
- package/Utils/PromQL/PromQLAst.d.ts +159 -0
- package/Utils/PromQL/PromQLAst.js +118 -0
- package/Utils/PromQL/PromQLAst.mjs +12 -0
- package/Utils/PromQL/PromQLDuration.d.mts +2 -0
- package/Utils/PromQL/PromQLDuration.d.ts +2 -0
- package/Utils/PromQL/PromQLDuration.js +78 -0
- package/Utils/PromQL/PromQLDuration.mjs +3 -0
- package/Utils/PromQL/PromQLEngine.d.mts +15 -0
- package/Utils/PromQL/PromQLEngine.d.ts +15 -0
- package/Utils/PromQL/PromQLEngine.js +965 -0
- package/Utils/PromQL/PromQLEngine.mjs +7 -0
- package/Utils/PromQL/PromQLEngineTypes.d.mts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.d.ts +84 -0
- package/Utils/PromQL/PromQLEngineTypes.js +10 -0
- package/Utils/PromQL/PromQLEngineTypes.mjs +2 -0
- package/Utils/PromQL/PromQLError.d.mts +11 -0
- package/Utils/PromQL/PromQLError.d.ts +11 -0
- package/Utils/PromQL/PromQLError.js +27 -0
- package/Utils/PromQL/PromQLError.mjs +3 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.mts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.d.ts +8 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.js +773 -0
- package/Utils/PromQL/PromQLFunctionEvaluators.mjs +3 -0
- package/Utils/PromQL/PromQLFunctions.d.mts +10 -0
- package/Utils/PromQL/PromQLFunctions.d.ts +10 -0
- package/Utils/PromQL/PromQLFunctions.js +127 -0
- package/Utils/PromQL/PromQLFunctions.mjs +4 -0
- package/Utils/PromQL/PromQLLabels.d.mts +11 -0
- package/Utils/PromQL/PromQLLabels.d.ts +11 -0
- package/Utils/PromQL/PromQLLabels.js +218 -0
- package/Utils/PromQL/PromQLLabels.mjs +9 -0
- package/Utils/PromQL/PromQLLexer.d.mts +39 -0
- package/Utils/PromQL/PromQLLexer.d.ts +39 -0
- package/Utils/PromQL/PromQLLexer.js +391 -0
- package/Utils/PromQL/PromQLLexer.mjs +3 -0
- package/Utils/PromQL/PromQLMath.d.mts +19 -0
- package/Utils/PromQL/PromQLMath.d.ts +19 -0
- package/Utils/PromQL/PromQLMath.js +200 -0
- package/Utils/PromQL/PromQLMath.mjs +9 -0
- package/Utils/PromQL/PromQLMetricNames.d.mts +21 -0
- package/Utils/PromQL/PromQLMetricNames.d.ts +21 -0
- package/Utils/PromQL/PromQLMetricNames.js +199 -0
- package/Utils/PromQL/PromQLMetricNames.mjs +8 -0
- package/Utils/PromQL/PromQLParser.d.mts +4 -0
- package/Utils/PromQL/PromQLParser.d.ts +4 -0
- package/Utils/PromQL/PromQLParser.js +831 -0
- package/Utils/PromQL/PromQLParser.mjs +4 -0
- package/Utils/PromQL/PromQLRegex.d.mts +9 -0
- package/Utils/PromQL/PromQLRegex.d.ts +9 -0
- package/Utils/PromQL/PromQLRegex.js +74 -0
- package/Utils/PromQL/PromQLRegex.mjs +2 -0
- package/Utils/PromQL/PrometheusResponse.d.mts +25 -0
- package/Utils/PromQL/PrometheusResponse.d.ts +25 -0
- package/Utils/PromQL/PrometheusResponse.js +90 -0
- package/Utils/PromQL/PrometheusResponse.mjs +3 -0
- package/Utils/Rum/PathInSentence.d.mts +5 -0
- package/Utils/Rum/PathInSentence.d.ts +5 -0
- package/Utils/Rum/PathInSentence.js +46 -0
- package/Utils/Rum/PathInSentence.mjs +6 -0
- package/Utils/Rum/UrlScrubber.d.mts +4 -0
- package/Utils/Rum/UrlScrubber.d.ts +4 -0
- package/Utils/Rum/UrlScrubber.js +143 -3
- package/Utils/Rum/UserFlow.d.mts +1 -1
- package/Utils/Rum/UserFlow.d.ts +1 -1
- package/Utils/Rum/UserFlow.js +180 -25
- package/Utils/Rum/UserFlow.mjs +1 -1
- package/Utils/Runbook/RunbookStepsSignature.d.mts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.d.ts +3 -0
- package/Utils/Runbook/RunbookStepsSignature.js +30 -0
- package/Utils/Runbook/RunbookStepsSignature.mjs +3 -0
- package/Utils/ScheduledMaintenanceStart.d.mts +3 -0
- package/Utils/ScheduledMaintenanceStart.d.ts +3 -0
- package/Utils/ScheduledMaintenanceStart.js +9 -0
- package/Utils/Schema/ModelSchema.js +10 -1
- package/Utils/Schema/TypeSchemas.js +6 -0
- package/Utils/Slo/SloDuration.d.mts +5 -2
- package/Utils/Slo/SloDuration.d.ts +5 -2
- package/Utils/Slo/SloDuration.js +11 -6
- package/Utils/Slo/SloHealth.js +1 -1
- package/Utils/StateOrder.js +1 -4
- package/Utils/StateTimeline/StateTimelineRowDelete.js +1 -1
- package/Utils/Telemetry/HeartbeatAvailability.d.mts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.d.ts +4 -0
- package/Utils/Telemetry/HeartbeatAvailability.js +118 -26
- package/Utils/Uptime/DayUptimeGraphUtil.js +2 -2
- package/Utils/Uptime/UptimeMaintenanceUtil.js +2 -1
- package/Utils/ValueFormatter.d.mts +8 -6
- package/Utils/ValueFormatter.d.ts +8 -6
- package/Utils/ValueFormatter.js +145 -0
- package/package.json +1 -1
|
@@ -1,25 +1,126 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forEachBracketedLabel = exports.getLinkReferenceDefinitions = exports.normalizeLinkLabel = void 0;
|
|
3
|
+
exports.forEachBracketedLabel = exports.getLinkReferenceDefinitions = exports.normalizeLinkLabel = exports.MAX_DEFINITION_NESTING_DEPTH = void 0;
|
|
4
4
|
const RegExpCharacterClasses_1 = require("../RegExpCharacterClasses");
|
|
5
|
+
/*
|
|
6
|
+
* How many block quotes and list items deep a definition is still found:
|
|
7
|
+
* the depth past which an email holds Markdown back from marked
|
|
8
|
+
* (SLOW_MARKDOWN_MAX_NESTING_DEPTH, Utils/Markdown/SlowMarkdown), where a
|
|
9
|
+
* definition is text.
|
|
10
|
+
*/
|
|
11
|
+
exports.MAX_DEFINITION_NESTING_DEPTH = 16;
|
|
5
12
|
const SPACE = 0x20;
|
|
6
13
|
const TAB = 0x09;
|
|
7
14
|
const LINE_FEED = 0x0a;
|
|
15
|
+
const EXCLAMATION_MARK = 0x21;
|
|
8
16
|
const DOUBLE_QUOTE = 0x22;
|
|
9
17
|
const HASH = 0x23;
|
|
10
18
|
const SINGLE_QUOTE = 0x27;
|
|
11
19
|
const OPEN_PARENTHESIS = 0x28;
|
|
20
|
+
const CLOSE_PARENTHESIS = 0x29;
|
|
12
21
|
const ASTERISK = 0x2a;
|
|
22
|
+
const PLUS = 0x2b;
|
|
13
23
|
const DASH = 0x2d;
|
|
24
|
+
const DOT = 0x2e;
|
|
25
|
+
const SLASH = 0x2f;
|
|
26
|
+
const DIGIT_ONE = 0x31;
|
|
14
27
|
const COLON = 0x3a;
|
|
15
28
|
const LESS_THAN = 0x3c;
|
|
29
|
+
const EQUALS = 0x3d;
|
|
16
30
|
const GREATER_THAN = 0x3e;
|
|
31
|
+
const QUESTION_MARK = 0x3f;
|
|
17
32
|
const OPEN_BRACKET = 0x5b;
|
|
18
33
|
const BACKSLASH = 0x5c;
|
|
19
34
|
const CLOSE_BRACKET = 0x5d;
|
|
20
35
|
const UNDERSCORE = 0x5f;
|
|
21
36
|
const BACKTICK = 0x60;
|
|
37
|
+
const PIPE = 0x7c;
|
|
22
38
|
const TILDE = 0x7e;
|
|
39
|
+
const LOWER_X = 0x78;
|
|
40
|
+
const UPPER_X = 0x58;
|
|
41
|
+
const LINE_SEPARATOR = String.fromCharCode(0x2028);
|
|
42
|
+
const PARAGRAPH_SEPARATOR = String.fromCharCode(0x2029);
|
|
43
|
+
/*
|
|
44
|
+
* The tags an HTML block of marked's sixth kind opens with (its "html"
|
|
45
|
+
* rule, which reads them whatever their case). Written in lower case, they
|
|
46
|
+
* also end a paragraph.
|
|
47
|
+
*/
|
|
48
|
+
const BLOCK_TAG_NAMES = new Set([
|
|
49
|
+
"address",
|
|
50
|
+
"article",
|
|
51
|
+
"aside",
|
|
52
|
+
"base",
|
|
53
|
+
"basefont",
|
|
54
|
+
"blockquote",
|
|
55
|
+
"body",
|
|
56
|
+
"caption",
|
|
57
|
+
"center",
|
|
58
|
+
"col",
|
|
59
|
+
"colgroup",
|
|
60
|
+
"dd",
|
|
61
|
+
"details",
|
|
62
|
+
"dialog",
|
|
63
|
+
"dir",
|
|
64
|
+
"div",
|
|
65
|
+
"dl",
|
|
66
|
+
"dt",
|
|
67
|
+
"fieldset",
|
|
68
|
+
"figcaption",
|
|
69
|
+
"figure",
|
|
70
|
+
"footer",
|
|
71
|
+
"form",
|
|
72
|
+
"frame",
|
|
73
|
+
"frameset",
|
|
74
|
+
"h1",
|
|
75
|
+
"h2",
|
|
76
|
+
"h3",
|
|
77
|
+
"h4",
|
|
78
|
+
"h5",
|
|
79
|
+
"h6",
|
|
80
|
+
"head",
|
|
81
|
+
"header",
|
|
82
|
+
"hr",
|
|
83
|
+
"html",
|
|
84
|
+
"iframe",
|
|
85
|
+
"legend",
|
|
86
|
+
"li",
|
|
87
|
+
"link",
|
|
88
|
+
"main",
|
|
89
|
+
"menu",
|
|
90
|
+
"menuitem",
|
|
91
|
+
"meta",
|
|
92
|
+
"nav",
|
|
93
|
+
"noframes",
|
|
94
|
+
"ol",
|
|
95
|
+
"optgroup",
|
|
96
|
+
"option",
|
|
97
|
+
"p",
|
|
98
|
+
"param",
|
|
99
|
+
"search",
|
|
100
|
+
"section",
|
|
101
|
+
"summary",
|
|
102
|
+
"table",
|
|
103
|
+
"tbody",
|
|
104
|
+
"td",
|
|
105
|
+
"tfoot",
|
|
106
|
+
"th",
|
|
107
|
+
"thead",
|
|
108
|
+
"title",
|
|
109
|
+
"tr",
|
|
110
|
+
"track",
|
|
111
|
+
"ul",
|
|
112
|
+
]);
|
|
113
|
+
const LONGEST_BLOCK_TAG_NAME = 10;
|
|
114
|
+
/*
|
|
115
|
+
* The tags an HTML block of the first kind opens with, which runs to the
|
|
116
|
+
* line of its closing tag. Written in lower case, they end a paragraph too.
|
|
117
|
+
*/
|
|
118
|
+
const RAW_TEXT_TAG_NAMES = [
|
|
119
|
+
"script",
|
|
120
|
+
"pre",
|
|
121
|
+
"style",
|
|
122
|
+
"textarea",
|
|
123
|
+
];
|
|
23
124
|
/*
|
|
24
125
|
* A label as marked matches it: in lower case, each run of white space one
|
|
25
126
|
* space. Not trimmed - "[ home ]" is not "[home]" to marked - and escapes
|
|
@@ -67,17 +168,29 @@ const skipSpaces = (text, index) => {
|
|
|
67
168
|
}
|
|
68
169
|
return at;
|
|
69
170
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
171
|
+
// After the up to three spaces from `index`.
|
|
172
|
+
const skipUpToThreeSpaces = (text, index) => {
|
|
173
|
+
let at = index;
|
|
174
|
+
while (at - index < 3 && text.charCodeAt(at) === SPACE) {
|
|
175
|
+
at++;
|
|
176
|
+
}
|
|
177
|
+
return at;
|
|
178
|
+
};
|
|
179
|
+
// After the line breaks from `index`.
|
|
180
|
+
const skipLineBreaks = (text, index) => {
|
|
181
|
+
let at = index;
|
|
182
|
+
while (text.charCodeAt(at) === LINE_FEED) {
|
|
78
183
|
at++;
|
|
79
184
|
}
|
|
80
|
-
return
|
|
185
|
+
return at;
|
|
186
|
+
};
|
|
187
|
+
const isSpaceOrTab = (code) => {
|
|
188
|
+
return code === SPACE || code === TAB;
|
|
189
|
+
};
|
|
190
|
+
// Where the line `from` is on ends: at its line break, or the end of the text.
|
|
191
|
+
const getLineEnd = (text, from) => {
|
|
192
|
+
const lineBreak = text.indexOf("\n", from);
|
|
193
|
+
return lineBreak === -1 ? text.length : lineBreak;
|
|
81
194
|
};
|
|
82
195
|
/*
|
|
83
196
|
* Where the line ends if only spaces come after `index` on it: its line
|
|
@@ -207,13 +320,13 @@ const readAfterDestination = (text, definition, destinationEnd, finders) => {
|
|
|
207
320
|
if (afterSpaces > destinationEnd ||
|
|
208
321
|
text.charCodeAt(afterSpaces) === LINE_FEED) {
|
|
209
322
|
const titleStart = text.charCodeAt(afterSpaces) === LINE_FEED
|
|
210
|
-
?
|
|
323
|
+
? skipSpaces(text, afterSpaces + 1)
|
|
211
324
|
: afterSpaces;
|
|
212
325
|
const titleEnd = readTitle(text, titleStart, finders);
|
|
213
326
|
if (titleEnd !== -1) {
|
|
214
327
|
return {
|
|
215
328
|
definition: Object.assign(Object.assign({}, definition), { destinationEnd: destinationEnd, end: titleEnd }),
|
|
216
|
-
next: nextLineStart(text, lineEndAfterSpaces(text, titleEnd)),
|
|
329
|
+
next: skipLineBreaks(text, nextLineStart(text, lineEndAfterSpaces(text, titleEnd))),
|
|
217
330
|
};
|
|
218
331
|
}
|
|
219
332
|
}
|
|
@@ -223,7 +336,7 @@ const readAfterDestination = (text, definition, destinationEnd, finders) => {
|
|
|
223
336
|
}
|
|
224
337
|
return {
|
|
225
338
|
definition: Object.assign(Object.assign({}, definition), { destinationEnd: destinationEnd, end: destinationEnd }),
|
|
226
|
-
next: nextLineStart(text, lineEnd),
|
|
339
|
+
next: skipLineBreaks(text, nextLineStart(text, lineEnd)),
|
|
227
340
|
};
|
|
228
341
|
};
|
|
229
342
|
/*
|
|
@@ -251,12 +364,12 @@ const findLabelEnd = (text, labelStart) => {
|
|
|
251
364
|
}
|
|
252
365
|
return -1;
|
|
253
366
|
};
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
367
|
+
/*
|
|
368
|
+
* The definition that starts at `blockStart` of a text whose lines start
|
|
369
|
+
* with spaces, never tabs (a BlockLevel's text), if one starts there.
|
|
370
|
+
*/
|
|
371
|
+
const readDefinition = (text, blockStart, finders) => {
|
|
372
|
+
const at = skipUpToThreeSpaces(text, blockStart);
|
|
260
373
|
if (text.charCodeAt(at) !== OPEN_BRACKET) {
|
|
261
374
|
return null;
|
|
262
375
|
}
|
|
@@ -269,13 +382,13 @@ const readDefinition = (text, lineStart, finders) => {
|
|
|
269
382
|
}
|
|
270
383
|
let destinationStart = skipSpaces(text, labelEnd + 2);
|
|
271
384
|
if (text.charCodeAt(destinationStart) === LINE_FEED) {
|
|
272
|
-
destinationStart =
|
|
385
|
+
destinationStart = skipSpaces(text, destinationStart + 1);
|
|
273
386
|
}
|
|
274
387
|
if (destinationStart >= text.length) {
|
|
275
388
|
return null;
|
|
276
389
|
}
|
|
277
390
|
const definition = {
|
|
278
|
-
start:
|
|
391
|
+
start: blockStart,
|
|
279
392
|
labelStart: labelStart,
|
|
280
393
|
labelEnd: labelEnd,
|
|
281
394
|
label: (0, exports.normalizeLinkLabel)(text.slice(labelStart, labelEnd)),
|
|
@@ -307,67 +420,344 @@ const readDefinition = (text, lineStart, finders) => {
|
|
|
307
420
|
}
|
|
308
421
|
return readAfterDestination(text, definition, destinationEnd, finders);
|
|
309
422
|
};
|
|
423
|
+
// Where `part` is in `text`, in order.
|
|
424
|
+
const findEvery = (text, part) => {
|
|
425
|
+
const found = [];
|
|
426
|
+
for (let at = text.indexOf(part); at !== -1; at = text.indexOf(part, at + 1)) {
|
|
427
|
+
found.push(at);
|
|
428
|
+
}
|
|
429
|
+
return found;
|
|
430
|
+
};
|
|
431
|
+
/*
|
|
432
|
+
* Where the line and paragraph separators (U+2028, U+2029) of a level's
|
|
433
|
+
* text are, in order: found the first time they are asked.
|
|
434
|
+
*/
|
|
435
|
+
const NO_POSITIONS = [];
|
|
436
|
+
const getSeparators = (level) => {
|
|
437
|
+
if (level.separators === null) {
|
|
438
|
+
const text = level.text;
|
|
439
|
+
// Most texts have none: a level of each list item is made.
|
|
440
|
+
level.separators =
|
|
441
|
+
text.indexOf(LINE_SEPARATOR) === -1 &&
|
|
442
|
+
text.indexOf(PARAGRAPH_SEPARATOR) === -1
|
|
443
|
+
? NO_POSITIONS
|
|
444
|
+
: findEvery(text, LINE_SEPARATOR)
|
|
445
|
+
.concat(findEvery(text, PARAGRAPH_SEPARATOR))
|
|
446
|
+
.sort((one, other) => {
|
|
447
|
+
return one - other;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
return level.separators;
|
|
451
|
+
};
|
|
452
|
+
// The index of the first of the ordered `positions` at or after `from`, by halves.
|
|
453
|
+
const firstAtOrAfter = (positions, from) => {
|
|
454
|
+
let low = 0;
|
|
455
|
+
let high = positions.length;
|
|
456
|
+
while (low < high) {
|
|
457
|
+
const middle = Math.floor((low + high) / 2);
|
|
458
|
+
if (positions[middle] < from) {
|
|
459
|
+
low = middle + 1;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
high = middle;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return low;
|
|
466
|
+
};
|
|
467
|
+
// The piece of `lines` that `position` is in: the last to start at or before it.
|
|
468
|
+
const getLevelLine = (lines, position) => {
|
|
469
|
+
const starts = lines.starts;
|
|
470
|
+
for (let line = lines.cursor; line < Math.min(lines.cursor + 2, starts.length); line++) {
|
|
471
|
+
if (starts[line] <= position &&
|
|
472
|
+
(line + 1 >= starts.length || starts[line + 1] > position)) {
|
|
473
|
+
lines.cursor = line;
|
|
474
|
+
return line;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// By halves, when it is further on or back.
|
|
478
|
+
let low = 0;
|
|
479
|
+
let high = starts.length - 1;
|
|
480
|
+
while (low < high) {
|
|
481
|
+
const middle = Math.ceil((low + high) / 2);
|
|
482
|
+
if (starts[middle] <= position) {
|
|
483
|
+
low = middle;
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
high = middle - 1;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
lines.cursor = low;
|
|
490
|
+
return low;
|
|
491
|
+
};
|
|
492
|
+
/*
|
|
493
|
+
* Where a position of the level's text is in the whole text: one at or
|
|
494
|
+
* after the first character of its line that is neither a space nor a tab,
|
|
495
|
+
* and not among the spaces marked makes of tabs after a separator.
|
|
496
|
+
*/
|
|
497
|
+
const toWhole = (level, position) => {
|
|
498
|
+
if (level.lines === null) {
|
|
499
|
+
return position;
|
|
500
|
+
}
|
|
501
|
+
const line = getLevelLine(level.lines, position);
|
|
502
|
+
return (level.lines.wholeSolidStarts[line] +
|
|
503
|
+
(position - level.lines.solidStarts[line]));
|
|
504
|
+
};
|
|
505
|
+
// Where the line of the whole text that `position` is on starts.
|
|
506
|
+
const getWholeLineStart = (level, position) => {
|
|
507
|
+
if (level.lines === null) {
|
|
508
|
+
return level.text.lastIndexOf("\n", position - 1) + 1;
|
|
509
|
+
}
|
|
510
|
+
return level.lines.wholeLineStarts[getLevelLine(level.lines, position)];
|
|
511
|
+
};
|
|
512
|
+
/*
|
|
513
|
+
* After the run of `code` in text[at, to): where the first other character
|
|
514
|
+
* is, or `to`.
|
|
515
|
+
*/
|
|
516
|
+
const skipRun = (text, at, to, code) => {
|
|
517
|
+
let end = at;
|
|
518
|
+
while (end < to && text.charCodeAt(end) === code) {
|
|
519
|
+
end++;
|
|
520
|
+
}
|
|
521
|
+
return end;
|
|
522
|
+
};
|
|
310
523
|
/*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
524
|
+
* Adds to `made`, the lines of a level made from `source`, a piece that
|
|
525
|
+
* starts at `start` and is the whole text's from `solid` - `sourceSolid` in
|
|
526
|
+
* the source - on.
|
|
313
527
|
*/
|
|
314
|
-
const
|
|
315
|
-
|
|
528
|
+
const addPiece = (made, source, start, wholeLineStart, solid, sourceSolid) => {
|
|
529
|
+
made.starts.push(start);
|
|
530
|
+
made.wholeLineStarts.push(wholeLineStart);
|
|
531
|
+
made.solidStarts.push(solid);
|
|
532
|
+
made.wholeSolidStarts.push(toWhole(source, sourceSolid));
|
|
316
533
|
};
|
|
317
534
|
/*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
535
|
+
* The level of `lines` of `source`, as blockTokens makes it: the tabs that
|
|
536
|
+
* start each line made four spaces each, and so the tabs that come right
|
|
537
|
+
* after a line or paragraph separator, spaces before them or none - and, in
|
|
538
|
+
* a block quote (`stripsQuoteMarkers`), a quote's marker right after such a
|
|
539
|
+
* separator stripped first, spaces before it and a space or a tab after it,
|
|
540
|
+
* as marked strips each line's.
|
|
320
541
|
*/
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
|
|
542
|
+
const makeLevel = (source, lines, depth, stripsQuoteMarkers) => {
|
|
543
|
+
const text = source.text;
|
|
544
|
+
const separators = getSeparators(source);
|
|
545
|
+
let separator = lines.length > 0 ? firstAtOrAfter(separators, lines[0].from) : 0;
|
|
546
|
+
const pieces = [];
|
|
547
|
+
const made = {
|
|
548
|
+
starts: [],
|
|
549
|
+
wholeLineStarts: [],
|
|
550
|
+
solidStarts: [],
|
|
551
|
+
wholeSolidStarts: [],
|
|
552
|
+
cursor: 0,
|
|
553
|
+
};
|
|
554
|
+
let length = 0;
|
|
555
|
+
for (let index = 0; index < lines.length; index++) {
|
|
556
|
+
const line = lines[index];
|
|
557
|
+
if (index > 0) {
|
|
558
|
+
pieces.push("\n");
|
|
559
|
+
length++;
|
|
560
|
+
}
|
|
561
|
+
let spacesEnd = line.from;
|
|
562
|
+
while (spacesEnd < line.to && text.charCodeAt(spacesEnd) === SPACE) {
|
|
563
|
+
spacesEnd++;
|
|
564
|
+
}
|
|
565
|
+
let tabsEnd = spacesEnd;
|
|
566
|
+
while (tabsEnd < line.to && text.charCodeAt(tabsEnd) === TAB) {
|
|
567
|
+
tabsEnd++;
|
|
568
|
+
}
|
|
569
|
+
let spaces = line.lead;
|
|
570
|
+
let copiedFrom = line.from;
|
|
571
|
+
if (tabsEnd > spacesEnd) {
|
|
572
|
+
spaces += spacesEnd - line.from + 4 * (tabsEnd - spacesEnd);
|
|
573
|
+
copiedFrom = tabsEnd;
|
|
574
|
+
}
|
|
575
|
+
let solid = copiedFrom;
|
|
576
|
+
while (solid < line.to && isSpaceOrTab(text.charCodeAt(solid))) {
|
|
577
|
+
solid++;
|
|
578
|
+
}
|
|
579
|
+
const wholeLineStart = getWholeLineStart(source, line.from);
|
|
580
|
+
addPiece(made, source, length, wholeLineStart, length + spaces + (solid - copiedFrom), solid);
|
|
581
|
+
if (spaces > 0) {
|
|
582
|
+
pieces.push(" ".repeat(spaces));
|
|
583
|
+
length += spaces;
|
|
584
|
+
}
|
|
585
|
+
// The rest of the line, and what marked makes of it after a separator.
|
|
586
|
+
let copyFrom = copiedFrom;
|
|
587
|
+
while (separator < separators.length &&
|
|
588
|
+
separators[separator] < copiedFrom) {
|
|
589
|
+
separator++;
|
|
590
|
+
}
|
|
591
|
+
for (; separator < separators.length && separators[separator] < line.to; separator++) {
|
|
592
|
+
const after = separators[separator] + 1;
|
|
593
|
+
let rest = after;
|
|
594
|
+
if (stripsQuoteMarkers) {
|
|
595
|
+
const marker = skipRun(text, after, line.to, SPACE);
|
|
596
|
+
if (marker < line.to && text.charCodeAt(marker) === GREATER_THAN) {
|
|
597
|
+
rest = marker + 1;
|
|
598
|
+
if (rest < line.to && isSpaceOrTab(text.charCodeAt(rest))) {
|
|
599
|
+
rest++;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const restSpacesEnd = skipRun(text, rest, line.to, SPACE);
|
|
604
|
+
const restTabsEnd = skipRun(text, restSpacesEnd, line.to, TAB);
|
|
605
|
+
const restSpaces = restSpacesEnd - rest + 4 * (restTabsEnd - restSpacesEnd);
|
|
606
|
+
/*
|
|
607
|
+
* Up to the separator's end as it is, then its spaces and its tabs as
|
|
608
|
+
* spaces, and a piece from the first character after them: from there
|
|
609
|
+
* the line is the whole text's again - after the spaces of tabs the
|
|
610
|
+
* level it is made from made spaces too, which this piece reads past.
|
|
611
|
+
*/
|
|
612
|
+
pieces.push(text.slice(copyFrom, after));
|
|
613
|
+
length += after - copyFrom;
|
|
614
|
+
if (restSpaces > 0) {
|
|
615
|
+
pieces.push(" ".repeat(restSpaces));
|
|
616
|
+
length += restSpaces;
|
|
617
|
+
}
|
|
618
|
+
copyFrom = restTabsEnd;
|
|
619
|
+
addPiece(made, source, length, wholeLineStart, length, copyFrom);
|
|
620
|
+
}
|
|
621
|
+
if (line.to > copyFrom) {
|
|
622
|
+
pieces.push(text.slice(copyFrom, line.to));
|
|
623
|
+
length += line.to - copyFrom;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
text: pieces.join(""),
|
|
628
|
+
depth: depth,
|
|
629
|
+
lines: made,
|
|
630
|
+
separators: null,
|
|
631
|
+
};
|
|
324
632
|
};
|
|
633
|
+
/*
|
|
634
|
+
* The whole text as a level: a copy only when a line of it starts with a
|
|
635
|
+
* tab, or a separator comes right before tabs, spaces before them or none.
|
|
636
|
+
*/
|
|
637
|
+
const getWholeLevel = (text) => {
|
|
638
|
+
const whole = {
|
|
639
|
+
text: text,
|
|
640
|
+
depth: 0,
|
|
641
|
+
lines: null,
|
|
642
|
+
separators: null,
|
|
643
|
+
};
|
|
644
|
+
if (text.indexOf("\t") === -1) {
|
|
645
|
+
return whole;
|
|
646
|
+
}
|
|
647
|
+
const lines = [];
|
|
648
|
+
let startsWithTab = false;
|
|
649
|
+
for (let lineStart = 0; lineStart <= text.length;) {
|
|
650
|
+
const lineEnd = getLineEnd(text, lineStart);
|
|
651
|
+
startsWithTab =
|
|
652
|
+
startsWithTab || text.charCodeAt(skipSpaces(text, lineStart)) === TAB;
|
|
653
|
+
lines.push({ lead: 0, from: lineStart, to: lineEnd });
|
|
654
|
+
lineStart = lineEnd + 1;
|
|
655
|
+
}
|
|
656
|
+
for (const separator of getSeparators(whole)) {
|
|
657
|
+
startsWithTab =
|
|
658
|
+
startsWithTab || text.charCodeAt(skipSpaces(text, separator + 1)) === TAB;
|
|
659
|
+
}
|
|
660
|
+
return startsWithTab ? makeLevel(whole, lines, 0, false) : whole;
|
|
661
|
+
};
|
|
662
|
+
const startReading = (level, definitions) => {
|
|
663
|
+
const text = level.text;
|
|
664
|
+
return {
|
|
665
|
+
level: level,
|
|
666
|
+
definitions: definitions,
|
|
667
|
+
finders: null,
|
|
668
|
+
nextDefinitionColon: remembered((from) => {
|
|
669
|
+
return text.indexOf("]:", from);
|
|
670
|
+
}),
|
|
671
|
+
nextBlankLineBreak: remembered((from) => {
|
|
672
|
+
for (let lineBreak = text.indexOf("\n", from); lineBreak !== -1; lineBreak = text.indexOf("\n", lineBreak + 1)) {
|
|
673
|
+
if (text.charCodeAt(skipSpaces(text, lineBreak + 1)) === LINE_FEED) {
|
|
674
|
+
return lineBreak;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return -1;
|
|
678
|
+
}),
|
|
679
|
+
setextFrom: -1,
|
|
680
|
+
setextStop: -1,
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
const getFinders = (reading) => {
|
|
684
|
+
var _a;
|
|
685
|
+
reading.finders = (_a = reading.finders) !== null && _a !== void 0 ? _a : getTitleFinders(reading.level.text);
|
|
686
|
+
return reading.finders;
|
|
687
|
+
};
|
|
688
|
+
/*
|
|
689
|
+
* The first line or paragraph separator (U+2028, U+2029) in text[from,
|
|
690
|
+
* to), or -1: what "." does not match either, so a line that holds one is
|
|
691
|
+
* no heading, table row or setext heading's line to marked.
|
|
692
|
+
*/
|
|
693
|
+
const findSeparator = (reading, from, to) => {
|
|
694
|
+
const separators = getSeparators(reading.level);
|
|
695
|
+
const first = separators[firstAtOrAfter(separators, from)];
|
|
696
|
+
return first !== undefined && first < to ? first : -1;
|
|
697
|
+
};
|
|
698
|
+
/*
|
|
699
|
+
* Whether a definition's "]:" is in text[from, to): what a quote or a list
|
|
700
|
+
* item must hold to define anything.
|
|
701
|
+
*/
|
|
702
|
+
const holdsDefinitionColon = (reading, from, to) => {
|
|
703
|
+
const colon = reading.nextDefinitionColon(from);
|
|
704
|
+
return colon !== -1 && colon < to;
|
|
705
|
+
};
|
|
706
|
+
/*
|
|
707
|
+
* THE SHAPES OF LINES MARKED'S BLOCK RULES READ.
|
|
708
|
+
*
|
|
709
|
+
* Each is asked of a line of a level, from `at` - a line's start, or where
|
|
710
|
+
* an HTML block of the third to fifth kind ended on its line.
|
|
711
|
+
*/
|
|
325
712
|
/*
|
|
326
713
|
* Whether the line is a thematic break: up to three spaces, then three or
|
|
327
714
|
* more of one of "-", "_" and "*", with nothing but spaces and tabs between
|
|
328
715
|
* and after them.
|
|
329
716
|
*/
|
|
330
717
|
const isThematicBreak = (text, lineStart, lineEnd) => {
|
|
331
|
-
|
|
332
|
-
while (at - lineStart < 3 && text.charCodeAt(at) === SPACE) {
|
|
333
|
-
at++;
|
|
334
|
-
}
|
|
718
|
+
const at = skipUpToThreeSpaces(text, lineStart);
|
|
335
719
|
const mark = text.charCodeAt(at);
|
|
336
720
|
if (mark !== DASH && mark !== UNDERSCORE && mark !== ASTERISK) {
|
|
337
721
|
return false;
|
|
338
722
|
}
|
|
339
723
|
let marks = 0;
|
|
340
|
-
for (
|
|
341
|
-
const code = text.charCodeAt(
|
|
724
|
+
for (let index = at; index < lineEnd; index++) {
|
|
725
|
+
const code = text.charCodeAt(index);
|
|
342
726
|
if (code === mark) {
|
|
343
727
|
marks++;
|
|
344
728
|
}
|
|
345
|
-
else if (code
|
|
729
|
+
else if (!isSpaceOrTab(code)) {
|
|
346
730
|
return false;
|
|
347
731
|
}
|
|
348
732
|
}
|
|
349
733
|
return marks >= 3;
|
|
350
734
|
};
|
|
351
735
|
/*
|
|
352
|
-
* Whether
|
|
353
|
-
* then white space or the end of the text
|
|
354
|
-
* separator (U+2028, U+2029) on the line, which marked's heading rule reads
|
|
355
|
-
* with ".": such a line is text (`holdsSeparator`).
|
|
736
|
+
* Whether an ATX heading starts the line: up to three spaces, one to six
|
|
737
|
+
* "#", then white space or the end of the text. What ends a paragraph.
|
|
356
738
|
*/
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let hashes = 0;
|
|
363
|
-
while (text.charCodeAt(at + hashes) === HASH) {
|
|
364
|
-
hashes++;
|
|
739
|
+
const startsAtxHeading = (text, at) => {
|
|
740
|
+
const hashes = skipUpToThreeSpaces(text, at);
|
|
741
|
+
let end = hashes;
|
|
742
|
+
while (text.charCodeAt(end) === HASH) {
|
|
743
|
+
end++;
|
|
365
744
|
}
|
|
366
|
-
return (hashes >= 1 &&
|
|
367
|
-
hashes <= 6 &&
|
|
368
|
-
(
|
|
369
|
-
|
|
370
|
-
|
|
745
|
+
return (end - hashes >= 1 &&
|
|
746
|
+
end - hashes <= 6 &&
|
|
747
|
+
(end >= text.length || (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(end))));
|
|
748
|
+
};
|
|
749
|
+
/*
|
|
750
|
+
* Whether the line is an ATX heading: one starts it, and no line or
|
|
751
|
+
* paragraph separator is on it - marked's heading rule reads the line with
|
|
752
|
+
* ".", and such a line is text.
|
|
753
|
+
*/
|
|
754
|
+
const isAtxHeading = (reading, at, lineEnd) => {
|
|
755
|
+
return (startsAtxHeading(reading.level.text, at) &&
|
|
756
|
+
findSeparator(reading, at, lineEnd) === -1);
|
|
757
|
+
};
|
|
758
|
+
// Whether a block quote starts the line: up to three spaces, then ">".
|
|
759
|
+
const startsBlockQuote = (text, at) => {
|
|
760
|
+
return text.charCodeAt(skipUpToThreeSpaces(text, at)) === GREATER_THAN;
|
|
371
761
|
};
|
|
372
762
|
/*
|
|
373
763
|
* The fence the line opens, as marked's "fences" rule reads it: up to three
|
|
@@ -375,10 +765,7 @@ const isAtxHeading = (text, lineStart, lineEnd, holdsSeparator) => {
|
|
|
375
765
|
* line, or three or more tildes. null when it opens none.
|
|
376
766
|
*/
|
|
377
767
|
const getOpeningFence = (text, lineStart, lineEnd) => {
|
|
378
|
-
|
|
379
|
-
while (at - lineStart < 3 && text.charCodeAt(at) === SPACE) {
|
|
380
|
-
at++;
|
|
381
|
-
}
|
|
768
|
+
const at = skipUpToThreeSpaces(text, lineStart);
|
|
382
769
|
const code = text.charCodeAt(at);
|
|
383
770
|
if (code !== BACKTICK && code !== TILDE) {
|
|
384
771
|
return null;
|
|
@@ -391,9 +778,10 @@ const getOpeningFence = (text, lineStart, lineEnd) => {
|
|
|
391
778
|
return null;
|
|
392
779
|
}
|
|
393
780
|
if (code === BACKTICK) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
781
|
+
for (let index = runEnd; index < lineEnd; index++) {
|
|
782
|
+
if (text.charCodeAt(index) === BACKTICK) {
|
|
783
|
+
return null;
|
|
784
|
+
}
|
|
397
785
|
}
|
|
398
786
|
}
|
|
399
787
|
return { code: code, length: runEnd - at };
|
|
@@ -403,10 +791,7 @@ const getOpeningFence = (text, lineStart, lineEnd) => {
|
|
|
403
791
|
* more backticks or tildes, then spaces alone.
|
|
404
792
|
*/
|
|
405
793
|
const closesFence = (text, lineStart, lineEnd, fence) => {
|
|
406
|
-
let at = lineStart;
|
|
407
|
-
while (at - lineStart < 3 && text.charCodeAt(at) === SPACE) {
|
|
408
|
-
at++;
|
|
409
|
-
}
|
|
794
|
+
let at = skipUpToThreeSpaces(text, lineStart);
|
|
410
795
|
for (let index = 0; index < fence.length; index++) {
|
|
411
796
|
if (text.charCodeAt(at + index) !== fence.code) {
|
|
412
797
|
return false;
|
|
@@ -420,88 +805,1065 @@ const closesFence = (text, lineStart, lineEnd, fence) => {
|
|
|
420
805
|
return skipSpaces(text, at) >= lineEnd;
|
|
421
806
|
};
|
|
422
807
|
/*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
808
|
+
* Whether a list's bullet that ends a paragraph starts the line: up to three
|
|
809
|
+
* spaces, "*", "+", "-", "1." or "1)", then a space.
|
|
425
810
|
*/
|
|
426
|
-
const
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
811
|
+
const startsListInParagraph = (text, at) => {
|
|
812
|
+
const bullet = skipUpToThreeSpaces(text, at);
|
|
813
|
+
const code = text.charCodeAt(bullet);
|
|
814
|
+
let after = bullet + 1;
|
|
815
|
+
if (code === DIGIT_ONE) {
|
|
816
|
+
const delimiter = text.charCodeAt(bullet + 1);
|
|
817
|
+
if (delimiter !== DOT && delimiter !== CLOSE_PARENTHESIS) {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
after = bullet + 2;
|
|
821
|
+
}
|
|
822
|
+
else if (code !== ASTERISK && code !== PLUS && code !== DASH) {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
return text.charCodeAt(after) === SPACE;
|
|
826
|
+
};
|
|
827
|
+
/*
|
|
828
|
+
* Which of the lower case `names` the text at `at` starts with - in any
|
|
829
|
+
* case when `anyCase` - or null when none.
|
|
830
|
+
*/
|
|
831
|
+
const startsWithAny = (text, at, names, anyCase) => {
|
|
832
|
+
for (const name of names) {
|
|
833
|
+
const written = text.slice(at, at + name.length);
|
|
834
|
+
if ((anyCase ? written.toLowerCase() : written) === name) {
|
|
835
|
+
return name;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return null;
|
|
839
|
+
};
|
|
840
|
+
/*
|
|
841
|
+
* After a block tag opening or closing at "<" - `</?(tag)(?: +|\n|\/?>)` of
|
|
842
|
+
* marked's "html" rule, which reads it whatever its case, and of its
|
|
843
|
+
* paragraph rule, which reads it in lower case alone (`anyCase` false). -1
|
|
844
|
+
* when none is there.
|
|
845
|
+
*/
|
|
846
|
+
const readBlockTag = (text, open, anyCase) => {
|
|
847
|
+
let name = open + 1;
|
|
848
|
+
if (text.charCodeAt(name) === SLASH) {
|
|
849
|
+
name++;
|
|
850
|
+
}
|
|
851
|
+
let nameEnd = name;
|
|
852
|
+
while (nameEnd - name <= LONGEST_BLOCK_TAG_NAME &&
|
|
853
|
+
((0, RegExpCharacterClasses_1.isAsciiLetterCode)(text.charCodeAt(nameEnd)) ||
|
|
854
|
+
(0, RegExpCharacterClasses_1.isDigitCode)(text.charCodeAt(nameEnd)))) {
|
|
855
|
+
nameEnd++;
|
|
856
|
+
}
|
|
857
|
+
const written = text.slice(name, nameEnd);
|
|
858
|
+
if (nameEnd - name > LONGEST_BLOCK_TAG_NAME ||
|
|
859
|
+
!BLOCK_TAG_NAMES.has(anyCase ? written.toLowerCase() : written)) {
|
|
860
|
+
return -1;
|
|
861
|
+
}
|
|
862
|
+
const after = text.charCodeAt(nameEnd);
|
|
863
|
+
if (after === SPACE) {
|
|
864
|
+
return skipSpaces(text, nameEnd);
|
|
865
|
+
}
|
|
866
|
+
if (after === LINE_FEED || after === GREATER_THAN) {
|
|
867
|
+
return nameEnd + 1;
|
|
868
|
+
}
|
|
869
|
+
if (after === SLASH && text.charCodeAt(nameEnd + 1) === GREATER_THAN) {
|
|
870
|
+
return nameEnd + 2;
|
|
871
|
+
}
|
|
872
|
+
return -1;
|
|
873
|
+
};
|
|
874
|
+
/*
|
|
875
|
+
* Whether HTML that ends a paragraph starts the line - right at its start,
|
|
876
|
+
* in lower case: a block tag, or "<script", "<pre", "<style", "<textarea"
|
|
877
|
+
* or "<!--".
|
|
878
|
+
*/
|
|
879
|
+
const startsHtmlInParagraph = (text, at) => {
|
|
880
|
+
if (text.charCodeAt(at) !== LESS_THAN) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
return (startsWithAny(text, at + 1, RAW_TEXT_TAG_NAMES, false) !== null ||
|
|
884
|
+
text.startsWith("!--", at + 1) ||
|
|
885
|
+
readBlockTag(text, at, false) !== -1);
|
|
886
|
+
};
|
|
887
|
+
/*
|
|
888
|
+
* After a cell of a table's delimiter row at `at` - ":?-+:? *" - or -1
|
|
889
|
+
* when none is there.
|
|
890
|
+
*/
|
|
891
|
+
const readDelimiterCell = (text, at) => {
|
|
892
|
+
let end = at;
|
|
893
|
+
if (text.charCodeAt(end) === COLON) {
|
|
894
|
+
end++;
|
|
895
|
+
}
|
|
896
|
+
const dashes = end;
|
|
897
|
+
while (text.charCodeAt(end) === DASH) {
|
|
898
|
+
end++;
|
|
899
|
+
}
|
|
900
|
+
if (end === dashes) {
|
|
901
|
+
return -1;
|
|
902
|
+
}
|
|
903
|
+
if (text.charCodeAt(end) === COLON) {
|
|
904
|
+
end++;
|
|
430
905
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
906
|
+
return skipSpaces(text, end);
|
|
907
|
+
};
|
|
908
|
+
const readDelimiterRow = (text, lineStart, lineEnd) => {
|
|
909
|
+
const rowStart = skipUpToThreeSpaces(text, lineStart);
|
|
910
|
+
let end = readDelimiterCell(text, text.charCodeAt(rowStart) === PIPE
|
|
911
|
+
? skipSpaces(text, rowStart + 1)
|
|
912
|
+
: rowStart);
|
|
913
|
+
if (end === -1) {
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
916
|
+
let cells = 1;
|
|
917
|
+
while (text.charCodeAt(end) === PIPE) {
|
|
918
|
+
const next = skipSpaces(text, end + 1);
|
|
919
|
+
const cellEnd = readDelimiterCell(text, next);
|
|
920
|
+
// A last pipe, with no cell after it.
|
|
921
|
+
if (cellEnd === -1) {
|
|
922
|
+
end = next;
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
cells++;
|
|
926
|
+
end = cellEnd;
|
|
927
|
+
}
|
|
928
|
+
if (end !== lineEnd) {
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
let holdsPipeOrColon = false;
|
|
932
|
+
for (let index = rowStart; index < end; index++) {
|
|
933
|
+
const code = text.charCodeAt(index);
|
|
934
|
+
if (code === PIPE || code === COLON) {
|
|
935
|
+
holdsPipeOrColon = true;
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return { cells: cells, holdsPipeOrColon: holdsPipeOrColon };
|
|
940
|
+
};
|
|
941
|
+
/*
|
|
942
|
+
* How many cells marked splits a table's header row into (splitCells):
|
|
943
|
+
* one more than the pipes no backslash escapes, less a first or last cell
|
|
944
|
+
* of white space alone.
|
|
945
|
+
*/
|
|
946
|
+
const countHeaderCells = (text, from, to) => {
|
|
947
|
+
let pipes = 0;
|
|
948
|
+
let firstPipe = -1;
|
|
949
|
+
let lastPipe = -1;
|
|
950
|
+
let backslashes = 0;
|
|
951
|
+
for (let index = from; index < to; index++) {
|
|
952
|
+
const code = text.charCodeAt(index);
|
|
953
|
+
if (code === PIPE && backslashes % 2 === 0) {
|
|
954
|
+
pipes++;
|
|
955
|
+
firstPipe = firstPipe === -1 ? index : firstPipe;
|
|
956
|
+
lastPipe = index;
|
|
957
|
+
}
|
|
958
|
+
backslashes = code === BACKSLASH ? backslashes + 1 : 0;
|
|
959
|
+
}
|
|
960
|
+
let cells = pipes + 1;
|
|
961
|
+
if (isAllWhiteSpace(text, from, firstPipe === -1 ? to : firstPipe)) {
|
|
962
|
+
cells--;
|
|
963
|
+
}
|
|
964
|
+
if (pipes > 0 && cells > 0 && isAllWhiteSpace(text, lastPipe + 1, to)) {
|
|
965
|
+
cells--;
|
|
966
|
+
}
|
|
967
|
+
return cells;
|
|
968
|
+
};
|
|
969
|
+
/*
|
|
970
|
+
* Whether a table's header row starts the line - the line after it a
|
|
971
|
+
* delimiter row - as marked's GFM paragraph rule reads one, which ends a
|
|
972
|
+
* paragraph there: spaces, then a character that is no space, and no line
|
|
973
|
+
* or paragraph separator after it on the line.
|
|
974
|
+
*/
|
|
975
|
+
const startsTable = (reading, at, lineEnd) => {
|
|
976
|
+
const text = reading.level.text;
|
|
977
|
+
const header = skipSpaces(text, at);
|
|
978
|
+
return (lineEnd < text.length &&
|
|
979
|
+
header < lineEnd &&
|
|
980
|
+
findSeparator(reading, header + 1, lineEnd) === -1 &&
|
|
981
|
+
readDelimiterRow(text, lineEnd + 1, getLineEnd(text, lineEnd + 1)) !== null);
|
|
982
|
+
};
|
|
983
|
+
/*
|
|
984
|
+
* Whether the line at `at` - not empty - ends a paragraph before it:
|
|
985
|
+
* marked's paragraph rule, without the GFM tables when `withTables` is
|
|
986
|
+
* false (a block quote's paragraph, whose lazy lines it ends).
|
|
987
|
+
*/
|
|
988
|
+
const endsParagraph = (reading, at, withTables) => {
|
|
989
|
+
const text = reading.level.text;
|
|
990
|
+
const lineEnd = getLineEnd(text, at);
|
|
991
|
+
return (isThematicBreak(text, at, lineEnd) ||
|
|
992
|
+
startsAtxHeading(text, at) ||
|
|
993
|
+
startsBlockQuote(text, at) ||
|
|
994
|
+
// A fence, its line ending in a line break.
|
|
995
|
+
(lineEnd < text.length && getOpeningFence(text, at, lineEnd) !== null) ||
|
|
996
|
+
startsListInParagraph(text, at) ||
|
|
997
|
+
startsHtmlInParagraph(text, at) ||
|
|
998
|
+
// Spaces alone, a line break after them.
|
|
999
|
+
(lineEnd < text.length && skipSpaces(text, at) >= lineEnd) ||
|
|
1000
|
+
(withTables && startsTable(reading, at, lineEnd)));
|
|
1001
|
+
};
|
|
1002
|
+
/*
|
|
1003
|
+
* Whether the line, from `at`, is a setext heading's underline: up to three
|
|
1004
|
+
* spaces, a run of "=" or of "-", then spaces alone.
|
|
1005
|
+
*/
|
|
1006
|
+
const isSetextUnderline = (text, at) => {
|
|
1007
|
+
const mark = skipUpToThreeSpaces(text, at);
|
|
1008
|
+
const code = text.charCodeAt(mark);
|
|
1009
|
+
if (code !== EQUALS && code !== DASH) {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
let end = mark;
|
|
1013
|
+
while (text.charCodeAt(end) === code) {
|
|
1014
|
+
end++;
|
|
1015
|
+
}
|
|
1016
|
+
end = skipSpaces(text, end);
|
|
1017
|
+
return end >= text.length || text.charCodeAt(end) === LINE_FEED;
|
|
1018
|
+
};
|
|
1019
|
+
/*
|
|
1020
|
+
* Whether the line at `at` is one a setext heading cannot run over (its
|
|
1021
|
+
* "lheading" rule): a bullet and a space at the very start, four spaces, a
|
|
1022
|
+
* fence, ">", "#", or an HTML tag that ends its line, a line break after it
|
|
1023
|
+
* - and, past its first line, white space alone, a line break after it.
|
|
1024
|
+
*/
|
|
1025
|
+
const breaksSetextHeading = (text, at, isFirstLine) => {
|
|
1026
|
+
if (!isFirstLine) {
|
|
1027
|
+
let end = at;
|
|
1028
|
+
while (end < text.length &&
|
|
1029
|
+
text.charCodeAt(end) !== LINE_FEED &&
|
|
1030
|
+
(0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(end))) {
|
|
1031
|
+
end++;
|
|
1032
|
+
}
|
|
1033
|
+
if (text.charCodeAt(end) === LINE_FEED) {
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
const code = text.charCodeAt(at);
|
|
1038
|
+
if ((code === ASTERISK || code === PLUS || code === DASH) &&
|
|
1039
|
+
text.charCodeAt(at + 1) === SPACE) {
|
|
1040
|
+
return true;
|
|
1041
|
+
}
|
|
1042
|
+
let digitsEnd = at;
|
|
1043
|
+
while (digitsEnd - at < 10 && (0, RegExpCharacterClasses_1.isDigitCode)(text.charCodeAt(digitsEnd))) {
|
|
1044
|
+
digitsEnd++;
|
|
1045
|
+
}
|
|
1046
|
+
const delimiter = text.charCodeAt(digitsEnd);
|
|
1047
|
+
if (digitsEnd > at &&
|
|
1048
|
+
digitsEnd - at <= 9 &&
|
|
1049
|
+
(delimiter === DOT || delimiter === CLOSE_PARENTHESIS) &&
|
|
1050
|
+
text.charCodeAt(digitsEnd + 1) === SPACE) {
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
if (skipSpaces(text, at) - at >= 4) {
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
1056
|
+
const first = skipUpToThreeSpaces(text, at);
|
|
1057
|
+
const firstCode = text.charCodeAt(first);
|
|
1058
|
+
if ((firstCode === BACKTICK || firstCode === TILDE) &&
|
|
1059
|
+
text.charCodeAt(first + 1) === firstCode &&
|
|
1060
|
+
text.charCodeAt(first + 2) === firstCode) {
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
if (firstCode === GREATER_THAN || firstCode === HASH) {
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
if (firstCode === LESS_THAN) {
|
|
1067
|
+
let end = first + 1;
|
|
1068
|
+
while (end < text.length &&
|
|
1069
|
+
text.charCodeAt(end) !== GREATER_THAN &&
|
|
1070
|
+
text.charCodeAt(end) !== LINE_FEED) {
|
|
1071
|
+
end++;
|
|
1072
|
+
}
|
|
1073
|
+
return (end > first + 1 &&
|
|
1074
|
+
text.charCodeAt(end) === GREATER_THAN &&
|
|
1075
|
+
text.charCodeAt(end + 1) === LINE_FEED);
|
|
1076
|
+
}
|
|
1077
|
+
return false;
|
|
1078
|
+
};
|
|
1079
|
+
/*
|
|
1080
|
+
* THE BLOCKS, AS MARKED'S TOKENIZERS READ THEM.
|
|
1081
|
+
*
|
|
1082
|
+
* Each reads its block from `at` of a level and returns where the next
|
|
1083
|
+
* block starts - or -1, or `at`, when its block is not there.
|
|
1084
|
+
*/
|
|
1085
|
+
// Lines of spaces alone, and the line breaks after them.
|
|
1086
|
+
const readSpace = (text, at) => {
|
|
1087
|
+
let end = at;
|
|
1088
|
+
for (;;) {
|
|
1089
|
+
const spacesEnd = skipSpaces(text, end);
|
|
1090
|
+
if (spacesEnd >= text.length) {
|
|
1091
|
+
return text.length;
|
|
1092
|
+
}
|
|
1093
|
+
if (text.charCodeAt(spacesEnd) !== LINE_FEED) {
|
|
1094
|
+
return end;
|
|
1095
|
+
}
|
|
1096
|
+
end = spacesEnd + 1;
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
/*
|
|
1100
|
+
* Indented code: lines of four spaces and something more, the lines of
|
|
1101
|
+
* spaces alone between and after them.
|
|
1102
|
+
*/
|
|
1103
|
+
const readIndentedCode = (text, at) => {
|
|
1104
|
+
let end = at;
|
|
1105
|
+
while (end + 4 < text.length &&
|
|
1106
|
+
text.charCodeAt(end) === SPACE &&
|
|
1107
|
+
text.charCodeAt(end + 1) === SPACE &&
|
|
1108
|
+
text.charCodeAt(end + 2) === SPACE &&
|
|
1109
|
+
text.charCodeAt(end + 3) === SPACE &&
|
|
1110
|
+
text.charCodeAt(end + 4) !== LINE_FEED) {
|
|
1111
|
+
end = getLineEnd(text, end + 4);
|
|
1112
|
+
if (end >= text.length) {
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
end++;
|
|
1116
|
+
for (;;) {
|
|
1117
|
+
const spacesEnd = skipSpaces(text, end);
|
|
1118
|
+
if (spacesEnd >= text.length) {
|
|
1119
|
+
end = text.length;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
if (text.charCodeAt(spacesEnd) !== LINE_FEED) {
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
end = spacesEnd + 1;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return end;
|
|
1129
|
+
};
|
|
1130
|
+
// A fenced code block, to its closing fence's line or the end of the text.
|
|
1131
|
+
const readFencedCode = (text, at, lineEnd) => {
|
|
1132
|
+
const fence = getOpeningFence(text, at, lineEnd);
|
|
1133
|
+
if (fence === null) {
|
|
1134
|
+
return -1;
|
|
1135
|
+
}
|
|
1136
|
+
for (let lineStart = nextLineStart(text, lineEnd); lineStart < text.length;) {
|
|
1137
|
+
const closeEnd = getLineEnd(text, lineStart);
|
|
1138
|
+
if (closesFence(text, lineStart, closeEnd, fence)) {
|
|
1139
|
+
return closeEnd;
|
|
1140
|
+
}
|
|
1141
|
+
lineStart = nextLineStart(text, closeEnd);
|
|
1142
|
+
}
|
|
1143
|
+
return text.length;
|
|
1144
|
+
};
|
|
1145
|
+
/*
|
|
1146
|
+
* A block quote: lines that start with up to three spaces and ">", each
|
|
1147
|
+
* carried on - when anything follows its ">" - by the lazy lines of a
|
|
1148
|
+
* paragraph, which only what ends a paragraph ends (blockquote rule). Its
|
|
1149
|
+
* lines are read again, as marked reads them, without their markers.
|
|
1150
|
+
*/
|
|
1151
|
+
const readBlockQuote = (reading, at) => {
|
|
1152
|
+
const text = reading.level.text;
|
|
1153
|
+
if (!startsBlockQuote(text, at)) {
|
|
1154
|
+
return -1;
|
|
1155
|
+
}
|
|
1156
|
+
let end = at;
|
|
1157
|
+
while (end < text.length && startsBlockQuote(text, end)) {
|
|
1158
|
+
const marker = skipUpToThreeSpaces(text, end);
|
|
1159
|
+
let groupEnd = getLineEnd(text, end);
|
|
1160
|
+
/*
|
|
1161
|
+
* Lazy lines carry on what follows the ">" and a space after it: none
|
|
1162
|
+
* when nothing does - marked reads "> " alone as a line of its own.
|
|
1163
|
+
*/
|
|
1164
|
+
const afterMarker = marker + (text.charCodeAt(marker + 1) === SPACE ? 2 : 1);
|
|
1165
|
+
if (afterMarker < groupEnd) {
|
|
1166
|
+
while (groupEnd < text.length) {
|
|
1167
|
+
const next = groupEnd + 1;
|
|
1168
|
+
if (next >= text.length ||
|
|
1169
|
+
text.charCodeAt(next) === LINE_FEED ||
|
|
1170
|
+
endsParagraph(reading, next, false)) {
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
groupEnd = getLineEnd(text, next);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
end = nextLineStart(text, groupEnd);
|
|
1177
|
+
}
|
|
1178
|
+
if (reading.level.depth < exports.MAX_DEFINITION_NESTING_DEPTH &&
|
|
1179
|
+
holdsDefinitionColon(reading, at, end)) {
|
|
1180
|
+
const lines = [];
|
|
1181
|
+
for (let lineStart = at; lineStart < end;) {
|
|
1182
|
+
const lineEnd = getLineEnd(text, lineStart);
|
|
1183
|
+
/*
|
|
1184
|
+
* A lazy line that would underline a setext heading gets four spaces
|
|
1185
|
+
* first, so it does not; every line loses spaces, a ">" and the space
|
|
1186
|
+
* or tab after it.
|
|
1187
|
+
*/
|
|
1188
|
+
if (lineStart > at && isSetextUnderline(text, lineStart)) {
|
|
1189
|
+
lines.push({
|
|
1190
|
+
lead: 4,
|
|
1191
|
+
from: skipSpaces(text, lineStart),
|
|
1192
|
+
to: lineEnd,
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
else {
|
|
1196
|
+
const marker = skipSpaces(text, lineStart);
|
|
1197
|
+
let from = lineStart;
|
|
1198
|
+
if (text.charCodeAt(marker) === GREATER_THAN) {
|
|
1199
|
+
from = marker + 1;
|
|
1200
|
+
if (from < lineEnd && isSpaceOrTab(text.charCodeAt(from))) {
|
|
1201
|
+
from++;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
lines.push({ lead: 0, from: from, to: lineEnd });
|
|
1205
|
+
}
|
|
1206
|
+
lineStart = lineEnd + 1;
|
|
1207
|
+
}
|
|
1208
|
+
// No line breaks at its end.
|
|
1209
|
+
while (lines.length > 0 &&
|
|
1210
|
+
lines[lines.length - 1].lead === 0 &&
|
|
1211
|
+
lines[lines.length - 1].from >= lines[lines.length - 1].to) {
|
|
1212
|
+
lines.pop();
|
|
1213
|
+
}
|
|
1214
|
+
readBlocks(makeLevel(reading.level, lines, reading.level.depth + 1, true), true, reading.definitions);
|
|
1215
|
+
}
|
|
1216
|
+
return end;
|
|
1217
|
+
};
|
|
1218
|
+
const readBullet = (text, at) => {
|
|
1219
|
+
const code = text.charCodeAt(at);
|
|
1220
|
+
if (code === ASTERISK || code === PLUS || code === DASH) {
|
|
1221
|
+
return { end: at + 1, mark: code, isOrdered: false };
|
|
1222
|
+
}
|
|
1223
|
+
let digitsEnd = at;
|
|
1224
|
+
while (digitsEnd - at < 10 && (0, RegExpCharacterClasses_1.isDigitCode)(text.charCodeAt(digitsEnd))) {
|
|
1225
|
+
digitsEnd++;
|
|
1226
|
+
}
|
|
1227
|
+
const delimiter = text.charCodeAt(digitsEnd);
|
|
1228
|
+
if (digitsEnd === at ||
|
|
1229
|
+
digitsEnd - at > 9 ||
|
|
1230
|
+
(delimiter !== DOT && delimiter !== CLOSE_PARENTHESIS)) {
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
return { end: digitsEnd + 1, mark: delimiter, isOrdered: true };
|
|
1234
|
+
};
|
|
1235
|
+
/*
|
|
1236
|
+
* Where the line text[from, to), after `lead` spaces, has its first
|
|
1237
|
+
* character that is no space - -1 when it has none - and the shapes of it
|
|
1238
|
+
* that end a list item, as its list tokenizer reads them with up to
|
|
1239
|
+
* `maxSpaces` spaces before them.
|
|
1240
|
+
*/
|
|
1241
|
+
const getFirstNonSpace = (text, line) => {
|
|
1242
|
+
let at = line.from;
|
|
1243
|
+
while (at < line.to && text.charCodeAt(at) === SPACE) {
|
|
1244
|
+
at++;
|
|
1245
|
+
}
|
|
1246
|
+
return { index: at < line.to ? line.lead + (at - line.from) : -1, at: at };
|
|
1247
|
+
};
|
|
1248
|
+
const beginsItemBreak = (text, line, maxSpaces, withBullets) => {
|
|
1249
|
+
const first = getFirstNonSpace(text, line);
|
|
1250
|
+
if (first.index === -1 || first.index > maxSpaces) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
const at = first.at;
|
|
1254
|
+
const code = text.charCodeAt(at);
|
|
1255
|
+
// A fence: "```" or "~~~".
|
|
1256
|
+
if ((code === BACKTICK || code === TILDE) &&
|
|
1257
|
+
at + 2 < line.to &&
|
|
1258
|
+
text.charCodeAt(at + 1) === code &&
|
|
1259
|
+
text.charCodeAt(at + 2) === code) {
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
// A heading: "#".
|
|
1263
|
+
if (code === HASH) {
|
|
1264
|
+
return true;
|
|
1265
|
+
}
|
|
1266
|
+
// A thematic break of spaces and three or more of one mark.
|
|
1267
|
+
if (code === DASH || code === UNDERSCORE || code === ASTERISK) {
|
|
1268
|
+
let marks = 0;
|
|
1269
|
+
let isBreak = true;
|
|
1270
|
+
for (let index = at; index < line.to && isBreak; index++) {
|
|
1271
|
+
const next = text.charCodeAt(index);
|
|
1272
|
+
if (next === code) {
|
|
1273
|
+
marks++;
|
|
1274
|
+
}
|
|
1275
|
+
else if (next !== SPACE) {
|
|
1276
|
+
isBreak = false;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
if (isBreak && marks >= 3) {
|
|
1280
|
+
return true;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
// A bullet, then a space, a tab or the end of the line.
|
|
1284
|
+
if (withBullets) {
|
|
1285
|
+
const bullet = readBullet(text, at);
|
|
1286
|
+
return (bullet !== null &&
|
|
1287
|
+
(bullet.end >= line.to || isSpaceOrTab(text.charCodeAt(bullet.end))));
|
|
1288
|
+
}
|
|
1289
|
+
return false;
|
|
1290
|
+
};
|
|
1291
|
+
const readListItem = (text, at, bullet) => {
|
|
1292
|
+
const lineEnd = getLineEnd(text, at);
|
|
1293
|
+
const itemBullet = readBullet(text, skipUpToThreeSpaces(text, at));
|
|
1294
|
+
if (itemBullet === null ||
|
|
1295
|
+
itemBullet.isOrdered !== bullet.isOrdered ||
|
|
1296
|
+
itemBullet.mark !== bullet.mark ||
|
|
1297
|
+
(itemBullet.end < lineEnd &&
|
|
1298
|
+
!isSpaceOrTab(text.charCodeAt(itemBullet.end))) ||
|
|
1299
|
+
isThematicBreak(text, at, lineEnd)) {
|
|
1300
|
+
return null;
|
|
1301
|
+
}
|
|
1302
|
+
// The first line after the bullet, its first tabs three spaces each.
|
|
1303
|
+
const contentStart = itemBullet.end;
|
|
1304
|
+
let tabsEnd = contentStart;
|
|
1305
|
+
while (tabsEnd < lineEnd && text.charCodeAt(tabsEnd) === TAB) {
|
|
1306
|
+
tabsEnd++;
|
|
1307
|
+
}
|
|
1308
|
+
const firstLine = {
|
|
1309
|
+
lead: 3 * (tabsEnd - contentStart),
|
|
1310
|
+
from: tabsEnd,
|
|
1311
|
+
to: lineEnd,
|
|
443
1312
|
};
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
1313
|
+
/*
|
|
1314
|
+
* How far the item's lines are indented: to the first character after
|
|
1315
|
+
* the bullet that is no space - its line break too - or one space past it
|
|
1316
|
+
* when that is more than four.
|
|
1317
|
+
*/
|
|
1318
|
+
const firstNonSpace = skipSpaces(text, contentStart);
|
|
1319
|
+
let indent = firstNonSpace < text.length ? firstNonSpace - contentStart : -1;
|
|
1320
|
+
indent = indent > 4 ? 1 : indent;
|
|
1321
|
+
/*
|
|
1322
|
+
* What the item holds of its first line: from its indent - all of it
|
|
1323
|
+
* when a tab starts it, and the last of the spaces up to the end of the
|
|
1324
|
+
* text when they are all it has.
|
|
1325
|
+
*/
|
|
1326
|
+
let head = firstLine;
|
|
1327
|
+
if (firstLine.lead === 0) {
|
|
1328
|
+
head = {
|
|
1329
|
+
lead: 0,
|
|
1330
|
+
from: indent >= 0
|
|
1331
|
+
? Math.min(contentStart + indent, lineEnd)
|
|
1332
|
+
: Math.max(contentStart, lineEnd - 1),
|
|
1333
|
+
to: lineEnd,
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
indent += contentStart - at;
|
|
1337
|
+
const lines = [head];
|
|
1338
|
+
let end = nextLineStart(text, lineEnd);
|
|
1339
|
+
// An item that is no more than its bullet ends at a blank line after it.
|
|
1340
|
+
const isEmpty = firstLine.lead === 0 && contentStart === lineEnd;
|
|
1341
|
+
if (isEmpty && skipSpaces(text, end) >= getLineEnd(text, end)) {
|
|
1342
|
+
return {
|
|
1343
|
+
lines: lines,
|
|
1344
|
+
end: nextLineStart(text, getLineEnd(text, end)),
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
const maxSpaces = Math.min(3, indent - 1);
|
|
1348
|
+
let hasBlankLine = false;
|
|
1349
|
+
let previous = firstLine;
|
|
1350
|
+
while (end < text.length) {
|
|
1351
|
+
const nextEnd = getLineEnd(text, end);
|
|
1352
|
+
const next = { lead: 0, from: end, to: nextEnd };
|
|
1353
|
+
if (beginsItemBreak(text, next, maxSpaces, true)) {
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
const isBlank = isAllWhiteSpace(text, end, nextEnd);
|
|
1357
|
+
const nextFirst = getFirstNonSpace(text, next).index;
|
|
1358
|
+
const dedented = {
|
|
1359
|
+
lead: 0,
|
|
1360
|
+
from: Math.min(end + indent, nextEnd),
|
|
1361
|
+
to: nextEnd,
|
|
1362
|
+
};
|
|
1363
|
+
if (nextFirst >= indent || isBlank) {
|
|
1364
|
+
lines.push(dedented);
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
// A lazy line carries on a paragraph alone.
|
|
1368
|
+
if (hasBlankLine ||
|
|
1369
|
+
getFirstNonSpace(text, previous).index >= 4 ||
|
|
1370
|
+
beginsItemBreak(text, previous, maxSpaces, false)) {
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
lines.push(next);
|
|
1374
|
+
}
|
|
1375
|
+
hasBlankLine = hasBlankLine || isBlank;
|
|
1376
|
+
end = nextLineStart(text, nextEnd);
|
|
1377
|
+
previous = dedented;
|
|
1378
|
+
}
|
|
1379
|
+
// A task's "[ ] " or "[x] ", and the spaces after it, are no content.
|
|
1380
|
+
const content = lines[0];
|
|
1381
|
+
if (content.lead === 0 &&
|
|
1382
|
+
content.from + 3 < content.to &&
|
|
1383
|
+
text.charCodeAt(content.from) === OPEN_BRACKET &&
|
|
1384
|
+
(text.charCodeAt(content.from + 1) === SPACE ||
|
|
1385
|
+
text.charCodeAt(content.from + 1) === LOWER_X ||
|
|
1386
|
+
text.charCodeAt(content.from + 1) === UPPER_X) &&
|
|
1387
|
+
text.charCodeAt(content.from + 2) === CLOSE_BRACKET &&
|
|
1388
|
+
text.charCodeAt(content.from + 3) === SPACE) {
|
|
1389
|
+
lines[0] = {
|
|
1390
|
+
lead: 0,
|
|
1391
|
+
from: Math.min(skipSpaces(text, content.from + 3), content.to),
|
|
1392
|
+
to: content.to,
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
return { lines: lines, end: end };
|
|
1396
|
+
};
|
|
1397
|
+
/*
|
|
1398
|
+
* A list: its items, each up to the next item of the same list (list
|
|
1399
|
+
* rule) - the last without the white space at its end, which the blocks
|
|
1400
|
+
* after the list read. Each item's lines are read again, as marked reads
|
|
1401
|
+
* them, without the bullet and indentation.
|
|
1402
|
+
*/
|
|
1403
|
+
const readList = (reading, at) => {
|
|
1404
|
+
const text = reading.level.text;
|
|
1405
|
+
const lineEnd = getLineEnd(text, at);
|
|
1406
|
+
const bullet = readBullet(text, skipUpToThreeSpaces(text, at));
|
|
1407
|
+
/*
|
|
1408
|
+
* The first item's bullet ends its line, or a space or a tab and more
|
|
1409
|
+
* come after it.
|
|
1410
|
+
*/
|
|
1411
|
+
if (bullet === null ||
|
|
1412
|
+
(bullet.end < lineEnd &&
|
|
1413
|
+
(!isSpaceOrTab(text.charCodeAt(bullet.end)) || bullet.end + 1 >= lineEnd))) {
|
|
1414
|
+
return -1;
|
|
1415
|
+
}
|
|
1416
|
+
const items = [];
|
|
1417
|
+
let itemsEnd = at;
|
|
1418
|
+
while (itemsEnd < text.length) {
|
|
1419
|
+
const item = readListItem(text, itemsEnd, bullet);
|
|
1420
|
+
if (item === null) {
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
items.push(item.lines);
|
|
1424
|
+
itemsEnd = item.end;
|
|
1425
|
+
}
|
|
1426
|
+
let end = itemsEnd;
|
|
1427
|
+
while (end > at && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(end - 1))) {
|
|
1428
|
+
end--;
|
|
1429
|
+
}
|
|
1430
|
+
// The last item without the white space at its end.
|
|
1431
|
+
const last = items[items.length - 1];
|
|
1432
|
+
while (last.length > 0) {
|
|
1433
|
+
const line = last[last.length - 1];
|
|
1434
|
+
let to = line.to;
|
|
1435
|
+
while (to > line.from && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(to - 1))) {
|
|
1436
|
+
to--;
|
|
1437
|
+
}
|
|
1438
|
+
if (to > line.from) {
|
|
1439
|
+
last[last.length - 1] = { lead: line.lead, from: line.from, to: to };
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
last.pop();
|
|
1443
|
+
}
|
|
1444
|
+
if (reading.level.depth < exports.MAX_DEFINITION_NESTING_DEPTH) {
|
|
1445
|
+
for (const lines of items) {
|
|
1446
|
+
if (lines.length > 0 &&
|
|
1447
|
+
holdsDefinitionColon(reading, lines[0].from, lines[lines.length - 1].to)) {
|
|
1448
|
+
readBlocks(makeLevel(reading.level, lines, reading.level.depth + 1, false), false, reading.definitions);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
return end;
|
|
1453
|
+
};
|
|
1454
|
+
/*
|
|
1455
|
+
* After the line breaks after text[found, found + length), or the end of
|
|
1456
|
+
* the text when `found` is -1: the end of an HTML block of the third to
|
|
1457
|
+
* fifth kind, which can end inside its line.
|
|
1458
|
+
*/
|
|
1459
|
+
const afterAndLineBreaks = (text, found, length) => {
|
|
1460
|
+
return found === -1 ? text.length : skipLineBreaks(text, found + length);
|
|
1461
|
+
};
|
|
1462
|
+
// After a line of the text from `at` that is spaces and tabs alone.
|
|
1463
|
+
const isRestOfLineBlank = (text, at) => {
|
|
1464
|
+
let end = at;
|
|
1465
|
+
while (isSpaceOrTab(text.charCodeAt(end))) {
|
|
1466
|
+
end++;
|
|
1467
|
+
}
|
|
1468
|
+
return end >= text.length || text.charCodeAt(end) === LINE_FEED;
|
|
1469
|
+
};
|
|
1470
|
+
/*
|
|
1471
|
+
* After a tag's name - a letter, then letters, digits, "_" and "-" - at
|
|
1472
|
+
* `at`, or -1 when no name starts there.
|
|
1473
|
+
*/
|
|
1474
|
+
const readTagName = (text, at) => {
|
|
1475
|
+
if (!(0, RegExpCharacterClasses_1.isAsciiLetterCode)(text.charCodeAt(at))) {
|
|
1476
|
+
return -1;
|
|
1477
|
+
}
|
|
1478
|
+
let end = at + 1;
|
|
1479
|
+
while ((0, RegExpCharacterClasses_1.isWordCode)(text.charCodeAt(end)) || text.charCodeAt(end) === DASH) {
|
|
1480
|
+
end++;
|
|
1481
|
+
}
|
|
1482
|
+
return end;
|
|
1483
|
+
};
|
|
1484
|
+
/*
|
|
1485
|
+
* After an attribute's value at `at` - in double quotes, in single quotes,
|
|
1486
|
+
* on its line, or characters that are none of white space, quotes, "=",
|
|
1487
|
+
* "<", ">" and "`" - or -1 when none is there.
|
|
1488
|
+
*/
|
|
1489
|
+
const readAttributeValue = (text, at) => {
|
|
1490
|
+
const opening = text.charCodeAt(at);
|
|
1491
|
+
if (opening === DOUBLE_QUOTE || opening === SINGLE_QUOTE) {
|
|
1492
|
+
for (let index = at + 1; index < text.length; index++) {
|
|
1493
|
+
const code = text.charCodeAt(index);
|
|
1494
|
+
if (code === opening) {
|
|
1495
|
+
return index + 1;
|
|
457
1496
|
}
|
|
458
|
-
|
|
1497
|
+
if (code === LINE_FEED) {
|
|
1498
|
+
return -1;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
return -1;
|
|
1502
|
+
}
|
|
1503
|
+
let end = at;
|
|
1504
|
+
while (end < text.length) {
|
|
1505
|
+
const code = text.charCodeAt(end);
|
|
1506
|
+
if ((0, RegExpCharacterClasses_1.isWhiteSpaceCode)(code) ||
|
|
1507
|
+
code === DOUBLE_QUOTE ||
|
|
1508
|
+
code === SINGLE_QUOTE ||
|
|
1509
|
+
code === EQUALS ||
|
|
1510
|
+
code === LESS_THAN ||
|
|
1511
|
+
code === GREATER_THAN ||
|
|
1512
|
+
code === BACKTICK) {
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
end++;
|
|
1516
|
+
}
|
|
1517
|
+
return end > at ? end : -1;
|
|
1518
|
+
};
|
|
1519
|
+
/*
|
|
1520
|
+
* After a whole open or closing tag at "<" that only spaces and tabs
|
|
1521
|
+
* follow on its line - an HTML block of marked's seventh kind - or -1. Its
|
|
1522
|
+
* name starts with none of "script", "pre", "style" and "textarea".
|
|
1523
|
+
*/
|
|
1524
|
+
const readWholeTag = (text, open) => {
|
|
1525
|
+
const isClosing = text.charCodeAt(open + 1) === SLASH;
|
|
1526
|
+
const name = open + (isClosing ? 2 : 1);
|
|
1527
|
+
if (startsWithAny(text, name, RAW_TEXT_TAG_NAMES, true) !== null) {
|
|
1528
|
+
return -1;
|
|
1529
|
+
}
|
|
1530
|
+
let end = readTagName(text, name);
|
|
1531
|
+
if (end === -1) {
|
|
1532
|
+
return -1;
|
|
1533
|
+
}
|
|
1534
|
+
if (isClosing) {
|
|
1535
|
+
while (end < text.length && (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(text.charCodeAt(end))) {
|
|
1536
|
+
end++;
|
|
1537
|
+
}
|
|
1538
|
+
return text.charCodeAt(end) === GREATER_THAN &&
|
|
1539
|
+
isRestOfLineBlank(text, end + 1)
|
|
1540
|
+
? end + 1
|
|
1541
|
+
: -1;
|
|
1542
|
+
}
|
|
1543
|
+
// Attributes: spaces, a name, and perhaps "=" and a value.
|
|
1544
|
+
for (;;) {
|
|
1545
|
+
const attribute = skipSpaces(text, end);
|
|
1546
|
+
const code = text.charCodeAt(attribute);
|
|
1547
|
+
if (attribute === end ||
|
|
1548
|
+
!((0, RegExpCharacterClasses_1.isAsciiLetterCode)(code) || code === COLON || code === UNDERSCORE)) {
|
|
1549
|
+
break;
|
|
1550
|
+
}
|
|
1551
|
+
end = attribute + 1;
|
|
1552
|
+
while ((0, RegExpCharacterClasses_1.isWordCode)(text.charCodeAt(end)) ||
|
|
1553
|
+
text.charCodeAt(end) === DOT ||
|
|
1554
|
+
text.charCodeAt(end) === COLON ||
|
|
1555
|
+
text.charCodeAt(end) === DASH) {
|
|
1556
|
+
end++;
|
|
1557
|
+
}
|
|
1558
|
+
const equals = skipSpaces(text, end);
|
|
1559
|
+
if (text.charCodeAt(equals) === EQUALS) {
|
|
1560
|
+
// An "=" no value follows can be read no other way.
|
|
1561
|
+
end = readAttributeValue(text, skipSpaces(text, equals + 1));
|
|
1562
|
+
if (end === -1) {
|
|
1563
|
+
return -1;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
let close = skipSpaces(text, end);
|
|
1568
|
+
if (text.charCodeAt(close) === SLASH) {
|
|
1569
|
+
close++;
|
|
1570
|
+
}
|
|
1571
|
+
return text.charCodeAt(close) === GREATER_THAN &&
|
|
1572
|
+
isRestOfLineBlank(text, close + 1)
|
|
1573
|
+
? close + 1
|
|
1574
|
+
: -1;
|
|
1575
|
+
};
|
|
1576
|
+
/*
|
|
1577
|
+
* After the blank line that ends an HTML block of the sixth or seventh kind
|
|
1578
|
+
* from `from` - and the lines of spaces alone after it - or the end of the
|
|
1579
|
+
* text.
|
|
1580
|
+
*/
|
|
1581
|
+
const readHtmlBlockEnd = (reading, from) => {
|
|
1582
|
+
const text = reading.level.text;
|
|
1583
|
+
let end = reading.nextBlankLineBreak(from);
|
|
1584
|
+
if (end === -1) {
|
|
1585
|
+
return text.length;
|
|
1586
|
+
}
|
|
1587
|
+
for (;;) {
|
|
1588
|
+
const next = skipSpaces(text, end + 1);
|
|
1589
|
+
if (text.charCodeAt(next) !== LINE_FEED) {
|
|
1590
|
+
return end + 1;
|
|
1591
|
+
}
|
|
1592
|
+
end = next;
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
/*
|
|
1596
|
+
* An HTML block (html rule), of the first of its kinds that starts at
|
|
1597
|
+
* `at`: <script>, <pre>, <style> or <textarea> to the line of its closing
|
|
1598
|
+
* tag; a comment, to the line of its "-->"; "<?" to "?>"; "<!" and a letter
|
|
1599
|
+
* to ">"; "<![CDATA[" to "]]>"; a block tag, or a whole tag alone on its
|
|
1600
|
+
* line, to a blank line. Each runs to the end of the text when what ends it
|
|
1601
|
+
* is not there.
|
|
1602
|
+
*/
|
|
1603
|
+
const readHtml = (reading, at) => {
|
|
1604
|
+
const text = reading.level.text;
|
|
1605
|
+
const open = skipUpToThreeSpaces(text, at);
|
|
1606
|
+
if (text.charCodeAt(open) !== LESS_THAN) {
|
|
1607
|
+
return -1;
|
|
1608
|
+
}
|
|
1609
|
+
const name = open + 1;
|
|
1610
|
+
const rawTextTag = startsWithAny(text, name, RAW_TEXT_TAG_NAMES, true);
|
|
1611
|
+
const afterRawTextTag = rawTextTag === null ? -1 : text.charCodeAt(name + rawTextTag.length);
|
|
1612
|
+
if (rawTextTag !== null &&
|
|
1613
|
+
(afterRawTextTag === GREATER_THAN || (0, RegExpCharacterClasses_1.isWhiteSpaceCode)(afterRawTextTag))) {
|
|
1614
|
+
// The first closing tag on a line a line break ends.
|
|
1615
|
+
for (let close = text.indexOf("</", name + rawTextTag.length + 1); close !== -1; close = text.indexOf("</", close + 1)) {
|
|
1616
|
+
const tagEnd = close + 2 + rawTextTag.length;
|
|
1617
|
+
if (text.slice(close + 2, tagEnd).toLowerCase() === rawTextTag &&
|
|
1618
|
+
text.charCodeAt(tagEnd) === GREATER_THAN) {
|
|
1619
|
+
const lineEnd = getLineEnd(text, tagEnd);
|
|
1620
|
+
return lineEnd >= text.length
|
|
1621
|
+
? text.length
|
|
1622
|
+
: skipLineBreaks(text, lineEnd);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return text.length;
|
|
1626
|
+
}
|
|
1627
|
+
if (text.startsWith("!--", name)) {
|
|
1628
|
+
const afterOpening = name + 3;
|
|
1629
|
+
let close = afterOpening + 1;
|
|
1630
|
+
if (text.charCodeAt(afterOpening) === DASH) {
|
|
1631
|
+
close = afterOpening + 2;
|
|
1632
|
+
}
|
|
1633
|
+
if (text.charCodeAt(close - 1) !== GREATER_THAN) {
|
|
1634
|
+
const found = text.indexOf("-->", afterOpening);
|
|
1635
|
+
close = found === -1 ? text.length : found + 3;
|
|
1636
|
+
}
|
|
1637
|
+
const lineEnd = getLineEnd(text, close);
|
|
1638
|
+
return lineEnd >= text.length ? text.length : skipLineBreaks(text, lineEnd);
|
|
1639
|
+
}
|
|
1640
|
+
if (text.charCodeAt(name) === QUESTION_MARK) {
|
|
1641
|
+
return afterAndLineBreaks(text, text.indexOf("?>", name + 1), 2);
|
|
1642
|
+
}
|
|
1643
|
+
if (text.charCodeAt(name) === EXCLAMATION_MARK &&
|
|
1644
|
+
(0, RegExpCharacterClasses_1.isAsciiLetterCode)(text.charCodeAt(name + 1))) {
|
|
1645
|
+
return afterAndLineBreaks(text, text.indexOf(">", name + 2), 1);
|
|
1646
|
+
}
|
|
1647
|
+
if (text.slice(name, name + 8).toUpperCase() === "![CDATA[") {
|
|
1648
|
+
return afterAndLineBreaks(text, text.indexOf("]]>", name + 8), 3);
|
|
1649
|
+
}
|
|
1650
|
+
const afterBlockTag = readBlockTag(text, open, true);
|
|
1651
|
+
if (afterBlockTag !== -1) {
|
|
1652
|
+
return readHtmlBlockEnd(reading, afterBlockTag);
|
|
1653
|
+
}
|
|
1654
|
+
const afterWholeTag = readWholeTag(text, open);
|
|
1655
|
+
return afterWholeTag === -1 ? -1 : readHtmlBlockEnd(reading, afterWholeTag);
|
|
1656
|
+
};
|
|
1657
|
+
/*
|
|
1658
|
+
* A GFM table (table rule): a header row, a delimiter row with a pipe or a
|
|
1659
|
+
* colon and as many cells, then the rows up to a line that is none -
|
|
1660
|
+
* blank, or what starts another block - and the line breaks after them.
|
|
1661
|
+
*/
|
|
1662
|
+
const readTable = (reading, at, lineEnd) => {
|
|
1663
|
+
const text = reading.level.text;
|
|
1664
|
+
if (!startsTable(reading, at, lineEnd)) {
|
|
1665
|
+
return -1;
|
|
1666
|
+
}
|
|
1667
|
+
const delimiterEnd = getLineEnd(text, lineEnd + 1);
|
|
1668
|
+
const delimiter = readDelimiterRow(text, lineEnd + 1, delimiterEnd);
|
|
1669
|
+
if (!delimiter.holdsPipeOrColon ||
|
|
1670
|
+
delimiter.cells !== countHeaderCells(text, skipSpaces(text, at), lineEnd)) {
|
|
1671
|
+
return -1;
|
|
1672
|
+
}
|
|
1673
|
+
let rowStart = nextLineStart(text, delimiterEnd);
|
|
1674
|
+
while (rowStart < text.length) {
|
|
1675
|
+
const rowEnd = getLineEnd(text, rowStart);
|
|
1676
|
+
const first = skipSpaces(text, rowStart);
|
|
1677
|
+
if (
|
|
1678
|
+
// Spaces alone, a line break after them.
|
|
1679
|
+
(first === rowEnd && rowEnd < text.length) ||
|
|
1680
|
+
isThematicBreak(text, rowStart, rowEnd) ||
|
|
1681
|
+
startsAtxHeading(text, rowStart) ||
|
|
1682
|
+
startsBlockQuote(text, rowStart) ||
|
|
1683
|
+
// Four spaces, and anything after them.
|
|
1684
|
+
(first - rowStart >= 4 && rowStart + 4 < rowEnd) ||
|
|
1685
|
+
(rowEnd < text.length &&
|
|
1686
|
+
getOpeningFence(text, rowStart, rowEnd) !== null) ||
|
|
1687
|
+
startsListInParagraph(text, rowStart) ||
|
|
1688
|
+
startsHtmlInParagraph(text, rowStart) ||
|
|
1689
|
+
findSeparator(reading, rowStart, rowEnd) !== -1) {
|
|
1690
|
+
break;
|
|
1691
|
+
}
|
|
1692
|
+
rowStart = nextLineStart(text, rowEnd);
|
|
1693
|
+
}
|
|
1694
|
+
return skipLineBreaks(text, rowStart);
|
|
1695
|
+
};
|
|
1696
|
+
/*
|
|
1697
|
+
* A setext heading (lheading rule): lines up to the first underline of "="
|
|
1698
|
+
* or "-" - unless a line it cannot run over, or a line or paragraph
|
|
1699
|
+
* separator, comes first.
|
|
1700
|
+
*/
|
|
1701
|
+
const readSetextHeading = (reading, at) => {
|
|
1702
|
+
if (reading.setextFrom < at && at <= reading.setextStop) {
|
|
1703
|
+
return -1;
|
|
1704
|
+
}
|
|
1705
|
+
const text = reading.level.text;
|
|
1706
|
+
if (breaksSetextHeading(text, at, true)) {
|
|
1707
|
+
return -1;
|
|
1708
|
+
}
|
|
1709
|
+
for (let lineStart = at;;) {
|
|
1710
|
+
const lineEnd = getLineEnd(text, lineStart);
|
|
1711
|
+
const separator = findSeparator(reading, lineStart, lineEnd);
|
|
1712
|
+
if (separator !== -1 || lineEnd >= text.length) {
|
|
1713
|
+
reading.setextFrom = at;
|
|
1714
|
+
reading.setextStop = separator === -1 ? text.length : separator;
|
|
1715
|
+
return -1;
|
|
1716
|
+
}
|
|
1717
|
+
if (isSetextUnderline(text, lineEnd + 1)) {
|
|
1718
|
+
return skipLineBreaks(text, getLineEnd(text, lineEnd + 1));
|
|
1719
|
+
}
|
|
1720
|
+
if (breaksSetextHeading(text, lineEnd + 1, false)) {
|
|
1721
|
+
reading.setextFrom = at;
|
|
1722
|
+
reading.setextStop = lineEnd;
|
|
1723
|
+
return -1;
|
|
1724
|
+
}
|
|
1725
|
+
lineStart = lineEnd + 1;
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
/*
|
|
1729
|
+
* A paragraph whose first line ends at `lineEnd`: lines up to one that is
|
|
1730
|
+
* empty or ends it.
|
|
1731
|
+
*/
|
|
1732
|
+
const readParagraph = (reading, lineEnd) => {
|
|
1733
|
+
const text = reading.level.text;
|
|
1734
|
+
let end = lineEnd;
|
|
1735
|
+
while (end + 1 < text.length) {
|
|
1736
|
+
const next = end + 1;
|
|
1737
|
+
if (text.charCodeAt(next) === LINE_FEED ||
|
|
1738
|
+
endsParagraph(reading, next, true)) {
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
end = getLineEnd(text, next);
|
|
1742
|
+
}
|
|
1743
|
+
return end;
|
|
1744
|
+
};
|
|
1745
|
+
/*
|
|
1746
|
+
* A definition read at `blockStart` of a level, where it is in the whole
|
|
1747
|
+
* text: in a quote or a list item, with what marked reads of it there.
|
|
1748
|
+
*/
|
|
1749
|
+
const toWholeDefinition = (level, definition) => {
|
|
1750
|
+
const blockStart = definition.start;
|
|
1751
|
+
const startsLine = blockStart === 0 || level.text.charCodeAt(blockStart - 1) === LINE_FEED;
|
|
1752
|
+
const whole = {
|
|
1753
|
+
start: startsLine
|
|
1754
|
+
? getWholeLineStart(level, blockStart)
|
|
1755
|
+
: toWhole(level, blockStart),
|
|
1756
|
+
labelStart: toWhole(level, definition.labelStart),
|
|
1757
|
+
labelEnd: toWhole(level, definition.labelEnd),
|
|
1758
|
+
label: definition.label,
|
|
1759
|
+
destinationStart: toWhole(level, definition.destinationStart),
|
|
1760
|
+
destinationEnd: toWhole(level, definition.destinationEnd),
|
|
1761
|
+
end: toWhole(level, definition.end),
|
|
1762
|
+
};
|
|
1763
|
+
if (level.depth > 0) {
|
|
1764
|
+
whole.nested = {
|
|
1765
|
+
text: level.text.slice(blockStart, definition.end),
|
|
1766
|
+
labelStart: definition.labelStart - blockStart,
|
|
1767
|
+
labelEnd: definition.labelEnd - blockStart,
|
|
1768
|
+
destinationEnd: definition.destinationEnd - blockStart,
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
return whole;
|
|
1772
|
+
};
|
|
1773
|
+
/*
|
|
1774
|
+
* Every definition marked reads in a level, read as its lexer reads the
|
|
1775
|
+
* level's blocks (blockTokens): `top` when its paragraphs run over lines -
|
|
1776
|
+
* the whole text, a quote, and a list item's lines after a list in it -
|
|
1777
|
+
* and not when each line is text of its own, as in a list item.
|
|
1778
|
+
*/
|
|
1779
|
+
const readBlocks = (level, top, definitions) => {
|
|
1780
|
+
const reading = startReading(level, definitions);
|
|
1781
|
+
const text = level.text;
|
|
1782
|
+
let isTop = top;
|
|
1783
|
+
// Whether the block before is a paragraph or text: a definition carries it on.
|
|
1784
|
+
let carriesOn = false;
|
|
1785
|
+
let at = 0;
|
|
1786
|
+
while (at < text.length) {
|
|
1787
|
+
// One line break joins the block before it; more end a paragraph.
|
|
1788
|
+
const spaceEnd = readSpace(text, at);
|
|
1789
|
+
if (spaceEnd > at) {
|
|
1790
|
+
carriesOn = carriesOn && spaceEnd - at === 1;
|
|
1791
|
+
at = spaceEnd;
|
|
459
1792
|
continue;
|
|
460
1793
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
1794
|
+
// Indented code carries on a paragraph, as a definition would.
|
|
1795
|
+
const codeEnd = readIndentedCode(text, at);
|
|
1796
|
+
if (codeEnd > at) {
|
|
1797
|
+
at = codeEnd;
|
|
464
1798
|
continue;
|
|
465
1799
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
indentedCode = false;
|
|
473
|
-
blockStart = true;
|
|
1800
|
+
const lineEnd = getLineEnd(text, at);
|
|
1801
|
+
const fenceEnd = readFencedCode(text, at, lineEnd);
|
|
1802
|
+
if (fenceEnd !== -1) {
|
|
1803
|
+
carriesOn = false;
|
|
1804
|
+
at = fenceEnd;
|
|
1805
|
+
continue;
|
|
474
1806
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
1807
|
+
if (isAtxHeading(reading, at, lineEnd) ||
|
|
1808
|
+
isThematicBreak(text, at, lineEnd)) {
|
|
1809
|
+
carriesOn = false;
|
|
1810
|
+
at = nextLineStart(text, lineEnd);
|
|
479
1811
|
continue;
|
|
480
1812
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1813
|
+
const quoteEnd = readBlockQuote(reading, at);
|
|
1814
|
+
if (quoteEnd !== -1) {
|
|
1815
|
+
carriesOn = false;
|
|
1816
|
+
at = quoteEnd;
|
|
485
1817
|
continue;
|
|
486
1818
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
1819
|
+
// After a list, marked reads paragraphs over lines (its items set "top").
|
|
1820
|
+
const listEnd = readList(reading, at);
|
|
1821
|
+
if (listEnd !== -1) {
|
|
1822
|
+
carriesOn = false;
|
|
1823
|
+
isTop = true;
|
|
1824
|
+
at = listEnd;
|
|
1825
|
+
continue;
|
|
1826
|
+
}
|
|
1827
|
+
const htmlEnd = readHtml(reading, at);
|
|
1828
|
+
if (htmlEnd !== -1) {
|
|
1829
|
+
carriesOn = false;
|
|
1830
|
+
at = htmlEnd;
|
|
1831
|
+
continue;
|
|
1832
|
+
}
|
|
1833
|
+
const definition = readDefinition(text, at, getFinders(reading));
|
|
1834
|
+
if (definition !== null) {
|
|
1835
|
+
if (!carriesOn) {
|
|
1836
|
+
definitions.push(toWholeDefinition(level, definition.definition));
|
|
499
1837
|
}
|
|
1838
|
+
at = definition.next;
|
|
1839
|
+
continue;
|
|
500
1840
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
1841
|
+
const tableEnd = readTable(reading, at, lineEnd);
|
|
1842
|
+
if (tableEnd !== -1) {
|
|
1843
|
+
carriesOn = false;
|
|
1844
|
+
at = tableEnd;
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
const headingEnd = readSetextHeading(reading, at);
|
|
1848
|
+
if (headingEnd !== -1) {
|
|
1849
|
+
carriesOn = false;
|
|
1850
|
+
at = headingEnd;
|
|
1851
|
+
continue;
|
|
1852
|
+
}
|
|
1853
|
+
at = isTop ? readParagraph(reading, lineEnd) : lineEnd;
|
|
1854
|
+
carriesOn = true;
|
|
1855
|
+
}
|
|
1856
|
+
};
|
|
1857
|
+
/*
|
|
1858
|
+
* Every link reference definition marked reads in `text` (see the top of
|
|
1859
|
+
* this file), in the order of the text: a label defined twice, twice.
|
|
1860
|
+
*/
|
|
1861
|
+
const getLinkReferenceDefinitions = (text) => {
|
|
1862
|
+
const definitions = [];
|
|
1863
|
+
if (typeof text !== "string" || text.indexOf("]:") === -1) {
|
|
1864
|
+
return definitions;
|
|
504
1865
|
}
|
|
1866
|
+
readBlocks(getWholeLevel(text), true, definitions);
|
|
505
1867
|
return definitions;
|
|
506
1868
|
};
|
|
507
1869
|
exports.getLinkReferenceDefinitions = getLinkReferenceDefinitions;
|