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
Expand all
Hide 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 {
...
@@ -913,13 +913,15 @@ public final class Filler {
}
}
/**
/**
* Processes the abstract of the specified article with the specified
* Processes the abstract of the specified article with the specified preference.
* preference.
*
*
* <p> <ul> <li>If the abstract is {@code null}, sets it with ""</li> <li>If
* <p>
* user configured preference "titleOnly", sets the abstract with ""</li>
* <ul>
* <li>If user configured preference "titleAndContent", sets the abstract
* <li>If the abstract is {@code null}, sets it with ""</li>
* with the content of the article</li> </ul> </p>
* <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 preference the specified preference
* @param article the specified article
* @param article the specified article
...
...
core/src/main/java/org/b3log/solo/util/Markdowns.java
View file @
cc1d3e63
/*
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org
.
b3log
.
solo
.
util
;
package
org
.
b3log
.
solo
.
util
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
org.b3log.latke.util.Strings
;
import
java.util.logging.Level
;
import
org.tautua.markdownpapers.Markdown
;
import
java.util.logging.Logger
;
import
org.b3log.latke.util.Strings
;
import
org.tautua.markdownpapers.Markdown
;
/**
import
org.tautua.markdownpapers.parser.ParseException
;
* <a href="http://en.wikipedia.org/wiki/Markdown">Markdown</a> utilities.
*
* <p>Uses the <a href="http://markdown.tautua.org/">MarkdownPapers</a> as the converter.</p>
/**
*
* <a href="http://en.wikipedia.org/wiki/Markdown">Markdown</a> utilities.
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
*
* @version 1.0.0.0, Apr 28, 2012
* <p>Uses the <a href="http://markdown.tautua.org/">MarkdownPapers</a> as the converter.</p>
* @since 0.4.5
*
*/
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
public
final
class
Markdowns
{
* @version 1.0.0.1, Feb 8, 2013
* @since 0.4.5
/**
*/
* Converts the specified markdown text to HTML.
public
final
class
Markdowns
{
*
* @param markdownText the specified markdown text
/**
* @return converted HTML, returns {@code null} if the specified markdown text is "" or {@code null}
* Logger.
* @throws Exception exception
*/
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Markdowns
.
class
.
getName
());
public
static
String
toHTML
(
final
String
markdownText
)
throws
Exception
{
if
(
Strings
.
isEmptyOrNull
(
markdownText
))
{
/**
return
null
;
* Converts the specified markdown text to HTML.
}
*
* @param markdownText the specified markdown text
final
StringWriter
writer
=
new
StringWriter
();
* @return converted HTML, returns {@code null} if the specified markdown text is "" or {@code null}, returns "Markdown error" if
final
Markdown
markdown
=
new
Markdown
();
* exception
*/
markdown
.
transform
(
new
StringReader
(
markdownText
),
writer
);
public
static
String
toHTML
(
final
String
markdownText
)
{
if
(
Strings
.
isEmptyOrNull
(
markdownText
))
{
return
writer
.
toString
();
return
null
;
}
}
/**
final
StringWriter
writer
=
new
StringWriter
();
* Private constructor.
final
Markdown
markdown
=
new
Markdown
();
*/
private
Markdowns
()
{}
try
{
}
markdown
.
transform
(
new
StringReader
(
markdownText
),
writer
);
}
catch
(
final
ParseException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Markdown error"
,
e
);
return
"Markdown error"
;
}
return
writer
.
toString
();
}
/**
* Private constructor.
*/
private
Markdowns
()
{}
}
pom.xml
View file @
cc1d3e63
This diff is collapsed.
Click to expand it.
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