Closed jhongiv closed 3 years ago
I've got the same error on Atom 1.48.0
Sometimes second time preview is ok
I was able to trigger first render only by making a first action on the page (add newline, remove newline; renders correct.)
This has persisted for the last 3 releases for me. Current: 1.49.0 Debian 9, 4.9.0-12-amd64
Only stuff in the console log is for ruby aligner, don't see anything particularly related to this.
It is still broken in Atom 1.49.0 on MacOS 10.15.6 when trying to display the default Jekyll start page.
@renemarcelo 's tip did work though. Thanks.
Just to update.
Same issue still on Atom 1.50.0
with macOS 10.15.6
and markdown-preview 0.160.2
. @renemarcelo's workaround still works though.
Same problem on Atom 1.50.0 on Ubuntu Mate 18.04.
Same here, 1.50.0
on Windows 10
Can't reproduce this issue when running atom in dev mode. The only one place where trim()
invokes in this extension is here https://github.com/atom/markdown-preview/blob/ae9f2e6e26015379eb138d991e3852b66ff16231/lib/renderer.js#L93
I think the issue may be caused by cherrio or dompurify, but here are no any errors in console output.
Huh, same here. It works when running in dev mode, but in regular mode it crashes with the r.trim
error.
Cheerio seems to be up to date, but DOMPurify is at version 1.0.10
. Maybe it needs to be upgraded? Still it would be better to track the issue first, I guess.
Yes, I confirm that starting atom --dev <my markdown file>
I may correctly display the markdown (my version is 1.51.0 on Ubuntu 20.04).
My install says that all packages are updated - and I don't see anything about any cherrio or DOMPurify package (?), how could they be seen if there are installed?
Same error on 1.51.0
on Ubuntu 18.04
As a workaround, running apm install markdown-preview
solved the problem for me.
If you then run apm uninstall markdown-preview
you get the error again.
This is strange because apm view markdown-preview
shows I am on version 0.160.2 both when running the built-in and the community version of the package.
I just tried @nachoalonso tip on Debian 10 and it seems to have solved it for me, too!
Very odd! but thanks! :smile:
However, this seems to trigger the deprecation cop:
You have the core package "markdown-preview" installed as a community package.
Weird, but It works for openSUSE Tumbleweed (20201014) and Atom 1.52
Same issue here "r.trim is not a function" with Atom 1.52.0x64 on MacOS Catalina 10.15.7.
Atom : 1.52.0 Electron: 6.1.12 Chrome : 76.0.3809.146 Node : 12.4.0
Figured I'd subscribe to this thread since I'm now troubleshooting.
Also, here's the README.md file I was trying to preview when the error appeared. README.txt
Please note, since GitHub does not support uploading .md files, I changed to extension to .txt.
I just had the same problem today, but it only shows when using the shortcut ctrl+shift+M. If I go to Packages>Preview HTML>Enable Preview it works. How odd.
Where do you have that? I only have Packages -> Markdown preview -> Toggle as you may see in the attached screenshot.
Same problem on MacOS 10.15.7, Atom 1.52.0 and markdown-preview 0.160.2
https://discuss.atom.io/t/version-1-4-7-and-markdown-preview/74943/16?u=wlwl2
There's a fix for it here. This is only temporary of course. I'm guessing that it's getting confused between Github Flavored Markdown and regular Markdown- I have to emphasize that this is totally a quick guess though.
Toolbar/Packages/markdown and selected Toggle GitHub style
Edit (21 Nov 2020): It's not working well. I have to keep toggling it on and off to fix the error now.
See my latest comment on using another package as a solution (if you don't mind using a non-official package with more features for markdown preview). https://github.com/atom/markdown-preview/issues/579#issuecomment-731472497
I tried this workaround. While it did work, as @wlwl2 mentioned, its only a temporary fix. I mean, selecting GitHub flavored (styled) markdown does get past the r.trim error (allowing the package to work), this certainly seems to be connected to the package’s theming functionlaity.
There's a workaround though (1.52.0):
r.trim is not a function
,I also noticed that in my ~/.atom/config.cson file I have
"markdown-preview":
useGitHubStyle: true
Mine appears a little further down the list in Packages. I am running Atom in a win10 machine, same version 1.52.0
If you don't mind using a better package to view markdown here is a clean fix (for now):
Windows 10.0.19041 Build 19041, Atom Version 1.53.0
Install markdown-preview-plus
(v 4.8.4).
It will automatically disable markdown-preview
. Just make sure that markdown-preview
from Core Packages is disabled.
Change Settings:
Packages that can affect preview rendering
:
Change from fonts
to *
.
I don't consider this optional even though it is, because I want the default atom markdown preview fonts restored.
Preview position synchronization behavior
:
Check Sync preview position when text in editor changes
.
Check Sync preview position when text editor is scrolled
.
Check Sync editor position when preview is scrolled
.
These 3 checkboxes are optional, but you should try them out first.
Same issue here: Mac OSX: 10.14.6 Atom: 1.53.0 x86
Same here. Windows 10 Atom: 1.53.0 x64
I need to press Ctrl+Shift+M (three times: error, close, normal)
The message "Previewing Markdown Failed r.trim is not a function" appears the first time I toggle Markdown Preview on, but the second time the content is rendered as expected. The same happens each time I quit Atom and restart it.
Mac 10.15.7 Atom: 1.53.0 x64
Just for the record, still there with
Ubuntu 20.10 Atom 1.53
and package markdown-preview-plus works around it (thanks, @wlwl2) (but it is odd that it imposes a new CSS..., oh well).
I have the same problem!
I had this problem and it went away when I put spaces between [the pound symbols] and [the header] i.e. instead of ##Title I changed it to ## Title
Same problem on Ubuntu 20.04 and atom 1.54.0 x64 ;-(
Right clicking on a file and choosing "Markdown Preview" worked Microsoft Windows [Version 10.0.19042.746] Atom 1.54.0
This reproduces a 100% for what seems like over a year now. Clean install on Ubuntu or macOS, create markdown file (file.md) and preview. If you make a small edit, like adding a space, it then suddenly works.
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H15
Atom : 1.54.0
Electron: 6.1.12
Chrome : 76.0.3809.146
Node : 12.4.0
IIRC the smal edit is not needed. Just requesting the render twice works the second time.
I confirm (on Ubuntu 20.04 with atom 1.54.0) - not twice but three times! The second time the rendering window closes, and the third time it renders markdown correctly.
Still there six months later. Atom 1.54.0, macOS 11.1.
I downloaded this specifically to edit and preview markdown. Entirely useless.
I noticed recently this behavior and I didn't have any issue at all before, since my last Desktop setup: I put it out there, maybe it helps somebody else as well with this nasty issue (at least who is running Ubuntu/snaps - maybe @eddelbuettel , @j75 this could be helpful..):
I came to this issue #579 in desperation and ran @nachoalonso workaround with the community package. https://github.com/atom/markdown-preview/issues/579#issuecomment-705827134 worked well but my atom App icon disappeared from the OS bar (that's where I thought about Ubuntu snaps! like "ups I did it again"-style by Britney Spears)..
I am not sure yet why or how and you probably know better, but I believe it may be linked to the way Ubuntu handles snaps and apps confinement - specifically this atom snap.
in /var/lib/snapd/desktop/applications/atom_atom.desktop
change
Icon=/snap/atom/263/usr/share/pixmaps/atom.png
to Icon=/snap/atom/current/usr/share/pixmaps/atom.png
where for me:
/snap/atom/263/ was an old snap that was magically deleted by the system :man_shrugging:
/snap/atom/270/ was a stale snap
/snap/atom/271/ was my latest and current one.
/snap/atom/current is a symlink in /snap/atom/
that points to the latest snap running on your system for that app (in my case it was 271).
This did the trick and popped back up the Atom icon.
apm uninstall markdown-preview
to remove the package CTRL+SHIFT+M works again and beautifully (no r.trim
error) :tada: :sunglasses:
ah one last note, you may want to consider refreshing your snaps and/or deleting the old stales ones if they are left laying around.
refs
(and credits :pray: go to:)
@nachoalonso (obviously for his first fix)
@majcherek2048 (for his reply on an old post https://github.com/atom/atom/issues/9667 that sparked the idea that led me to this fix the icon issue
@daviwil for his post and explanation on https://github.com/atom/atom/blob/master/packages/dalek/README.md
PS: I know I know! it's not a fix but just another workaround.. I do confide though in the dev community to understand the issue and maybe get it fixed.. let me know if this helped you too..
Thank you all for the answers ... I absolutely forgot this issue and now I find so many answers ... I have tried @nachoalonso solution, and it worked when restarting atom ... thank you very much ...
I don't use the snap (but a standard .deb
) and still have the problem so closing this seems premature.
The problem is solved? If not, this issue must not be closed.
It is not. As I wrote. I can write it again.
apt
, regular updates$ echo "## Headline" > testfile.md
$ atom testfile.md
$ # now pressing Control-M in the editor on `testfile.md`
I am not sure how much clearer we can make this.
As a workaround, running
apm install markdown-preview
solved the problem for me.
Yes, that works for me too (on Ubuntu 20.04 + Atom 1.54.0 x64), but when installing I noticed the following message :
The markdown-preview package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall markdown-preview` to uninstall it and then the version bundled
with Atom will be used.
Installing markdown-preview to ~/.atom/packages
So I would rather say that there's something wrong with the bundled package...
I am apparently using the bundled version, which is the one that fails:
$ dpkg -l | grep markdown-preview
$ apm uninstall markdown-preview
Uninstalling markdown-preview ✗
Failed to delete markdown-preview: No package.json found at /home/edd/.atom/packages/markdown-preview/package.json
$
But you are right: doing the opposite of what the message says works:
$ apm uninstall markdown-preview
Uninstalling markdown-preview ✗
Failed to delete markdown-preview: No package.json found at /home/edd/.atom/packages/markdown-preview/package.json
$ apm install markdown-preview
The markdown-preview package is bundled with Atom and should not be explicitly installed.
You can run `apm uninstall markdown-preview` to uninstall it and then the version bundled
with Atom will be used.
Installing markdown-preview to /home/edd/.atom/packages ✓
$
So if we
apm install markdown-preview
to ignore the (apparently bad) built-in versionthen things appear to work. At last. Thanks for the help!
For me, this is not solving a bug but just a way of avoiding it!
Completely agree. It requires an additional installation of the same package rather than, as I had done for a while, of an alternate package (namely markdown-preview-plus
). I like the default look better, so this beats hitting C-m
three times...
You'd think that someone with the resources of GitHub (and, hence, Microsoft) could fix this eventually...
…cough well, guess GitHub MS has other priorities editors/IDEs now. Apparently…
I still experience this on 1.54.0 on macOS Big Sur 11.2.1 (why did the ticket get closed?) I too can avoid it by typing a single character and forcing the preview to re-render, but as @j75 said: that is simply avoiding the bug, not fixing it.
This is still a problem, I don't want to use plugins but I think I'm going to have to. This is my first time using atom.
For some strange reason, it started working when I was about to open an issue.
Prerequisites
Description
Steps to Reproduce
Expected behavior:
Actual behavior:
Reproduces how often: always at first time preview. Sometimes second time preview is ok
Versions
Atom 1.47.0 markdown-preview 0.160.2
Additional Information
Previewing Markdown Failed r.trim is not a function