GithubHelp home page GithubHelp logo

titor8115 / mandown Goto Github PK

View Code? Open in Web Editor NEW
239.0 6.0 13.0 556 KB

man-page inspired Markdown viewer

License: GNU General Public License v3.0

Makefile 2.51% C 97.49%
man-page markdown ncurses tui c terminal command-line man console ncurses-ui

mandown's Introduction

mandown - mdn

A man-page inspired Markdown pager written in C.

Name change: executable's name changed to mdn

What is it

Need to lookup things from README? Or from manual page? Or perhaps just want to install something cool...

Update

  • User Customization
    • Added control schemes: mdn, vim, less(default since mdn isn't complete)
    • Config file location: ~/.config/mdn/mdnrc

Sample

screenshot

Installation

Current version is still being developed for some HTML tags. However, it should work on most Markdown documents.

Homebrew

$ brew install mandown

The installed binary mdn would be at /usr/local/bin/

$ git clone https://github.com/Titor8115/mandown.git
$ cd mandown
$ make install

To remove the binary, you can run the commands below, or remove manually.

$ cd mandown
$ make uninstall

If you just want to compile and test it.

$ cd mandown
$ make

Feel free to create an issue.

Usage

Check out the new sample

$ mdn sample.md

Mouse wheel scrolling is supported! (if your terminal emulator allows)

Scroll Up: , k

Scroll Down: , j

Page Up: space bar, pg up, fn + ↑a, b

Page Down: back space, pg down, fn + ↓, f

Select & Get href: tab or double click mouse 1 & enter

Exit: q

To read detailed usage, run mdn -h

Library dependency

Mandown requires libncurses(w) and libxml2 as compile-time dependencies.

Make sure you have them installed before compiling.

Debian

$ apt-get install libncursesw5-dev
$ apt-get install libxml2-dev

Todo

  • Line fold/wrap on white space
  • Optimized resizing
  • Table and contents rendering
  • Makefile makeover

mandown's People

Contributors

alexmyczko avatar an-prata avatar diegomagdaleno avatar esmil avatar hellricer avatar jfaltis avatar titor8115 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mandown's Issues

Render empty lines

Empty lines are not printed meaning it is very hard to make out paragraphs.

It would also be good if comments in the markdown file wasn't rendered (but perhaps I should open a new issue for this?).

Erroneous rendering

This markdown :

1 # NAME
1
2 ftl - terminal file manager, tmux based
3
4 ## Commands shortcuts (⇑: alt-gr, ⇈: shift+alt-gr)
5 6 q Q @ ) close, > &3, keep shell ? ) show help 7 a ) kill sound preview j B ) next entry 8 b ⇑b ) find/fzf entry in directory k A ) previous entry 9 c ) copy selection h D ) parent directory 10 ⇑c ) compress/decompress l C '' ) cd or open file 11 d ) delete 5 6 ) page down/up 12 ... 13 14 for a complete list see resources/.config/ftl/help.md or press '?' in ftl 15 16 17
18
19 Screenshot
20 Screenshot
21
22 # DOCUMENTATION
23
24 There are many promising file managers for the terminal, from fff to nnn, clifm, ranger, vimfm, broot, etc ...

renders as:

README.md(7)

NAME
NAME
ftl - terminal file manager, tmux based

Commands shortcuts (⇑: alt-gr, ⇈: shift+alt-gr)
``` q Q @ ) close, > &3, keep shell ? ) show help a ) kill sound preview j B ) next entry b ⇑b ) find/fzf entry in directory k A ) previous entry c ) copy selection h D ) parent
directory ⇑c ) compress/decompress l C '' ) cd or open file d ) delete 5 6 ) page down/up ...

   for a complete list see resources/.config/ftl/help.md or press '?' in ftl

   ```

   Screenshot Screenshot

NAME
DOCUMENTATION
There are many promising file managers for the terminal, from fff to nnn, clifm, ranger, vimfm, broot, etc ...

the errors:

NAME

-> NAME is written twice

 q Q @  ) close, > &3, keep shell         ?       ) show help
 a      ) kill sound preview              j B     ) next entry

-> rendered all on one line

![Screenshot](https://raw.github.com/nkh/ftl/master/screenshots/ftl.png)
-> url not shown

# DOCUMENTATION
 ->  NAME is rendered again!, DOCUMENTATION is not indented properly

Design: leave paging to less(1)?

From what I see this tool is doing two things: markdown parsing/formatting and paging.

Why not just do md formatting and leave the rest for less? That way users are free to use a pager of choice (or none at all) and you don't need to duplicate the functionality of less.

Thoughts?

Stdin piping

Hi, I am using ubuntu 20.04, and my terminal is now set to xterm-256color

When I render a mardown document, rather than seeing bullet points, I am seeing "M-BM-7". Can you tell me what's going on?

Also, is it possible for render from stdin rather than from a file?

thank you.

-tp

Code blocks

You need to fix lines between lines that starting with ``` to not process them.

# echo hello

Fails while compiling

macOS 10.11:

gcc -c -g -O3 -fPIC -Wall -Wsign-compare -Iparser -Iblender -Iinclude -I/usr/include/libxml2   -c -o src/mandown.o src/mandown.c
gcc -c -g -O3 -fPIC -Wall -Wsign-compare -Iparser -Iblender -Iinclude -I/usr/include/libxml2   -c -o src/view.o src/view.c
src/view.c:104:19: error: use of undeclared identifier
      'A_ITALIC'
        attr[1] = A_ITALIC;
                  ^
1 error generated.
make: *** [src/view.o] Error 1

Multiple Parser errors (Ignore parsing certain elements)

I saw this tool from the reddit post. So I downloaded and gave it a go on my blogs markdown files, which didn't go so well.

How I installed

git clone https://github.com/Titor8115/mandown.git
cd mandown
make
sudo install -C -m 755 -o root -g root mandown /usr/bin/mdn

Gave it a test run on the readme from the repo and it seemed to work. I then next went to my blog post. This one specifically which follows GitHub Flavored Markdown Spec

Errors

noname.xml:9: parser error : Opening and ending tag mismatch: br line 8 and p
79/">reference</a>. With this short preamble out of the way lets get into it!</p
                                                                               ^
noname.xml:11: parser error : Opening and ending tag mismatch: br line 11 and p
r to me, as they all had different cons and gotchas, with very few pros.<br> </p
                                                                               ^
noname.xml:13: parser error : Opening and ending tag mismatch: use line 13 and code
/SVG/Element/use#Browser_compatibility">compatibility</a> for <code><use></code>
                                                                               ^
noname.xml:13: parser error : Opening and ending tag mismatch: code line 13 and p
ser_compatibility">compatibility</a> for <code><use></code> is  pretty good. </p
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: symbol line 41 and code
se></code> - <strong>Does work</strong> (this requires the <code><symbol></code>
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: use line 41 and code
n.svg to have an id attached to it so you can reference it in <code><use></code>
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: code line 41 and p
g to have an id attached to it so you can reference it in <code><use></code>)</p
                                                                               ^
noname.xml:90: parser error : Opening and ending tag mismatch: code line 41 and article
</article>
          ^
noname.xml:91: parser error : Premature end of data in tag br line 40

^
noname.xml:91: parser error : Premature end of data in tag br line 40

^
noname.xml:91: parser error : Premature end of data in tag p line 39

^
noname.xml:91: parser error : Premature end of data in tag p line 13

^
noname.xml:91: parser error : Premature end of data in tag p line 11

^
noname.xml:91: parser error : Premature end of data in tag p line 8

^
noname.xml:91: parser error : Premature end of data in tag hr line 2

^
noname.xml:91: parser error : Premature end of data in tag article line 1

^
error: Failed to parse document

Side note

man-page inspired Markdown viewer
This tool is fine to be used as a general purpose markdown viewer correct, or did I misinterpret the tagline?

Add dockerization option?

I think a simple dockerfile will suffice :)
will help with stability across diff environments.

I messed around and made a new repo which is basically a clone of this with a dockerfile. all you need to do is build :P

I'll close it(And the issue) if you think it's inappropriate obviously, just say so :)

https://github.com/MatanKribus/dockerized-mandown

compilation errors with `panel.h: No such file or directory`

Hi, I just did

sudo apt install libxml2-dev libncursesw5-dev
git clone https://github.com/Titor8115/mandown.git
cd mandown
make clean && make install

but I get

rm -f mdn
rm -f blender/blender.o blender/houdini_blender_e.o blender/houdini_href_e.o parser/autolink.o parser/buffer.o parser/markdown.o parser/stack.o src/dom.o src/mandown.o src/view.o
cc -c -g -O3 -Wall -Wsign-compare -Iparser -Iblender -Iinclude -I/usr/include/libxml2 -D HAS_NCURSESW_H   -c -o src/mandown.o src/mandown.c
cc -c -g -O3 -Wall -Wsign-compare -Iparser -Iblender -Iinclude -I/usr/include/libxml2 -D HAS_NCURSESW_H   -c -o src/view.o src/view.c
src/view.c:8:10: fatal error: panel.h: No such file or directory
 #include <panel.h>
          ^~~~~~~~~
compilation terminated.
<builtin>: recipe for target 'src/view.o' failed
make: *** [src/view.o] Error 1

Any ideas?

gcc warning

Hi

src/view.c: In function ‘view’:
src/view.c:475:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
  475 |         if (getmouse(&event) == OK) {
      |            ^
src/view.c:486:7: note: here
  486 |       case TAB: {  tab_find:
      |       ^~~~
formula   mdn

missing header file

Hi

your are miss some files

cli/mandown.c:18:10: fatal error: mandown.h: Adresář nebo soubor neexistuje
18 | #include "mandown.h"
| ^~~~~~~~~~~

Add install section to Makefile

I know, this is probably part of point "Makefile makeover" in TODO but this is important and simple to do. When you do that I can add and maintain package in AUR (Arch User Repository) if you want.

Builds fine on MacOS with small Makefile addition

Not a bug but a comment that mdn builds fine on MacOS via the following (assumes use of HomeBrew):

brew install libxml2

Add libxml2 HomeBrew Cellar include path to the mandown Makefile as follows:

CFLAGS = -c -g -O3 -Wall -Wsign-compare -Iparser -Iblender -Iinclude -I/usr/include/libxml2 -I/usr/local/Cellar/libxml2/2.9.10_1/include/libxml2 $(DEFINE)

segfault

I try to watch README.md from plpgsql_check project, and it finish by segfault
xREADME.md.gz

#0  0x00007ffff7c40a25 in raise () from /lib64/libc.so.6
#1  0x00007ffff7c29895 in abort () from /lib64/libc.so.6
#2  0x00007ffff7c848c7 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff7c8494a in __libc_fatal () from /lib64/libc.so.6
#4  0x00007ffff7c6d6ca in printf_positional () from /lib64/libc.so.6
#5  0x00007ffff7c6fb50 in __vfprintf_internal () from /lib64/libc.so.6
#6  0x00007ffff7c83aaa in __vsnprintf_internal () from /lib64/libc.so.6
#7  0x00007ffff7f8ffa4 in _nc_printf_string_sp () from /lib64/libncursesw.so.6
#8  0x00007ffff7f89285 in vw_printw () from /lib64/libncursesw.so.6
#9  0x00007ffff7f89418 in wprintw () from /lib64/libncursesw.so.6
#10 0x000000000040316c in render_content (dest=0x4202a0, ib=)
    at src/view.c:186
#11 0x0000000000403b6a in view (configed=configed@entry=0x4122a0, ob=ob@entry=0x4128e0, 
    blocks=) at src/view.c:464
#12 0x00000000004026c8 in main (argc=, argv=)
    at src/mandown.c:180

React to window size changes

Hey, first of all let me thank you for this project!

One of my biggest gripes with man is that the text is not "re-wrapped" when the window size changes. Because I'm using tiling managers, this is often problem as I have to quit man and run it again.

The reason is, of course, that man only sends output of groff to pager, so it's basically impossible to fix.

But maybe it could be implemented here?

Debian packages for mandown

Hey,

I've created Debian packages for mandown over at barnumbirr/mandown-debian and was wondering if you'd be interested in adding them to the installation instructions in the README.

If you're up for it, just tell me what you want the formatting to look like and I'll create a PR.

Thanks a lot.
Cheers.

dropped spaces between styled text and following text

On my Manjaro workstation (if that matters), spaces following styled text are removed. On the page I'm looking at, this includes text following a bold, a link, and back-tick-enclosed text. Adding extra spaces doesn't help, a styled text and its following text are adjacent.

broken html ?

When I leave mdn I see:

[pavel@localhost pspg-master]$ mdn README.md 
file:182: HTML parser error : Unexpected end tag : p
</pre></p>
          ^
file:217: HTML parser error : Unexpected end tag : p
<pre></p>
         ^
file:223: HTML parser error : Unexpected end tag : p
<p></pre></p>
             ^
file:238: HTML parser error : Unexpected end tag : p
</pre></p>
          ^
file:278: HTML parser error : Unexpected end tag : p
</pre></p>
          ^
file:283: HTML parser error : Unexpected end tag : p
In this case comment line with function set_escdelay</p>
                                                        ^

README.md.txt

Does not compile due to ncurses header path

I've cloned the 1.0.0 release (congrats!) and make gives me the following;

In file included from src/mandown.c:14:
include/view.h:12:10: fatal error: ncursesw/ncurses.h: No such file or directory
   12 | #include <ncursesw/ncurses.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/mandown.o] Error 1

I'm on Manjaro, uname -s is Linux

I've found this, basically says you should use ncurses.h.

adding;

ifeq ($(UNAME_S),Linux)
    CURSES := ncurses
    OSFLAGS :=
    DEFINE := -D HAS_NCURSES_H
endif

to the Makefile fixes the problem, make correctly produces mandown and mdn executibles.

Error while compiling on manjaro

I get this error when running make install:

cc -c -g -O3 -Wall -Wsign-compare -Iparser -Iblender -I/usr/include/libxml2 -D HAS_NCURSESW_H   -c -o src/view.o src/view.c
In file included from src/view.h:9,
                 from src/view.c:1:
src/st_curses.h:4:10: fatal error: ncursesw/ncurses.h: No such file or directory
    4 | #include <ncursesw/ncurses.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/view.o] Error 1

I've installed ncurses 6.2 from my package manager, so I'm not sure what I'm doing wrong here. I'm on Manjaro.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.