Comments (13)
Mmmm, thanks again. Anyway I think the effort is doomed to fail because variable expansion doesn't seem to work for inputs:
"inputs": [
{
"id": "preview-html",
"type": "command",
"command": "livePreview.start.preview.atFileString",
"args": "${relativeFileDirname}/${fileBasenameNoExtension}.html"
}
]
I guess I'm going to manually open the preview :(
from vscode-livepreview.
@andreamah it looks like we don't resolve arguments, so at the moment, it's up to the extension to do so
from vscode-livepreview.
You can use the command palette to run > Live Preview: Show Preview
. If you want it to update when the script updates it, you can set "livePreview.autoRefreshPreview": "On Changes to Saved Files"
in your settings. Does this help?
from vscode-livepreview.
Not really. What you describe is exactly what I'm doing now. I'm not saying it's bad, just that it requires to load the html first, which is a byproduct of a compilation, I'm not actually working on the html itself. I would like that this watchdog could invoke code <url>
or code <html>
after the compilation and then the preview automatically opens. Perhaps code <html>
would conflict with the intention of opening the source html instead, which one may argue is the natural behavior for a text editor, but I guess there is some way to define a url that's handled by a particular extension, isn't there?
from vscode-livepreview.
Oh, are you looking for something that can be invoked via a command of some sort to preview? We had an issue here #368 about having a 'call' for starting the server, but that didn't include previewing. There's also a way of configuring a task to preview, which you could attach to a keybinding: #388. I think that might be the closest to what you want you could use.
from vscode-livepreview.
That may be useful indeed. I'm already running the watchdog from a background task so I guess I could add to it a dependency on a new task that opens the preview. I'm going to give it a try. I'm closing this for now and in any case I'll reopen it if I run into further difficulties. Thanks!
from vscode-livepreview.
Just one more question related to this, if you don't mind:
"On Changes to Saved Files"
I was using this setting but I realized that there were lots of extra reloadings, so I ended up turning autoreload off and opening a websocket client in the page then notifying it from the watchdog after each successful compilation.
Just to understand, the previewer has no notion of which file is being previewed, right? So every open file in the workspace or similar is monitored for save events?
This is unfortunate in my case because the sequence is more or less like this:
- I save the markdown file I'm editing
- The watchdog triggers a compilation and at almost the same time the page is reloaded
- The compilation generates an updated html
So the previewer may have updated the page too early, and since the html is not open nor explicitly saved from Code, but just changed at the filesystem level, I'm afraid its changes may not be displayed.
from vscode-livepreview.
Yes, unfortunately, that is what happens. the refresh will trigger on any workspace change because it's more complicated to follow what would change based on which file changes. You can try modifying livePreview.previewDebounceDelay
to a larger number, then perhaps it will just refresh once and on time.
from vscode-livepreview.
I see, fortunately I was able to work around that.
I'm trying to follow your advice regarding #388 (comment), but bumping into:
2024-03-08 15:56:54.510 [error] [Extension Host] Tried to open a non-file URI with file opener
2024-03-08 15:56:54.514 [error] The "path" argument must be of type string. Received undefined: Error: The "path" argument must be of type string. Received undefined
I tried using a url-like expression like "args": "file:///Users/carlos/Desktop/test.html"
but to no avail.
from vscode-livepreview.
Oh, this fixed the issue: #388 (comment)
Anyway I would like to understand the problem above. Does atFile
expect a URL object that can't be conveyed by using a URL string representation from tasks.json?
from vscode-livepreview.
I think that a full absolute path like C:/Users/andreamah/OneDrive - Microsoft/Documents/vscode-livepreview/test-workspace/page0.html
worked for me. So if you look at the comment you linked and replace the "{path_to_preview}" to a string like what I have above.
from vscode-livepreview.
I believe that the URI parser had difficulty parsing that string for some reason- aka calling vscode.Uri.file()
on it errored out.
from vscode-livepreview.
@meganrogge curious: is variable expansion supposed to work here, or is this handled by the individual extension?
"inputs": [ { "id": "preview-html", "type": "command", "command": "livePreview.start.preview.atFileString", "args": "${relativeFileDirname}/${fileBasenameNoExtension}.html" } ]
from vscode-livepreview.
Related Issues (20)
- Can't find the live preview icon HOT 15
- it is not working HOT 1
- The IP address "192.168.XXX.9" cannot be used to host the server. Using default IP 127.0.X.X. HOT 2
- it is not working properly HOT 1
- Live Preview Button not showing HOT 8
- Feature Request: Support for multiple Live Preview Windows HOT 1
- live preview not showing up while using Github Repositories extension HOT 1
- just white,cannot work normal HOT 8
- preview HOT 3
- Click on tags/elements in HTML and jump to it in HTML document HOT 2
- live server HOT 1
- Launch as http://localhost instead of http://127.0.0.1? HOT 6
- PHP support HOT 1
- It becomes Dark!!! HOT 1
- xaml后续能支持吗 HOT 1
- An unknown error occurred. Please consult the log for more details. HOT 2
- Not working HOT 11
- Problem with "charset=ISO-8859-1" HOT 6
- Add a "Start Preview" button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-livepreview.