Imported Upstream version 1.0.5
Lev Lamberov
7 years ago
0 | 0 | # |
1 | 1 | # Makefile |
2 | # Copyright (C) 2015 Michael Goehler | |
2 | # Copyright (C) 2016 Michael Goehler | |
3 | 3 | # |
4 | 4 | # This file is part of mdp. |
5 | 5 | # |
8 | 8 | |
9 | 9 | mdp needs the ncursesw headers to compile. |
10 | 10 | So make sure you have them installed: |
11 | - on Ubuntu/Debian you need `libncursesw5` and `libncursesw5-dev` | |
12 | 11 | - on Cygwin you need `libncursesw10` and `libncurses-devel` |
13 | 12 | |
14 | 13 | Now download and install mdp: |
20 | 19 | $ mdp sample.md |
21 | 20 | |
22 | 21 | - On Arch, you can use the existing [AUR package](https://aur.archlinux.org/packages/mdp-git/). |
23 | - On Slackware, grab the SlackBuild here: (http://slackbuilds.org/apps/mdp/), or run `sbopkg -i mdp`. | |
22 | - On Debian, you can use the existing [DEB package](https://tracker.debian.org/pkg/mdp-src), or run `apt-get install mdp`. | |
24 | 23 | - On FreeBSD, you can use the port [misc/mdp](http://www.freshports.org/misc/mdp). |
25 | 24 | - On OS-X, use the existing [Homebrew Formula](http://brewformulas.org/Mdp) by running `brew install mdp`. |
25 | - On Slackware, grab the SlackBuild here: (http://slackbuilds.org/apps/mdp/), or run `sbopkg -i mdp`. | |
26 | - On Ubuntu, you can use the existing [DEB package](https://launchpad.net/ubuntu/+source/mdp-src), or run `apt-get install mdp`. | |
26 | 27 | |
27 | 28 | Most terminals support 256 colors only if the TERM variable is |
28 | 29 | set correctly. To enjoy mdp's color fading feature: |
76 | 77 | To make a debug version of `mdp`, just type: |
77 | 78 | |
78 | 79 | $ make DEBUG=1 |
79 |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * Macros to do bit operations on integer variables. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * Common macros. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * An implementation of a char stack in heap memory. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * An implementation of expandable c strings in heap memory. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * mdp -- A command-line based markdown presentation tool. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This program is free software: you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
24 | 24 | |
25 | 25 | #define MDP_VER_MAJOR 1 |
26 | 26 | #define MDP_VER_MINOR 0 |
27 | #define MDP_VER_REVISION 4 | |
27 | #define MDP_VER_REVISION 5 | |
28 | 28 | |
29 | 29 | #endif // !defined( MAIN_H ) |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * An implementation of markdown objects. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
4 | 4 | * Functions necessary to parse a file and transform its content into |
5 | 5 | * a deck of slides containing lines. All based on markdown formating |
6 | 6 | * rules. |
7 | * Copyright (C) 2015 Michael Goehler | |
7 | * Copyright (C) 2016 Michael Goehler | |
8 | 8 | * |
9 | 9 | * This file is part of mdp. |
10 | 10 | * |
2 | 2 | |
3 | 3 | /* |
4 | 4 | * An object to store all urls of a slide. |
5 | * Copyright (C) 2015 Michael Goehler | |
5 | * Copyright (C) 2016 Michael Goehler | |
6 | 6 | * |
7 | 7 | * This file is part of mdp. |
8 | 8 | * |
4 | 4 | * Functions necessary to display a deck of slides in different color modes |
5 | 5 | * using ncurses. Only white, red, and blue are supported, as they can be |
6 | 6 | * faded in 256 color mode. |
7 | * Copyright (C) 2015 Michael Goehler | |
7 | * Copyright (C) 2016 Michael Goehler | |
8 | 8 | * |
9 | 9 | * This file is part of mdp. |
10 | 10 | * |
4 | 4 | .\" |
5 | 5 | . |
6 | 6 | . |
7 | .TH MDP 1 "2015-04-10" "User Commands" | |
7 | .TH MDP 1 "2016-02-07" "User Commands" | |
8 | 8 | .SH NAME |
9 | 9 | mdp \- A command-line based |
10 | 10 | markdown presentation tool |
139 | 139 | Written by Michael Goehler and others, see |
140 | 140 | .IR https://github.com/visit1985/mdp/blob/master/AUTHORS "." |
141 | 141 | .SH COPYRIGHT |
142 | Copyright (C) 2015 Michael Goehler | |
142 | Copyright (C) 2016 Michael Goehler | |
143 | 143 | .PP |
144 | 144 | This is free software; see the source for copying conditions. There is NO |
145 | 145 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
0 | 0 | %title: mdp - Sample Presentation |
1 | 1 | %author: visit1985 |
2 | %date: 2014-09-22 | |
2 | %date: 2016-02-07 | |
3 | 3 | |
4 | 4 | -> mdp <- |
5 | 5 | ========= |
81 | 81 | |
82 | 82 | -> # Supported markdown formatting <- |
83 | 83 | |
84 | Code blocks are automatically detected by 4 | |
85 | spaces at the beginning of a line. | |
86 | ||
87 | Tabs are automatically expanded to 4 spaces | |
88 | while parsing the input. | |
84 | Code blocks are automatically detected by 4 spaces | |
85 | at the beginning of a line. | |
86 | ||
87 | Tabs are automatically expanded to 4 spaces while | |
88 | parsing the input. | |
89 | 89 | |
90 | 90 | \ int main(int argc, char \*argv[]) { |
91 | 91 | \ printf("%s\\n", "Hello world!"); |
101 | 101 | |
102 | 102 | -> # Supported markdown formatting <- |
103 | 103 | |
104 | You can also use [pandoc](http://pandoc.org/demo/example9/pandocs-markdown.html)'s fenced code block extension. | |
105 | Use at least three ~ chars to open and at least as many or | |
106 | more ~ for closing. | |
104 | You can also use [pandoc](http://pandoc.org/demo/example9/pandocs-markdown.html)'s fenced code block | |
105 | extension. Use at least three ~ chars to open and | |
106 | at least as many or more ~ for closing. | |
107 | 107 | |
108 | 108 | \~~~ {.numberLines} |
109 | 109 | \int main(int argc, char \*argv[]) { |
119 | 119 | } |
120 | 120 | ~~~~~~~~~~~~~~~~~~ |
121 | 121 | |
122 | Pandoc attributes (like ".numberlines" etc.) will be ignored | |
122 | Pandoc attributes (like ".numberlines" etc.) | |
123 | will be ignored | |
123 | 124 | |
124 | 125 | ------------------------------------------------- |
125 | 126 | |
159 | 160 | -> # Supported markdown formatting <- |
160 | 161 | |
161 | 162 | Backslashes force special markdown characters |
162 | like *\**, *\_*, *#* and *>* to be printed as normal | |
163 | characters. | |
163 | like *\**, *\_*, *#* and *>* to be printed as | |
164 | normal characters. | |
164 | 165 | |
165 | 166 | \\\*special\\\* |
166 | 167 |
0 | 0 | # |
1 | 1 | # Makefile |
2 | # Copyright (C) 2015 Michael Goehler | |
2 | # Copyright (C) 2016 Michael Goehler | |
3 | 3 | # |
4 | 4 | # This file is part of mdp. |
5 | 5 | # |
0 | 0 | /* |
1 | 1 | * An implementation of a char stack in heap memory. |
2 | * Copyright (C) 2015 Michael Goehler | |
2 | * Copyright (C) 2016 Michael Goehler | |
3 | 3 | * |
4 | 4 | * This file is part of mdp. |
5 | 5 | * |
0 | 0 | /* |
1 | 1 | * An implementation of expandable c strings in heap memory. |
2 | * Copyright (C) 2015 Michael Goehler | |
2 | * Copyright (C) 2016 Michael Goehler | |
3 | 3 | * |
4 | 4 | * This file is part of mdp. |
5 | 5 | * |
0 | 0 | /* |
1 | 1 | * mdp -- A command-line based markdown presentation tool. |
2 | * Copyright (C) 2015 Michael Goehler | |
2 | * Copyright (C) 2016 Michael Goehler | |
3 | 3 | * |
4 | 4 | * This program is free software: you can redistribute it and/or modify |
5 | 5 | * it under the terms of the GNU General Public License as published by |
43 | 43 | |
44 | 44 | void version() { |
45 | 45 | printf("mdp %d.%d.%d\n", MDP_VER_MAJOR, MDP_VER_MINOR, MDP_VER_REVISION); |
46 | printf("Copyright (C) 2015 Michael Goehler\n"); | |
46 | printf("Copyright (C) 2016 Michael Goehler\n"); | |
47 | 47 | printf("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"); |
48 | 48 | printf("This is free software: you are free to change and redistribute it.\n"); |
49 | 49 | printf("There is NO WARRANTY, to the extent permitted by law.\n"); |
0 | 0 | /* |
1 | 1 | * An implementation of markdown objects. |
2 | * Copyright (C) 2015 Michael Goehler | |
2 | * Copyright (C) 2016 Michael Goehler | |
3 | 3 | * |
4 | 4 | * This file is part of mdp. |
5 | 5 | * |
1 | 1 | * Functions necessary to parse a file and transform its content into |
2 | 2 | * a deck of slides containing lines. All based on markdown formating |
3 | 3 | * rules. |
4 | * Copyright (C) 2015 Michael Goehler | |
4 | * Copyright (C) 2016 Michael Goehler | |
5 | 5 | * |
6 | 6 | * This file is part of mdp. |
7 | 7 | * |
88 | 88 | slide = next_slide(slide); |
89 | 89 | sc++; |
90 | 90 | |
91 | } else if(CHECK_BIT(bits, IS_TILDE_CODE) && CHECK_BIT(bits, IS_EMPTY)) { | |
91 | } else if(CHECK_BIT(bits, IS_TILDE_CODE) && | |
92 | CHECK_BIT(bits, IS_EMPTY)) { | |
92 | 93 | // remove tilde code markers |
93 | 94 | (text->reset)(text); |
94 | 95 | |
338 | 339 | // return IS_EMPTY on null pointers |
339 | 340 | if(!text || !text->value) { |
340 | 341 | SET_BIT(bits, IS_EMPTY); |
342 | ||
343 | // continue fenced code blocks across empty lines | |
344 | if(num_tilde_characters > 0) | |
345 | SET_BIT(bits, IS_CODE); | |
346 | ||
341 | 347 | return bits; |
342 | 348 | } |
343 | 349 | |
599 | 605 | void adjust_line_length(line_t *line) { |
600 | 606 | int l = 0; |
601 | 607 | const static wchar_t *special = L"\\*_`"; // list of interpreted chars |
602 | const wchar_t *c = &line->text->value[line->offset]; | |
608 | const wchar_t *c = &line->text->value[0]; | |
603 | 609 | cstack_t *stack = cstack_init(); |
604 | 610 | |
605 | 611 | // for each char in line |
0 | 0 | /* |
1 | 1 | * Functions necessary to handle pandoc URLs. |
2 | * Copyright (C) 2015 Michael Goehler | |
2 | * Copyright (C) 2016 Michael Goehler | |
3 | 3 | * |
4 | 4 | * This file is part of mdp. |
5 | 5 | * |
1 | 1 | * Functions necessary to display a deck of slides in different color modes |
2 | 2 | * using ncurses. Only white, red, and blue are supported, as they can be |
3 | 3 | * faded in 256 color mode. |
4 | * Copyright (C) 2015 Michael Goehler | |
4 | * Copyright (C) 2016 Michael Goehler | |
5 | 5 | * |
6 | 6 | * This file is part of mdp. |
7 | 7 | * |
92 | 92 | |
93 | 93 | while(line && line->text) { |
94 | 94 | |
95 | if (line->text->value) | |
95 | if (line->text->value) { | |
96 | 96 | lc += url_count_inline(line->text->value); |
97 | ||
98 | if (line->text->value) | |
99 | 97 | line->length -= url_len_inline(line->text->value); |
98 | } | |
100 | 99 | |
101 | 100 | if(line->length > COLS) { |
102 | 101 | i = line->length; |
510 | 509 | |
511 | 510 | void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) { |
512 | 511 | |
513 | if(!line->text->value) { | |
514 | return; | |
515 | } | |
516 | ||
517 | 512 | int i; // increment |
518 | 513 | int offset = 0; // text offset |
519 | 514 | |
520 | 515 | // move the cursor in position |
521 | 516 | wmove(window, y, x); |
517 | ||
518 | if(!line->text->value) { | |
519 | ||
520 | // fill rest off line with spaces if we are in a code block | |
521 | if(CHECK_BIT(line->bits, IS_CODE) && colors) { | |
522 | wattron(window, COLOR_PAIR(CP_BLACK)); | |
523 | for(i = getcurx(window) - x; i < max_cols; i++) | |
524 | wprintw(window, "%s", " "); | |
525 | } | |
526 | ||
527 | // do nothing | |
528 | return; | |
529 | } | |
522 | 530 | |
523 | 531 | // IS_UNORDERED_LIST_3 |
524 | 532 | if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_3)) { |