在Django后台添加markdown编辑器中说过如何在Django后台添加markdown编辑器,后来发现这里添加的pagedown有一个问题,也就是换行问题。在markdown中,单个换行会用空格代替,但pagedown中并没有这么做。经过跟踪,发现问题是在pagedown-extra中,解决的办法是在pagedown/Markdown.Converter.js的_FormParagraphs函数1168行//if this is an HTML marker, copy it前添加str = str.replace(/\n/g, " ");即可.
public synchronized void start() { /** * Thismethodisnot invoked for the main method thread or"system" * group threads created/set up by the VM. Any new functionality added * to this methodin the future may have to also be added to the VM. * * A zero status value corresponds to state "NEW". */ if (threadStatus != 0) throw new IllegalThreadStateException();
/* Notify the group that this thread is about to be started * so that it can be added to the group's list of threads * and the group's unstarted count can be decremented. */ group.add(this);
boolean started = false; try { start0(); started = true; } finally { try { if (!started) { group.threadStartFailed(this); } } catch (Throwable ignore) { /* do nothing. If start0 threw a Throwable then it will be passed up the call stack */ } } }
public class GenerateParenthesis { public staticList<String> generateParenthesis(int n) { List<String> result = new ArrayList<String>(); generateParenthesis(n, n , n, "", result); returnresult; } private staticvoid generateParenthesis(int left, int right, int n, String s, List<String> result) {
if (s.length() == n * 2) { result.add(s); } else { if (left == right) { generateParenthesis(left - 1, right, n , s + "(", result); } elseif (left < right) { if (left > 0) { generateParenthesis(left - 1, right, n , s + "(", result); } generateParenthesis(left, right - 1, n, s + ")", result); } } } public staticvoid main(String[] args) { List<String> result = generateParenthesis(3); for (String s: result) { System.out.println(s); } } }
public class GenerateParenthesis { public staticList<String> generateParenthesis(int n) { List<String> result = new ArrayList<String>(); char[] str = new char[n * 2]; generateParenthesis(n, n , str, 0, result); returnresult; } private staticvoid generateParenthesis(int left, int right, char[] str, int length, List<String> result) {