Browse Source

fix HGMarkdownHighlighter regular expression

Change the default markdown.css.

Signed-off-by: Le Tan <[email protected]>
Le Tan 9 years ago
parent
commit
51d0eedcb2
2 changed files with 33 additions and 2 deletions
  1. 2 2
      src/hgmarkdownhighlighter.cpp
  2. 31 0
      src/resources/markdown.css

+ 2 - 2
src/hgmarkdownhighlighter.cpp

@@ -32,8 +32,8 @@ HGMarkdownHighlighter::HGMarkdownHighlighter(const QVector<HighlightingStyle> &s
     : QSyntaxHighlighter(parent), parsing(0),
       waitInterval(waitInterval), content(NULL), capacity(0), result(NULL)
 {
-    codeBlockStartExp = QRegExp("^```");
-    codeBlockEndExp = QRegExp("^```$");
+    codeBlockStartExp = QRegExp("^(\\s)*```");
+    codeBlockEndExp = QRegExp("^(\\s)*```$");
     codeBlockFormat.setForeground(QBrush(Qt::darkYellow));
     for (int index = 0; index < styles.size(); ++index) {
         if (styles[index].type == pmh_VERBATIM) {

+ 31 - 0
src/resources/markdown.css

@@ -116,6 +116,37 @@ hr {
     color: #999;
 }
 
+table {
+   padding: 0;
+   border-collapse: collapse;
+}
+table tr {
+   border-top: 1px solid #cccccc;
+   background-color: white;
+   margin: 0;
+   padding: 0;
+}
+table tr:nth-child(2n) {
+   background-color: #f8f8f8;
+}
+table tr th {
+   font-weight: bold;
+   border: 1px solid #cccccc;
+   margin: 0;
+   padding: 6px 13px;
+}
+table tr td {
+   border: 1px solid #cccccc;
+   margin: 0;
+   padding: 6px 13px;
+}
+table tr th :first-child, table tr td :first-child {
+   margin-top: 0;
+}
+table tr th :last-child, table tr td :last-child {
+   margin-bottom: 0;
+}
+
 /* Code below this line is copyright Twitter Inc. */
 
 button,