Bug 405386 - RKWard Version 0.7.0z+0.7.1+devel1 can't preview Markdown
Summary: RKWard Version 0.7.0z+0.7.1+devel1 can't preview Markdown
Status: RESOLVED FIXED
Alias: None
Product: rkward
Classification: Applications
Component: User Interface (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: RKWard Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-12 08:25 UTC by Adley
Modified: 2020-05-03 20:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot (277.12 KB, image/jpeg)
2019-03-12 08:25 UTC, Adley
Details
File generated by preview (614.32 KB, text/html)
2019-03-13 03:57 UTC, Adley
Details
rk.sessionInfo() (1.99 KB, text/plain)
2019-03-13 17:01 UTC, Adley
Details
file mime type (112.48 KB, image/jpeg)
2019-03-13 18:58 UTC, Adley
Details
which_rkward (25.54 KB, image/jpeg)
2019-03-18 14:11 UTC, Adley
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adley 2019-03-12 08:25:36 UTC
Created attachment 118739 [details]
screenshot

Markdown can't display properly in the preview window, but it can open correctly in browser.

please read the attachment for the screenshot
Comment 1 Thomas Friedrichsmeier 2019-03-12 10:21:53 UTC
Interesting problem. For some reason the preview is shown as plain text, rather than as rendered HTML.

I don't see this, here. Therefore, first question, how old exactly is the build you are using? (It is a development build, and the preview-functionality was added in this development cycle - possibly you are using an intermediate state, where the preview functionality was still buggy).

If updating to a more recent snapshot does not help:
1) Do you see the same problem for "R Console" preview mode?
2) Does rk.show.html() work for you, when used with a local HTML file?

Regards
Thomas
Comment 2 Adley 2019-03-13 03:19:50 UTC
How old exactly is the build you are using?
   I am using the last snapshot. 
   It worked fine before the snapshot "a new export plugin".
   

1) Do you see the same problem for "R Console" preview mode?
   Yes, it works fine for "non-markdown"  

2) Does rk.show.html() work for you, when used with a local HTML file?  
   Yes, rk.show.html() works fine.
Comment 3 Adley 2019-03-13 03:23:23 UTC
(In reply to Adley from comment #2)
> How old exactly is the build you are using?
>    I am using the last snapshot. 
>    It worked fine before the snapshot "a new export plugin".
>    
> 
> 1) Do you see the same problem for "R Console" preview mode?
>    Yes, it works fine for "non-markdown"  
> 
> 2) Does rk.show.html() work for you, when used with a local HTML file?  
>    Yes, rk.show.html() works fine.

sorry for typo,

1) Do you see the same problem for "R Console" preview mode?
   No, it works fine for "non-markdown"
Comment 4 Adley 2019-03-13 03:57:08 UTC
Created attachment 118763 [details]
File generated by preview
Comment 5 Adley 2019-03-13 04:10:57 UTC
I found something.
It work properly after I removed the attributes 

"xmlns="http://www.w3.org/1999/xhtml" from

<html xmlns="http://www.w3.org/1999/xhtml"> in output.html

regards
Comment 6 Thomas Friedrichsmeier 2019-03-13 07:27:58 UTC
Interesting observation. But for me, the xmlns-line does not cause any trouble, and I'm not sure, why it should.

Sorry, if I need to insist: How *exactly* did you install RKWard. Is it directly from git? Or did you download a package? If so, where from, exactly?

Also, the output of rk.sessionInfo() may be useful, as this could be a bug in Qt/KDE libraries, and so I'd like to know the version numbers of those.

Finally, I was not asking specific enough with question number 2: Does rk.show.html() work, correctly, when pointed to the preview file (without removing the xmlns)?
Comment 7 Adley 2019-03-13 17:01:52 UTC
Created attachment 118778 [details]
rk.sessionInfo()

For question number 2: 
    rk.show.html(), Preview->R Markdown and Preview->R Console are the same; 
    They can't work properly to the "output.html", but Preview->R Console 
    shows a message: 
        Warnings or Errors: 
           Error in attr(exprs, "srcref")[[i]] : subscript out of bounds
    I think it means the attr "xmlns".

Yes, you right. I think it might be related to my installation steps, since it works in kdevelop without removing the "xmlns".

My installation steps as below:
Fist, I list all the dependencies I installed.
kf5-kdewebkit-devel.x86_64    kf5-ktexteditor-devel.x86_64  kf5-kdoctools-devel.x86_64 R-devel.x86_64 extra-cmake-modules.noarch  qt5-qtscript-devel.x86_64 kf5-knotifications-devel.x86_64 kf5-kxmlgui-devel.x86_64 kf5-kwidgetsaddons-devel.x86_64 kf5-kdbusaddons-devel.x86_64 kf5-kconfigwidgets-devel.x86_64 kf5-ki18n-devel.x86_64 kf5-kwindowsystem-devel.x86_64 kf5-kcrash-devel.x86_64

get the snapshot from github kde mirror
1. mkdir build; cd build 
2. cmake /home/user/rkward-master/ -DR_LIBDIR='/home/user/R/x86_64-redhat-linux-gnu-library/3.5'
3. make
4. make install
Comment 8 Thomas Friedrichsmeier 2019-03-13 17:51:16 UTC
Ok, thanks, at least the pattern makes a bit more sense, now.

The subscript out of bounds on console preview simply means you did not have statment (only perhaps comments) in the script. I'll try to improve that error message, but it's something all different.

Could you run
  file --mime-type -b output.html
on the preview file, before and after removing the "xmlns"? For me it shows "text/html" in both cases, but I suspect it will show something else for you.
Comment 9 Adley 2019-03-13 18:58:20 UTC
Created attachment 118784 [details]
file mime type

They are the same "text/html"

Thanks.
Comment 10 Thomas Friedrichsmeier 2019-03-13 20:54:03 UTC
I'll have to admit, I don't quite get it. What I suspect is at play, is that somehow your system is configured to open XHTML files as text. You may want to check the File Associations section in your System Settings, particularly the "Embedding" tab.

*However*, I tried reproducing your issue, here, by fiddling with these settings, and failed.

You can probably "fix" the problem, by removing the string "KPartsIntegration | " from rkward/windows/rkhtmlwindow.cpp, as this will limit our HTML window to always showing rendered HTML, instead of an appropriate KPart (in this case a ktexteditor part).

I'm not quite sure what side-effects this might be causing, though.
Comment 11 Adley 2019-03-15 05:33:29 UTC
removing the string "KPartsIntegration | " from rkward/windows/rkhtmlwindow.cpp seems not work.

I installed RKWard in a new virtualbox images, still can't display properly.

It's seems hard to figure out in a short time.
Comment 12 Thomas Friedrichsmeier 2019-03-15 07:40:53 UTC
> removing the string "KPartsIntegration | " from rkward/windows/rkhtmlwindow.cpp seems not work.

Are you sure? The thing you have there is clearly a katepart, and I absolutely do not see where else it would come from. Please double check whether you are actually running the fresh-compiled binary: run "(sudo) make install" after "make", and start rkward with a full path to the binary.
Comment 13 Adley 2019-03-15 20:41:05 UTC
I uploaded my whole process to youtube.

https://www.youtube.com/watch?v=vRoZGoIAnkQ

Thanks
Comment 14 Thomas Friedrichsmeier 2019-03-17 20:01:15 UTC
Hi!

Thanks for the video. What I *believe* is happening is that your rkward is getting installed to

   /usr/local/bin/rkward

but you *probably* also have /usr/bin/rkward from an earlier installation. Thus, when you type "rkward", the old installation will be started. Try "which rkward", or start as "/usr/local/bin/rkward", explicitly!
Comment 15 Adley 2019-03-18 14:11:09 UTC
Created attachment 118881 [details]
which_rkward

Hi,

No other version of RKWard installed. I had reinstalled the OS before recorded the video. 

Thanks
Comment 16 Thomas Friedrichsmeier 2019-03-18 16:57:11 UTC
Alright, I give up: What distribution (version) exactly, and how much space will I need in a virtual machine?
Comment 17 Adley 2019-03-18 22:13:47 UTC
Hi,

  it seems can plugs and play the image: https://www.osboxes.org/fedora/

R version 3.5.2 (2018-12-20)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 29 (Workstation Edition) gnome

dependencies:
kf5-kdewebkit-devel.x86_64    kf5-ktexteditor-devel.x86_64  kf5-kdoctools-devel.x86_64 R-devel.x86_64 extra-cmake-modules.noarch  qt5-qtscript-devel.x86_64 kf5-knotifications-devel.x86_64 kf5-kxmlgui-devel.x86_64 kf5-kwidgetsaddons-devel.x86_64 kf5-kdbusaddons-devel.x86_64 kf5-kconfigwidgets-devel.x86_64 kf5-ki18n-devel.x86_64 kf5-kwindowsystem-devel.x86_64 kf5-kcrash-devel.x86_64
Comment 18 Thomas Friedrichsmeier 2019-03-19 15:39:17 UTC
I loaded the Fedora 29 image in VirtualBox, installed rkward (from git), and pandoc, and installed package rmarkdown inside rkward.

Bug does not occur for me.

Can you reproduce the bug in a fresh Fedora 29 image installed from https://www.osboxes.org/fedora/ ?
Comment 19 Adley 2019-03-20 07:45:14 UTC
Hi, 
  The issue occurred after system update.
  
  Please update the system with "sudo dnf update -y" (roughly hundreds of updates) and try again.

Thanks
Comment 20 Thomas Friedrichsmeier 2019-03-20 19:38:08 UTC
Git commit 9028a6413f77059ad812825c4c1e0eaab82a3626 by Thomas Friedrichsmeier.
Committed on 20/03/2019 at 19:37.
Pushed by tfry into branch 'master'.

Allow to handle all supported content types, instead of hard-coded text/html .

M  +5    -4    rkward/windows/rkhtmlwindow.cpp

https://commits.kde.org/rkward/9028a6413f77059ad812825c4c1e0eaab82a3626
Comment 21 Thomas Friedrichsmeier 2019-03-20 19:45:25 UTC
Ok, I can finally see the bug. First problem is in fact that after the update QMimeDatabase will no longer recognize the file as text/html, but rather application/xhtml. Not sure, whether that is a bug or not, i.e. whether the problem will soon go away, or proliferate to all other systems...

The rendered file has some contradicting information on what type it is. But in fact it is *not* valid XHTML. Which is where the next problem lingers: I have now changed the code so that QWebPage will *try* to render the file, *but* QWebPage is very strict about XHTML validity, and so it will report a validity error, instead of displaying anything.

I'll probably have to find a way to force html-mode for XHTML, ugly as that will be. Hang on.
Comment 22 Thomas Friedrichsmeier 2019-03-28 08:47:11 UTC
Git commit a0d72bb050c5e3280e0df8712d0b73ddf1a4e121 by Thomas Friedrichsmeier.
Committed on 28/03/2019 at 08:46.
Pushed by tfry into branch 'master'.

Experimental workaround for 405386 .

M  +9    -1    rkward/windows/rkhtmlwindow.cpp

https://commits.kde.org/rkward/a0d72bb050c5e3280e0df8712d0b73ddf1a4e121
Comment 23 Adley 2019-05-01 19:52:19 UTC
Hi,
 
  Everything works excellent for me now. 
  Should I close this ticket?