[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs markdown.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs markdown.c |
Date: |
Tue, 31 Jan 2017 15:18:55 -0500 (EST) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 17/01/31 15:18:55
Modified files:
. : markdown.c
Log message:
markdown: fix code fragment coloring
- code fragments introduced with the ``` syntax can now be indented
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/markdown.c?cvsroot=qemacs&r1=1.25&r2=1.26
Patches:
Index: markdown.c
===================================================================
RCS file: /sources/qemacs/qemacs/markdown.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- markdown.c 1 Jan 2017 15:33:18 -0000 1.25
+++ markdown.c 31 Jan 2017 20:18:55 -0000 1.26
@@ -114,6 +114,16 @@
if (syn == &litcoffee_mode)
base_style = MKD_STYLE_COMMENT;
+ for (indent = j = 0;; j++) {
+ if (str[j] == ' ')
+ indent++;
+ else
+ if (str[j] == '\t')
+ indent += 4;
+ else
+ break;
+ }
+
if (str[i] == '<' && str[i + 1] == '!' && str[i + 2] == '-' && str[i + 3]
== '-') {
colstate |= IN_MKD_HTML_COMMENT;
i += 3;
@@ -142,8 +152,8 @@
if (colstate & IN_MKD_BLOCK) {
/* Should count number of ~ to detect end of block */
- if (ustrstart(str + i, "~~~", NULL)
- || ustrstart(str + i, "```", NULL)) {
+ if (ustrstart(str + j, "~~~", NULL)
+ || ustrstart(str + j, "```", NULL)) {
colstate &= ~IN_MKD_BLOCK;
i = n;
SET_COLOR(str, start, i, MKD_STYLE_TILDE);
@@ -156,7 +166,7 @@
colstate &= ~IN_MKD_LANG_STATE;
colstate |= cp->colorize_state & IN_MKD_LANG_STATE;
} else {
- SET_COLOR(str, i, n, MKD_STYLE_CODE);
+ SET_COLOR(str, start, n, MKD_STYLE_CODE);
}
i = n;
}
@@ -220,14 +230,14 @@
if (str[i] == '|') {
base_style = MKD_STYLE_TABLE;
} else
- if (ustrstart(str + i, "~~~", NULL)
- || ustrstart(str + i, "```", NULL)) {
+ if (ustrstart(str + j, "~~~", NULL)
+ || ustrstart(str + j, "```", NULL)) {
/* verbatim block */
char lang_name[16];
int lang = syn->colorize_flags, len; // was MKD_LANG_MAX
colstate &= ~(IN_MKD_BLOCK | IN_MKD_LANG_STATE);
- for (i += 3; qe_isblank(str[i]); i++)
+ for (i = j + 3; qe_isblank(str[i]); i++)
continue;
for (len = 0; i < n && !qe_isblank(str[i]); i++) {
if (len < countof(lang_name) - 1)
@@ -259,15 +269,7 @@
/* \ ` * _ { } [ ] ( ) # + - . ! */
level = (colstate & IN_MKD_LEVEL) >> MKD_LEVEL_SHIFT;
- for (indent = 0;; i++) {
- if (str[i] == ' ')
- indent++;
- else
- if (str[i] == '\t')
- indent += 4;
- else
- break;
- }
+ i = j;
if (i < n) {
start = i;