react-native-enriched-markdown-scaffold 1.0.2-scaffold.9 → 1.2.0-scaffold.2
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/ReactNativeEnrichedMarkdown.podspec +31 -10
- package/android/build.gradle +49 -12
- package/android/consumer-rules.pro +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +6 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerDelegate.java +3 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextInputManagerInterface.java +1 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +6 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/android/src/main/baseline-prof.txt +21 -22
- package/android/src/main/cpp/jni-adapter.cpp +17 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +729 -768
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +72 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +222 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +65 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +191 -26
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt +54 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CodeBlockPressEvent.kt +24 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/ImagePressEvent.kt +25 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LatexErrorEvent.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputManager.kt +21 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +101 -9
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/EditPipeline.kt +48 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/MarkdownShortcutMatcher.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/formatting/InputRemend.kt +44 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/input/layout/InputEventEmitter.kt +9 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/math/LatexErrorReporter.kt +9 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/MarkdownASTNode.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlankLineRenderer.kt +38 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt +2 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/BlockquoteTextRenderer.kt +55 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt +8 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/HighlightRenderer.kt +10 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +31 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/ParagraphRenderer.kt +17 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/Renderer.kt +40 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/AdmonitionIcons.kt +62 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/BlockSegmentView.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/BlockquoteContainerView.kt +401 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/CodeBlockContainerView.kt +55 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/ContainerNodeView.kt +164 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/MarkdownSegment.kt +21 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/RenderedSegment.kt +137 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentHeightMeasurer.kt +139 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentReconciler.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/{utils/common → segments}/SegmentSignature.kt +3 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewCreators.kt +262 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/segments/SegmentViewFactory.kt +29 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/{views → segments}/TableContainerView.kt +100 -36
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +18 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/HighlightSpan.kt +60 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/ImageSpan.kt +15 -5
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineBackgroundGeometry.kt +42 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +4 -27
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LineHeightSpan.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spoiler/SpoilerDrawUtils.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/BlockquoteStyle.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/StyleConfig.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/VideoStyle.kt +31 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/BorderStyleUtils.kt +86 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EllipsizeUtils.kt +27 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/EnrichedMarkdownAncestorUtils.kt +10 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/ReadableMapExtensions.kt +5 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt +227 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +50 -28
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +16 -21
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +4 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/BlockSpacing.kt +3 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/span/SpanFlags.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/CodeBlockPressHost.kt +15 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/ImagePressHost.kt +19 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkEvents.kt +11 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLongPressMovementMethod.kt +87 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/TextViewSetup.kt +79 -0
- package/android/src/main/jni/react/renderer/components/EnrichedMarkdownTextSpec/conversions.h +2 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +9 -3
- package/android/src/math/java/com/swmansion/enriched/markdown/{views → segments}/MathContainerView.kt +86 -29
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +33 -7
- package/android/src/video/java/com/swmansion/enriched/markdown/segments/VideoContainerView.kt +115 -0
- package/cpp/md4c/md4c.c +343 -236
- package/cpp/md4c/md4c.h +28 -11
- package/cpp/parser/MD4CParser.cpp +266 -4
- package/cpp/parser/MD4CParser.hpp +6 -2
- package/cpp/parser/MarkdownASTNode.hpp +4 -1
- package/cpp/wasm/ASTSerializer.cpp +6 -0
- package/cpp/wasm/md4c_wasm.cpp +5 -1
- package/docs/API_REFERENCE.md +199 -12
- package/docs/BREAKING_CHANGES.md +75 -0
- package/docs/CODE_HIGHLIGHT.md +4 -0
- package/docs/COPY_OPTIONS.md +52 -9
- package/docs/ELEMENTS_STRUCTURE.md +48 -1
- package/docs/INPUT.md +60 -3
- package/docs/LATEX_MATH.md +30 -0
- package/docs/MACOS.md +1 -1
- package/docs/MENTIONS.md +2 -2
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +8 -0
- package/docs/WEB.md +44 -10
- package/ios/EnrichedMarkdown.mm +285 -43
- package/ios/EnrichedMarkdownText.mm +185 -23
- package/ios/attachments/ENRMImageAttachment.h +17 -2
- package/ios/attachments/ENRMImageAttachment.m +26 -28
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +10 -2
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -1
- package/ios/attachments/ENRMMathInlineAttachment.m +17 -1
- package/ios/attachments/ENRMMathInlineAttachmentShared.h +3 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +62 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +44 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +67 -2
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +929 -178
- package/ios/input/ENRMInputFormatter.mm +68 -12
- package/ios/input/ENRMInputFormatterStyle.mm +9 -2
- package/ios/input/ENRMInputParser.mm +18 -0
- package/ios/input/ENRMInputRemend.mm +40 -3
- package/ios/input/ENRMMarkdownShortcutMatcher.h +39 -0
- package/ios/input/ENRMMarkdownShortcutMatcher.mm +66 -0
- package/ios/input/EnrichedMarkdownTextInput.mm +129 -1
- package/ios/internals/ENRMViewFreeMeasurement.h +45 -6
- package/ios/internals/MeasurementCache.h +20 -4
- package/ios/internals/ShadowMeasurementUtils.h +2 -0
- package/ios/math/ENRMLatexErrorCoordinator.h +27 -0
- package/ios/math/ENRMLatexErrorCoordinator.mm +75 -0
- package/ios/math/ENRMLatexErrorReporting.h +13 -0
- package/ios/math/ENRMRaTeXBridge.swift +46 -3
- package/ios/parser/ENRMMarkdownParser.h +3 -0
- package/ios/parser/ENRMMarkdownParser.mm +11 -2
- package/ios/parser/MarkdownASTNode.h +8 -1
- package/ios/parser/MarkdownASTNode.m +20 -0
- package/ios/parser/MarkdownParserBridge.mm +13 -2
- package/ios/renderer/AttributedRenderer.h +13 -1
- package/ios/renderer/AttributedRenderer.m +24 -13
- package/ios/renderer/BaselineShiftTextAttributes.h +4 -0
- package/ios/renderer/BaselineShiftTextAttributes.m +4 -0
- package/ios/renderer/BlankLineRenderer.h +4 -0
- package/ios/renderer/BlankLineRenderer.m +51 -0
- package/ios/renderer/BlockquoteRenderer.m +1 -0
- package/ios/renderer/CodeBlockRenderer.m +8 -0
- package/ios/renderer/CodeRenderer.m +5 -2
- package/ios/renderer/ENRMBlockquoteTextRenderer.h +25 -0
- package/ios/renderer/ENRMBlockquoteTextRenderer.m +48 -0
- package/ios/renderer/ENRMImageRenderer.m +1 -1
- package/ios/renderer/ENRMMathInlineRenderer.m +9 -1
- package/ios/renderer/HeadingRenderer.m +1 -0
- package/ios/renderer/HighlightRenderer.m +6 -0
- package/ios/renderer/LinkRenderer.m +1 -1
- package/ios/renderer/ListItemRenderer.m +51 -2
- package/ios/renderer/ParagraphRenderer.m +10 -3
- package/ios/renderer/RenderContext.h +16 -0
- package/ios/renderer/RenderContext.m +16 -0
- package/ios/renderer/RendererFactory.m +6 -0
- package/ios/renderer/SubscriptRenderer.m +1 -0
- package/ios/renderer/SuperscriptRenderer.m +1 -0
- package/ios/segments/ENRMAdmonitionIcons.h +31 -0
- package/ios/segments/ENRMAdmonitionIcons.m +93 -0
- package/ios/segments/ENRMBlockquoteContainerView.h +90 -0
- package/ios/segments/ENRMBlockquoteContainerView.mm +551 -0
- package/ios/{views → segments}/ENRMCodeBlockContainerView.h +9 -4
- package/ios/{views → segments}/ENRMCodeBlockContainerView.m +147 -36
- package/ios/segments/ENRMContainerNodeView.h +52 -0
- package/ios/segments/ENRMContainerNodeView.mm +201 -0
- package/ios/segments/ENRMDynamicBlockProps.h +32 -0
- package/ios/segments/ENRMDynamicBlockProps.m +15 -0
- package/ios/{views → segments}/ENRMMathContainerView.h +13 -5
- package/ios/{views → segments}/ENRMMathContainerView.m +60 -9
- package/ios/segments/ENRMSVGPath.h +21 -0
- package/ios/segments/ENRMSVGPath.m +409 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.h +33 -0
- package/ios/segments/ENRMSegmentHeightMeasurer.mm +94 -0
- package/ios/segments/ENRMVideoContainerView.h +40 -0
- package/ios/segments/ENRMVideoContainerView.m +421 -0
- package/ios/{utils → segments}/RenderedMarkdownSegment.h +19 -2
- package/ios/{utils → segments}/RenderedMarkdownSegment.m +42 -1
- package/ios/segments/SegmentRenderer.h +26 -0
- package/ios/{utils → segments}/SegmentRenderer.m +46 -9
- package/ios/{views → segments}/TableContainerView.h +5 -4
- package/ios/{views → segments}/TableContainerView.m +96 -12
- package/ios/styles/StyleConfig.h +17 -0
- package/ios/styles/StyleConfig.mm +90 -0
- package/ios/utils/ENRMCodeBlockContent.mm +13 -0
- package/ios/utils/ENRMFeatureFlags.h +6 -0
- package/ios/utils/ENRMTextRenderer.h +8 -0
- package/ios/utils/ENRMTextRenderer.m +26 -10
- package/ios/utils/ENRMUIKit.h +1 -0
- package/ios/utils/FontUtils.h +2 -1
- package/ios/utils/FontUtils.m +22 -6
- package/ios/utils/LinkTapUtils.h +17 -2
- package/ios/utils/LinkTapUtils.m +44 -2
- package/ios/utils/ListMarkerDrawer.m +25 -1
- package/ios/utils/MarkdownASTSerializer.h +7 -0
- package/ios/utils/MarkdownASTSerializer.m +243 -0
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +9 -67
- package/ios/utils/MarkdownExtractor.m +6 -3
- package/ios/utils/ParagraphStyleUtils.h +25 -1
- package/ios/utils/ParagraphStyleUtils.m +51 -7
- package/ios/utils/StylePropsUtils.h +60 -1
- package/ios/utils/TextViewLayoutManager.mm +57 -0
- package/lib/module/EnrichedMarkdownNativeComponent.ts +110 -4
- package/lib/module/EnrichedMarkdownTextInput.js +60 -2
- package/lib/module/EnrichedMarkdownTextInput.js.map +1 -1
- package/lib/module/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/lib/module/admonitionDefaults.js +34 -0
- package/lib/module/admonitionDefaults.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +84 -4
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +58 -5
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownShortcuts.js +31 -0
- package/lib/module/normalizeMarkdownShortcuts.js.map +1 -0
- package/lib/module/normalizeMarkdownStyle.js +15 -1
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +15 -1
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/styleUtils.js +15 -3
- package/lib/module/styleUtils.js.map +1 -1
- package/lib/module/utils/textInputState.js +4 -3
- package/lib/module/utils/textInputState.js.map +1 -1
- package/lib/module/utils/usePressability.js +28 -0
- package/lib/module/utils/usePressability.js.map +1 -0
- package/lib/module/web/EnrichedMarkdownText.js +19 -6
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/globalStyles.js +7 -1
- package/lib/module/web/globalStyles.js.map +1 -1
- package/lib/module/web/nativeProps.js +70 -0
- package/lib/module/web/nativeProps.js.map +1 -0
- package/lib/module/web/parseMarkdown.js +5 -3
- package/lib/module/web/parseMarkdown.js.map +1 -1
- package/lib/module/web/renderers/BlockRenderers.js +164 -8
- package/lib/module/web/renderers/BlockRenderers.js.map +1 -1
- package/lib/module/web/renderers/admonitionIcons.js +34 -0
- package/lib/module/web/renderers/admonitionIcons.js.map +1 -0
- package/lib/module/web/styles.js +30 -8
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/wasm/md4c.js +0 -0
- package/lib/module/web/wasm/md4c.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +103 -3
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts +27 -3
- package/lib/typescript/src/EnrichedMarkdownTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts +11 -0
- package/lib/typescript/src/EnrichedMarkdownTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +108 -3
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/admonitionDefaults.d.ts +10 -0
- package/lib/typescript/src/admonitionDefaults.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/jest/index.d.ts +2 -2
- package/lib/typescript/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +3 -3
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts +7 -0
- package/lib/typescript/src/normalizeMarkdownShortcuts.d.ts.map +1 -0
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/styleUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +59 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +21 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +93 -8
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +25 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +33 -5
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/utils/textInputState.d.ts +5 -3
- package/lib/typescript/src/utils/textInputState.d.ts.map +1 -1
- package/lib/typescript/src/utils/usePressability.d.ts +24 -0
- package/lib/typescript/src/utils/usePressability.d.ts.map +1 -0
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/globalStyles.d.ts +1 -0
- package/lib/typescript/src/web/globalStyles.d.ts.map +1 -1
- package/lib/typescript/src/web/nativeProps.d.ts +34 -0
- package/lib/typescript/src/web/nativeProps.d.ts.map +1 -0
- package/lib/typescript/src/web/parseMarkdown.d.ts +1 -1
- package/lib/typescript/src/web/parseMarkdown.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/BlockRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts +5 -0
- package/lib/typescript/src/web/renderers/admonitionIcons.d.ts.map +1 -0
- package/lib/typescript/src/web/styles.d.ts +1 -0
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +8 -2
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +7 -0
- package/src/EnrichedMarkdownNativeComponent.ts +110 -4
- package/src/EnrichedMarkdownTextInput.tsx +101 -4
- package/src/EnrichedMarkdownTextInputNativeComponent.ts +12 -0
- package/src/EnrichedMarkdownTextNativeComponent.ts +115 -4
- package/src/admonitionDefaults.ts +58 -0
- package/src/index.tsx +5 -0
- package/src/index.web.tsx +3 -0
- package/src/jest/index.tsx +138 -5
- package/src/native/EnrichedMarkdownText.tsx +55 -3
- package/src/normalizeMarkdownShortcuts.ts +38 -0
- package/src/normalizeMarkdownStyle.ts +17 -0
- package/src/normalizeMarkdownStyle.web.ts +17 -0
- package/src/styleUtils.ts +17 -6
- package/src/types/MarkdownStyle.ts +62 -1
- package/src/types/MarkdownStyleInternal.ts +24 -0
- package/src/types/MarkdownTextProps.ts +95 -7
- package/src/types/MarkdownTextProps.web.ts +26 -0
- package/src/types/events.ts +36 -5
- package/src/utils/textInputState.ts +5 -3
- package/src/utils/usePressability.ts +34 -0
- package/src/web/EnrichedMarkdownText.tsx +36 -3
- package/src/web/globalStyles.ts +10 -0
- package/src/web/nativeProps.ts +78 -0
- package/src/web/parseMarkdown.ts +10 -2
- package/src/web/renderers/BlockRenderers.tsx +175 -6
- package/src/web/renderers/admonitionIcons.ts +37 -0
- package/src/web/styles.ts +28 -3
- package/src/web/types.ts +12 -1
- package/src/web/wasm/md4c.js +0 -0
- package/vendor-ratex.mjs +86 -17
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/DocumentRenderer.kt +0 -16
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/RenderedSegment.kt +0 -88
- package/ios/utils/SegmentRenderer.h +0 -24
- /package/ios/{views → segments}/ENRMTableGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableGridView.m +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.h +0 -0
- /package/ios/{views → segments}/ENRMTableIOSGridView.m +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.h +0 -0
- /package/ios/{utils → segments}/SegmentReconciler.m +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.h +0 -0
- /package/ios/{utils → segments}/SegmentViewRegistry.m +0 -0
package/cpp/md4c/md4c.c
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
#include <limits.h>
|
|
27
|
+
#include <stdbool.h>
|
|
27
28
|
#include <stdint.h>
|
|
28
29
|
#include <stdio.h>
|
|
29
30
|
#include <stdlib.h>
|
|
@@ -72,11 +73,6 @@
|
|
|
72
73
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
|
73
74
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
74
75
|
|
|
75
|
-
#ifndef TRUE
|
|
76
|
-
#define TRUE 1
|
|
77
|
-
#define FALSE 0
|
|
78
|
-
#endif
|
|
79
|
-
|
|
80
76
|
#define MD_LOG(msg) \
|
|
81
77
|
do { \
|
|
82
78
|
if(ctx->parser.debug_log != NULL) \
|
|
@@ -222,7 +218,7 @@ struct MD_CTX_tag {
|
|
|
222
218
|
#endif
|
|
223
219
|
|
|
224
220
|
/* For resolving of inline spans. */
|
|
225
|
-
MD_MARKSTACK opener_stacks[
|
|
221
|
+
MD_MARKSTACK opener_stacks[20];
|
|
226
222
|
#define ASTERISK_OPENERS_oo_mod3_0 (ctx->opener_stacks[0]) /* Opener-only */
|
|
227
223
|
#define ASTERISK_OPENERS_oo_mod3_1 (ctx->opener_stacks[1])
|
|
228
224
|
#define ASTERISK_OPENERS_oo_mod3_2 (ctx->opener_stacks[2])
|
|
@@ -242,6 +238,7 @@ struct MD_CTX_tag {
|
|
|
242
238
|
#define PIPE_OPENERS (ctx->opener_stacks[16])
|
|
243
239
|
#define CARET_OPENERS (ctx->opener_stacks[17])
|
|
244
240
|
#define EQUAL_OPENERS (ctx->opener_stacks[18])
|
|
241
|
+
#define PLUS_OPENERS (ctx->opener_stacks[19])
|
|
245
242
|
|
|
246
243
|
/* Stack of dummies which need to call free() for pointers stored in them.
|
|
247
244
|
* These are constructed during inline parsing and freed after all the block
|
|
@@ -275,6 +272,10 @@ struct MD_CTX_tag {
|
|
|
275
272
|
int n_block_bytes;
|
|
276
273
|
int alloc_block_bytes;
|
|
277
274
|
|
|
275
|
+
/* Pending count of blank lines not yet reported as MD_BLOCK_BLANK.
|
|
276
|
+
* Used only with MD_FLAG_PRESERVEBLANKLINES. */
|
|
277
|
+
unsigned n_blank_lines;
|
|
278
|
+
|
|
278
279
|
/* For container block analysis. */
|
|
279
280
|
MD_CONTAINER* containers;
|
|
280
281
|
int n_containers;
|
|
@@ -395,9 +396,9 @@ md_ascii_case_eq(const CHAR* s1, const CHAR* s2, SZ n)
|
|
|
395
396
|
if(ISLOWER_(ch2))
|
|
396
397
|
ch2 += ('A'-'a');
|
|
397
398
|
if(ch1 != ch2)
|
|
398
|
-
return
|
|
399
|
+
return false;
|
|
399
400
|
}
|
|
400
|
-
return
|
|
401
|
+
return true;
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
static inline int
|
|
@@ -1118,7 +1119,7 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg, OFF
|
|
|
1118
1119
|
MD_ASSERT(CH(beg) == _T('<'));
|
|
1119
1120
|
|
|
1120
1121
|
if(off + 1 >= line_end)
|
|
1121
|
-
return
|
|
1122
|
+
return false;
|
|
1122
1123
|
off++;
|
|
1123
1124
|
|
|
1124
1125
|
/* For parsing attributes, we need a little state automaton below.
|
|
@@ -1141,7 +1142,7 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg, OFF
|
|
|
1141
1142
|
|
|
1142
1143
|
/* Tag name */
|
|
1143
1144
|
if(off >= line_end || !ISALPHA(off))
|
|
1144
|
-
return
|
|
1145
|
+
return false;
|
|
1145
1146
|
off++;
|
|
1146
1147
|
while(off < line_end && (ISALNUM(off) || CH(off) == _T('-')))
|
|
1147
1148
|
off++;
|
|
@@ -1190,22 +1191,22 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg, OFF
|
|
|
1190
1191
|
else if(!ISANYOF(off, _T("\"'=<>`")) && !ISNEWLINE(off))
|
|
1191
1192
|
attr_state = 41;
|
|
1192
1193
|
else
|
|
1193
|
-
return
|
|
1194
|
+
return false;
|
|
1194
1195
|
off++;
|
|
1195
1196
|
} else {
|
|
1196
1197
|
/* Anything unexpected. */
|
|
1197
|
-
return
|
|
1198
|
+
return false;
|
|
1198
1199
|
}
|
|
1199
1200
|
}
|
|
1200
1201
|
|
|
1201
1202
|
/* We have to be on a single line. See definition of start condition
|
|
1202
1203
|
* of HTML block, type 7. */
|
|
1203
1204
|
if(n_lines == 0)
|
|
1204
|
-
return
|
|
1205
|
+
return false;
|
|
1205
1206
|
|
|
1206
1207
|
line_index++;
|
|
1207
1208
|
if(line_index >= n_lines)
|
|
1208
|
-
return
|
|
1209
|
+
return false;
|
|
1209
1210
|
|
|
1210
1211
|
off = lines[line_index].beg;
|
|
1211
1212
|
line_end = lines[line_index].end;
|
|
@@ -1214,15 +1215,15 @@ md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg, OFF
|
|
|
1214
1215
|
attr_state = 1;
|
|
1215
1216
|
|
|
1216
1217
|
if(off >= max_end)
|
|
1217
|
-
return
|
|
1218
|
+
return false;
|
|
1218
1219
|
}
|
|
1219
1220
|
|
|
1220
1221
|
done:
|
|
1221
1222
|
if(off >= max_end)
|
|
1222
|
-
return
|
|
1223
|
+
return false;
|
|
1223
1224
|
|
|
1224
1225
|
*p_end = off+1;
|
|
1225
|
-
return
|
|
1226
|
+
return true;
|
|
1226
1227
|
}
|
|
1227
1228
|
|
|
1228
1229
|
static int
|
|
@@ -1237,15 +1238,15 @@ md_scan_for_html_closer(MD_CTX* ctx, const MD_CHAR* str, MD_SIZE len,
|
|
|
1237
1238
|
if(off < *p_scan_horizon && *p_scan_horizon >= max_end - len) {
|
|
1238
1239
|
/* We have already scanned the range up to the max_end so we know
|
|
1239
1240
|
* there is nothing to see. */
|
|
1240
|
-
return
|
|
1241
|
+
return false;
|
|
1241
1242
|
}
|
|
1242
1243
|
|
|
1243
|
-
while(
|
|
1244
|
+
while(true) {
|
|
1244
1245
|
while(off + len <= lines[line_index].end && off + len <= max_end) {
|
|
1245
1246
|
if(md_ascii_eq(STR(off), str, len)) {
|
|
1246
1247
|
/* Success. */
|
|
1247
1248
|
*p_end = off + len;
|
|
1248
|
-
return
|
|
1249
|
+
return true;
|
|
1249
1250
|
}
|
|
1250
1251
|
off++;
|
|
1251
1252
|
}
|
|
@@ -1254,7 +1255,7 @@ md_scan_for_html_closer(MD_CTX* ctx, const MD_CHAR* str, MD_SIZE len,
|
|
|
1254
1255
|
if(off >= max_end || line_index >= n_lines) {
|
|
1255
1256
|
/* Failure. */
|
|
1256
1257
|
*p_scan_horizon = off;
|
|
1257
|
-
return
|
|
1258
|
+
return false;
|
|
1258
1259
|
}
|
|
1259
1260
|
|
|
1260
1261
|
off = lines[line_index].beg;
|
|
@@ -1269,9 +1270,9 @@ md_is_html_comment(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
1269
1270
|
MD_ASSERT(CH(beg) == _T('<'));
|
|
1270
1271
|
|
|
1271
1272
|
if(off + 4 >= lines[0].end)
|
|
1272
|
-
return
|
|
1273
|
+
return false;
|
|
1273
1274
|
if(CH(off+1) != _T('!') || CH(off+2) != _T('-') || CH(off+3) != _T('-'))
|
|
1274
|
-
return
|
|
1275
|
+
return false;
|
|
1275
1276
|
|
|
1276
1277
|
/* Skip only "<!" so that we accept also "<!-->" or "<!--->" */
|
|
1277
1278
|
off += 2;
|
|
@@ -1287,9 +1288,9 @@ md_is_html_processing_instruction(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_l
|
|
|
1287
1288
|
OFF off = beg;
|
|
1288
1289
|
|
|
1289
1290
|
if(off + 2 >= lines[0].end)
|
|
1290
|
-
return
|
|
1291
|
+
return false;
|
|
1291
1292
|
if(CH(off+1) != _T('?'))
|
|
1292
|
-
return
|
|
1293
|
+
return false;
|
|
1293
1294
|
off += 2;
|
|
1294
1295
|
|
|
1295
1296
|
return md_scan_for_html_closer(ctx, _T("?>"), 2,
|
|
@@ -1302,14 +1303,14 @@ md_is_html_declaration(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF b
|
|
|
1302
1303
|
OFF off = beg;
|
|
1303
1304
|
|
|
1304
1305
|
if(off + 2 >= lines[0].end)
|
|
1305
|
-
return
|
|
1306
|
+
return false;
|
|
1306
1307
|
if(CH(off+1) != _T('!'))
|
|
1307
|
-
return
|
|
1308
|
+
return false;
|
|
1308
1309
|
off += 2;
|
|
1309
1310
|
|
|
1310
1311
|
/* Declaration name. */
|
|
1311
1312
|
if(off >= lines[0].end || !ISALPHA(off))
|
|
1312
|
-
return
|
|
1313
|
+
return false;
|
|
1313
1314
|
off++;
|
|
1314
1315
|
while(off < lines[0].end && ISALPHA(off))
|
|
1315
1316
|
off++;
|
|
@@ -1327,9 +1328,9 @@ md_is_html_cdata(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg, OF
|
|
|
1327
1328
|
OFF off = beg;
|
|
1328
1329
|
|
|
1329
1330
|
if(off + open_size >= lines[0].end)
|
|
1330
|
-
return
|
|
1331
|
+
return false;
|
|
1331
1332
|
if(memcmp(STR(off), open_str, open_size * sizeof(CHAR)) != 0)
|
|
1332
|
-
return
|
|
1333
|
+
return false;
|
|
1333
1334
|
off += open_size;
|
|
1334
1335
|
|
|
1335
1336
|
return md_scan_for_html_closer(ctx, _T("]]>"), 3,
|
|
@@ -1363,9 +1364,9 @@ md_is_hex_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, O
|
|
|
1363
1364
|
|
|
1364
1365
|
if(1 <= off - beg && off - beg <= 6) {
|
|
1365
1366
|
*p_end = off;
|
|
1366
|
-
return
|
|
1367
|
+
return true;
|
|
1367
1368
|
} else {
|
|
1368
|
-
return
|
|
1369
|
+
return false;
|
|
1369
1370
|
}
|
|
1370
1371
|
}
|
|
1371
1372
|
|
|
@@ -1380,9 +1381,9 @@ md_is_dec_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, O
|
|
|
1380
1381
|
|
|
1381
1382
|
if(1 <= off - beg && off - beg <= 7) {
|
|
1382
1383
|
*p_end = off;
|
|
1383
|
-
return
|
|
1384
|
+
return true;
|
|
1384
1385
|
} else {
|
|
1385
|
-
return
|
|
1386
|
+
return false;
|
|
1386
1387
|
}
|
|
1387
1388
|
}
|
|
1388
1389
|
|
|
@@ -1395,16 +1396,16 @@ md_is_named_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end,
|
|
|
1395
1396
|
if(off < max_end && ISALPHA_(text[off]))
|
|
1396
1397
|
off++;
|
|
1397
1398
|
else
|
|
1398
|
-
return
|
|
1399
|
+
return false;
|
|
1399
1400
|
|
|
1400
1401
|
while(off < max_end && ISALNUM_(text[off]) && off - beg <= 48)
|
|
1401
1402
|
off++;
|
|
1402
1403
|
|
|
1403
1404
|
if(2 <= off - beg && off - beg <= 48) {
|
|
1404
1405
|
*p_end = off;
|
|
1405
|
-
return
|
|
1406
|
+
return true;
|
|
1406
1407
|
} else {
|
|
1407
|
-
return
|
|
1408
|
+
return false;
|
|
1408
1409
|
}
|
|
1409
1410
|
}
|
|
1410
1411
|
|
|
@@ -1426,9 +1427,9 @@ md_is_entity_str(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end
|
|
|
1426
1427
|
|
|
1427
1428
|
if(is_contents && off < max_end && text[off] == _T(';')) {
|
|
1428
1429
|
*p_end = off+1;
|
|
1429
|
-
return
|
|
1430
|
+
return true;
|
|
1430
1431
|
} else {
|
|
1431
|
-
return
|
|
1432
|
+
return false;
|
|
1432
1433
|
}
|
|
1433
1434
|
}
|
|
1434
1435
|
|
|
@@ -1517,10 +1518,10 @@ md_build_attribute(MD_CTX* ctx, const CHAR* raw_text, SZ raw_size,
|
|
|
1517
1518
|
|
|
1518
1519
|
/* If there is no backslash and no ampersand, build trivial attribute
|
|
1519
1520
|
* without any malloc(). */
|
|
1520
|
-
is_trivial =
|
|
1521
|
+
is_trivial = true;
|
|
1521
1522
|
for(raw_off = 0; raw_off < raw_size; raw_off++) {
|
|
1522
1523
|
if(ISANYOF3_(raw_text[raw_off], _T('\\'), _T('&'), _T('\0'))) {
|
|
1523
|
-
is_trivial =
|
|
1524
|
+
is_trivial = false;
|
|
1524
1525
|
break;
|
|
1525
1526
|
}
|
|
1526
1527
|
}
|
|
@@ -1623,7 +1624,7 @@ md_label_hash(const CHAR* label, SZ size)
|
|
|
1623
1624
|
unsigned hash = MD_FNV1A_BASE;
|
|
1624
1625
|
OFF off;
|
|
1625
1626
|
unsigned codepoint;
|
|
1626
|
-
int is_whitespace =
|
|
1627
|
+
int is_whitespace = false;
|
|
1627
1628
|
|
|
1628
1629
|
off = md_skip_unicode_whitespace(label, 0, size);
|
|
1629
1630
|
while(off < size) {
|
|
@@ -1761,7 +1762,7 @@ static int
|
|
|
1761
1762
|
md_is_complex_label_bucket(MD_LABEL_HASH_TABLE* table, void* bucket)
|
|
1762
1763
|
{
|
|
1763
1764
|
if(bucket == NULL)
|
|
1764
|
-
return
|
|
1765
|
+
return false;
|
|
1765
1766
|
|
|
1766
1767
|
return (MD_LABEL_HASH_ENTRY*) bucket < (MD_LABEL_HASH_ENTRY*) table->defs ||
|
|
1767
1768
|
(MD_LABEL_HASH_ENTRY*) bucket >= (MD_LABEL_HASH_ENTRY*)((char*)table->defs + table->n_defs * table->def_size);
|
|
@@ -2009,7 +2010,6 @@ md_lookup_ref_def(MD_CTX* ctx, const CHAR* label, SZ label_size)
|
|
|
2009
2010
|
*** Footnote Definitions ***
|
|
2010
2011
|
*******************************/
|
|
2011
2012
|
|
|
2012
|
-
typedef struct MD_FOOTNOTE_DEF_tag MD_FOOTNOTE_DEF;
|
|
2013
2013
|
struct MD_FOOTNOTE_DEF_tag {
|
|
2014
2014
|
MD_LABEL_HASH_ENTRY entry;
|
|
2015
2015
|
unsigned int index; /* 0 = unreferenced; 1-based order of first reference */
|
|
@@ -2046,16 +2046,16 @@ md_is_footnote_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
|
|
|
2046
2046
|
off++;
|
|
2047
2047
|
label_end = off;
|
|
2048
2048
|
if(label_end == label_beg)
|
|
2049
|
-
return
|
|
2049
|
+
return false;
|
|
2050
2050
|
|
|
2051
2051
|
/* Closing bracket. */
|
|
2052
2052
|
if(off >= lines[0].end || CH(off) != _T(']'))
|
|
2053
|
-
return
|
|
2053
|
+
return false;
|
|
2054
2054
|
off++;
|
|
2055
2055
|
|
|
2056
2056
|
/* Colon. */
|
|
2057
2057
|
if(off >= lines[0].end || CH(off) != _T(':'))
|
|
2058
|
-
return
|
|
2058
|
+
return false;
|
|
2059
2059
|
off++;
|
|
2060
2060
|
|
|
2061
2061
|
/* Skip optional whitespace after colon on the first line. */
|
|
@@ -2183,7 +2183,7 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2183
2183
|
*p_beg_line_index = 0;
|
|
2184
2184
|
|
|
2185
2185
|
if(CH(off) != _T('['))
|
|
2186
|
-
return
|
|
2186
|
+
return false;
|
|
2187
2187
|
off++;
|
|
2188
2188
|
|
|
2189
2189
|
while(1) {
|
|
@@ -2198,7 +2198,7 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2198
2198
|
contents_end = off + 2;
|
|
2199
2199
|
off += 2;
|
|
2200
2200
|
} else if(CH(off) == _T('[')) {
|
|
2201
|
-
return
|
|
2201
|
+
return false;
|
|
2202
2202
|
} else if(CH(off) == _T(']')) {
|
|
2203
2203
|
if(contents_beg < contents_end) {
|
|
2204
2204
|
/* Success. */
|
|
@@ -2206,10 +2206,10 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2206
2206
|
*p_contents_end = contents_end;
|
|
2207
2207
|
*p_end = off+1;
|
|
2208
2208
|
*p_end_line_index = line_index;
|
|
2209
|
-
return
|
|
2209
|
+
return true;
|
|
2210
2210
|
} else {
|
|
2211
2211
|
/* Link label must have some non-whitespace contents. */
|
|
2212
|
-
return
|
|
2212
|
+
return false;
|
|
2213
2213
|
}
|
|
2214
2214
|
} else {
|
|
2215
2215
|
unsigned codepoint;
|
|
@@ -2229,7 +2229,7 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2229
2229
|
|
|
2230
2230
|
len++;
|
|
2231
2231
|
if(len > 999)
|
|
2232
|
-
return
|
|
2232
|
+
return false;
|
|
2233
2233
|
}
|
|
2234
2234
|
|
|
2235
2235
|
line_index++;
|
|
@@ -2240,7 +2240,7 @@ md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2240
2240
|
break;
|
|
2241
2241
|
}
|
|
2242
2242
|
|
|
2243
|
-
return
|
|
2243
|
+
return false;
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
2246
|
static int
|
|
@@ -2250,7 +2250,7 @@ md_is_link_destination_A(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
|
|
|
2250
2250
|
OFF off = beg;
|
|
2251
2251
|
|
|
2252
2252
|
if(off >= max_end || CH(off) != _T('<'))
|
|
2253
|
-
return
|
|
2253
|
+
return false;
|
|
2254
2254
|
off++;
|
|
2255
2255
|
|
|
2256
2256
|
while(off < max_end) {
|
|
@@ -2260,20 +2260,20 @@ md_is_link_destination_A(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
|
|
|
2260
2260
|
}
|
|
2261
2261
|
|
|
2262
2262
|
if(ISNEWLINE(off) || CH(off) == _T('<'))
|
|
2263
|
-
return
|
|
2263
|
+
return false;
|
|
2264
2264
|
|
|
2265
2265
|
if(CH(off) == _T('>')) {
|
|
2266
2266
|
/* Success. */
|
|
2267
2267
|
*p_contents_beg = beg+1;
|
|
2268
2268
|
*p_contents_end = off;
|
|
2269
2269
|
*p_end = off+1;
|
|
2270
|
-
return
|
|
2270
|
+
return true;
|
|
2271
2271
|
}
|
|
2272
2272
|
|
|
2273
2273
|
off++;
|
|
2274
2274
|
}
|
|
2275
2275
|
|
|
2276
|
-
return
|
|
2276
|
+
return false;
|
|
2277
2277
|
}
|
|
2278
2278
|
|
|
2279
2279
|
static int
|
|
@@ -2298,7 +2298,7 @@ md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
|
|
|
2298
2298
|
if(CH(off) == _T('(')) {
|
|
2299
2299
|
parenthesis_level++;
|
|
2300
2300
|
if(parenthesis_level > 32)
|
|
2301
|
-
return
|
|
2301
|
+
return false;
|
|
2302
2302
|
} else if(CH(off) == _T(')')) {
|
|
2303
2303
|
if(parenthesis_level == 0)
|
|
2304
2304
|
break;
|
|
@@ -2309,13 +2309,13 @@ md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
|
|
|
2309
2309
|
}
|
|
2310
2310
|
|
|
2311
2311
|
if(parenthesis_level != 0 || off == beg)
|
|
2312
|
-
return
|
|
2312
|
+
return false;
|
|
2313
2313
|
|
|
2314
2314
|
/* Success. */
|
|
2315
2315
|
*p_contents_beg = beg;
|
|
2316
2316
|
*p_contents_end = off;
|
|
2317
2317
|
*p_end = off;
|
|
2318
|
-
return
|
|
2318
|
+
return true;
|
|
2319
2319
|
}
|
|
2320
2320
|
|
|
2321
2321
|
static inline int
|
|
@@ -2343,11 +2343,11 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2343
2343
|
if(off >= lines[line_index].end) {
|
|
2344
2344
|
line_index++;
|
|
2345
2345
|
if(line_index >= n_lines)
|
|
2346
|
-
return
|
|
2346
|
+
return false;
|
|
2347
2347
|
off = lines[line_index].beg;
|
|
2348
2348
|
}
|
|
2349
2349
|
if(off == beg)
|
|
2350
|
-
return
|
|
2350
|
+
return false;
|
|
2351
2351
|
|
|
2352
2352
|
*p_beg_line_index = line_index;
|
|
2353
2353
|
|
|
@@ -2356,7 +2356,7 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2356
2356
|
case _T('"'): closer_char = _T('"'); break;
|
|
2357
2357
|
case _T('\''): closer_char = _T('\''); break;
|
|
2358
2358
|
case _T('('): closer_char = _T(')'); break;
|
|
2359
|
-
default: return
|
|
2359
|
+
default: return false;
|
|
2360
2360
|
}
|
|
2361
2361
|
off++;
|
|
2362
2362
|
|
|
@@ -2373,10 +2373,10 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2373
2373
|
*p_contents_end = off;
|
|
2374
2374
|
*p_end = off+1;
|
|
2375
2375
|
*p_end_line_index = line_index;
|
|
2376
|
-
return
|
|
2376
|
+
return true;
|
|
2377
2377
|
} else if(closer_char == _T(')') && CH(off) == _T('(')) {
|
|
2378
2378
|
/* ()-style title cannot contain (unescaped '(')) */
|
|
2379
|
-
return
|
|
2379
|
+
return false;
|
|
2380
2380
|
}
|
|
2381
2381
|
|
|
2382
2382
|
off++;
|
|
@@ -2385,7 +2385,7 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
2385
2385
|
line_index++;
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
|
-
return
|
|
2388
|
+
return false;
|
|
2389
2389
|
}
|
|
2390
2390
|
|
|
2391
2391
|
/* Returns 0 if it is not a reference definition.
|
|
@@ -2402,13 +2402,13 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2402
2402
|
OFF label_contents_beg;
|
|
2403
2403
|
OFF label_contents_end;
|
|
2404
2404
|
MD_SIZE label_contents_line_index;
|
|
2405
|
-
int label_is_multiline =
|
|
2405
|
+
int label_is_multiline = false;
|
|
2406
2406
|
OFF dest_contents_beg;
|
|
2407
2407
|
OFF dest_contents_end;
|
|
2408
2408
|
OFF title_contents_beg;
|
|
2409
2409
|
OFF title_contents_end;
|
|
2410
2410
|
MD_SIZE title_contents_line_index;
|
|
2411
|
-
int title_is_multiline =
|
|
2411
|
+
int title_is_multiline = false;
|
|
2412
2412
|
OFF off;
|
|
2413
2413
|
MD_SIZE line_index = 0;
|
|
2414
2414
|
MD_SIZE tmp_line_index;
|
|
@@ -2419,12 +2419,12 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2419
2419
|
if(!md_is_link_label(ctx, lines, n_lines, lines[0].beg,
|
|
2420
2420
|
&off, &label_contents_line_index, &line_index,
|
|
2421
2421
|
&label_contents_beg, &label_contents_end))
|
|
2422
|
-
return
|
|
2422
|
+
return false;
|
|
2423
2423
|
label_is_multiline = (label_contents_line_index != line_index);
|
|
2424
2424
|
|
|
2425
2425
|
/* Colon. */
|
|
2426
2426
|
if(off >= lines[line_index].end || CH(off) != _T(':'))
|
|
2427
|
-
return
|
|
2427
|
+
return false;
|
|
2428
2428
|
off++;
|
|
2429
2429
|
|
|
2430
2430
|
/* Optional white space with up to one line break. */
|
|
@@ -2433,14 +2433,14 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2433
2433
|
if(off >= lines[line_index].end) {
|
|
2434
2434
|
line_index++;
|
|
2435
2435
|
if(line_index >= n_lines)
|
|
2436
|
-
return
|
|
2436
|
+
return false;
|
|
2437
2437
|
off = lines[line_index].beg;
|
|
2438
2438
|
}
|
|
2439
2439
|
|
|
2440
2440
|
/* Link destination. */
|
|
2441
2441
|
if(!md_is_link_destination(ctx, off, lines[line_index].end,
|
|
2442
2442
|
&off, &dest_contents_beg, &dest_contents_end))
|
|
2443
|
-
return
|
|
2443
|
+
return false;
|
|
2444
2444
|
|
|
2445
2445
|
/* (Optional) title. Note we interpret it as an title only if nothing
|
|
2446
2446
|
* more follows on its last line. */
|
|
@@ -2454,7 +2454,7 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2454
2454
|
line_index += tmp_line_index;
|
|
2455
2455
|
} else {
|
|
2456
2456
|
/* Not a title. */
|
|
2457
|
-
title_is_multiline =
|
|
2457
|
+
title_is_multiline = false;
|
|
2458
2458
|
title_contents_beg = off;
|
|
2459
2459
|
title_contents_end = off;
|
|
2460
2460
|
title_contents_line_index = 0;
|
|
@@ -2462,7 +2462,7 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2462
2462
|
|
|
2463
2463
|
/* Nothing more can follow on the last line. */
|
|
2464
2464
|
if(off < lines[line_index].end)
|
|
2465
|
-
return
|
|
2465
|
+
return false;
|
|
2466
2466
|
|
|
2467
2467
|
if(label_is_multiline) {
|
|
2468
2468
|
CHAR* label;
|
|
@@ -2476,7 +2476,7 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2476
2476
|
free(label);
|
|
2477
2477
|
goto abort;
|
|
2478
2478
|
}
|
|
2479
|
-
def->label_needs_free =
|
|
2479
|
+
def->label_needs_free = true;
|
|
2480
2480
|
} else {
|
|
2481
2481
|
def = (MD_REF_DEF*) md_add_label_def(ctx, &ctx->ref_def_hashtable,
|
|
2482
2482
|
STR(label_contents_beg), label_contents_end - label_contents_beg);
|
|
@@ -2488,7 +2488,7 @@ md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lin
|
|
|
2488
2488
|
MD_CHECK(md_merge_lines_alloc(ctx, title_contents_beg, title_contents_end,
|
|
2489
2489
|
lines + title_contents_line_index, n_lines - title_contents_line_index,
|
|
2490
2490
|
_T('\n'), &def->title, &def->title_size));
|
|
2491
|
-
def->title_needs_free =
|
|
2491
|
+
def->title_needs_free = true;
|
|
2492
2492
|
} else {
|
|
2493
2493
|
def->title = (CHAR*) STR(title_contents_beg);
|
|
2494
2494
|
def->title_size = title_contents_end - title_contents_beg;
|
|
@@ -2518,13 +2518,13 @@ md_is_link_reference(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2518
2518
|
int is_multiline;
|
|
2519
2519
|
CHAR* label;
|
|
2520
2520
|
SZ label_size;
|
|
2521
|
-
int ret =
|
|
2521
|
+
int ret = false;
|
|
2522
2522
|
|
|
2523
2523
|
MD_ASSERT(CH(beg) == _T('[') || CH(beg) == _T('!'));
|
|
2524
2524
|
MD_ASSERT(CH(end-1) == _T(']'));
|
|
2525
2525
|
|
|
2526
2526
|
if(ctx->max_ref_def_output == 0)
|
|
2527
|
-
return
|
|
2527
|
+
return false;
|
|
2528
2528
|
|
|
2529
2529
|
beg += (CH(beg) == _T('!') ? 2 : 1);
|
|
2530
2530
|
end--;
|
|
@@ -2547,7 +2547,7 @@ md_is_link_reference(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2547
2547
|
attr->dest_end = def->dest_end;
|
|
2548
2548
|
attr->title = def->title;
|
|
2549
2549
|
attr->title_size = def->title_size;
|
|
2550
|
-
attr->title_needs_free =
|
|
2550
|
+
attr->title_needs_free = false;
|
|
2551
2551
|
}
|
|
2552
2552
|
|
|
2553
2553
|
if(is_multiline)
|
|
@@ -2558,7 +2558,7 @@ md_is_link_reference(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2558
2558
|
MD_SIZE output_size_estimation = def->entry.label_size + def->title_size + def->dest_end - def->dest_beg;
|
|
2559
2559
|
if(output_size_estimation < ctx->max_ref_def_output) {
|
|
2560
2560
|
ctx->max_ref_def_output -= output_size_estimation;
|
|
2561
|
-
ret =
|
|
2561
|
+
ret = true;
|
|
2562
2562
|
} else {
|
|
2563
2563
|
MD_LOG("Too many link reference definition instantiations.");
|
|
2564
2564
|
ctx->max_ref_def_output = 0;
|
|
@@ -2580,7 +2580,7 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2580
2580
|
MD_SIZE title_contents_line_index;
|
|
2581
2581
|
int title_is_multiline;
|
|
2582
2582
|
OFF off = beg;
|
|
2583
|
-
int ret =
|
|
2583
|
+
int ret = false;
|
|
2584
2584
|
|
|
2585
2585
|
md_lookup_line(off, lines, n_lines, &line_index);
|
|
2586
2586
|
|
|
@@ -2593,7 +2593,7 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2593
2593
|
if(off >= lines[line_index].end && (off >= ctx->size || ISNEWLINE(off))) {
|
|
2594
2594
|
line_index++;
|
|
2595
2595
|
if(line_index >= n_lines)
|
|
2596
|
-
return
|
|
2596
|
+
return false;
|
|
2597
2597
|
off = lines[line_index].beg;
|
|
2598
2598
|
}
|
|
2599
2599
|
|
|
@@ -2603,16 +2603,16 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2603
2603
|
attr->dest_end = off;
|
|
2604
2604
|
attr->title = NULL;
|
|
2605
2605
|
attr->title_size = 0;
|
|
2606
|
-
attr->title_needs_free =
|
|
2606
|
+
attr->title_needs_free = false;
|
|
2607
2607
|
off++;
|
|
2608
2608
|
*p_end = off;
|
|
2609
|
-
return
|
|
2609
|
+
return true;
|
|
2610
2610
|
}
|
|
2611
2611
|
|
|
2612
2612
|
/* Link destination. */
|
|
2613
2613
|
if(!md_is_link_destination(ctx, off, lines[line_index].end,
|
|
2614
2614
|
&off, &attr->dest_beg, &attr->dest_end))
|
|
2615
|
-
return
|
|
2615
|
+
return false;
|
|
2616
2616
|
|
|
2617
2617
|
/* (Optional) title. */
|
|
2618
2618
|
if(md_is_link_title(ctx, lines + line_index, n_lines - line_index, off,
|
|
@@ -2624,7 +2624,7 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2624
2624
|
line_index += tmp_line_index;
|
|
2625
2625
|
} else {
|
|
2626
2626
|
/* Not a title. */
|
|
2627
|
-
title_is_multiline =
|
|
2627
|
+
title_is_multiline = false;
|
|
2628
2628
|
title_contents_beg = off;
|
|
2629
2629
|
title_contents_end = off;
|
|
2630
2630
|
title_contents_line_index = 0;
|
|
@@ -2636,7 +2636,7 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2636
2636
|
if(off >= lines[line_index].end) {
|
|
2637
2637
|
line_index++;
|
|
2638
2638
|
if(line_index >= n_lines)
|
|
2639
|
-
return
|
|
2639
|
+
return false;
|
|
2640
2640
|
off = lines[line_index].beg;
|
|
2641
2641
|
}
|
|
2642
2642
|
if(CH(off) != _T(')'))
|
|
@@ -2646,20 +2646,20 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
2646
2646
|
if(title_contents_beg >= title_contents_end) {
|
|
2647
2647
|
attr->title = NULL;
|
|
2648
2648
|
attr->title_size = 0;
|
|
2649
|
-
attr->title_needs_free =
|
|
2649
|
+
attr->title_needs_free = false;
|
|
2650
2650
|
} else if(!title_is_multiline) {
|
|
2651
2651
|
attr->title = (CHAR*) STR(title_contents_beg);
|
|
2652
2652
|
attr->title_size = title_contents_end - title_contents_beg;
|
|
2653
|
-
attr->title_needs_free =
|
|
2653
|
+
attr->title_needs_free = false;
|
|
2654
2654
|
} else {
|
|
2655
2655
|
MD_CHECK(md_merge_lines_alloc(ctx, title_contents_beg, title_contents_end,
|
|
2656
2656
|
lines + title_contents_line_index, n_lines - title_contents_line_index,
|
|
2657
2657
|
_T('\n'), &attr->title, &attr->title_size));
|
|
2658
|
-
attr->title_needs_free =
|
|
2658
|
+
attr->title_needs_free = true;
|
|
2659
2659
|
}
|
|
2660
2660
|
|
|
2661
2661
|
*p_end = off;
|
|
2662
|
-
ret =
|
|
2662
|
+
ret = true;
|
|
2663
2663
|
|
|
2664
2664
|
abort:
|
|
2665
2665
|
return ret;
|
|
@@ -2729,6 +2729,7 @@ md_free_ref_defs(MD_CTX* ctx)
|
|
|
2729
2729
|
* '*': Maybe (strong) emphasis start/end.
|
|
2730
2730
|
* '_': Maybe (strong) emphasis start/end.
|
|
2731
2731
|
* '~': Maybe strikethrough start/end (needs MD_FLAG_STRIKETHROUGH).
|
|
2732
|
+
* '+': Maybe insert start/end (needs MD_FLAG_INSERT)
|
|
2732
2733
|
* '`': Maybe code span start/end.
|
|
2733
2734
|
* '&': Maybe start of entity.
|
|
2734
2735
|
* ';': Maybe end of entity.
|
|
@@ -2980,6 +2981,9 @@ md_build_mark_char_map(MD_CTX* ctx)
|
|
|
2980
2981
|
if(ctx->parser.flags & MD_FLAG_HIGHLIGHT)
|
|
2981
2982
|
ctx->mark_char_map['='] = 1;
|
|
2982
2983
|
|
|
2984
|
+
if(ctx->parser.flags & MD_FLAG_INSERT)
|
|
2985
|
+
ctx->mark_char_map['+'] = 1;
|
|
2986
|
+
|
|
2983
2987
|
if(ctx->parser.flags & MD_FLAG_PERMISSIVEEMAILAUTOLINKS)
|
|
2984
2988
|
ctx->mark_char_map['@'] = 1;
|
|
2985
2989
|
|
|
@@ -3015,11 +3019,11 @@ md_is_code_span(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
3015
3019
|
OFF closer_end;
|
|
3016
3020
|
SZ mark_len;
|
|
3017
3021
|
OFF line_end;
|
|
3018
|
-
int has_space_after_opener =
|
|
3019
|
-
int has_eol_after_opener =
|
|
3020
|
-
int has_space_before_closer =
|
|
3021
|
-
int has_eol_before_closer =
|
|
3022
|
-
int has_only_space =
|
|
3022
|
+
int has_space_after_opener = false;
|
|
3023
|
+
int has_eol_after_opener = false;
|
|
3024
|
+
int has_space_before_closer = false;
|
|
3025
|
+
int has_eol_before_closer = false;
|
|
3026
|
+
int has_only_space = true;
|
|
3023
3027
|
MD_SIZE line_index = 0;
|
|
3024
3028
|
|
|
3025
3029
|
line_end = lines[0].end;
|
|
@@ -3034,22 +3038,22 @@ md_is_code_span(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
3034
3038
|
|
|
3035
3039
|
mark_len = opener_end - opener_beg;
|
|
3036
3040
|
if(mark_len > CODESPAN_MARK_MAXLEN)
|
|
3037
|
-
return
|
|
3041
|
+
return false;
|
|
3038
3042
|
|
|
3039
3043
|
/* Check whether we already know there is no closer of this length.
|
|
3040
3044
|
* If so, re-scan does no sense. This fixes issue #59. */
|
|
3041
3045
|
if(last_potential_closers[mark_len-1] >= lines[n_lines-1].end ||
|
|
3042
3046
|
(*p_reached_paragraph_end && last_potential_closers[mark_len-1] < opener_end))
|
|
3043
|
-
return
|
|
3047
|
+
return false;
|
|
3044
3048
|
|
|
3045
3049
|
closer_beg = opener_end;
|
|
3046
3050
|
closer_end = opener_end;
|
|
3047
3051
|
|
|
3048
3052
|
/* Find closer mark. */
|
|
3049
|
-
while(
|
|
3053
|
+
while(true) {
|
|
3050
3054
|
while(closer_beg < line_end && CH(closer_beg) != _T('`')) {
|
|
3051
3055
|
if(CH(closer_beg) != _T(' '))
|
|
3052
|
-
has_only_space =
|
|
3056
|
+
has_only_space = false;
|
|
3053
3057
|
closer_beg++;
|
|
3054
3058
|
}
|
|
3055
3059
|
closer_end = closer_beg;
|
|
@@ -3065,7 +3069,7 @@ md_is_code_span(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
3065
3069
|
|
|
3066
3070
|
if(closer_end - closer_beg > 0) {
|
|
3067
3071
|
/* We have found a back-tick which is not part of the closer. */
|
|
3068
|
-
has_only_space =
|
|
3072
|
+
has_only_space = false;
|
|
3069
3073
|
|
|
3070
3074
|
/* But if we eventually fail, remember it as a potential closer
|
|
3071
3075
|
* of its own length for future attempts. This mitigates needs for
|
|
@@ -3080,8 +3084,8 @@ md_is_code_span(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
3080
3084
|
line_index++;
|
|
3081
3085
|
if(line_index >= n_lines) {
|
|
3082
3086
|
/* Reached end of the paragraph and still nothing. */
|
|
3083
|
-
*p_reached_paragraph_end =
|
|
3084
|
-
return
|
|
3087
|
+
*p_reached_paragraph_end = true;
|
|
3088
|
+
return false;
|
|
3085
3089
|
}
|
|
3086
3090
|
/* Try on the next line. */
|
|
3087
3091
|
line_end = lines[line_index].end;
|
|
@@ -3122,7 +3126,7 @@ md_is_code_span(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, OFF beg,
|
|
|
3122
3126
|
closer->beg = closer_beg;
|
|
3123
3127
|
closer->end = closer_end;
|
|
3124
3128
|
closer->flags = MD_MARK_POTENTIAL_CLOSER;
|
|
3125
|
-
return
|
|
3129
|
+
return true;
|
|
3126
3130
|
}
|
|
3127
3131
|
|
|
3128
3132
|
static int
|
|
@@ -3134,33 +3138,33 @@ md_is_autolink_uri(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
|
|
|
3134
3138
|
|
|
3135
3139
|
/* Check for scheme. */
|
|
3136
3140
|
if(off >= max_end || !ISALNUM(off))
|
|
3137
|
-
return
|
|
3141
|
+
return false;
|
|
3138
3142
|
off++;
|
|
3139
3143
|
while(1) {
|
|
3140
3144
|
if(off >= max_end)
|
|
3141
|
-
return
|
|
3145
|
+
return false;
|
|
3142
3146
|
if(off - beg > 32)
|
|
3143
|
-
return
|
|
3147
|
+
return false;
|
|
3144
3148
|
if(CH(off) == _T(':') && off - beg >= 3)
|
|
3145
3149
|
break;
|
|
3146
3150
|
if(!ISALNUM(off) && CH(off) != _T('+') && CH(off) != _T('-') && CH(off) != _T('.'))
|
|
3147
|
-
return
|
|
3151
|
+
return false;
|
|
3148
3152
|
off++;
|
|
3149
3153
|
}
|
|
3150
3154
|
|
|
3151
3155
|
/* Check the path after the scheme. */
|
|
3152
3156
|
while(off < max_end && CH(off) != _T('>')) {
|
|
3153
3157
|
if(ISWHITESPACE(off) || ISCNTRL(off) || CH(off) == _T('<'))
|
|
3154
|
-
return
|
|
3158
|
+
return false;
|
|
3155
3159
|
off++;
|
|
3156
3160
|
}
|
|
3157
3161
|
|
|
3158
3162
|
if(off >= max_end)
|
|
3159
|
-
return
|
|
3163
|
+
return false;
|
|
3160
3164
|
|
|
3161
3165
|
MD_ASSERT(CH(off) == _T('>'));
|
|
3162
3166
|
*p_end = off+1;
|
|
3163
|
-
return
|
|
3167
|
+
return true;
|
|
3164
3168
|
}
|
|
3165
3169
|
|
|
3166
3170
|
static int
|
|
@@ -3181,11 +3185,11 @@ md_is_autolink_email(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
|
|
|
3181
3185
|
while(off < max_end && (ISALNUM(off) || ISANYOF(off, _T(".!#$%&'*+/=?^_`{|}~-"))))
|
|
3182
3186
|
off++;
|
|
3183
3187
|
if(off <= beg+1)
|
|
3184
|
-
return
|
|
3188
|
+
return false;
|
|
3185
3189
|
|
|
3186
3190
|
/* '@' */
|
|
3187
3191
|
if(off >= max_end || CH(off) != _T('@'))
|
|
3188
|
-
return
|
|
3192
|
+
return false;
|
|
3189
3193
|
off++;
|
|
3190
3194
|
|
|
3191
3195
|
/* Labels delimited with '.'; each label is sequence of 1 - 63 alnum
|
|
@@ -3202,32 +3206,32 @@ md_is_autolink_email(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
|
|
|
3202
3206
|
break;
|
|
3203
3207
|
|
|
3204
3208
|
if(label_len > 63)
|
|
3205
|
-
return
|
|
3209
|
+
return false;
|
|
3206
3210
|
|
|
3207
3211
|
off++;
|
|
3208
3212
|
}
|
|
3209
3213
|
|
|
3210
3214
|
if(label_len <= 0 || off >= max_end || CH(off) != _T('>') || CH(off-1) == _T('-'))
|
|
3211
|
-
return
|
|
3215
|
+
return false;
|
|
3212
3216
|
|
|
3213
3217
|
*p_end = off+1;
|
|
3214
|
-
return
|
|
3218
|
+
return true;
|
|
3215
3219
|
}
|
|
3216
3220
|
|
|
3217
3221
|
static int
|
|
3218
3222
|
md_is_autolink(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end, int* p_missing_mailto)
|
|
3219
3223
|
{
|
|
3220
3224
|
if(md_is_autolink_uri(ctx, beg, max_end, p_end)) {
|
|
3221
|
-
*p_missing_mailto =
|
|
3222
|
-
return
|
|
3225
|
+
*p_missing_mailto = false;
|
|
3226
|
+
return true;
|
|
3223
3227
|
}
|
|
3224
3228
|
|
|
3225
3229
|
if(md_is_autolink_email(ctx, beg, max_end, p_end)) {
|
|
3226
|
-
*p_missing_mailto =
|
|
3227
|
-
return
|
|
3230
|
+
*p_missing_mailto = true;
|
|
3231
|
+
return true;
|
|
3228
3232
|
}
|
|
3229
3233
|
|
|
3230
|
-
return
|
|
3234
|
+
return false;
|
|
3231
3235
|
}
|
|
3232
3236
|
|
|
3233
3237
|
static int
|
|
@@ -3237,13 +3241,13 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
|
|
|
3237
3241
|
int ret = 0;
|
|
3238
3242
|
MD_MARK* mark;
|
|
3239
3243
|
OFF codespan_last_potential_closers[CODESPAN_MARK_MAXLEN] = { 0 };
|
|
3240
|
-
int codespan_scanned_till_paragraph_end =
|
|
3244
|
+
int codespan_scanned_till_paragraph_end = false;
|
|
3241
3245
|
|
|
3242
3246
|
for(line_index = 0; line_index < n_lines; line_index++) {
|
|
3243
3247
|
const MD_LINE* line = &lines[line_index];
|
|
3244
3248
|
OFF off = line->beg;
|
|
3245
3249
|
|
|
3246
|
-
while(
|
|
3250
|
+
while(true) {
|
|
3247
3251
|
CHAR ch;
|
|
3248
3252
|
|
|
3249
3253
|
#ifdef MD4C_USE_UTF16
|
|
@@ -3589,6 +3593,30 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
|
|
|
3589
3593
|
continue;
|
|
3590
3594
|
}
|
|
3591
3595
|
|
|
3596
|
+
/* A potential insert start/end: ++text++ */
|
|
3597
|
+
if(ch == _T('+') && (ctx->parser.flags & MD_FLAG_INSERT)) {
|
|
3598
|
+
OFF tmp = off + 1;
|
|
3599
|
+
|
|
3600
|
+
while(tmp < line->end && CH(tmp) == _T('+'))
|
|
3601
|
+
tmp++;
|
|
3602
|
+
|
|
3603
|
+
/* Only exactly two plus signs form a insert delimiter. */
|
|
3604
|
+
if(tmp - off == 2) {
|
|
3605
|
+
unsigned flags = MD_MARK_POTENTIAL_OPENER | MD_MARK_POTENTIAL_CLOSER;
|
|
3606
|
+
|
|
3607
|
+
/* Cannot open before whitespace; cannot close after whitespace. */
|
|
3608
|
+
if(tmp >= line->end || ISUNICODEWHITESPACE(tmp))
|
|
3609
|
+
flags &= ~MD_MARK_POTENTIAL_OPENER;
|
|
3610
|
+
if(off == line->beg || ISUNICODEWHITESPACEBEFORE(off))
|
|
3611
|
+
flags &= ~MD_MARK_POTENTIAL_CLOSER;
|
|
3612
|
+
if(flags != 0)
|
|
3613
|
+
ADD_MARK(ch, off, tmp, flags);
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
off = tmp;
|
|
3617
|
+
continue;
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3592
3620
|
/* A potential strikethrough/subscript start/end. */
|
|
3593
3621
|
if(ch == _T('~')) {
|
|
3594
3622
|
OFF tmp = off + 1;
|
|
@@ -3730,7 +3758,7 @@ static void md_analyze_link_contents(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE
|
|
|
3730
3758
|
|
|
3731
3759
|
/* Try to resolve a bracket pair as a wiki link '[[destination]]' or
|
|
3732
3760
|
* '[[destination|label]]'.
|
|
3733
|
-
* Returns
|
|
3761
|
+
* Returns true if resolved, false if not a wiki link, -1 on error. */
|
|
3734
3762
|
static int
|
|
3735
3763
|
md_resolve_bracket_wikilink(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
3736
3764
|
int opener_index, int closer_index,
|
|
@@ -3745,16 +3773,16 @@ md_resolve_bracket_wikilink(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
3745
3773
|
OFF off;
|
|
3746
3774
|
|
|
3747
3775
|
if(!(ctx->parser.flags & MD_FLAG_WIKILINKS))
|
|
3748
|
-
return
|
|
3776
|
+
return false;
|
|
3749
3777
|
|
|
3750
3778
|
if(opener->ch != _T('[') || opener->end - opener->beg != 1 ||
|
|
3751
3779
|
next_opener == NULL || next_opener->ch != _T('[') || next_opener->end - next_opener->beg != 1 ||
|
|
3752
3780
|
next_closer == NULL || next_closer->ch != _T(']') || next_closer->end - next_closer->beg != 1)
|
|
3753
|
-
return
|
|
3781
|
+
return false;
|
|
3754
3782
|
|
|
3755
3783
|
/* Check that the next_opener and next_closer are nested properly. */
|
|
3756
3784
|
if(next_opener->beg != opener->beg - 1 || next_closer->beg != closer->beg + 1)
|
|
3757
|
-
return
|
|
3785
|
+
return false;
|
|
3758
3786
|
|
|
3759
3787
|
/* We don't allow destination to be longer than 100 characters.
|
|
3760
3788
|
* Lets scan to see whether there is '|'. (If not then the whole
|
|
@@ -3778,12 +3806,12 @@ md_resolve_bracket_wikilink(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
3778
3806
|
dest_beg = opener->end;
|
|
3779
3807
|
dest_end = (delim != NULL) ? delim->beg : closer->beg;
|
|
3780
3808
|
if(dest_end - dest_beg == 0 || dest_end - dest_beg > 100)
|
|
3781
|
-
return
|
|
3809
|
+
return false;
|
|
3782
3810
|
|
|
3783
3811
|
/* There may not be any new line in the destination. */
|
|
3784
3812
|
for(off = dest_beg; off < dest_end; off++) {
|
|
3785
3813
|
if(ISNEWLINE(off))
|
|
3786
|
-
return
|
|
3814
|
+
return false;
|
|
3787
3815
|
}
|
|
3788
3816
|
|
|
3789
3817
|
md_pop_openers(ctx, opener_index);
|
|
@@ -3811,7 +3839,7 @@ md_resolve_bracket_wikilink(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
3811
3839
|
md_analyze_link_contents(ctx, lines, n_lines, delim_index+1, closer_index);
|
|
3812
3840
|
|
|
3813
3841
|
*p_opener_index = next_opener->prev;
|
|
3814
|
-
return
|
|
3842
|
+
return true;
|
|
3815
3843
|
}
|
|
3816
3844
|
|
|
3817
3845
|
/* Resolve footnote references [^label] in the current block. */
|
|
@@ -3825,9 +3853,9 @@ md_resolve_bracket_footnote(MD_CTX* ctx, MD_MARK* opener, MD_MARK* closer,
|
|
|
3825
3853
|
OFF label_beg, label_end;
|
|
3826
3854
|
|
|
3827
3855
|
if(!(ctx->parser.flags & MD_FLAG_FOOTNOTES))
|
|
3828
|
-
return
|
|
3856
|
+
return false;
|
|
3829
3857
|
if(opener->ch != _T('[') || opener->end >= ctx->size || CH(opener->end) != _T('^'))
|
|
3830
|
-
return
|
|
3858
|
+
return false;
|
|
3831
3859
|
|
|
3832
3860
|
/* Expand the opener to eat the '^' */
|
|
3833
3861
|
opener->end++;
|
|
@@ -3840,11 +3868,11 @@ md_resolve_bracket_footnote(MD_CTX* ctx, MD_MARK* opener, MD_MARK* closer,
|
|
|
3840
3868
|
label_end = closer->beg;
|
|
3841
3869
|
|
|
3842
3870
|
if(label_beg >= label_end)
|
|
3843
|
-
return
|
|
3871
|
+
return false; /* empty label */
|
|
3844
3872
|
|
|
3845
3873
|
def = md_lookup_footnote_def(ctx, STR(label_beg), label_end - label_beg);
|
|
3846
3874
|
if(def == NULL)
|
|
3847
|
-
return
|
|
3875
|
+
return false;
|
|
3848
3876
|
|
|
3849
3877
|
/* Assign index on first reference. */
|
|
3850
3878
|
if(def->index == 0)
|
|
@@ -3864,7 +3892,7 @@ md_resolve_bracket_footnote(MD_CTX* ctx, MD_MARK* opener, MD_MARK* closer,
|
|
|
3864
3892
|
*last_link_end = closer->end;
|
|
3865
3893
|
|
|
3866
3894
|
*p_opener_index = opener->prev;
|
|
3867
|
-
return
|
|
3895
|
+
return true;
|
|
3868
3896
|
}
|
|
3869
3897
|
|
|
3870
3898
|
/* Try to resolve a bracket pair as a CommonMark link or image.
|
|
@@ -3879,7 +3907,7 @@ md_resolve_bracket_link(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
3879
3907
|
OFF* last_img_beg, OFF* last_img_end)
|
|
3880
3908
|
{
|
|
3881
3909
|
MD_LINK_ATTR attr;
|
|
3882
|
-
int is_link =
|
|
3910
|
+
int is_link = false;
|
|
3883
3911
|
|
|
3884
3912
|
if(next_opener != NULL && next_opener->beg == closer->end) {
|
|
3885
3913
|
if(next_closer->beg > closer->end + 1) {
|
|
@@ -3926,7 +3954,7 @@ md_resolve_bracket_link(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
3926
3954
|
/* Cancel the link status. */
|
|
3927
3955
|
if(attr.title_needs_free)
|
|
3928
3956
|
free(attr.title);
|
|
3929
|
-
is_link =
|
|
3957
|
+
is_link = false;
|
|
3930
3958
|
break;
|
|
3931
3959
|
}
|
|
3932
3960
|
|
|
@@ -4333,6 +4361,27 @@ md_analyze_highlight(MD_CTX* ctx, int mark_index)
|
|
|
4333
4361
|
md_mark_stack_push(ctx, &EQUAL_OPENERS, mark_index);
|
|
4334
4362
|
}
|
|
4335
4363
|
|
|
4364
|
+
static void
|
|
4365
|
+
md_analyze_insert(MD_CTX* ctx, int mark_index)
|
|
4366
|
+
{
|
|
4367
|
+
MD_MARK* mark = &ctx->marks[mark_index];
|
|
4368
|
+
|
|
4369
|
+
/* Only "++" is recognized as a insert mark. */
|
|
4370
|
+
if(mark->end - mark->beg != 2)
|
|
4371
|
+
return;
|
|
4372
|
+
|
|
4373
|
+
if((mark->flags & MD_MARK_POTENTIAL_CLOSER) && PLUS_OPENERS.top >= 0) {
|
|
4374
|
+
int opener_index = PLUS_OPENERS.top;
|
|
4375
|
+
|
|
4376
|
+
md_pop_openers(ctx, opener_index);
|
|
4377
|
+
md_resolve_range(ctx, opener_index, mark_index);
|
|
4378
|
+
return;
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
if(mark->flags & MD_MARK_POTENTIAL_OPENER)
|
|
4382
|
+
md_mark_stack_push(ctx, &PLUS_OPENERS, mark_index);
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4336
4385
|
static MD_MARK*
|
|
4337
4386
|
md_scan_left_for_resolved_mark(MD_CTX* ctx, MD_MARK* mark_from, OFF off, MD_MARK** p_cursor)
|
|
4338
4387
|
{
|
|
@@ -4384,8 +4433,8 @@ md_analyze_permissive_autolink_segment(MD_CTX* ctx, OFF off, OFF end, OFF* p_end
|
|
|
4384
4433
|
{
|
|
4385
4434
|
int n_components = 0;
|
|
4386
4435
|
int n_open_brackets = 0;
|
|
4387
|
-
int seen_word_delim =
|
|
4388
|
-
int seen_component_delim =
|
|
4436
|
+
int seen_word_delim = true;
|
|
4437
|
+
int seen_component_delim = true;
|
|
4389
4438
|
OFF component_beg = off;
|
|
4390
4439
|
|
|
4391
4440
|
if(word_extra == NULL)
|
|
@@ -4421,18 +4470,18 @@ md_analyze_permissive_autolink_segment(MD_CTX* ctx, OFF off, OFF end, OFF* p_end
|
|
|
4421
4470
|
}
|
|
4422
4471
|
|
|
4423
4472
|
if(ISALNUM(off) || ISANYOF(off, word_extra)) {
|
|
4424
|
-
seen_word_delim =
|
|
4425
|
-
seen_component_delim =
|
|
4473
|
+
seen_word_delim = false;
|
|
4474
|
+
seen_component_delim = false;
|
|
4426
4475
|
} else {
|
|
4427
4476
|
if(seen_word_delim)
|
|
4428
4477
|
break;
|
|
4429
4478
|
|
|
4430
4479
|
if(ISANYOF(off, word_delims)) {
|
|
4431
|
-
seen_word_delim =
|
|
4480
|
+
seen_word_delim = true;
|
|
4432
4481
|
} else if(component_delim != _T('\0') && CH(off) == component_delim) {
|
|
4433
4482
|
if(seen_component_delim)
|
|
4434
4483
|
break;
|
|
4435
|
-
seen_component_delim =
|
|
4484
|
+
seen_component_delim = true;
|
|
4436
4485
|
component_beg = off;
|
|
4437
4486
|
n_components++;
|
|
4438
4487
|
} else {
|
|
@@ -4477,7 +4526,7 @@ md_analyze_permissive_autolink(MD_CTX* ctx, int mark_index)
|
|
|
4477
4526
|
/* E-mail requires the user name (before '@', i.e. scanning backwards). */
|
|
4478
4527
|
if(opener->ch == '@') {
|
|
4479
4528
|
MD_ASSERT(CH(opener->beg) == _T('@'));
|
|
4480
|
-
if(md_analyze_permissive_autolink_segment(ctx, beg, line_beg, &beg,
|
|
4529
|
+
if(md_analyze_permissive_autolink_segment(ctx, beg, line_beg, &beg, true,
|
|
4481
4530
|
_T('\0'), NULL, _T(".-_+"), &left_cursor) < 1)
|
|
4482
4531
|
return;
|
|
4483
4532
|
}
|
|
@@ -4494,15 +4543,15 @@ md_analyze_permissive_autolink(MD_CTX* ctx, int mark_index)
|
|
|
4494
4543
|
|
|
4495
4544
|
/* Scan for hostname segment. Hostname is mandatory and requires at least two
|
|
4496
4545
|
* components delimited with a dot. */
|
|
4497
|
-
if(md_analyze_permissive_autolink_segment(ctx, end, line_end, &end,
|
|
4546
|
+
if(md_analyze_permissive_autolink_segment(ctx, end, line_end, &end, false,
|
|
4498
4547
|
_T('.'), NULL, _T("-_"), &right_cursor) < 2)
|
|
4499
4548
|
return;
|
|
4500
4549
|
|
|
4501
4550
|
if(opener->ch != '@') {
|
|
4502
4551
|
/* Scan for path segment. */
|
|
4503
4552
|
if(end < line_end && CH(end) == _T('/')) {
|
|
4504
|
-
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end,
|
|
4505
|
-
_T('/'), _T(".+-_
|
|
4553
|
+
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end, false,
|
|
4554
|
+
_T('/'), _T(".+-_~%"), NULL, &right_cursor) < 0)
|
|
4506
4555
|
return;
|
|
4507
4556
|
|
|
4508
4557
|
/* Path can also end with additional '/' if its a directory. */
|
|
@@ -4512,14 +4561,14 @@ md_analyze_permissive_autolink(MD_CTX* ctx, int mark_index)
|
|
|
4512
4561
|
|
|
4513
4562
|
/* Scan for query segment. */
|
|
4514
4563
|
if(end < line_end && CH(end) == _T('?')) {
|
|
4515
|
-
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end,
|
|
4564
|
+
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end, false,
|
|
4516
4565
|
_T('&'), _T("._=()"), _T("+-"), &right_cursor) < 0)
|
|
4517
4566
|
return;
|
|
4518
4567
|
}
|
|
4519
4568
|
|
|
4520
4569
|
/* Scan for fragment segment. */
|
|
4521
4570
|
if(end < line_end && CH(end) == _T('#')) {
|
|
4522
|
-
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end,
|
|
4571
|
+
if(md_analyze_permissive_autolink_segment(ctx, end+1, line_end, &end, false,
|
|
4523
4572
|
_T('\0'), NULL, _T(".-+_"), &right_cursor) < 0)
|
|
4524
4573
|
return;
|
|
4525
4574
|
}
|
|
@@ -4586,20 +4635,21 @@ md_analyze_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
4586
4635
|
|
|
4587
4636
|
/* Analyze the mark. */
|
|
4588
4637
|
switch(mark->ch) {
|
|
4589
|
-
case '[':
|
|
4590
|
-
case '!':
|
|
4638
|
+
case '[': MD_FALLTHROUGH();
|
|
4639
|
+
case '!': MD_FALLTHROUGH();
|
|
4591
4640
|
case ']': md_analyze_bracket(ctx, i); break;
|
|
4592
4641
|
case '&': md_analyze_entity(ctx, i); break;
|
|
4593
|
-
case '_':
|
|
4642
|
+
case '_': MD_FALLTHROUGH();
|
|
4594
4643
|
case '*': md_analyze_emph(ctx, i); break;
|
|
4595
4644
|
case '~': md_analyze_tilde(ctx, i); break;
|
|
4596
4645
|
case '^': md_analyze_caret(ctx, i); break;
|
|
4597
4646
|
case '$': md_analyze_dollar(ctx, i); break;
|
|
4598
|
-
case '.':
|
|
4599
|
-
case ':':
|
|
4647
|
+
case '.': MD_FALLTHROUGH();
|
|
4648
|
+
case ':': MD_FALLTHROUGH();
|
|
4600
4649
|
case '@': md_analyze_permissive_autolink(ctx, i); break;
|
|
4601
4650
|
case '|': md_analyze_spoiler(ctx, i); break;
|
|
4602
4651
|
case '=': md_analyze_highlight(ctx, i); break;
|
|
4652
|
+
case '+': md_analyze_insert(ctx, i); break;
|
|
4603
4653
|
}
|
|
4604
4654
|
|
|
4605
4655
|
if(mark->flags & MD_MARK_RESOLVED) {
|
|
@@ -4668,6 +4718,8 @@ md_analyze_link_contents(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
|
|
|
4668
4718
|
emph_mark_types[n_emph_mark_types++] = _T('$');
|
|
4669
4719
|
if(ctx->parser.flags & MD_FLAG_HIGHLIGHT)
|
|
4670
4720
|
emph_mark_types[n_emph_mark_types++] = _T('=');
|
|
4721
|
+
if(ctx->parser.flags & MD_FLAG_INSERT)
|
|
4722
|
+
emph_mark_types[n_emph_mark_types++] = _T('+');
|
|
4671
4723
|
if(ctx->parser.flags & MD_FLAG_SPOILERS)
|
|
4672
4724
|
emph_mark_types[n_emph_mark_types++] = _T('|');
|
|
4673
4725
|
if(ctx->parser.flags & MD_FLAG_SUPERSCRIPTS)
|
|
@@ -4904,6 +4956,15 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
|
|
|
4904
4956
|
}
|
|
4905
4957
|
break;
|
|
4906
4958
|
|
|
4959
|
+
case '+':
|
|
4960
|
+
if(mark->end - mark->beg == 2) {
|
|
4961
|
+
if(mark->flags & MD_MARK_OPENER)
|
|
4962
|
+
MD_ENTER_SPAN(MD_SPAN_INS, NULL);
|
|
4963
|
+
else
|
|
4964
|
+
MD_LEAVE_SPAN(MD_SPAN_INS, NULL);
|
|
4965
|
+
}
|
|
4966
|
+
break;
|
|
4967
|
+
|
|
4907
4968
|
case '$':
|
|
4908
4969
|
if(mark->flags & MD_MARK_OPENER) {
|
|
4909
4970
|
MD_ENTER_SPAN((mark->end - off) % 2 ? MD_SPAN_LATEXMATH : MD_SPAN_LATEXMATH_DISPLAY, NULL);
|
|
@@ -4967,7 +5028,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
|
|
|
4967
5028
|
|
|
4968
5029
|
MD_CHECK(md_enter_leave_span_a(ctx, (mark->ch != ']'),
|
|
4969
5030
|
(opener->ch == '!' ? MD_SPAN_IMG : MD_SPAN_A),
|
|
4970
|
-
STR(dest_mark->beg), dest_mark->end - dest_mark->beg,
|
|
5031
|
+
STR(dest_mark->beg), dest_mark->end - dest_mark->beg, false,
|
|
4971
5032
|
md_mark_get_ptr(ctx, (int)(title_mark - ctx->marks)),
|
|
4972
5033
|
title_mark->prev));
|
|
4973
5034
|
|
|
@@ -5025,7 +5086,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
|
|
|
5025
5086
|
|
|
5026
5087
|
if(closer->flags & MD_MARK_VALIDPERMISSIVEAUTOLINK)
|
|
5027
5088
|
MD_CHECK(md_enter_leave_span_a(ctx, (mark->flags & MD_MARK_OPENER),
|
|
5028
|
-
MD_SPAN_A, dest, dest_size,
|
|
5089
|
+
MD_SPAN_A, dest, dest_size, true, NULL, 0));
|
|
5029
5090
|
break;
|
|
5030
5091
|
}
|
|
5031
5092
|
|
|
@@ -5069,8 +5130,13 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
|
|
|
5069
5130
|
if(off > tmp)
|
|
5070
5131
|
MD_TEXT(text_type, STR(tmp), off-tmp);
|
|
5071
5132
|
|
|
5072
|
-
/* and new lines are transformed into single spaces.
|
|
5073
|
-
|
|
5133
|
+
/* and new lines are transformed into single spaces. Emit the
|
|
5134
|
+
* space when off rests on an interior newline still preceding
|
|
5135
|
+
* the closer. Testing off == line->end here instead drops the
|
|
5136
|
+
* space when the line ends in whitespace, because the loop
|
|
5137
|
+
* above advances off past line->end over the trailing blanks
|
|
5138
|
+
* (CommonMark code-span examples 335, 337, 640). */
|
|
5139
|
+
if(off < mark->beg && ISNEWLINE(off))
|
|
5074
5140
|
MD_TEXT(text_type, _T(" "), 1);
|
|
5075
5141
|
} else if(text_type == MD_TEXT_HTML) {
|
|
5076
5142
|
/* Inside raw HTML, we output the new line verbatim, including
|
|
@@ -5125,7 +5191,7 @@ md_analyze_table_alignment(MD_CTX* ctx, OFF beg, OFF end, MD_ALIGN* align, int n
|
|
|
5125
5191
|
while(n_align > 0) {
|
|
5126
5192
|
int index = 0; /* index into align_map[] */
|
|
5127
5193
|
|
|
5128
|
-
while(CH(off) != _T('-'))
|
|
5194
|
+
while(off < end && CH(off) != _T('-'))
|
|
5129
5195
|
off++;
|
|
5130
5196
|
if(off > beg && CH(off-1) == _T(':'))
|
|
5131
5197
|
index |= 1;
|
|
@@ -5182,7 +5248,7 @@ md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end,
|
|
|
5182
5248
|
|
|
5183
5249
|
/* Break the line into table cells by identifying pipe characters who
|
|
5184
5250
|
* form the cell boundary. */
|
|
5185
|
-
MD_CHECK(md_analyze_inlines(ctx, &line, 1,
|
|
5251
|
+
MD_CHECK(md_analyze_inlines(ctx, &line, 1, true));
|
|
5186
5252
|
|
|
5187
5253
|
/* We have to remember the cell boundaries in local buffer because
|
|
5188
5254
|
* ctx->marks[] shall be reused during cell contents processing. */
|
|
@@ -5312,7 +5378,7 @@ md_process_normal_block_contents(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_li
|
|
|
5312
5378
|
int i;
|
|
5313
5379
|
int ret;
|
|
5314
5380
|
|
|
5315
|
-
MD_CHECK(md_analyze_inlines(ctx, lines, n_lines,
|
|
5381
|
+
MD_CHECK(md_analyze_inlines(ctx, lines, n_lines, false));
|
|
5316
5382
|
MD_CHECK(md_process_inlines(ctx, lines, n_lines));
|
|
5317
5383
|
|
|
5318
5384
|
abort:
|
|
@@ -5427,11 +5493,12 @@ md_process_leaf_block(MD_CTX* ctx, MD_BLOCK* block)
|
|
|
5427
5493
|
MD_BLOCK_H_DETAIL header;
|
|
5428
5494
|
MD_BLOCK_CODE_DETAIL code;
|
|
5429
5495
|
MD_BLOCK_TABLE_DETAIL table;
|
|
5496
|
+
MD_BLOCK_BLANK_DETAIL blank;
|
|
5430
5497
|
} det;
|
|
5431
5498
|
MD_ATTRIBUTE_BUILD info_build = { 0 };
|
|
5432
5499
|
MD_ATTRIBUTE_BUILD lang_build = { 0 };
|
|
5433
5500
|
int is_in_tight_list;
|
|
5434
|
-
int clean_fence_code_detail =
|
|
5501
|
+
int clean_fence_code_detail = false;
|
|
5435
5502
|
int ret = 0;
|
|
5436
5503
|
|
|
5437
5504
|
/* For large tables check the table density: If it's too low, lets suppress
|
|
@@ -5462,7 +5529,7 @@ md_process_leaf_block(MD_CTX* ctx, MD_BLOCK* block)
|
|
|
5462
5529
|
memset(&det, 0, sizeof(det));
|
|
5463
5530
|
|
|
5464
5531
|
if(ctx->n_containers == 0)
|
|
5465
|
-
is_in_tight_list =
|
|
5532
|
+
is_in_tight_list = false;
|
|
5466
5533
|
else
|
|
5467
5534
|
is_in_tight_list = !ctx->containers[ctx->n_containers-1].is_loose;
|
|
5468
5535
|
|
|
@@ -5475,7 +5542,7 @@ md_process_leaf_block(MD_CTX* ctx, MD_BLOCK* block)
|
|
|
5475
5542
|
/* For fenced code block, we may need to set the info string. */
|
|
5476
5543
|
if(block->data != 0) {
|
|
5477
5544
|
memset(&det.code, 0, sizeof(MD_BLOCK_CODE_DETAIL));
|
|
5478
|
-
clean_fence_code_detail =
|
|
5545
|
+
clean_fence_code_detail = true;
|
|
5479
5546
|
MD_CHECK(md_setup_fenced_code_detail(ctx, block, &det.code, &info_build, &lang_build));
|
|
5480
5547
|
}
|
|
5481
5548
|
break;
|
|
@@ -5486,6 +5553,10 @@ md_process_leaf_block(MD_CTX* ctx, MD_BLOCK* block)
|
|
|
5486
5553
|
det.table.body_row_count = block->n_lines - 2;
|
|
5487
5554
|
break;
|
|
5488
5555
|
|
|
5556
|
+
case MD_BLOCK_BLANK:
|
|
5557
|
+
det.blank.line_count = block->data;
|
|
5558
|
+
break;
|
|
5559
|
+
|
|
5489
5560
|
default:
|
|
5490
5561
|
/* Noop. */
|
|
5491
5562
|
break;
|
|
@@ -5497,7 +5568,8 @@ md_process_leaf_block(MD_CTX* ctx, MD_BLOCK* block)
|
|
|
5497
5568
|
/* Process the block contents accordingly to is type. */
|
|
5498
5569
|
switch(block->type) {
|
|
5499
5570
|
case MD_BLOCK_HR:
|
|
5500
|
-
|
|
5571
|
+
case MD_BLOCK_BLANK:
|
|
5572
|
+
/* noop (no contents) */
|
|
5501
5573
|
break;
|
|
5502
5574
|
|
|
5503
5575
|
case MD_BLOCK_CODE:
|
|
@@ -5559,13 +5631,13 @@ md_process_all_blocks(MD_CTX* ctx)
|
|
|
5559
5631
|
|
|
5560
5632
|
switch(block->type) {
|
|
5561
5633
|
case MD_BLOCK_UL:
|
|
5562
|
-
det.ul.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ?
|
|
5634
|
+
det.ul.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ? false : true;
|
|
5563
5635
|
det.ul.mark = (CHAR) block->data;
|
|
5564
5636
|
break;
|
|
5565
5637
|
|
|
5566
5638
|
case MD_BLOCK_OL:
|
|
5567
5639
|
det.ol.start = block->n_lines;
|
|
5568
|
-
det.ol.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ?
|
|
5640
|
+
det.ol.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ? false : true;
|
|
5569
5641
|
det.ol.mark_delimiter = (CHAR) block->data;
|
|
5570
5642
|
break;
|
|
5571
5643
|
|
|
@@ -5603,13 +5675,13 @@ md_process_all_blocks(MD_CTX* ctx)
|
|
|
5603
5675
|
MD_ENTER_BLOCK(block->type, &det);
|
|
5604
5676
|
|
|
5605
5677
|
if(block->type == MD_BLOCK_UL || block->type == MD_BLOCK_OL) {
|
|
5606
|
-
ctx->containers[ctx->n_containers].is_loose = (block->flags & MD_BLOCK_LOOSE_LIST) ?
|
|
5678
|
+
ctx->containers[ctx->n_containers].is_loose = (block->flags & MD_BLOCK_LOOSE_LIST) ? true : false;
|
|
5607
5679
|
ctx->n_containers++;
|
|
5608
5680
|
} else if(block->type == MD_BLOCK_QUOTE || block->type == MD_BLOCK_ADMONITION) {
|
|
5609
5681
|
/* This causes that any text in a block quote, even if
|
|
5610
5682
|
* nested inside a tight list item, is wrapped with
|
|
5611
5683
|
* <p>...</p>. */
|
|
5612
|
-
ctx->containers[ctx->n_containers].is_loose =
|
|
5684
|
+
ctx->containers[ctx->n_containers].is_loose = true;
|
|
5613
5685
|
ctx->n_containers++;
|
|
5614
5686
|
}
|
|
5615
5687
|
}
|
|
@@ -5850,6 +5922,28 @@ md_add_line_into_current_block(MD_CTX* ctx, const MD_LINE_ANALYSIS* analysis)
|
|
|
5850
5922
|
return 0;
|
|
5851
5923
|
}
|
|
5852
5924
|
|
|
5925
|
+
/* Part of the MD_FLAG_PRESERVEBLANKLINES implementation. */
|
|
5926
|
+
static int
|
|
5927
|
+
md_flush_blank_lines(MD_CTX* ctx)
|
|
5928
|
+
{
|
|
5929
|
+
MD_BLOCK* block;
|
|
5930
|
+
|
|
5931
|
+
if(ctx->n_blank_lines == 0)
|
|
5932
|
+
return 0;
|
|
5933
|
+
|
|
5934
|
+
block = (MD_BLOCK*) md_push_block_bytes(ctx, sizeof(MD_BLOCK));
|
|
5935
|
+
if(block == NULL)
|
|
5936
|
+
return -1;
|
|
5937
|
+
|
|
5938
|
+
block->type = MD_BLOCK_BLANK;
|
|
5939
|
+
block->flags = 0;
|
|
5940
|
+
block->data = ctx->n_blank_lines;
|
|
5941
|
+
block->n_lines = 0;
|
|
5942
|
+
|
|
5943
|
+
ctx->n_blank_lines = 0;
|
|
5944
|
+
return 0;
|
|
5945
|
+
}
|
|
5946
|
+
|
|
5853
5947
|
static int
|
|
5854
5948
|
md_push_container_bytes(MD_CTX* ctx, MD_BLOCKTYPE type, unsigned start,
|
|
5855
5949
|
unsigned data, unsigned flags)
|
|
@@ -5857,6 +5951,7 @@ md_push_container_bytes(MD_CTX* ctx, MD_BLOCKTYPE type, unsigned start,
|
|
|
5857
5951
|
MD_BLOCK* block;
|
|
5858
5952
|
int ret = 0;
|
|
5859
5953
|
|
|
5954
|
+
MD_CHECK(md_flush_blank_lines(ctx));
|
|
5860
5955
|
MD_CHECK(md_end_current_block(ctx));
|
|
5861
5956
|
|
|
5862
5957
|
block = (MD_BLOCK*) md_push_block_bytes(ctx, sizeof(MD_BLOCK));
|
|
@@ -5892,17 +5987,17 @@ md_is_hr_line(MD_CTX* ctx, OFF beg, OFF* p_end, OFF* p_killer)
|
|
|
5892
5987
|
|
|
5893
5988
|
if(n < 3) {
|
|
5894
5989
|
*p_killer = off;
|
|
5895
|
-
return
|
|
5990
|
+
return false;
|
|
5896
5991
|
}
|
|
5897
5992
|
|
|
5898
5993
|
/* Nothing else can be present on the line. */
|
|
5899
5994
|
if(off < ctx->size && !ISNEWLINE(off)) {
|
|
5900
5995
|
*p_killer = off;
|
|
5901
|
-
return
|
|
5996
|
+
return false;
|
|
5902
5997
|
}
|
|
5903
5998
|
|
|
5904
5999
|
*p_end = off;
|
|
5905
|
-
return
|
|
6000
|
+
return true;
|
|
5906
6001
|
}
|
|
5907
6002
|
|
|
5908
6003
|
static int
|
|
@@ -5916,18 +6011,18 @@ md_is_atxheader_line(MD_CTX* ctx, OFF beg, OFF* p_beg, OFF* p_end, unsigned* p_l
|
|
|
5916
6011
|
n = off - beg;
|
|
5917
6012
|
|
|
5918
6013
|
if(n > 6)
|
|
5919
|
-
return
|
|
6014
|
+
return false;
|
|
5920
6015
|
*p_level = n;
|
|
5921
6016
|
|
|
5922
6017
|
if(!(ctx->parser.flags & MD_FLAG_PERMISSIVEATXHEADERS) && off < ctx->size &&
|
|
5923
6018
|
!ISBLANK(off) && !ISNEWLINE(off))
|
|
5924
|
-
return
|
|
6019
|
+
return false;
|
|
5925
6020
|
|
|
5926
6021
|
while(off < ctx->size && ISBLANK(off))
|
|
5927
6022
|
off++;
|
|
5928
6023
|
*p_beg = off;
|
|
5929
6024
|
*p_end = off;
|
|
5930
|
-
return
|
|
6025
|
+
return true;
|
|
5931
6026
|
}
|
|
5932
6027
|
|
|
5933
6028
|
static int
|
|
@@ -5944,35 +6039,35 @@ md_is_setext_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_level)
|
|
|
5944
6039
|
|
|
5945
6040
|
/* But nothing more is allowed on the line. */
|
|
5946
6041
|
if(off < ctx->size && !ISNEWLINE(off))
|
|
5947
|
-
return
|
|
6042
|
+
return false;
|
|
5948
6043
|
|
|
5949
6044
|
*p_level = (CH(beg) == _T('=') ? 1 : 2);
|
|
5950
6045
|
*p_end = off;
|
|
5951
|
-
return
|
|
6046
|
+
return true;
|
|
5952
6047
|
}
|
|
5953
6048
|
|
|
5954
6049
|
static int
|
|
5955
6050
|
md_is_table_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_col_count)
|
|
5956
6051
|
{
|
|
5957
6052
|
OFF off = beg;
|
|
5958
|
-
int found_pipe =
|
|
6053
|
+
int found_pipe = false;
|
|
5959
6054
|
unsigned col_count = 0;
|
|
5960
6055
|
|
|
5961
6056
|
if(off < ctx->size && CH(off) == _T('|')) {
|
|
5962
|
-
found_pipe =
|
|
6057
|
+
found_pipe = true;
|
|
5963
6058
|
off++;
|
|
5964
6059
|
while(off < ctx->size && ISWHITESPACE(off))
|
|
5965
6060
|
off++;
|
|
5966
6061
|
}
|
|
5967
6062
|
|
|
5968
6063
|
while(1) {
|
|
5969
|
-
int delimited =
|
|
6064
|
+
int delimited = false;
|
|
5970
6065
|
|
|
5971
6066
|
/* Cell underline ("-----", ":----", "----:" or ":----:") */
|
|
5972
6067
|
if(off < ctx->size && CH(off) == _T(':'))
|
|
5973
6068
|
off++;
|
|
5974
6069
|
if(off >= ctx->size || CH(off) != _T('-'))
|
|
5975
|
-
return
|
|
6070
|
+
return false;
|
|
5976
6071
|
while(off < ctx->size && CH(off) == _T('-'))
|
|
5977
6072
|
off++;
|
|
5978
6073
|
if(off < ctx->size && CH(off) == _T(':'))
|
|
@@ -5984,8 +6079,8 @@ md_is_table_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_col_count)
|
|
|
5984
6079
|
while(off < ctx->size && ISWHITESPACE(off))
|
|
5985
6080
|
off++;
|
|
5986
6081
|
if(off < ctx->size && CH(off) == _T('|')) {
|
|
5987
|
-
delimited =
|
|
5988
|
-
found_pipe =
|
|
6082
|
+
delimited = true;
|
|
6083
|
+
found_pipe = true;
|
|
5989
6084
|
off++;
|
|
5990
6085
|
while(off < ctx->size && ISWHITESPACE(off))
|
|
5991
6086
|
off++;
|
|
@@ -5996,15 +6091,15 @@ md_is_table_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_col_count)
|
|
|
5996
6091
|
break;
|
|
5997
6092
|
|
|
5998
6093
|
if(!delimited)
|
|
5999
|
-
return
|
|
6094
|
+
return false;
|
|
6000
6095
|
}
|
|
6001
6096
|
|
|
6002
6097
|
if(!found_pipe)
|
|
6003
|
-
return
|
|
6098
|
+
return false;
|
|
6004
6099
|
|
|
6005
6100
|
*p_end = off;
|
|
6006
6101
|
*p_col_count = col_count;
|
|
6007
|
-
return
|
|
6102
|
+
return true;
|
|
6008
6103
|
}
|
|
6009
6104
|
|
|
6010
6105
|
static int
|
|
@@ -6017,7 +6112,7 @@ md_is_opening_code_fence(MD_CTX* ctx, OFF beg, OFF* p_end)
|
|
|
6017
6112
|
|
|
6018
6113
|
/* Fence must have at least three characters. */
|
|
6019
6114
|
if(off - beg < 3)
|
|
6020
|
-
return
|
|
6115
|
+
return false;
|
|
6021
6116
|
|
|
6022
6117
|
ctx->code_fence_length = off - beg;
|
|
6023
6118
|
|
|
@@ -6029,19 +6124,19 @@ md_is_opening_code_fence(MD_CTX* ctx, OFF beg, OFF* p_end)
|
|
|
6029
6124
|
while(off < ctx->size && !ISNEWLINE(off)) {
|
|
6030
6125
|
/* Backtick-based fence must not contain '`' in the info string. */
|
|
6031
6126
|
if(CH(beg) == _T('`') && CH(off) == _T('`'))
|
|
6032
|
-
return
|
|
6127
|
+
return false;
|
|
6033
6128
|
off++;
|
|
6034
6129
|
}
|
|
6035
6130
|
|
|
6036
6131
|
*p_end = off;
|
|
6037
|
-
return
|
|
6132
|
+
return true;
|
|
6038
6133
|
}
|
|
6039
6134
|
|
|
6040
6135
|
static int
|
|
6041
6136
|
md_is_closing_code_fence(MD_CTX* ctx, CHAR ch, OFF beg, OFF* p_end)
|
|
6042
6137
|
{
|
|
6043
6138
|
OFF off = beg;
|
|
6044
|
-
int ret =
|
|
6139
|
+
int ret = false;
|
|
6045
6140
|
|
|
6046
6141
|
/* Closing fence must have at least the same length and use same char as
|
|
6047
6142
|
* opening one. */
|
|
@@ -6058,7 +6153,7 @@ md_is_closing_code_fence(MD_CTX* ctx, CHAR ch, OFF beg, OFF* p_end)
|
|
|
6058
6153
|
if(off < ctx->size && !ISNEWLINE(off))
|
|
6059
6154
|
goto out;
|
|
6060
6155
|
|
|
6061
|
-
ret =
|
|
6156
|
+
ret = true;
|
|
6062
6157
|
|
|
6063
6158
|
out:
|
|
6064
6159
|
/* Note we set *p_end even on failure: If we are not closing fence, caller
|
|
@@ -6103,12 +6198,13 @@ static const TAG s6[] = { X("search"), X("section"), X("summary"), Xend };
|
|
|
6103
6198
|
static const TAG t6[] = { X("table"), X("tbody"), X("td"), X("tfoot"), X("th"),
|
|
6104
6199
|
X("thead"), X("title"), X("tr"), X("track"), Xend };
|
|
6105
6200
|
static const TAG u6[] = { X("ul"), Xend };
|
|
6201
|
+
static const TAG v6[] = { X("video"), Xend };
|
|
6106
6202
|
static const TAG xx[] = { Xend };
|
|
6107
6203
|
|
|
6108
6204
|
#undef X
|
|
6109
6205
|
#undef Xend
|
|
6110
6206
|
|
|
6111
|
-
/* Returns type of the raw HTML block, or
|
|
6207
|
+
/* Returns type of the raw HTML block, or false if it is not HTML block.
|
|
6112
6208
|
* (Refer to CommonMark specification for details about the types.)
|
|
6113
6209
|
*/
|
|
6114
6210
|
static int
|
|
@@ -6118,7 +6214,7 @@ md_is_html_block_start_condition(MD_CTX* ctx, OFF beg)
|
|
|
6118
6214
|
* tree to speed-up the search. */
|
|
6119
6215
|
static const TAG* map6[26] = {
|
|
6120
6216
|
a6, b6, c6, d6, xx, f6, xx, h6, i6, xx, xx, l6, m6,
|
|
6121
|
-
n6, o6, p6, xx, xx, s6, t6, u6,
|
|
6217
|
+
n6, o6, p6, xx, xx, s6, t6, u6, v6, xx, xx, xx, xx
|
|
6122
6218
|
};
|
|
6123
6219
|
OFF off = beg + 1;
|
|
6124
6220
|
int i;
|
|
@@ -6192,7 +6288,7 @@ md_is_html_block_start_condition(MD_CTX* ctx, OFF beg)
|
|
|
6192
6288
|
}
|
|
6193
6289
|
}
|
|
6194
6290
|
|
|
6195
|
-
return
|
|
6291
|
+
return false;
|
|
6196
6292
|
}
|
|
6197
6293
|
|
|
6198
6294
|
/* Case sensitive check whether there is a substring 'what' between 'beg'
|
|
@@ -6206,15 +6302,15 @@ md_line_contains(MD_CTX* ctx, OFF beg, const CHAR* what, SZ what_len, OFF* p_end
|
|
|
6206
6302
|
break;
|
|
6207
6303
|
if(memcmp(STR(i), what, what_len * sizeof(CHAR)) == 0) {
|
|
6208
6304
|
*p_end = i + what_len;
|
|
6209
|
-
return
|
|
6305
|
+
return true;
|
|
6210
6306
|
}
|
|
6211
6307
|
}
|
|
6212
6308
|
|
|
6213
6309
|
*p_end = i;
|
|
6214
|
-
return
|
|
6310
|
+
return false;
|
|
6215
6311
|
}
|
|
6216
6312
|
|
|
6217
|
-
/* Returns type of HTML block end condition or
|
|
6313
|
+
/* Returns type of HTML block end condition or false if not an end condition.
|
|
6218
6314
|
*
|
|
6219
6315
|
* Note it fills p_end even when it is not end condition as the caller
|
|
6220
6316
|
* does not need to analyze contents of a raw HTML block.
|
|
@@ -6236,7 +6332,7 @@ md_is_html_block_end_condition(MD_CTX* ctx, OFF beg, OFF* p_end)
|
|
|
6236
6332
|
CH(off+2+t1[i].len) == _T('>'))
|
|
6237
6333
|
{
|
|
6238
6334
|
*p_end = off+2+t1[i].len+1;
|
|
6239
|
-
return
|
|
6335
|
+
return true;
|
|
6240
6336
|
}
|
|
6241
6337
|
}
|
|
6242
6338
|
}
|
|
@@ -6244,34 +6340,34 @@ md_is_html_block_end_condition(MD_CTX* ctx, OFF beg, OFF* p_end)
|
|
|
6244
6340
|
off++;
|
|
6245
6341
|
}
|
|
6246
6342
|
*p_end = off;
|
|
6247
|
-
return
|
|
6343
|
+
return false;
|
|
6248
6344
|
}
|
|
6249
6345
|
|
|
6250
6346
|
case 2:
|
|
6251
|
-
return (md_line_contains(ctx, beg, _T("-->"), 3, p_end) ? 2 :
|
|
6347
|
+
return (md_line_contains(ctx, beg, _T("-->"), 3, p_end) ? 2 : false);
|
|
6252
6348
|
|
|
6253
6349
|
case 3:
|
|
6254
|
-
return (md_line_contains(ctx, beg, _T("?>"), 2, p_end) ? 3 :
|
|
6350
|
+
return (md_line_contains(ctx, beg, _T("?>"), 2, p_end) ? 3 : false);
|
|
6255
6351
|
|
|
6256
6352
|
case 4:
|
|
6257
|
-
return (md_line_contains(ctx, beg, _T(">"), 1, p_end) ? 4 :
|
|
6353
|
+
return (md_line_contains(ctx, beg, _T(">"), 1, p_end) ? 4 : false);
|
|
6258
6354
|
|
|
6259
6355
|
case 5:
|
|
6260
|
-
return (md_line_contains(ctx, beg, _T("]]>"), 3, p_end) ? 5 :
|
|
6356
|
+
return (md_line_contains(ctx, beg, _T("]]>"), 3, p_end) ? 5 : false);
|
|
6261
6357
|
|
|
6262
|
-
case 6:
|
|
6358
|
+
case 6: MD_FALLTHROUGH();
|
|
6263
6359
|
case 7:
|
|
6264
6360
|
if(beg >= ctx->size || ISNEWLINE(beg)) {
|
|
6265
6361
|
/* Blank line ends types 6 and 7. */
|
|
6266
6362
|
*p_end = beg;
|
|
6267
6363
|
return ctx->html_block_type;
|
|
6268
6364
|
}
|
|
6269
|
-
return
|
|
6365
|
+
return false;
|
|
6270
6366
|
|
|
6271
6367
|
default:
|
|
6272
6368
|
MD_UNREACHABLE();
|
|
6273
6369
|
}
|
|
6274
|
-
return
|
|
6370
|
+
return false;
|
|
6275
6371
|
}
|
|
6276
6372
|
|
|
6277
6373
|
|
|
@@ -6280,14 +6376,14 @@ md_is_container_compatible(const MD_CONTAINER* pivot, const MD_CONTAINER* contai
|
|
|
6280
6376
|
{
|
|
6281
6377
|
/* Block quote has no "items" like lists. */
|
|
6282
6378
|
if(container->ch == _T('>'))
|
|
6283
|
-
return
|
|
6379
|
+
return false;
|
|
6284
6380
|
|
|
6285
6381
|
if(container->ch != pivot->ch)
|
|
6286
|
-
return
|
|
6382
|
+
return false;
|
|
6287
6383
|
if(container->mark_indent > pivot->contents_indent)
|
|
6288
|
-
return
|
|
6384
|
+
return false;
|
|
6289
6385
|
|
|
6290
|
-
return
|
|
6386
|
+
return true;
|
|
6291
6387
|
}
|
|
6292
6388
|
|
|
6293
6389
|
static int
|
|
@@ -6320,12 +6416,12 @@ md_enter_child_containers(MD_CTX* ctx, int n_children)
|
|
|
6320
6416
|
|
|
6321
6417
|
for(i = ctx->n_containers - n_children; i < ctx->n_containers; i++) {
|
|
6322
6418
|
MD_CONTAINER* c = &ctx->containers[i];
|
|
6323
|
-
int is_ordered_list =
|
|
6419
|
+
int is_ordered_list = false;
|
|
6324
6420
|
|
|
6325
6421
|
switch(c->ch) {
|
|
6326
6422
|
case _T(')'):
|
|
6327
6423
|
case _T('.'):
|
|
6328
|
-
is_ordered_list =
|
|
6424
|
+
is_ordered_list = true;
|
|
6329
6425
|
MD_FALLTHROUGH();
|
|
6330
6426
|
|
|
6331
6427
|
case _T('-'):
|
|
@@ -6368,12 +6464,12 @@ md_leave_child_containers(MD_CTX* ctx, int n_keep)
|
|
|
6368
6464
|
|
|
6369
6465
|
while(ctx->n_containers > n_keep) {
|
|
6370
6466
|
MD_CONTAINER* c = &ctx->containers[ctx->n_containers-1];
|
|
6371
|
-
int is_ordered_list =
|
|
6467
|
+
int is_ordered_list = false;
|
|
6372
6468
|
|
|
6373
6469
|
switch(c->ch) {
|
|
6374
6470
|
case _T(')'):
|
|
6375
6471
|
case _T('.'):
|
|
6376
|
-
is_ordered_list =
|
|
6472
|
+
is_ordered_list = true;
|
|
6377
6473
|
MD_FALLTHROUGH();
|
|
6378
6474
|
|
|
6379
6475
|
case _T('-'):
|
|
@@ -6412,29 +6508,29 @@ md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTA
|
|
|
6412
6508
|
OFF max_end;
|
|
6413
6509
|
|
|
6414
6510
|
if(off >= ctx->size || indent >= ctx->code_indent_offset)
|
|
6415
|
-
return
|
|
6511
|
+
return false;
|
|
6416
6512
|
|
|
6417
6513
|
/* Check for block quote mark. */
|
|
6418
6514
|
if(CH(off) == _T('>')) {
|
|
6419
6515
|
off++;
|
|
6420
6516
|
p_container->ch = _T('>');
|
|
6421
|
-
p_container->is_loose =
|
|
6422
|
-
p_container->is_task =
|
|
6517
|
+
p_container->is_loose = false;
|
|
6518
|
+
p_container->is_task = false;
|
|
6423
6519
|
p_container->mark_indent = indent;
|
|
6424
6520
|
p_container->contents_indent = indent + 1;
|
|
6425
6521
|
*p_end = off;
|
|
6426
|
-
return
|
|
6522
|
+
return true;
|
|
6427
6523
|
}
|
|
6428
6524
|
|
|
6429
6525
|
/* Check for list item bullet mark. */
|
|
6430
6526
|
if(ISANYOF(off, _T("-+*")) && (off+1 >= ctx->size || ISBLANK(off+1) || ISNEWLINE(off+1))) {
|
|
6431
6527
|
p_container->ch = CH(off);
|
|
6432
|
-
p_container->is_loose =
|
|
6433
|
-
p_container->is_task =
|
|
6528
|
+
p_container->is_loose = false;
|
|
6529
|
+
p_container->is_task = false;
|
|
6434
6530
|
p_container->mark_indent = indent;
|
|
6435
6531
|
p_container->contents_indent = indent + 1;
|
|
6436
6532
|
*p_end = off+1;
|
|
6437
|
-
return
|
|
6533
|
+
return true;
|
|
6438
6534
|
}
|
|
6439
6535
|
|
|
6440
6536
|
/* Check for ordered list item marks. */
|
|
@@ -6452,15 +6548,15 @@ md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTA
|
|
|
6452
6548
|
(off+1 >= ctx->size || ISBLANK(off+1) || ISNEWLINE(off+1)))
|
|
6453
6549
|
{
|
|
6454
6550
|
p_container->ch = CH(off);
|
|
6455
|
-
p_container->is_loose =
|
|
6456
|
-
p_container->is_task =
|
|
6551
|
+
p_container->is_loose = false;
|
|
6552
|
+
p_container->is_task = false;
|
|
6457
6553
|
p_container->mark_indent = indent;
|
|
6458
6554
|
p_container->contents_indent = indent + off - beg + 1;
|
|
6459
6555
|
*p_end = off+1;
|
|
6460
|
-
return
|
|
6556
|
+
return true;
|
|
6461
6557
|
}
|
|
6462
6558
|
|
|
6463
|
-
return
|
|
6559
|
+
return false;
|
|
6464
6560
|
}
|
|
6465
6561
|
|
|
6466
6562
|
static unsigned
|
|
@@ -6502,7 +6598,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6502
6598
|
line->indent = md_line_indentation(ctx, total_indent, off, &off);
|
|
6503
6599
|
total_indent += line->indent;
|
|
6504
6600
|
line->beg = off;
|
|
6505
|
-
line->enforce_new_block =
|
|
6601
|
+
line->enforce_new_block = false;
|
|
6506
6602
|
|
|
6507
6603
|
/* Given the indentation and block quote marks '>', determine how many of
|
|
6508
6604
|
* the current containers are our parents. */
|
|
@@ -6543,7 +6639,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6543
6639
|
}
|
|
6544
6640
|
}
|
|
6545
6641
|
|
|
6546
|
-
while(
|
|
6642
|
+
while(true) {
|
|
6547
6643
|
/* Check whether we are fenced code continuation. */
|
|
6548
6644
|
if(pivot_line->type == MD_LINE_FENCEDCODE) {
|
|
6549
6645
|
line->beg = off;
|
|
@@ -6553,7 +6649,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6553
6649
|
if(line->indent < ctx->code_indent_offset) {
|
|
6554
6650
|
if(md_is_closing_code_fence(ctx, CH(pivot_line->beg), off, &off)) {
|
|
6555
6651
|
line->type = MD_LINE_BLANK;
|
|
6556
|
-
ctx->last_line_has_list_loosening_effect =
|
|
6652
|
+
ctx->last_line_has_list_loosening_effect = false;
|
|
6557
6653
|
break;
|
|
6558
6654
|
}
|
|
6559
6655
|
}
|
|
@@ -6608,7 +6704,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6608
6704
|
line->indent -= ctx->code_indent_offset;
|
|
6609
6705
|
else
|
|
6610
6706
|
line->indent = 0;
|
|
6611
|
-
ctx->last_line_has_list_loosening_effect =
|
|
6707
|
+
ctx->last_line_has_list_loosening_effect = false;
|
|
6612
6708
|
} else {
|
|
6613
6709
|
line->type = MD_LINE_BLANK;
|
|
6614
6710
|
ctx->last_line_has_list_loosening_effect = (n_parents > 0 &&
|
|
@@ -6633,7 +6729,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6633
6729
|
{
|
|
6634
6730
|
MD_BLOCK* top_block = (MD_BLOCK*) ((char*)ctx->block_bytes + ctx->n_block_bytes - sizeof(MD_BLOCK));
|
|
6635
6731
|
if(top_block->type == MD_BLOCK_LI)
|
|
6636
|
-
ctx->last_list_item_starts_with_two_blank_lines =
|
|
6732
|
+
ctx->last_list_item_starts_with_two_blank_lines = true;
|
|
6637
6733
|
}
|
|
6638
6734
|
#endif
|
|
6639
6735
|
}
|
|
@@ -6660,10 +6756,10 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6660
6756
|
}
|
|
6661
6757
|
}
|
|
6662
6758
|
|
|
6663
|
-
ctx->last_list_item_starts_with_two_blank_lines =
|
|
6759
|
+
ctx->last_list_item_starts_with_two_blank_lines = false;
|
|
6664
6760
|
}
|
|
6665
6761
|
#endif
|
|
6666
|
-
ctx->last_line_has_list_loosening_effect =
|
|
6762
|
+
ctx->last_line_has_list_loosening_effect = false;
|
|
6667
6763
|
}
|
|
6668
6764
|
|
|
6669
6765
|
/* Check whether we are Setext underline. */
|
|
@@ -6805,7 +6901,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6805
6901
|
if(md_is_opening_code_fence(ctx, off, &off)) {
|
|
6806
6902
|
line->type = MD_LINE_FENCEDCODE;
|
|
6807
6903
|
line->data = 1;
|
|
6808
|
-
line->enforce_new_block =
|
|
6904
|
+
line->enforce_new_block = true;
|
|
6809
6905
|
break;
|
|
6810
6906
|
}
|
|
6811
6907
|
}
|
|
@@ -6827,7 +6923,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6827
6923
|
ctx->html_block_type = 0;
|
|
6828
6924
|
}
|
|
6829
6925
|
|
|
6830
|
-
line->enforce_new_block =
|
|
6926
|
+
line->enforce_new_block = true;
|
|
6831
6927
|
line->type = MD_LINE_HTML;
|
|
6832
6928
|
break;
|
|
6833
6929
|
}
|
|
@@ -6869,7 +6965,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6869
6965
|
(tmp + 3 == ctx->size || ISBLANK(tmp+3) || ISNEWLINE(tmp+3)))
|
|
6870
6966
|
{
|
|
6871
6967
|
MD_CONTAINER* task_container = (n_children > 0 ? &ctx->containers[ctx->n_containers-1] : &container);
|
|
6872
|
-
task_container->is_task =
|
|
6968
|
+
task_container->is_task = true;
|
|
6873
6969
|
task_container->task_mark_off = tmp + 1;
|
|
6874
6970
|
off = tmp + 3;
|
|
6875
6971
|
while(off < ctx->size && ISWHITESPACE(off))
|
|
@@ -6958,7 +7054,7 @@ md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end,
|
|
|
6958
7054
|
if(line->end - line->beg == md_strlen(MD_ADMONITION_TAGS[i]) + 3 &&
|
|
6959
7055
|
md_ascii_case_eq(STR(line->beg+2), MD_ADMONITION_TAGS[i], line->end - line->beg - 3))
|
|
6960
7056
|
{
|
|
6961
|
-
ctx->containers[ctx->n_containers-1].is_admonition =
|
|
7057
|
+
ctx->containers[ctx->n_containers-1].is_admonition = true;
|
|
6962
7058
|
ctx->containers[ctx->n_containers-1].admonition_type = i;
|
|
6963
7059
|
line->type = MD_LINE_BLANK;
|
|
6964
7060
|
break;
|
|
@@ -6983,10 +7079,19 @@ md_process_line(MD_CTX* ctx, const MD_LINE_ANALYSIS** p_pivot_line, MD_LINE_ANAL
|
|
|
6983
7079
|
/* Blank line ends current leaf block. */
|
|
6984
7080
|
if(line->type == MD_LINE_BLANK) {
|
|
6985
7081
|
MD_CHECK(md_end_current_block(ctx));
|
|
7082
|
+
/* Count only genuinely empty lines: some non-blank lines (e.g. a closing
|
|
7083
|
+
* code fence) are internally retyped as MD_LINE_BLANK but still hold
|
|
7084
|
+
* their text (beg < end), and must not be counted. */
|
|
7085
|
+
if((ctx->parser.flags & MD_FLAG_PRESERVEBLANKLINES) && line->beg >= line->end)
|
|
7086
|
+
ctx->n_blank_lines++;
|
|
6986
7087
|
*p_pivot_line = &md_dummy_blank_line;
|
|
6987
7088
|
return 0;
|
|
6988
7089
|
}
|
|
6989
7090
|
|
|
7091
|
+
/* The blank lines preceding this block (if any) form a block separation
|
|
7092
|
+
* which we report before the block itself. */
|
|
7093
|
+
MD_CHECK(md_flush_blank_lines(ctx));
|
|
7094
|
+
|
|
6990
7095
|
if(line->enforce_new_block)
|
|
6991
7096
|
MD_CHECK(md_end_current_block(ctx));
|
|
6992
7097
|
|
|
@@ -7145,6 +7250,8 @@ md_process_doc(MD_CTX *ctx)
|
|
|
7145
7250
|
|
|
7146
7251
|
/* Process all blocks. */
|
|
7147
7252
|
MD_CHECK(md_leave_child_containers(ctx, 0));
|
|
7253
|
+
/* Report any blank lines trailing the document. */
|
|
7254
|
+
MD_CHECK(md_flush_blank_lines(ctx));
|
|
7148
7255
|
MD_CHECK(md_process_all_blocks(ctx));
|
|
7149
7256
|
|
|
7150
7257
|
/* Emit footnote definitions that were referenced, in reference order. */
|