From 9dd192cc4d187cdfc1328458ba02d0ec6a0f8cfa Mon Sep 17 00:00:00 2001 From: Terbium-135 Date: Sat, 21 Dec 2024 20:27:12 +0100 Subject: [PATCH 1/3] Add markdown highlighting --- syntaxes/elixir.json | 118 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 105 insertions(+), 13 deletions(-) diff --git a/syntaxes/elixir.json b/syntaxes/elixir.json index f244e3f..32d75a4 100644 --- a/syntaxes/elixir.json +++ b/syntaxes/elixir.json @@ -1,7 +1,10 @@ { "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/refs/heads/master/tmlanguage.json", "comment": "Atom Syntax Parser for Elixir Programming Language.", - "fileTypes": ["ex", "exs"], + "fileTypes": [ + "ex", + "exs" + ], "firstLineMatch": "^#!/.*\\belixir", "foldingStartMarker": "(after|else|catch|rescue|\\-\\>|\\{|\\[|do)\\s*$", "foldingStopMarker": "^\\s*((\\}|\\]|after|else|catch|rescue)\\s*$|end\\b)", @@ -20,71 +23,160 @@ "name": "meta.module.elixir" }, { - "begin": "@(module|type)?doc (~s)?\"\"\"", + "begin": "@(?:module|type)?doc (?:~s)?\"\"\"", "comment": "@doc with interpolated heredocs", "end": "\\s*\"\"\"", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "begin": ".*", + "while": "(^|\\G)(?!\\s*\"\"\"\\s*$)", + "patterns": [ + { + "include": "text.html.markdown" + } + ] } ] }, { - "begin": "@(module|type)?doc ~s'''", + "begin": "@(?:module|type)?doc ~s'''", "comment": "@doc with interpolated single quoted heredocs", "end": "\\s*'''", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "begin": ".*", + "while": "(^|\\G)(?!\\s*'''\\s*$)", + "patterns": [ + { + "include": "text.html.markdown" + } + ] } ] }, { - "begin": "@(module|type)?doc ~S\"\"\"", + "begin": "@(?:module|type)?doc ~S\"\"\"", "comment": "@doc with heredocs is treated as documentation", "end": "\\s*\"\"\"", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#escaped_char" + }, + { + "begin": ".*", + "while": "(^|\\G)(?!\\s*\"\"\"\\s*$)", + "patterns": [ + { + "include": "text.html.markdown" + } + ] } ] }, { - "begin": "@(module|type)?doc ~S'''", + "begin": "@(?:module|type)?doc ~S'''", "comment": "@doc with heredocs is treated as documentation", "end": "\\s*'''", - "name": "comment.documentation.heredoc.elixir", + "name": "documentation.heredoc.elixir", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#escaped_char" + }, + { + "begin": ".*", + "while": "(^|\\G)(?!\\s*'''\\s*$)", + "patterns": [ + { + "include": "text.html.markdown" + } + ] } ] }, { "comment": "@doc false is treated as documentation", - "match": "@(module|type)?doc false", + "match": "@(?:module|type)?doc false", "name": "comment.documentation.false" }, { - "begin": "@(module|type)?doc \"", + "begin": "@(?:module|type)?doc \"", "comment": "@doc with string is treated as documentation", "end": "\"", - "name": "comment.documentation.string", + "name": "documentation.string", + "beginCaptures": { + "0": { + "name": "comment" + } + }, + "endCaptures": { + "0": { + "name": "comment" + } + }, "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" + }, + { + "include": "text.html.markdown" } ] }, @@ -2547,4 +2639,4 @@ } }, "scopeName": "source.elixir" -} +} \ No newline at end of file From 24abe93efa91d94a2aab556da4fa598cd96a64e8 Mon Sep 17 00:00:00 2001 From: Terbium-135 Date: Wed, 25 Dec 2024 13:42:07 +0100 Subject: [PATCH 2/3] Added requested changes --- CHANGELOG.md | 5 +++++ syntaxes/elixir.json | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 428bdeb..e6a37ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +# [Unreleased] + +### Added + +- Added syntax highlighting for markdown in `@doc`, `@moduledoc` and `@typedoc` modules attributes. All credits for this solution belong to @SteffenDE ## [0.0.18] ### Fixed diff --git a/syntaxes/elixir.json b/syntaxes/elixir.json index 32d75a4..5f7c3a7 100644 --- a/syntaxes/elixir.json +++ b/syntaxes/elixir.json @@ -1,10 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/refs/heads/master/tmlanguage.json", "comment": "Atom Syntax Parser for Elixir Programming Language.", - "fileTypes": [ - "ex", - "exs" - ], + "fileTypes": ["ex", "exs"], "firstLineMatch": "^#!/.*\\belixir", "foldingStartMarker": "(after|else|catch|rescue|\\-\\>|\\{|\\[|do)\\s*$", "foldingStopMarker": "^\\s*((\\}|\\]|after|else|catch|rescue)\\s*$|end\\b)", @@ -2639,4 +2636,4 @@ } }, "scopeName": "source.elixir" -} \ No newline at end of file +} From 53331c260e5ade06ef8c00315f6d6b717d32b9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Wed, 25 Dec 2024 13:44:26 -0500 Subject: [PATCH 3/3] Also thank Terbium in the changelog. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a37ed..c1ad3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Added -- Added syntax highlighting for markdown in `@doc`, `@moduledoc` and `@typedoc` modules attributes. All credits for this solution belong to @SteffenDE +- Added syntax highlighting for markdown in `@doc`, `@moduledoc` and `@typedoc` modules attributes. Thanks to @SteffenDE for suggesting the solution and @Terbium-135 for implementing it. + ## [0.0.18] ### Fixed