Merge pull request #31 from FreeBirdLjj/issue#30
authorMichael Göhler <somebody.here@gmx.de>
Sun, 21 Sep 2014 09:22:12 +0000 (11:22 +0200)
committerMichael Göhler <somebody.here@gmx.de>
Sun, 21 Sep 2014 09:22:12 +0000 (11:22 +0200)
Enhanced: Issue#30

sample.md
viewer.c

index fd3a8d8..8cea5d6 100644 (file)
--- a/sample.md
+++ b/sample.md
@@ -52,6 +52,18 @@ second-level
 ------------
 
 
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Inline codes are surrounded with backticks.
+
+C program starts with \`main()\`.
+
+becomes
+
+C program starts with `main()`.
+
 -------------------------------------------------
 
 # Supported markdown formatting's
@@ -161,3 +173,4 @@ open an issue on GitHub:
 
 _https://github.com/visit1985/mdp_
 
+
index e31dbcb..f5e43d4 100644 (file)
--- a/viewer.c
+++ b/viewer.c
@@ -363,7 +363,7 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) {
 void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) {
     int i = 0; // increment
     char *c; // char pointer for iteration
-    char *special = "\\*_"; // list of interpreted chars
+    char *special = "\\*_`"; // list of interpreted chars
     cstack_t *stack = cstack_init();
 
     if(line->text->text) {
@@ -450,6 +450,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo
                                 case '_':
                                     wattroff(window, A_UNDERLINE);
                                     break;
+                               // disable inline code
+                                case '`':
+                                    wattroff(window, A_REVERSE);
+                                   break;
                             }
 
                             // remove top special char from stack
@@ -474,6 +478,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo
                                 case '_':
                                     wattron(window, A_UNDERLINE);
                                     break;
+                                // enable inline code
+                                case '`':
+                                    wattron(window, A_REVERSE);
+                                    break;
                                 // do nothing for backslashes
                             }
 
@@ -505,6 +513,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo
                         case '_':
                             wattroff(window, A_UNDERLINE);
                             break;
+                        // disable inline code
+                        case '`':
+                           wattroff(window, A_REVERSE);
+                            break;
                         // do nothing for backslashes
                     }
                 }