Skip to content

Add Markdown Support #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
6CA62EA929F9D36700785B11 /* TreeSitterTS in Frameworks */ = {isa = PBXBuildFile; productRef = 6CA62EA829F9D36700785B11 /* TreeSitterTS */; };
6CA62EAB29F9D36700785B11 /* TreeSitterTSX in Frameworks */ = {isa = PBXBuildFile; productRef = 6CA62EAA29F9D36700785B11 /* TreeSitterTSX */; };
6CEC70FE29C3A85000B61C7A /* TreeSitterRegex in Frameworks */ = {isa = PBXBuildFile; productRef = 6CEC70FD29C3A85000B61C7A /* TreeSitterRegex */; };
9D2DFC8C29FAE5FE00CE01C8 /* TreeSitterMarkdown in Frameworks */ = {isa = PBXBuildFile; productRef = 9D2DFC8B29FAE5FE00CE01C8 /* TreeSitterMarkdown */; };
9D6DA3B8298F1A4600E69066 /* TreeSitterOCaml in Frameworks */ = {isa = PBXBuildFile; productRef = 9D6DA3B7298F1A4600E69066 /* TreeSitterOCaml */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -72,6 +73,7 @@
28B3F063290C372D000CD04D /* TreeSitterZig in Frameworks */,
28B3F045290C366E000CD04D /* TreeSitterHTML in Frameworks */,
28B3F05A290C36E5000CD04D /* TreeSitterRust in Frameworks */,
9D2DFC8C29FAE5FE00CE01C8 /* TreeSitterMarkdown in Frameworks */,
28AAB6AE29CA57D40087654B /* TreeSitterDart in Frameworks */,
28B3F054290C36C5000CD04D /* TreeSitterPython in Frameworks */,
28171CB829814CD800523F1C /* TreeSitterObjC in Frameworks */,
Expand Down Expand Up @@ -187,6 +189,7 @@
28AAB6AD29CA57D40087654B /* TreeSitterDart */,
6CA62EA829F9D36700785B11 /* TreeSitterTS */,
6CA62EAA29F9D36700785B11 /* TreeSitterTSX */,
9D2DFC8B29FAE5FE00CE01C8 /* TreeSitterMarkdown */,
);
productName = "CodeLanguages-Container";
productReference = 28B3F00C290C207D000CD04D /* CodeLanguages_Container.framework */;
Expand Down Expand Up @@ -246,6 +249,7 @@
6CEC70FC29C3A85000B61C7A /* XCRemoteSwiftPackageReference "tree-sitter-regex" */,
28AAB6AC29CA57D40087654B /* XCRemoteSwiftPackageReference "tree-sitter-dart" */,
6CA62EA729F9D36700785B11 /* XCRemoteSwiftPackageReference "tree-sitter-typescript" */,
9D2DFC8A29FAE5FE00CE01C8 /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */,
);
productRefGroup = 28B3F00D290C207D000CD04D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -719,6 +723,14 @@
kind = branch;
};
};
9D2DFC8A29FAE5FE00CE01C8 /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/cengelbart39/tree-sitter-markdown.git";
requirement = {
branch = feature/spm;
kind = branch;
};
};
9D6DA3B6298F1A4500E69066 /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/cengelbart39/tree-sitter-ocaml.git";
Expand Down Expand Up @@ -875,6 +887,11 @@
package = 6CEC70FC29C3A85000B61C7A /* XCRemoteSwiftPackageReference "tree-sitter-regex" */;
productName = TreeSitterRegex;
};
9D2DFC8B29FAE5FE00CE01C8 /* TreeSitterMarkdown */ = {
isa = XCSwiftPackageProductDependency;
package = 9D2DFC8A29FAE5FE00CE01C8 /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */;
productName = TreeSitterMarkdown;
};
9D6DA3B7298F1A4600E69066 /* TreeSitterOCaml */ = {
isa = XCSwiftPackageProductDependency;
package = 9D6DA3B6298F1A4500E69066 /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@
"revision" : "47d56065016862b85ad327d6976b1e664e1c034b"
}
},
{
"identity" : "tree-sitter-markdown",
"kind" : "remoteSourceControl",
"location" : "https://github.com/cengelbart39/tree-sitter-markdown.git",
"state" : {
"branch" : "feature/spm",
"revision" : "4b2f595da752267f8e45ea30cbbad4d4c8ee9061"
}
},
{
"identity" : "tree-sitter-objc",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern TSLanguage *tree_sitter_javascript();
extern TSLanguage *tree_sitter_json();
extern TSLanguage *tree_sitter_kotlin();
extern TSLanguage *tree_sitter_lua();
extern TSLanguage *tree_sitter_markdown();
extern TSLanguage *tree_sitter_objc();
extern TSLanguage *tree_sitter_ocaml();
extern TSLanguage *tree_sitter_ocaml_interface();
Expand Down
Binary file modified CodeLanguagesContainer.xcframework.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In order to add support for additional languages we have a complete guide on how
| [Julia](https://github.com/tree-sitter/tree-sitter-julia) | | _not available_ |
| [Kotlin](https://github.com/lukepistrol/tree-sitter-kotlin/tree/feature/spm-queries) | ✅ | ✅ |
| [Lua](https://github.com/lukepistrol/tree-sitter-lua/tree/feature/spm) | ✅ | ✅ |
| [Markdown](https://github.com/ikatyang/tree-sitter-markdown) | | _not available_ |
| [Markdown](https://github.com/cengelbart39/tree-sitter-markdown/tree/feature/spm) | | _not available_ |
| [Objective C](https://github.com/lukepistrol/tree-sitter-objc/tree/feature/spm) | ✅ | ✅ |
| [OCaml](https://github.com/cengelbart39/tree-sitter-ocaml/tree/feature/spm) | ✅ | ✅ |
| Plain Text | ✅ | _not available_ |
Expand Down
8 changes: 8 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage+Definitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public extension CodeLanguage {
.jsx,
.kotlin,
.lua,
.markdown,
.objc,
.ocaml,
.ocamlInterface,
Expand Down Expand Up @@ -178,6 +179,13 @@ public extension CodeLanguage {
highlights: ["injections"]
)

/// A language structure for `Markdown`
static let markdown: CodeLanguage = .init(
id: .markdown,
tsName: "markdown",
extensions: ["md", "mkd", "mkdn", "mdwn", "mdown", "markdown"]
)

/// A language structure for `Objective C`
static let objc: CodeLanguage = .init(
id: .objc,
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public struct CodeLanguage {
return tree_sitter_kotlin()
case .lua:
return tree_sitter_lua()
case .markdown:
return tree_sitter_markdown()
case .objc:
return tree_sitter_objc()
case .ocaml:
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- JSX
- Kotlin
- Lua
- Markdown
- Objective C
- OCaml / OCaml Interface
- PHP
Expand Down Expand Up @@ -87,6 +88,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- ``jsx``
- ``kotlin``
- ``lua``
- ``markdown``
- ``objc``
- ``php``
- ``python``
Expand Down
1 change: 1 addition & 0 deletions Sources/CodeEditLanguages/TreeSitterLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum TreeSitterLanguage: String {
case jsx
case kotlin
case lua
case markdown
case objc
case ocaml
case ocamlInterface
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/TreeSitterModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class TreeSitterModel {
return kotlinQuery
case .lua:
return luaQuery
case .markdown:
return nil
case .objc:
return objcQuery
case .ocaml:
Expand Down
44 changes: 44 additions & 0 deletions Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,50 @@ final class CodeEditLanguagesTests: XCTestCase {
XCTAssertNotEqual(query?.patternCount, 0)
}

// MARK: - Markdown

func test_CodeLanguageMarkdown() throws {
let url = URL(fileURLWithPath: "~/path/to/file.md")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

func test_CodeLanguageMarkdown2() throws {
let url = URL(fileURLWithPath: "~/path/to/file.mkd")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

func test_CodeLanguageMarkdown3() throws {
let url = URL(fileURLWithPath: "~/path/to/file.mkdn")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

func test_CodeLanguageMarkdown4() throws {
let url = URL(fileURLWithPath: "~/path/to/file.mdwn")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

func test_CodeLanguageMarkdown5() throws {
let url = URL(fileURLWithPath: "~/path/to/file.mdown")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

func test_CodeLanguageMarkdown6() throws {
let url = URL(fileURLWithPath: "~/path/to/file.markdown")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .markdown)
}

// MARK: - Objective C

func test_CodeLanguageObjC() throws {
Expand Down