Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
f7b75b07
Commit
f7b75b07
authored
Nov 11, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
导入 Markdown 解析改进
parent
e8c69eb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
src/main/java/org/b3log/solo/service/ImportService.java
src/main/java/org/b3log/solo/service/ImportService.java
+10
-4
No files found.
src/main/java/org/b3log/solo/service/ImportService.java
View file @
f7b75b07
...
...
@@ -38,7 +38,7 @@ import java.util.*;
* Import service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.
0, Aug 3
1, 2017
* @version 1.0.1.
1, Nov 1
1, 2017
* @since 2.2.0
*/
@Service
...
...
@@ -145,9 +145,11 @@ public class ImportService {
}).
start
();
}
private
JSONObject
parseArticle
(
final
String
fileName
,
final
String
fileContent
)
{
String
frontMatter
=
StringUtils
.
substringBetween
(
fileContent
,
"---"
,
"---"
);
private
JSONObject
parseArticle
(
final
String
fileName
,
String
fileContent
)
{
fileContent
=
StringUtils
.
trim
(
fileContent
);
String
frontMatter
=
StringUtils
.
substringBefore
(
fileContent
,
"---"
);
if
(
StringUtils
.
isBlank
(
frontMatter
))
{
fileContent
=
StringUtils
.
substringAfter
(
fileContent
,
"---"
);
frontMatter
=
StringUtils
.
substringBefore
(
fileContent
,
"---"
);
}
...
...
@@ -176,7 +178,11 @@ public class ImportService {
}
ret
.
put
(
Article
.
ARTICLE_TITLE
,
title
);
final
String
content
=
StringUtils
.
substringAfter
(
fileContent
,
frontMatter
);
String
content
=
StringUtils
.
substringAfter
(
fileContent
,
frontMatter
);
if
(
StringUtils
.
startsWith
(
content
,
"---"
))
{
content
=
StringUtils
.
substringAfter
(
content
,
"---"
);
content
=
StringUtils
.
trim
(
content
);
}
ret
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
final
String
abs
=
parseAbstract
(
elems
,
content
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment