Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
cc1d3e63
Commit
cc1d3e63
authored
Feb 08, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Markdown 解析错误时返回 "Markdown error"
parent
6391464a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
485 additions
and
469 deletions
+485
-469
core/src/main/java/org/b3log/solo/processor/util/Filler.java
core/src/main/java/org/b3log/solo/processor/util/Filler.java
+8
-6
core/src/main/java/org/b3log/solo/util/Markdowns.java
core/src/main/java/org/b3log/solo/util/Markdowns.java
+74
-60
pom.xml
pom.xml
+403
-403
No files found.
core/src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
cc1d3e63
...
...
@@ -913,13 +913,15 @@ public final class Filler {
}
/**
* Processes the abstract of the specified article with the specified
* preference.
*
* <p> <ul> <li>If the abstract is {@code null}, sets it with ""</li> <li>If
* user configured preference "titleOnly", sets the abstract with ""</li>
* <li>If user configured preference "titleAndContent", sets the abstract
* with the content of the article</li> </ul> </p>
* Processes the abstract of the specified article with the specified preference.
*
* <p>
* <ul>
* <li>If the abstract is {@code null}, sets it with ""</li>
* <li>If user configured preference "titleOnly", sets the abstract with ""</li>
* <li>If user configured preference "titleAndContent", sets the abstract with the content of the article</li>
* </ul>
* </p>
*
* @param preference the specified preference
* @param article the specified article
...
...
core/src/main/java/org/b3log/solo/util/Markdowns.java
View file @
cc1d3e63
...
...
@@ -18,8 +18,11 @@ package org.b3log.solo.util;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.b3log.latke.util.Strings
;
import
org.tautua.markdownpapers.Markdown
;
import
org.tautua.markdownpapers.parser.ParseException
;
/**
...
...
@@ -28,19 +31,24 @@ import org.tautua.markdownpapers.Markdown;
* <p>Uses the <a href="http://markdown.tautua.org/">MarkdownPapers</a> as the converter.</p>
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.
0, Apr 28, 2012
* @version 1.0.0.
1, Feb 8, 2013
* @since 0.4.5
*/
public
final
class
Markdowns
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Markdowns
.
class
.
getName
());
/**
* Converts the specified markdown text to HTML.
*
* @param markdownText the specified markdown text
* @return converted HTML, returns {@code null} if the specified markdown text is "" or {@code null}
*
@throws Exception exception
* @return converted HTML, returns {@code null} if the specified markdown text is "" or {@code null}
, returns "Markdown error" if
*
exception
*/
public
static
String
toHTML
(
final
String
markdownText
)
throws
Exception
{
public
static
String
toHTML
(
final
String
markdownText
)
{
if
(
Strings
.
isEmptyOrNull
(
markdownText
))
{
return
null
;
}
...
...
@@ -48,7 +56,13 @@ public final class Markdowns {
final
StringWriter
writer
=
new
StringWriter
();
final
Markdown
markdown
=
new
Markdown
();
try
{
markdown
.
transform
(
new
StringReader
(
markdownText
),
writer
);
}
catch
(
final
ParseException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Markdown error"
,
e
);
return
"Markdown error"
;
}
return
writer
.
toString
();
}
...
...
pom.xml
View file @
cc1d3e63
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: B3log Solo parent POM.
Version: 2.0.2.
7, Jan 15, 2013
Version: 2.0.2.
8, Feb 8, 2013
Author: Liang Ding
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
...
...
@@ -38,7 +38,7 @@
<freemarker-gae.version>
2.3.19
</freemarker-gae.version>
<jsoup.version>
1.5.2
</jsoup.version>
<markdownpapers-core.version>
1.
2.7
</markdownpapers-core.version>
<markdownpapers-core.version>
1.
3.2
</markdownpapers-core.version>
<!-- <com.google.api.client.version>1.2.1-alpha</com.google.api.client.version>-->
<!-- maven plugin -->
<maven-compiler-plugin.version>
2.3.2
</maven-compiler-plugin.version>
...
...
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