diff --git a/.idea/libraries/intellij_markdown.xml b/.idea/libraries/intellij_markdown.xml
deleted file mode 100644
index 40847321e580..000000000000
--- a/.idea/libraries/intellij_markdown.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/jetbrains_markdown_jvm.xml b/.idea/libraries/jetbrains_markdown_jvm.xml
new file mode 100644
index 000000000000..5c111da39e42
--- /dev/null
+++ b/.idea/libraries/jetbrains_markdown_jvm.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
index 07a90e5bdc10..862f55df5c51 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
+// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.intellij.build
import groovy.transform.CompileStatic
@@ -767,9 +767,9 @@ final class CommunityLibraryLicenses {
jetbrainsLibrary("find-file-model"),
jetbrainsLibrary("git-learning-project"),
jetbrainsLibrary("intellij-coverage"),
- jetbrainsLibrary("intellij-markdown"),
jetbrainsLibrary("intellij-test-discovery"),
jetbrainsLibrary("io.ktor.network.jvm"),
+ jetbrainsLibrary("jetbrains.markdown.jvm"),
jetbrainsLibrary("jetbrains.research.refactorinsight.kotlin.impl"),
jetbrainsLibrary("jps-build-script-dependencies-bootstrap"),
jetbrainsLibrary("jshell-frontend"),
@@ -819,4 +819,4 @@ final class CommunityLibraryLicenses {
jetbrainsLibrary("tips-idea-ce"),
jetbrainsLibrary("tips-pycharm-community"),
] as List
-}
+}
\ No newline at end of file
diff --git a/platform/collaboration-tools/intellij.platform.collaborationTools.iml b/platform/collaboration-tools/intellij.platform.collaborationTools.iml
index d8196ee7b8c5..50aaf0fc18d1 100644
--- a/platform/collaboration-tools/intellij.platform.collaborationTools.iml
+++ b/platform/collaboration-tools/intellij.platform.collaborationTools.iml
@@ -34,7 +34,7 @@
-
+
\ No newline at end of file
diff --git a/platform/markdown-utils/intellij.platform.markdown.utils.iml b/platform/markdown-utils/intellij.platform.markdown.utils.iml
index 97594957e143..2ada5ceb1ce6 100644
--- a/platform/markdown-utils/intellij.platform.markdown.utils.iml
+++ b/platform/markdown-utils/intellij.platform.markdown.utils.iml
@@ -11,7 +11,7 @@
-
+
diff --git a/plugins/github/intellij.vcs.github.iml b/plugins/github/intellij.vcs.github.iml
index c31789b1a9c1..a0d9887b496d 100644
--- a/plugins/github/intellij.vcs.github.iml
+++ b/plugins/github/intellij.vcs.github.iml
@@ -50,6 +50,6 @@
-
+
\ No newline at end of file
diff --git a/plugins/kotlin/idea/kotlin.idea.iml b/plugins/kotlin/idea/kotlin.idea.iml
index c3f5e2fb9dad..bf14771af988 100644
--- a/plugins/kotlin/idea/kotlin.idea.iml
+++ b/plugins/kotlin/idea/kotlin.idea.iml
@@ -63,7 +63,7 @@
-
+
diff --git a/plugins/markdown/core/intellij.markdown.core.iml b/plugins/markdown/core/intellij.markdown.core.iml
index ed0a4bb5e004..ea83696faa20 100644
--- a/plugins/markdown/core/intellij.markdown.core.iml
+++ b/plugins/markdown/core/intellij.markdown.core.iml
@@ -24,7 +24,7 @@
-
+
diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/lexer/MarkdownLexerAdapter.java b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/lexer/MarkdownLexerAdapter.java
index bb7697522fd5..f7e58a749866 100644
--- a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/lexer/MarkdownLexerAdapter.java
+++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/lexer/MarkdownLexerAdapter.java
@@ -32,7 +32,7 @@ public class MarkdownLexerAdapter extends LexerBase {
@Override
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
this.endOffset = endOffset;
- delegateLexer.start(buffer, startOffset, endOffset);
+ delegateLexer.start(buffer, startOffset, endOffset, initialState);
}
@Override
diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/parser/CommentAwareLinkReferenceDefinitionProvider.kt b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/parser/CommentAwareLinkReferenceDefinitionProvider.kt
index d1b7ba6fef1d..2ffcb4cad894 100644
--- a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/parser/CommentAwareLinkReferenceDefinitionProvider.kt
+++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/parser/CommentAwareLinkReferenceDefinitionProvider.kt
@@ -23,7 +23,7 @@ class CommentAwareLinkReferenceDefinitionProvider : MarkerBlockProvider' ->
- MarkdownTokenTypes.BLOCK_QUOTE
- '.', ')' ->
- MarkdownTokenTypes.LIST_NUMBER
- else ->
- MarkdownTokenTypes.LIST_BULLET
+ check(constraints.types.isNotEmpty())
+ val type = when (constraints.types.last()) {
+ '>' -> MarkdownTokenTypes.BLOCK_QUOTE
+ '.', ')' -> MarkdownTokenTypes.LIST_NUMBER
+ else -> MarkdownTokenTypes.LIST_BULLET
}
val middleOffset = pos.offset - pos.offsetInCurrentLine + offset
val endOffset = min(pos.offset - pos.offsetInCurrentLine + constraints.getCharsEaten(pos.currentLine),
diff --git a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/psi/impl/MarkdownList.java b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/psi/impl/MarkdownList.java
index b22a9d9b666b..8adfd3a3bbb5 100644
--- a/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/psi/impl/MarkdownList.java
+++ b/plugins/markdown/core/src/org/intellij/plugins/markdown/lang/psi/impl/MarkdownList.java
@@ -3,12 +3,12 @@ package org.intellij.plugins.markdown.lang.psi.impl;
import com.intellij.icons.AllIcons;
import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import org.intellij.plugins.markdown.lang.MarkdownElementTypes;
import org.intellij.plugins.markdown.lang.psi.MarkdownElementVisitor;
import org.intellij.plugins.markdown.util.MarkdownPsiUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -43,14 +43,10 @@ public class MarkdownList extends MarkdownCompositePsiElementBase {
return new ItemPresentation() {
@Override
public String getPresentableText() {
- PsiElement[] parentChildren = getParent().getChildren();
- if (MarkdownPsiUtil.isSimpleNestedList(parentChildren)) {
- ItemPresentation parentPresentation = getParent().getNode().getPsi(MarkdownListItem.class).getPresentation();
- if (parentPresentation != null) {
- return parentPresentation.getPresentableText();
- }
+ final var nestedPresentation = getSimpleNestedPresentation(MarkdownList.this);
+ if (nestedPresentation != null) {
+ return nestedPresentation.getPresentableText();
}
-
return getNode().getElementType() == MarkdownElementTypes.ORDERED_LIST
? ORDERED_LIST_TEXT
: UNORDERED_LIST_TEXT;
@@ -58,14 +54,10 @@ public class MarkdownList extends MarkdownCompositePsiElementBase {
@Override
public String getLocationString() {
- PsiElement[] parentChildren = getParent().getChildren();
- if (MarkdownPsiUtil.isSimpleNestedList(parentChildren)) {
- ItemPresentation parentPresentation = getParent().getNode().getPsi(MarkdownListItem.class).getPresentation();
- if (parentPresentation != null) {
- return parentPresentation.getLocationString();
- }
+ final var nestedPresentation = getSimpleNestedPresentation(MarkdownList.this);
+ if (nestedPresentation != null) {
+ return nestedPresentation.getLocationString();
}
-
return null;
}
@@ -77,4 +69,12 @@ public class MarkdownList extends MarkdownCompositePsiElementBase {
}
};
}
+
+ private static @Nullable ItemPresentation getSimpleNestedPresentation(@NotNull MarkdownList element) {
+ final var parent = element.getParent();
+ if (MarkdownPsiUtil.isSimpleNestedList(parent.getChildren()) && parent instanceof MarkdownListItem) {
+ return ((MarkdownListItem)parent).getPresentation();
+ }
+ return null;
+ }
}
diff --git a/plugins/markdown/test/data/formatter/headers_after.md b/plugins/markdown/test/data/formatter/headers_after.md
index 4ae88eb02260..e096c6d8cd71 100644
--- a/plugins/markdown/test/data/formatter/headers_after.md
+++ b/plugins/markdown/test/data/formatter/headers_after.md
@@ -2,13 +2,13 @@
# Header with excessive spaces
-# Header with missing spaces
+#Header with missing spaces
# Minor header
#### Minor header with excessive spaces
-#### Minor header with missing spaces
+####Minor header with missing spaces
# Two headers one by one
@@ -40,7 +40,7 @@ One paragraph
* # Normal header in list
-* # Header with missing space in list
+* #Header with missing space in list
* # Header with excessive spaces in list
@@ -55,7 +55,8 @@ One paragraph
> # Normal header in blockquote
-> # Header with missing space in blockquote
+> #Header with missing space in
+blockquote
> # Header with excessive spaces in blockquote
diff --git a/plugins/markdown/test/data/formatter/smoke_after.md b/plugins/markdown/test/data/formatter/smoke_after.md
index b0fe81ae01b2..393fd0e03fe5 100644
--- a/plugins/markdown/test/data/formatter/smoke_after.md
+++ b/plugins/markdown/test/data/formatter/smoke_after.md
@@ -3,8 +3,7 @@
Sample paragraph with two spaces
Other paragraph with newline too early
-
-# Other header
+#Other header
```kotlin
val a = 12
diff --git a/plugins/markdown/test/data/structureView/withLists/multipleCompositeChildrenInLists.md b/plugins/markdown/test/data/structureView/withLists/multipleCompositeChildrenInLists.md
index 35f895be1fb3..a94ceda6dfb0 100644
--- a/plugins/markdown/test/data/structureView/withLists/multipleCompositeChildrenInLists.md
+++ b/plugins/markdown/test/data/structureView/withLists/multipleCompositeChildrenInLists.md
@@ -1,4 +1,4 @@
-#Mad party
+# Mad party
* [IntelliJ platform overview](#intellij-platform-overview)
1. # First
@@ -16,4 +16,4 @@
* Mysterious item
#### Header 4
* [How to configure development environment](#configure-idea-development-environment)
-* #Header 1
+* # Header 1