Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lua-language-server-srb2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LJ Sonic
lua-language-server-srb2
Commits
c0c707d9
Commit
c0c707d9
authored
3 years ago
by
最萌小汐
Browse files
Options
Downloads
Patches
Plain Diff
cleanup markdown
parent
907bbbe0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/provider/markdown.lua
+71
-32
71 additions, 32 deletions
script/provider/markdown.lua
with
71 additions
and
32 deletions
script/provider/markdown.lua
+
71
−
32
View file @
c0c707d9
---@class markdown
local
mt
=
{}
mt
.
__index
=
mt
mt
.
__name
=
'markdown'
...
...
@@ -8,50 +9,88 @@ function mt:__tostring()
return
self
:
string
()
end
local
function
checkSplitLine
(
self
)
if
not
self
.
_splitLine
then
return
end
self
.
_splitLine
=
nil
if
#
self
==
0
then
return
end
self
[
#
self
+
1
]
=
'
\n
---'
end
---@param language string
---@param text string|markdown
function
mt
:
add
(
language
,
text
)
if
not
text
then
return
end
if
type
(
text
)
==
'table'
then
self
[
#
self
+
1
]
=
{
type
=
'markdown'
,
markdown
=
text
,
}
else
text
=
tostring
(
text
)
if
#
text
==
0
then
return
end
self
[
#
self
+
1
]
=
{
type
=
'text'
,
language
=
language
,
text
=
text
,
}
end
end
function
mt
:
splitLine
()
self
[
#
self
+
1
]
=
{
type
=
'splitline'
,
}
end
checkSplitLine
(
self
)
function
mt
:
string
()
local
lines
=
{}
local
language
=
'md'
if
language
==
'md'
then
if
self
.
_last
==
'md'
then
self
[
#
self
+
1
]
=
''
local
function
concat
(
markdown
)
for
_
,
obj
in
ipairs
(
markdown
)
do
if
obj
.
type
==
'splitline'
then
if
language
~=
'md'
then
lines
[
#
lines
+
1
]
=
'```'
language
=
'md'
end
if
#
lines
>
0
and
lines
[
#
lines
]
~=
'---'
then
lines
[
#
lines
+
1
]
=
''
lines
[
#
lines
+
1
]
=
'---'
end
self
[
#
self
+
1
]
=
text
elseif
obj
.
type
==
'markdown'
then
concat
(
obj
.
markdown
)
else
if
#
self
>
0
then
self
[
#
self
+
1
]
=
''
if
obj
.
language
==
language
then
lines
[
#
lines
+
1
]
=
obj
.
text
else
if
language
~=
'md'
then
lines
[
#
lines
+
1
]
=
'```'
end
if
#
lines
>
0
then
lines
[
#
lines
+
1
]
=
''
end
if
obj
.
language
~=
'md'
then
lines
[
#
lines
+
1
]
=
'```'
..
obj
.
language
end
lines
[
#
lines
+
1
]
=
obj
.
text
language
=
obj
.
language
end
end
self
[
#
self
+
1
]
=
(
'```%s\n%s\n```'
):
format
(
language
,
text
)
end
self
.
_last
=
language
end
function
mt
:
string
()
return
table.concat
(
self
,
'
\n
'
)
concat
(
self
)
if
language
~=
'md'
then
lines
[
#
lines
+
1
]
=
'```'
end
while
true
do
if
lines
[
#
lines
]
==
'---'
or
lines
[
#
lines
]
==
''
then
lines
[
#
lines
]
=
nil
else
break
end
end
function
mt
:
splitLine
()
self
.
_splitLine
=
true
return
table.concat
(
lines
,
'
\n
'
)
end
return
function
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment