mdview, a markdown viewer

Miscellaneous tools
Message
Author
jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

mdview, a markdown viewer

#1 Post by jamesbond »

From the page:

mdview is a super light-weight, GTK-based markdown files viewer. It has no other dependencies other than GTK itself. It reads and displays text files in (a subset of) markdown format, and provide live links to other files as well as to the Internet. It is ideal for showing help files (its original purpose), user manuals, and other small set of hyperlinked markdown files.

Subset of markdown that mdview supports:

* Heading level 1,2,3
* Horizontal rules
* Single-level bullets (but no ordered list)
* Inline-code and codeblocks
* Hyperlinks (format is a simplified version of original markdown)
* Inline images
* Inline formatting: italic, bold, smart double/single quotes, em-dash.

Compiles down to only 60K. No further dependency other than GTK.

Get it from here: https://chiselapp.com/user/jamesbond/re ... view3/home

-----
EDIT: Markdown files are plain text files with some human-readable formatting added. Markdown files are created and editable using standard text editor. mdview only supports a limited subset; the formatting that it supports is given in example/index.md.

-----
EDIT: mdview now can converts markdowns to plain text, decorated plain text (with vt100 bold/underline codes), and html too.
Last edited by jamesbond on Tue 19 May 2015, 15:37, edited 2 times in total.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#2 Post by 01micko »

Works well with github markdown 8)


A few typos in the help on the cli.

Code: Select all

# ./mdview -h                                                 
mdview - (C) Leandro Pereira 2009, James B 2015.

Usage: mdview [directory [file [home [title]]]]
 - directory where the files arem if not specified, current directory.
 - file to open, if not specified, index.md is used.
 - home file. f not specified, index.md is used.
 - title - window title, if not specifieid, mdview is used
You can skip parameters by specifying blanks. 

# ./mdview /mnt/sda6/git-repos/pmcputemp-builds/pmcputemp-0.63 home README.md
(ha, not the only one with typos .. read my screeny!)
Attachments
md.jpg
(53.56 KiB) Downloaded 1144 times
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#3 Post by L18L »

### is not h3 but link to png

working `inline code` would be nice.

:wink:
Attachments
index.md.gz
save as...
/usr/share/doc/index.md
(5.4 KiB) Downloaded 538 times
fd.png
Glued with PeasyGlue
(108.54 KiB) Downloaded 1094 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Fatdog's Home

#4 Post by L18L »

re-uploaded index.md

download to /usr/share/doc/index.md

launch by:

Code: Select all

mdview /usr/share/doc "" "" "Fatdog's Home"
... there will be a title too.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#5 Post by 01micko »

How about a run action?

Code: Select all

#!/bin/sh
DIR=${@%/*}
FILE=${@##*/}
HOME=$FILE
TITLE=${FILE%.*}
mdview $DIR $FILE "$HOME" "$TITLE"
text_x-markdown (replace the current symlink in fatdog)

In older pups with older shared-mime-info it is reported wrongly as application_x-genesis-rom .. see https://bugs.freedesktop.org/show_bug.cgi?id=27441
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

mdview, a markdown viewer

#6 Post by L18L »

Looks like there is just one link allowed in a "paragraph".

This is working:

Code: Select all

Over the time, Fatdog migrated to support 64-bit platform (hence Fatdog64 name) and grew became an independent distribution of its own - while striving to keep the original spirit of Puppy Linux of being small, fast, and versatile. For a fuller history [http://distro.ibiblio.org/fatdog/web/history.html click here].

Fatdog64 700 series - the latest iteration of Fatdog64 - is
hand-built based on recipes from [http://linuxfromscratch.org Linux From Scratch], version 7.5 (the latest when the Fatdog64 700 alpha1, the first
public release of Fatdog64 700, was released).

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#7 Post by jamesbond »

Thanks guys for the feedback, you keep me busy :)
- ah, the typo :(
- executable code is not in markdown spec, so I prefer not to extend it. Or, perhaps, I can add a command line switch to enable this extra feature.
- The ### bug is confirmed. This is because the original code does not support links, Leandro use some hack to enable it (I think by marking text with underlines), so everything that has underlines is taken as links.
- line can only have one link bug is also confirmed.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#8 Post by jamesbond »

All done except L18L's executable code request. Fossil updated.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#9 Post by jamesbond »

L18L's suggestion now implemented. Use $(xxx) to do it, and you need to specify "-x" on the command line. The code is very simplistic, nested $() is not supported e.g. $(echo $(echo a)) will *surely* fail.

I also added non-standard strikethrough, using --- (3 dashes). So 3-dashes now have mutliple functions. Just make sure that these dashes does not begin a line, otherwise it will be taken as either a ruler, or as a marker for header #2.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

mdview, a markdown viewer

#10 Post by L18L »

jamesbond wrote:L18L's suggestion now implemented. Use $(xxx) to do it, and you need to specify "-x" on the command line. The code is very simplistic, nested $() is not supported e.g. $(echo $(echo a)) will *surely* fail.
Thanks jamesbond, you keep me busy.
Tested:

Code: Select all

![Fatdog](faqs/fatdog.png) 
# Fatdog 64-bit GNU/Linux Operating System

$(TEXTDOMAIN=fatdog; gettext Cancel)

$(gettext fatdog Quit)

$(gettext  'Cancel and Quit')
The first two work.
Last one not. We need ' inside $().
Re-produce it by:

Code: Select all

LANGUAGE=de mdview -x  /usr/share/doc home.md "" "Fatdog's Home"
Attachments
single_word_is_OK.png
(19.61 KiB) Downloaded 960 times

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

Re: mdview, a markdown viewer

#11 Post by jamesbond »

L18L wrote:Thanks jamesbond, you keep me busy.
And I will make you even busier. Fossil updated :twisted:
This now works:

Code: Select all

$(echo '$LANG') is $(echo $LANG) 

$(echo '$LANG' is $LANG)
Btw - the output of $() *will* be interpreted as markdown code. Output of $(echo **bold**) will be shown as bold. But again, please don't nest $() or get too smart with it - the code inside is simple and stupid :lol:
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: mdview, a markdown viewer ready for global use

#12 Post by L18L »

Cannot use ( ) in text.
Replaced it by --....--

Sorry if have killed an apostrophe without real need.
$(gettext 'here apostrophe can't be used')
$(gettext 'here apostrophe can\'t be used')
$(gettext "here apostrophe can be used")
review text please.

Code: Select all

mdview -x  /usr/share/doc home.md "" "Fatdog's Home"
Attachments
heim.png
(36.9 KiB) Downloaded 911 times
home.md.gz
/usr/share/doc/home.md
(5.94 KiB) Downloaded 527 times

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

Re: mdview, a markdown viewer ready for global use

#13 Post by jamesbond »

L18L wrote:Cannot use ( ) in text.
Replaced it by --....--
Ah yes, because the ")" will end the $( prematurely. As I said the code is simple and stupid. Let me see if I can make it smarter. I'll be back.
Sorry if have killed an apostrophe without real need.
$(gettext 'here apostrophe can't be used')
$(gettext 'here apostrophe can\'t be used')
$(gettext "here apostrophe can be used")
review text please.
In this case, you will need to do
$(gettext 'here apostrophe can '\''be used')
That is, you end the single-quote, add a \', and then start the single-quote again. Tthe same way how you single-quote strings in shell, too.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: mdview, a markdown viewer ready for global use

#14 Post by L18L »

jamesbond wrote:I'll be back.
No sleep tonight? :shock:

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

Re: mdview, a markdown viewer ready for global use

#15 Post by jamesbond »

L18L wrote:No sleep tonight? :shock:
:twisted: Try it. Attached test cases in examples.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: mdview, a markdown viewer ready for global use

#16 Post by L18L »

jamesbond wrote:Try it.
Tried.
All right.
Going to convert entire FAQ to mdview..... :wink:

Help can be launched by:

Code: Select all

export TEXTDOMAIN=fatdoghelp; mdview -x  /usr/share/doc/faqs ../home.md "" "Fatdog"
for now.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: mdview, a markdown viewer ready for global use

#17 Post by L18L »

L18L wrote:Going to convert entire FAQ to mdview.....
done
see Fatdog thread please.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: mdview, a markdown viewer ready for global use

#18 Post by L18L »

Fatdog64's docs/faq are going to use this markdown format,
extension .md, to be viewed with mdview.

In order to enable SURE translations we are using GNU gettext.

gettext has 2 parameters:
1st is textdomain, (name of the .mo file)
2nd is the translatable message string (msgstr).
If it is one paramter only
then environment variable TEXTDOMAIN is being used.

Example:

Code: Select all

$(gettext fatdoghelp "The VLC media player in Fatdog64 can support BluRay playback.")
Space is cheap but there is no reason for wasting bytes.

Code: Select all

alias _=gettext
usually used with C sources would be nice
but does not work because _ is a markdown tag
and alias cannot be used in mdview AFAIK.

But this little wrapper /usr/bin/t_ does work:

Code: Select all

#!/bin/sh
gettext fatdoghelp "$1"; echo
... and above line is just:

Code: Select all

$(t_ "The VLC media player in Fatdog64 can support BluRay playback.")
___________________________________

How much saved?
About

Code: Select all

$((16 * `grep msgid fatdoghelp.pot | wc -l` / 1024))
= 23 kB.
Not that much but it is looking much nicer.
___________________________________

Speed?

Or an implementation of alias (alias t_=gettext) in mdview?

Code: Select all

$(t_ fatdoghelp"The VLC media player in Fatdog64 can support BluRay playback.")
___________________________________

poor man's solution?

Or maybe just renaming the textdomain?

Code: Select all

$(gettext fh "The VLC media player in Fatdog64 can support BluRay playback.")
___________________________________

Or both?

Code: Select all

$(t_ fh "The VLC media player in Fatdog64 can support BluRay playback.")
___________________________________

Your choice.
___________________________________

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#19 Post by disciple »

https://github.com/visionmedia/mad
Guys, have you considered compatibility with mad?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#20 Post by musher0 »

Hi, guys.

This viewer looks absolutely splendid, except for the obvious:
Maybe I'm missing a nut and a bolt (which is entirely likely!), :) but:

what editor do you use to create the marked text to be viewed? :shock:

Thanks in advance.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply