Merge pull request #20 from FreeBirdLjj/AddGitIgnore
authorMichael Göhler <somebody.here@gmx.de>
Fri, 19 Sep 2014 17:53:40 +0000 (19:53 +0200)
committerMichael Göhler <somebody.here@gmx.de>
Fri, 19 Sep 2014 17:53:40 +0000 (19:53 +0200)
Init `.gitignore'.

Makefile
README.md
parser.c
sample.md
viewer.c

index 63a1feb..1d4ce07 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,8 @@ clean:
        $(RM) $(OBJECTS) mdp
 
 install: mdp
-       install -Dm755 mdp $(PREFIX)$(DESTDIR)/mdp
+       install -d $(PREFIX)$(DESTDIR)
+       install -m 755 mdp $(PREFIX)$(DESTDIR)/mdp
 
 uninstall:
        rm -f $(PREFIX)$(DESTDIR)/mdp
index 8f58d78..c7b10cf 100644 (file)
--- a/README.md
+++ b/README.md
@@ -7,11 +7,11 @@
 
 *How to get started:*
 
-mpd needs the ncurses headers to compile.
+mdp needs the ncurses headers to compile.
 So make sure you have them installed:
 - On Ubuntu you need ```libncurses5``` and ```libncurses5-dev``` to be installed.
 
-Now download and install mpd:
+Now download and install mdp:
 
     $ git clone https://github.com/visit1985/mdp.git
     $ cd mdp
index ec341ab..8489ab0 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -39,7 +39,8 @@ deck_t *markdown_load(FILE *input) {
 
     deck_t *deck = new_deck();
     slide_t *slide = new_slide();
-    line_t *line;
+    line_t *line = NULL;
+    line_t *tmp = NULL;
     cstring_t *text = cstring_init();
 
     // assign first slide to deck
@@ -198,7 +199,7 @@ deck_t *markdown_load(FILE *input) {
                 if(line->next)
                     line->next->prev = line->prev;
 
-                // set bits on revious line
+                // set bits on previous line
                 if(CHECK_BIT(line->bits, IS_H1)) {
                     SET_BIT(line->prev->bits, IS_H1);
                 } else {
@@ -208,9 +209,13 @@ deck_t *markdown_load(FILE *input) {
                 // adjust line count
                 slide->lines -= 1;
 
+                // maintain loop condition
+                tmp = line;
+                line = line->prev;
+
                 // delete line
-                (line->text->delete)(line->text);
-                free(line);
+                (tmp->text->delete)(tmp->text);
+                free(tmp);
             }
             line = line->next;
         }
index 53afc65..2a7b934 100644 (file)
--- a/sample.md
+++ b/sample.md
-%title: Sample Presentation
+%title: mdp - Sample Presentation
 %author: Michael Göhler
-%date: 2014-09-14
+%date: 2014-09-18
 
 mdp
 ===
 
-A command-line based presentation tool.
+A command-line based markdown presentation tool.
 
---------------------------------------------
+-------------------------------------------------
 
-Here are some formating tests:
+# Supported markdown formatting's
 
-These are 3 stars: \*\*\*
-And two backslashes: \\\\
+First-level headers can be prefixed by single *#*
+or underlined by *===*.
 
-This text is _underlined_ and *highlighted*.
+\# first-level
 
-These are some _incomplete *tags.
+becomes
 
-********************************************
+# first-level
 
-# UTF-8 support
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Second-level headers can be prefixed by *##* or
+underlined by *---*.
+
+second-level
+\------------
+
+becomes
+
+second-level
+------------
+
+
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Code blocks are automatically detected by 4
+spaces at the beginning of a line.
+
+Tabs are automatically expanded to 4 spaces
+while parsing the input.
+
+\    int main(int argc, char \*argv[]) {
+\        printf("%s\\n", "Hello world!");
+\    }
+
+becomes
+
+    int main(int argc, char *argv[]) {
+        printf("%s\n", "Hello world!");
+    }
+
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Quotes are auto-detected by preceding *>*.
+
+Multiple *>* are interpreted as nested quotes.
+
+\> quote
+\>> nested quote 1
+\> > nested quote 2
+
+becomes
+
+> quote
+>> nested quote 1
+> > nested quote 2
+
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Inline highlighting is supported as followed:
+
+- *\** colors text as red
+- *\_* underlines text
+
+\_some\_ \*highlighted\* \_\*text\*\_
+
+becomes
+
+_some_ *highlighted* _*text*_
+
+-------------------------------------------------
+
+# Supported markdown formatting's
+
+Backslashes force special markdown characters
+like *\**, *\_*, *#* and *>* to be printed as normal
+characters.
+
+\\\*special\\\*
+
+becomes
+
+\*special\*
+
+-------------------------------------------------
+
+## More information about markdown
+
+can be found on
+
+_http://daringfireball.net/projects/markdown/_
+
+-------------------------------------------------
+
+# Support for UTF-8 special characters
+
+Here are some examples.
 
 ae = ä, oe = ö, ue = ü, ss = ß
 upsilon = Ʊ, phi = ɸ
@@ -29,27 +124,24 @@ upsilon = Ʊ, phi = ɸ
 ▌rectangle▐
 ▙▄▄▄▄▄▄▄▄▄▟
 
-* * *
 
-## Code examples
+-------------------------------------------------
 
-    public static void main() {
-    
-        printf("%s\n", "hello");
-    }
+# Suspend your presentation for hands-on examples
 
-Now with *different* indentation.
+Use *Ctrl + z* to suspend the presentation.
 
-       function expand_tab {
-        printf("%s\n", "hello");
-    }
+Use *fg* to resume it.
+
+-------------------------------------------------
+
+## Last words
 
-***
+I hope you like *mdp*. But be aware, that it is
+still in alpha status.
 
-This is the end.
-----------------
+If you observe strange behavior, feel free to
+open an issue on GitHub:
 
->
-> My only friend, the end.
->
+_https://github.com/visit1985/mdp_
 
index ba76f2f..6db88b9 100644 (file)
--- a/viewer.c
+++ b/viewer.c
@@ -472,6 +472,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo
                         }
 
                     } else {
+                        // remove backslash from stack
+                        if((stack->top)(stack, '\\'))
+                            (stack->pop)(stack);
+
                         // print regular char
                         wprintw(window, "%c", *c);
                     }