changed CHANGELOG.md
 
@@ -1,5 +1,9 @@
1
1
# Changelog
2
2
3
+ ### 1.1.2 - 2024-05-11
4
+
5
+ Do not attempt reparsing if surrounded by reaches end of string.
6
+
3
7
### 1.1.1 - 2023-11-08
4
8
5
9
Add dracula theme.
 
@@ -8,7 +12,6 @@ Add one dark theme.
8
12
9
13
Fix warnings on recent Elixir versions.
10
14
11
-
12
15
### 1.1.0 - 2022-02-12
13
16
14
17
Require NimbleParsec `~> 1.2.2` onwards to prepare for future deprecations.
changed hex_metadata.config
 
@@ -3,7 +3,7 @@
3
3
{<<"Contributing">>,<<"https://hexdocs.pm/makeup/contributing.html">>},
4
4
{<<"GitHub">>,<<"https://github.com/elixir-makeup/makeup">>}]}.
5
5
{<<"name">>,<<"makeup">>}.
6
- {<<"version">>,<<"1.1.1">>}.
6
+ {<<"version">>,<<"1.1.2">>}.
7
7
{<<"description">>,
8
8
<<"Syntax highlighter for source code in the style of Pygments.">>}.
9
9
{<<"elixir">>,<<"~> 1.6">>}.
changed lib/makeup/lexer/combinators.ex
 
@@ -120,6 +120,9 @@ defmodule Makeup.Lexer.Combinators do
120
120
Matches a given combinator, repeated 0 or more times, surrounded by left and right delimiters.
121
121
122
122
Delimiters can be combinators or literal strings (either both combinators or both literal strings).
123
+
124
+ It also succeeds if we get to the end of string and the closing delimiter is missing,
125
+ to avoid parsing the program multiple times in case of mismatched delimeters or invalid programs.
123
126
"""
124
127
def many_surrounded_by(combinator, left, right) when is_binary(left) and is_binary(right) do
125
128
token(left, :punctuation)
 
@@ -129,7 +132,7 @@ defmodule Makeup.Lexer.Combinators do
129
132
|> concat(combinator)
130
133
)
131
134
)
132
- |> concat(token(right, :punctuation))
135
+ |> choice([token(right, :punctuation), eos()])
133
136
end
134
137
135
138
def many_surrounded_by(combinator, left, right) do
 
@@ -140,12 +143,15 @@ defmodule Makeup.Lexer.Combinators do
140
143
|> concat(combinator)
141
144
)
142
145
)
143
- |> concat(right)
146
+ |> choice([right, eos()])
144
147
end
145
148
146
149
@doc """
147
150
Matches a given combinator, repeated 0 or more times, surrounded by left and right delimiters,
148
151
and wraps the `right` and `left` delimiters into a token of the given `ttype`.
152
+
153
+ It also succeeds if we get to the end of string and the closing delimiter is missing,
154
+ to avoid parsing the program multiple times in case of mismatched delimeters or invalid programs.
149
155
"""
150
156
def many_surrounded_by(combinator, left, right, ttype) do
151
157
token(left, ttype)
 
@@ -155,7 +161,7 @@ defmodule Makeup.Lexer.Combinators do
155
161
|> concat(combinator)
156
162
)
157
163
)
158
- |> concat(token(right, ttype))
164
+ |> choice([token(right, ttype), eos()])
159
165
end
160
166
161
167
@doc false
changed mix.exs
 
@@ -1,7 +1,7 @@
1
1
defmodule Makeup.Mixfile do
2
2
use Mix.Project
3
3
4
- @version "1.1.1"
4
+ @version "1.1.2"
5
5
@url "https://github.com/elixir-makeup/makeup"
6
6
7
7
def project do
 
@@ -67,12 +67,13 @@ defmodule Makeup.Mixfile do
67
67
ex_doc = Path.join(Mix.path_for(:escripts), "ex_doc")
68
68
69
69
unless File.exists?(ex_doc) do
70
- raise "cannot build docs because escript for ex_doc is not installed"
70
+ raise "cannot build docs because escript for ex_doc is not installed, run \"mix escript.install hex ex_doc\""
71
71
end
72
72
73
+ paths = Path.join(Mix.Project.build_path(), "lib/*/ebin")
73
74
args = ["Makeup", @version, Mix.Project.compile_path()]
74
75
opts = ~w[--main Makeup --source-ref v#{@version} --source-url #{@url} --config .ex_doc.exs]
75
- System.cmd(ex_doc, args ++ opts)
76
+ System.cmd(ex_doc, args ++ ["--paths", paths] ++ opts)
76
77
Mix.shell().info("Docs built successfully")
77
78
end
78
79
end