Commit 608548d5 authored by Liang Ding's avatar Liang Ding

Markdown 支持改进 #54

parent fd2d2c6c
...@@ -26,7 +26,7 @@ import org.json.JSONObject; ...@@ -26,7 +26,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.6.0.4, Jan 24, 2020 * @version 1.6.0.5, Jan 25, 2020
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -52,11 +52,37 @@ public final class Option { ...@@ -52,11 +52,37 @@ public final class Option {
public static final String OPTION_CATEGORY = "optionCategory"; public static final String OPTION_CATEGORY = "optionCategory";
// oId constants // oId constants
/**
* Key of inline math allow digit after open marker flag. 内联数学公式是否允许起始 $ 后紧跟数字 https://github.com/88250/solo/issues/54
*/
public static final String ID_C_IMADAOM = "inlineMathAllowDigitAfterOpenMarker";
/**
* Key of chinese punct flag. 中文后跟英文逗号句号等标点替换为中文对应标点 https://github.com/88250/solo/issues/54
*/
public static final String ID_C_CHINESE_PUNCT = "chinesePunct";
/**
* Key of fix term typo flag. 术语修正 https://github.com/88250/solo/issues/54
*/
public static final String ID_C_FIX_TERM_TYPO = "fixTermTypo";
/** /**
* Key of show ToC flag. 支持 ToC 显示 https://github.com/88250/solo/issues/52 * Key of auto space flag. 中西文间自动插入空格 https://github.com/88250/solo/issues/54
*/
public static final String ID_C_AUTO_SPACE = "autoSpace";
/**
* Key of show ToC flag. 支持 [ToC] https://github.com/88250/solo/issues/54
*/ */
public static final String ID_C_SHOW_TOC = "showToC"; public static final String ID_C_SHOW_TOC = "showToC";
/**
* Key of footnotes flag. 支持脚注 https://github.com/88250/solo/issues/54
*/
public static final String ID_C_FOOTNOTES = "footnotes";
/** /**
* Key of show code block line num flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4 * Key of show code block line num flag. 支持代码块行号显示 https://github.com/88250/solo/issues/4
*/ */
...@@ -310,16 +336,11 @@ public final class Option { ...@@ -310,16 +336,11 @@ public final class Option {
* Default preference. * Default preference.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.0.5, Jan 24, 2020 * @version 2.3.0.6, Jan 25, 2020
* @since 0.3.1 * @since 0.3.1
*/ */
public static final class DefaultPreference { public static final class DefaultPreference {
/**
* Default show ToC.
*/
public static final String DEFAULT_SHOW_TOC = "false";
/** /**
* Default show code block line num. * Default show code block line num.
*/ */
......
...@@ -472,12 +472,42 @@ public class InitService { ...@@ -472,12 +472,42 @@ public class InitService {
private void initOptions(final JSONObject requestJSONObject) throws Exception { private void initOptions(final JSONObject requestJSONObject) throws Exception {
LOGGER.debug("Initializing preference...."); LOGGER.debug("Initializing preference....");
final JSONObject IMADAOMOpt = new JSONObject();
IMADAOMOpt.put(Keys.OBJECT_ID, Option.ID_C_IMADAOM);
IMADAOMOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
IMADAOMOpt.put(Option.OPTION_VALUE, "false");
optionRepository.add(IMADAOMOpt);
final JSONObject chinesePunctOpt = new JSONObject();
chinesePunctOpt.put(Keys.OBJECT_ID, Option.ID_C_CHINESE_PUNCT);
chinesePunctOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
chinesePunctOpt.put(Option.OPTION_VALUE, "true");
optionRepository.add(chinesePunctOpt);
final JSONObject fixTermTypoOpt = new JSONObject();
fixTermTypoOpt.put(Keys.OBJECT_ID, Option.ID_C_FIX_TERM_TYPO);
fixTermTypoOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
fixTermTypoOpt.put(Option.OPTION_VALUE, "true");
optionRepository.add(fixTermTypoOpt);
final JSONObject autoSpaceOpt = new JSONObject();
autoSpaceOpt.put(Keys.OBJECT_ID, Option.ID_C_AUTO_SPACE);
autoSpaceOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
autoSpaceOpt.put(Option.OPTION_VALUE, "true");
optionRepository.add(autoSpaceOpt);
final JSONObject showToCOpt = new JSONObject(); final JSONObject showToCOpt = new JSONObject();
showToCOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_TOC); showToCOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_TOC);
showToCOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); showToCOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
showToCOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_SHOW_TOC); showToCOpt.put(Option.OPTION_VALUE, "false");
optionRepository.add(showToCOpt); optionRepository.add(showToCOpt);
final JSONObject footnotesOpt = new JSONObject();
footnotesOpt.put(Keys.OBJECT_ID, Option.ID_C_FOOTNOTES);
footnotesOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
footnotesOpt.put(Option.OPTION_VALUE, "true");
optionRepository.add(footnotesOpt);
final JSONObject showCodeBlockLnOpt = new JSONObject(); final JSONObject showCodeBlockLnOpt = new JSONObject();
showCodeBlockLnOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_CODE_BLOCK_LN); showCodeBlockLnOpt.put(Keys.OBJECT_ID, Option.ID_C_SHOW_CODE_BLOCK_LN);
showCodeBlockLnOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); showCodeBlockLnOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
...@@ -60,7 +60,7 @@ import java.util.concurrent.*; ...@@ -60,7 +60,7 @@ import java.util.concurrent.*;
* </p> * </p>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.1.14, Jan 24, 2020 * @version 2.3.1.15, Jan 25, 2020
* @since 0.4.5 * @since 0.4.5
*/ */
public final class Markdowns { public final class Markdowns {
...@@ -113,7 +113,12 @@ public final class Markdowns { ...@@ -113,7 +113,12 @@ public final class Markdowns {
public static boolean LUTE_AVAILABLE; public static boolean LUTE_AVAILABLE;
public static boolean SHOW_CODE_BLOCK_LN = false; public static boolean SHOW_CODE_BLOCK_LN = false;
public static boolean FOOTNOTES = false;
public static boolean SHOW_TOC = false; public static boolean SHOW_TOC = false;
public static boolean AUTO_SPACE = false;
public static boolean FIX_TERM_TYPO = false;
public static boolean CHINESE_PUNCT = false;
public static boolean IMADAOM = false;
/** /**
* Clears cache. * Clears cache.
...@@ -269,9 +274,14 @@ public final class Markdowns { ...@@ -269,9 +274,14 @@ public final class Markdowns {
final URL url = new URL(LUTE_ENGINE_URL); final URL url = new URL(LUTE_ENGINE_URL);
final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-CodeSyntaxHighlightLineNum", String.valueOf(Markdowns.SHOW_CODE_BLOCK_LN)); conn.setRequestProperty("X-CodeSyntaxHighlightLineNum", String.valueOf(Markdowns.SHOW_CODE_BLOCK_LN));
conn.setRequestProperty("X-Footnotes", String.valueOf(Markdowns.FOOTNOTES));
conn.setRequestProperty("X-ToC", String.valueOf(Markdowns.SHOW_TOC)); conn.setRequestProperty("X-ToC", String.valueOf(Markdowns.SHOW_TOC));
conn.setRequestProperty("X-AutoSpace", String.valueOf(Markdowns.AUTO_SPACE));
conn.setRequestProperty("X-FixTermTypo", String.valueOf(Markdowns.FIX_TERM_TYPO));
conn.setRequestProperty("X-ChinesePunct", String.valueOf(Markdowns.CHINESE_PUNCT));
conn.setRequestProperty("X-IMADAOM", String.valueOf(Markdowns.IMADAOM));
conn.setConnectTimeout(100); conn.setConnectTimeout(100);
conn.setReadTimeout(1000); conn.setReadTimeout(3000);
conn.setDoOutput(true); conn.setDoOutput(true);
try (final OutputStream outputStream = conn.getOutputStream()) { try (final OutputStream outputStream = conn.getOutputStream()) {
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
<a href="#tools/preference/setting">${paramSettingsLabel}</a> <a href="#tools/preference/setting">${paramSettingsLabel}</a>
</div> </div>
</li> </li>
<li>
<div id="tabPreference_markdown">
<a href="#tools/preference/markdown">Markdown</a>
</div>
</li>
</ul> </ul>
</div> </div>
<div id="tabPreferencePanel" class="sub-tabs-main"> <div id="tabPreferencePanel" class="sub-tabs-main">
...@@ -185,7 +190,7 @@ ...@@ -185,7 +190,7 @@
</label> </label>
<label> <label>
<div class="fn__flex-inline"> <div class="fn__flex-inline">
${showToCLabel} ${supportToCLabel}
<input id="showToC" type="checkbox" class="normalInput"/> <input id="showToC" type="checkbox" class="normalInput"/>
</div> </div>
</label> </label>
...@@ -249,5 +254,53 @@ ...@@ -249,5 +254,53 @@
<button onclick="admin.preference.update()" class="fn__right">${updateLabel}</button> <button onclick="admin.preference.update()" class="fn__right">${updateLabel}</button>
<div class="fn__clear"></div> <div class="fn__clear"></div>
</div> </div>
<div id="tabPreferencePanel_markdown" class="fn__none form">
<div class="fn__clear">
${luteHTTPLabel}
</div>
<button class="fn__right" onclick="admin.preference.update()">${updateLabel}</button>
<div class="fn__flex">
<div class="fn__flex-1">
<label>
<div class="fn__flex-inline">
<input id="footnotes" type="checkbox" class="normalInput"/>
&nbsp;${supportFootnotesLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="showToC" type="checkbox" class="normalInput"/>
&nbsp;${supportToCLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="autoSpace" type="checkbox" class="normalInput"/>
&nbsp;${autoSpaceLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="fixTermTypo" type="checkbox" class="normalInput"/>
&nbsp;${fixTermTypoLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="chinesePunct" type="checkbox" class="normalInput"/>
&nbsp;${chinesePunctLabel}
</div>
</label>
<label>
<div class="fn__flex-inline">
<input id="inlineMathAllowDigitAfterOpenMarker" type="checkbox" class="normalInput"/>
&nbsp;${inlineMathAllowDigitAfterOpenMarkerLabel}
</div>
</label>
</div>
</div>
<button class="fn__right" onclick="admin.preference.update()">${updateLabel}</button>
<div class="fn__clear"></div>
</div>
</div> </div>
${plugins} ${plugins}
This diff is collapsed.
This diff is collapsed.
...@@ -18,13 +18,19 @@ ...@@ -18,13 +18,19 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.38.0.0, Jan 24, 2020 # Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
showToCLabel=Support Markdown [TOC] (need&nbsp;<a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>): inlineMathAllowDigitAfterOpenMarkerLabel=Whether inline math formulas allow a starting $ followed by a number
chinesePunctLabel=Chinese punctuation followed by English comma and period are replaced with Chinese corresponding punctuation
fixTermTypoLabel=Fix term typo
autoSpaceLabel=Automatically insert spaces between Chinese and Western languages
supportFootnotesLabel=Support footnotes
supportToCLabel=Support [TOC]
luteHTTPLabel=The following features are based on <a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>.
showCodeBlockLnLabel=Show code block line num: showCodeBlockLnLabel=Show code block line num:
siteURLLabel=Site URL: siteURLLabel=Site URL:
siteGenedLabel=Site generated, target dir is [{dir}] siteGenedLabel=Site generated, target dir is [{dir}]
......
...@@ -18,13 +18,19 @@ ...@@ -18,13 +18,19 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.38.0.0, Jan 24, 2020 # Version: 2.39.0.0, Jan 25, 2020
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
showToCLabel=\u652F\u6301 Markdown [TOC]\uFF08\u9700\u542F\u7528&nbsp;<a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a>\uFF09\uFF1A inlineMathAllowDigitAfterOpenMarkerLabel=\u5185\u8054\u6570\u5B66\u516C\u5F0F\u662F\u5426\u5141\u8BB8\u8D77\u59CB $ \u540E\u7D27\u8DDF\u6570\u5B57
chinesePunctLabel=\u4E2D\u6587\u540E\u8DDF\u82F1\u6587\u9017\u53F7\u53E5\u53F7\u7B49\u6807\u70B9\u66FF\u6362\u4E3A\u4E2D\u6587\u5BF9\u5E94\u6807\u70B9
fixTermTypoLabel=\u672F\u8BED\u4FEE\u6B63
autoSpaceLabel=\u4E2D\u897F\u6587\u95F4\u81EA\u52A8\u63D2\u5165\u7A7A\u683C
supportFootnotesLabel=\u652F\u6301\u811A\u6CE8
supportToCLabel=\u652F\u6301 [TOC]
luteHTTPLabel=\u4EE5\u4E0B\u914D\u7F6E\u9879\u9700\u542F\u7528 <a href="https://hacpai.com/article/1569240189601" target="_blank">Lute-HTTP</a> \u5F15\u64CE\u624D\u80FD\u5F97\u5230\u652F\u6301\u3002
showCodeBlockLnLabel=\u4EE3\u7801\u5757\u663E\u793A\u884C\u53F7\uFF1A showCodeBlockLnLabel=\u4EE3\u7801\u5757\u663E\u793A\u884C\u53F7\uFF1A
siteURLLabel=\u7AD9\u70B9\u5730\u5740\uFF1A siteURLLabel=\u7AD9\u70B9\u5730\u5740\uFF1A
siteGenedLabel=\u7AD9\u70B9\u751F\u6210\u5B8C\u6BD5\uFF0C\u8BF7\u67E5\u770B\u76EE\u5F55 [{dir}] siteGenedLabel=\u7AD9\u70B9\u751F\u6210\u5B8C\u6BD5\uFF0C\u8BF7\u67E5\u770B\u76EE\u5F55 [{dir}]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment