Package list mdp-src / e5ebc58
Imported Upstream version 1.0.5 Lev Lamberov 5 years ago
21 changed file(s) with 61 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
00 #
11 # Makefile
2 # Copyright (C) 2015 Michael Goehler
2 # Copyright (C) 2016 Michael Goehler
33 #
44 # This file is part of mdp.
55 #
88
99 mdp needs the ncursesw headers to compile.
1010 So make sure you have them installed:
11 - on Ubuntu/Debian you need `libncursesw5` and `libncursesw5-dev`
1211 - on Cygwin you need `libncursesw10` and `libncurses-devel`
1312
1413 Now download and install mdp:
2019 $ mdp sample.md
2120
2221 - 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`.
2423 - On FreeBSD, you can use the port [misc/mdp](http://www.freshports.org/misc/mdp).
2524 - 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`.
2627
2728 Most terminals support 256 colors only if the TERM variable is
2829 set correctly. To enjoy mdp's color fading feature:
7677 To make a debug version of `mdp`, just type:
7778
7879 $ make DEBUG=1
79
22
33 /*
44 * Macros to do bit operations on integer variables.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
22
33 /*
44 * Common macros.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
22
33 /*
44 * An implementation of a char stack in heap memory.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
22
33 /*
44 * An implementation of expandable c strings in heap memory.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
22
33 /*
44 * mdp -- A command-line based markdown presentation tool.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This program is free software: you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
2424
2525 #define MDP_VER_MAJOR 1
2626 #define MDP_VER_MINOR 0
27 #define MDP_VER_REVISION 4
27 #define MDP_VER_REVISION 5
2828
2929 #endif // !defined( MAIN_H )
22
33 /*
44 * An implementation of markdown objects.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
44 * Functions necessary to parse a file and transform its content into
55 * a deck of slides containing lines. All based on markdown formating
66 * rules.
7 * Copyright (C) 2015 Michael Goehler
7 * Copyright (C) 2016 Michael Goehler
88 *
99 * This file is part of mdp.
1010 *
22
33 /*
44 * An object to store all urls of a slide.
5 * Copyright (C) 2015 Michael Goehler
5 * Copyright (C) 2016 Michael Goehler
66 *
77 * This file is part of mdp.
88 *
44 * Functions necessary to display a deck of slides in different color modes
55 * using ncurses. Only white, red, and blue are supported, as they can be
66 * faded in 256 color mode.
7 * Copyright (C) 2015 Michael Goehler
7 * Copyright (C) 2016 Michael Goehler
88 *
99 * This file is part of mdp.
1010 *
44 .\"
55 .
66 .
7 .TH MDP 1 "2015-04-10" "User Commands"
7 .TH MDP 1 "2016-02-07" "User Commands"
88 .SH NAME
99 mdp \- A command-line based
1010 markdown presentation tool
139139 Written by Michael Goehler and others, see
140140 .IR https://github.com/visit1985/mdp/blob/master/AUTHORS "."
141141 .SH COPYRIGHT
142 Copyright (C) 2015 Michael Goehler
142 Copyright (C) 2016 Michael Goehler
143143 .PP
144144 This is free software; see the source for copying conditions. There is NO
145145 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00 %title: mdp - Sample Presentation
11 %author: visit1985
2 %date: 2014-09-22
2 %date: 2016-02-07
33
44 -> mdp <-
55 =========
8181
8282 -> # Supported markdown formatting <-
8383
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.
8989
9090 \ int main(int argc, char \*argv[]) {
9191 \ printf("%s\\n", "Hello world!");
101101
102102 -> # Supported markdown formatting <-
103103
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.
107107
108108 \~~~ {.numberLines}
109109 \int main(int argc, char \*argv[]) {
119119 }
120120 ~~~~~~~~~~~~~~~~~~
121121
122 Pandoc attributes (like ".numberlines" etc.) will be ignored
122 Pandoc attributes (like ".numberlines" etc.)
123 will be ignored
123124
124125 -------------------------------------------------
125126
159160 -> # Supported markdown formatting <-
160161
161162 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.
164165
165166 \\\*special\\\*
166167
00 #
11 # Makefile
2 # Copyright (C) 2015 Michael Goehler
2 # Copyright (C) 2016 Michael Goehler
33 #
44 # This file is part of mdp.
55 #
00 /*
11 * An implementation of a char stack in heap memory.
2 * Copyright (C) 2015 Michael Goehler
2 * Copyright (C) 2016 Michael Goehler
33 *
44 * This file is part of mdp.
55 *
00 /*
11 * An implementation of expandable c strings in heap memory.
2 * Copyright (C) 2015 Michael Goehler
2 * Copyright (C) 2016 Michael Goehler
33 *
44 * This file is part of mdp.
55 *
00 /*
11 * mdp -- A command-line based markdown presentation tool.
2 * Copyright (C) 2015 Michael Goehler
2 * Copyright (C) 2016 Michael Goehler
33 *
44 * This program is free software: you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
4343
4444 void version() {
4545 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");
4747 printf("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n");
4848 printf("This is free software: you are free to change and redistribute it.\n");
4949 printf("There is NO WARRANTY, to the extent permitted by law.\n");
00 /*
11 * An implementation of markdown objects.
2 * Copyright (C) 2015 Michael Goehler
2 * Copyright (C) 2016 Michael Goehler
33 *
44 * This file is part of mdp.
55 *
11 * Functions necessary to parse a file and transform its content into
22 * a deck of slides containing lines. All based on markdown formating
33 * rules.
4 * Copyright (C) 2015 Michael Goehler
4 * Copyright (C) 2016 Michael Goehler
55 *
66 * This file is part of mdp.
77 *
8888 slide = next_slide(slide);
8989 sc++;
9090
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)) {
9293 // remove tilde code markers
9394 (text->reset)(text);
9495
338339 // return IS_EMPTY on null pointers
339340 if(!text || !text->value) {
340341 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
341347 return bits;
342348 }
343349
599605 void adjust_line_length(line_t *line) {
600606 int l = 0;
601607 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];
603609 cstack_t *stack = cstack_init();
604610
605611 // for each char in line
00 /*
11 * Functions necessary to handle pandoc URLs.
2 * Copyright (C) 2015 Michael Goehler
2 * Copyright (C) 2016 Michael Goehler
33 *
44 * This file is part of mdp.
55 *
11 * Functions necessary to display a deck of slides in different color modes
22 * using ncurses. Only white, red, and blue are supported, as they can be
33 * faded in 256 color mode.
4 * Copyright (C) 2015 Michael Goehler
4 * Copyright (C) 2016 Michael Goehler
55 *
66 * This file is part of mdp.
77 *
9292
9393 while(line && line->text) {
9494
95 if (line->text->value)
95 if (line->text->value) {
9696 lc += url_count_inline(line->text->value);
97
98 if (line->text->value)
9997 line->length -= url_len_inline(line->text->value);
98 }
10099
101100 if(line->length > COLS) {
102101 i = line->length;
510509
511510 void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) {
512511
513 if(!line->text->value) {
514 return;
515 }
516
517512 int i; // increment
518513 int offset = 0; // text offset
519514
520515 // move the cursor in position
521516 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 }
522530
523531 // IS_UNORDERED_LIST_3
524532 if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_3)) {