mdview, a markdown viewer

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

#46 Post by L18L »

step wrote:I tried to make me like this type of convenience several times, but I couldn't convince myself for the following reasons:
1. mdview is not a puppy standard, it's a Fatdog add-on.
You forgot to say: It is new!
[EDIT]And you forgot to say: it is not an Ubuntu standard...[/EDIT]
step wrote:2. mdview markdown support has some limits
Everything has some limits.
step wrote:3. What are the advantages of creating HTML documentation and giving that out to translate vs giving the md file out to translate? I still need to figure that out.
Give out is publish?
Both of these are not good in my opinion as translators have to know some rules of html or mdview's markdown.
Translators are used to translate msgid to msgstr.
step wrote:If the perceived benefits aren't readily apparent, gettexting md files is a hard sell, IMO.
There isn't anything to sell.

It is all free.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

bug report

#47 Post by step »

@jamesbond, I think I found a bug. Attached an md file to reproduce the issue. Essentially, when a line starts with [2] and includes matching brackets the text between [2] and the brackets included disappears. Version 2016.02.04 built on Thu Feb 4 07:09:52 2016.
Attachments
mdview-bug-report-1.md.fake.gz
(1.57 KiB) Downloaded 306 times
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

fenced blocks and gettext

#48 Post by step »

@jamesbond, there's another issue concerning fenced code blocks and translations. I just realized that mdview --po doesn't output the text inside fenced blocks. On one hand that makes sense - it's source code after all - on the other hand it is a problem, because that text becomes invisible to the translation process, so it's hard to realize that it even exists before deciding if it should be translated or not.

There are valid cases for using fenced blocks for text other than source code, which should therefore be translated. So I'm proposing a work-around which I think doesn't break the fenced block syntax.

Code: Select all

```
this text is pre-formatted and hidden to gettext
```
vs.

Code: Select all

```gettext
this text is pre-formatted and it's also gettexted
```
This should work, since GFM fenced blocks can take an optional language tag to select appropriate syntax highlightling rules. GFM seems to ignore unknown tags, so here 'gettext' is passed as a language tag but mdview interprets it as an operational directive. What do you think?

----
Reproduce issue by

Code: Select all

# cat >> /tmp/zz.md
HAL's typewriter ticked a message:
```
I can't let you do that, David, I can't let you turn me off.
```
David was afraid.

# mdview --po /tmp/zz.md
#: //tmp/zz.md:1
msgid "HAL's typewriter ticked a message:"
msgstr ""

#: /tmp/zz.md:5
msgid "David was afraid. "
msgstr ""
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

update on bug reported two posts above

#49 Post by step »

@jamesbond, here's another test case for the bug reported two posts above

Code: Select all

 * Run mdview[3] to test your translation of markdown files (see below)
This is rendered as "* Run mdview3" and nothing else.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

proposed patch Re: fenced blocks and gettext

#50 Post by step »

@jamesbond
step wrote:...I'm proposing a work-around which I think doesn't break the fenced block syntax.

Code: Select all

```gettext
this text is pre-formatted and it's also ouput with mdview --po
```
I'm attaching a patch file, which implements the above work-around, for you and anyone else interested to review. Patch file against fossil 4fb552f2b09ca5ec 2016-02-04 07:11:16.

I still haven't started debugging the other issue I reported.

edit 20160223 I'm attaching a second patch file, which contains the first one. This file adds tests for the proposed patch and turns off translation of GitHub codeblocks unless they are marked "```gettext```". I'm not sure if you left translations enabled for GH codeblocks intentionally, but I think that disabling translations is consistent with all other types of codeblocks. Once again, "```gettext```" has a dual purpose, 1) enable outputting codeblock text with option --po, and 2) translating such text in normal operation.
Attachments
codeblock-gettext-2.patch.gz
Delete fake .gz extension
(6.66 KiB) Downloaded 272 times
codeblock-gettext.patch.gz
Delete fake .gz extension
(4.19 KiB) Downloaded 276 times
Last edited by step on Tue 23 Feb 2016, 17:09, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

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

Re: bug report

#51 Post by L18L »

step wrote:@jamesbond, I think I found a bug. Attached an md file to reproduce the issue. Essentially, when a line starts with [2] and includes matching brackets the text between [2] and the brackets included disappears. Version 2016.02.04 built on Thu Feb 4 07:09:52 2016.


I don't know any thing about triple backticks
What I do know is: Brackets are used with external links.
[mdview](http://chiselapp.com/user/jamesbond/rep ... iew3/index)

Tried to solve your problem, see screenshot.
Attachments
use_escape_with_markdown.png
Note escapes
(25.48 KiB) Downloaded 377 times

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

Re: bug report

#52 Post by step »

Hi L18L, thanks for your help. Your work-around shows that mdview can create correct output when "\[2\]" replaces "[2]" in the example above. This is useful, but backslashes shouldn't be needed in a common markdown implementation, so I think mdview still needs to be fixed about this problem.

As far as I know, in markdown brackets immediately followed by parens (round brackets) introduce a link label and its link target, like so:
[label](target)
where the target can be a local file or a URL.

This bug concerns the case where there is extra text between the closing square bracket and the opening round bracket, like so:
[2] some (text)

It should not produce a link with 2 as the label and "some (text)" as the target. It should produce just the text "[2] some (text)".

wikipedia states that a markdown standard doesn't exist. However, most common markdown implementations render "[2] some (text)" as text and not as a link, unlike mdview.

You can test several markdown engines at once by visiting this link: http://johnmacfarlane.net/babelmark2/?t ... 5D(target)

(apparently if I wrap the above URL inside url bbcode this post renders as an empty box)
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

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

Re: bug report and "translated pre-formated" text

#53 Post by L18L »

step wrote:wikipedia states that a markdown standard doesn't exist. However, most common markdown implementations render "[2] some (text)" as text and not as a link, unlike mdview.

You can test several markdown engines at once by visiting this link: http://johnmacfarlane.net/babelmark2/?t ... 5D(target)
Thanks for this interesting link.

However, I am not interested in markdown engines other than mdview.
It is clearly stated to support a subset of markdown.
This subset has been working good enough for Fatdog's Help which does not use reference-style links
... and not need translated pre-formated text.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

Re: bug report and "translated pre-formated" text

#54 Post by step »

L18L wrote: This subset has been working good enough for Fatdog's Help which does not use reference-style links
... and not need translated pre-formated text.
Findnrun needs the latter. That's why I'm proposing patches. I'm careful not to break existing code, and it's all intentional anyway, since Jamesbond will review my patches and decide whether they can go in or not.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

text links proposed patch

#55 Post by step »

@jamesbond, for your consideration, here is a proposed patch for the text links issue I reported earlier. It affects function egg_markdown_to_text_line_formatter_links. Note: I didn't patch image links, function egg_markdown_to_text_line_formatter_image, in a similar fashion, because in practical use I don't expect this issue to occur for image links.

The patch file is made against the source code already patched for code blocks. A markdown test file is attached.

I should make clear that this patch doesn't concern so-called reference-style links, which I don't think mdview supports. It's a patch for regular text links.
Attachments
text-links-patch.md.fake.gz
remove .fake.gz extension
(1.77 KiB) Downloaded 269 times
text-links.patch.fake.gz
remove .fake.gz extension
(2.36 KiB) Downloaded 287 times
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

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

#56 Post by jamesbond »

step, all patches applied (both codeblock-gettext and text-links patch): https://chiselapp.com/user/jamesbond/re ... 3/timeline

Thank you.
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:

#57 Post by 01micko »

In the very latest build (recently pushed to petbuilds) everything seems to be working fine - but I have a feature request.

The files from puppylinux.com (which are in markdown format - converted to html server side) open fine on my local machine - but if there is a wide image it can't be viewed (re the timeline). I wonder if it is feasible to add a horizontal scrollbar? Mind you, this is probably beyond the scope of the project so I understand if you'd rather keep it simple. :)
Puppy Linux Blog - contact me for access

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

#58 Post by jamesbond »

01micko wrote:I wonder if it is feasible to add a horizontal scrollbar?
Turns out it's a one line change:

Code: Select all

--- help-viewer.c
+++ help-viewer.c
@@ -599,11 +599,11 @@
 #endif	/* GTK_CHECK_VERSION(2,16,0) */
 	
     scrolledhelp_viewer = gtk_scrolled_window_new (NULL, NULL);
     gtk_widget_show (scrolledhelp_viewer);
     gtk_box_pack_start (GTK_BOX (vbox), scrolledhelp_viewer, TRUE, TRUE, 0);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledhelp_viewer), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledhelp_viewer), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
     markdown_textview = markdown_textview_new();
     markdown_textview_set_image_directory(MARKDOWN_TEXTVIEW(markdown_textview), help_dir);
     markdown_textview_set_exec(MARKDOWN_TEXTVIEW(markdown_textview),enable_exec);
     markdown_textview_set_use_gettext(MARKDOWN_TEXTVIEW(markdown_textview),use_gettext);
I will update this in fossil 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
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#59 Post by 01micko »

jamesbond wrote:
01micko wrote:I wonder if it is feasible to add a horizontal scrollbar?
Turns out it's a one line change:

Code: Select all

--- help-viewer.c
+++ help-viewer.c
@@ -599,11 +599,11 @@
 #endif	/* GTK_CHECK_VERSION(2,16,0) */
 	
     scrolledhelp_viewer = gtk_scrolled_window_new (NULL, NULL);
     gtk_widget_show (scrolledhelp_viewer);
     gtk_box_pack_start (GTK_BOX (vbox), scrolledhelp_viewer, TRUE, TRUE, 0);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledhelp_viewer), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledhelp_viewer), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
     markdown_textview = markdown_textview_new();
     markdown_textview_set_image_directory(MARKDOWN_TEXTVIEW(markdown_textview), help_dir);
     markdown_textview_set_exec(MARKDOWN_TEXTVIEW(markdown_textview),enable_exec);
     markdown_textview_set_use_gettext(MARKDOWN_TEXTVIEW(markdown_textview),use_gettext);
I will update this in fossil too.
Image
Attachments
mdview.jpg
(38.35 KiB) Downloaded 281 times
Puppy Linux Blog - contact me for access

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#60 Post by Sailor Enceladus »

For some reason, mdview doesn't seem to show this md file at all. Viewing it in Leafpad or in that link (with Firefox) works ok.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#61 Post by step »

Sailor Enceladus wrote:For some reason, mdview doesn't seem to show this md file at all. Viewing it in Leafpad or in that link (with Firefox) works ok.
Jamesbond fixed a couple of bugs that affect page views very recently. I have uploaded a courtesy build (32 and 64 bit) here. mdview 2016.06.17 built on Fri Jun 17 07:01:19 2016 - it doesn't include the horizontal scrollbar.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#62 Post by Sailor Enceladus »

step wrote:
Sailor Enceladus wrote:For some reason, mdview doesn't seem to show this md file at all. Viewing it in Leafpad or in that link (with Firefox) works ok.
Jamesbond fixed a couple of bugs that affect page views very recently. I have uploaded a courtesy build (32 and 64 bit) here. mdview 2016.06.17 built on Fri Jun 17 07:01:19 2016 - it doesn't include the horizontal scrollbar.
Thanks. That one had the same issue though, it seems to get confused by markup lines like this:

*** text ***

Which apparently means both bold and italics, and it tries to close the bold before the italics but it opened the bold first so it gets confused because the italics is still open and bails out completely. You can click on the "Raw" button to save it to test.

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

#63 Post by jamesbond »

Fixed in last commit.

Just don't try to use **** or ***** :twisted:
mdview has a simple, stupid parser. It won't cope with abomination like that :twisted:
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]

Post Reply