frederisk / wikitext-vscode-extension Goto Github PK
View Code? Open in Web Editor NEWA Visual Studio Code Extension that provides language support for Wikitext.
License: MIT License
A Visual Studio Code Extension that provides language support for Wikitext.
License: MIT License
G'day, thanks for this very useful extension. FYI, in v.3.7.0 bracket highlighting doesn't work at all on my machine. Nada, niente. In v.3.6.5 it works 99% fine; only issue is that highlighting of some closing brackets is delayed. I'm currently using the extension with VS Code 1.74.0 with macOS Catalina (10.15.7). If you need more information please let me know. Cheers, Lucas
Any way to add in some additional tags that are used a lot in writing templates?
autoClosingPairs:
- - <includeonly>
- </includeonly>
- - <noinclude>
- </noinclude>
- - <onlyinclude>
- </onlyinclude>
I've been writing a lot of templates lately and it's definitely a lot of work to not have any autocomplete/autoclose with these tags.
I'm trying to run this extension on this Wiki , and tried to preview the results, I have got this error: ErrorCode:ENOTFOUND| ErrorInfo:undefined
The Code:
__INDEX__
==Students==
Me
You
Currently, when accessing a mediawiki site that requires credentials, the extension will fail if no username/password is defined in config.
Defining the username/password in config however leaves it in plaintext and creates a security risk.
What should happen is that, upon accessing a mediawiki site that requires credentials, a popup should appear requesting the username & password (with the password not being rendered in plaintext). This user/pass combination should not be saved to disk.
When trying to pull pages to edit in the Module
namespace (828), I'm getting the following error:
ErrorName: TypeError; ErrorMessage: Cannot read properties of undefined (reading 'join');
Example page: https://thealchemistcode.fandom.com/wiki/Module:Data
VSC: 1.69.0
Wikitext: v3.6.4
In version 3.8.0 Released a few hours ago. You can't run the command Get Preview as it responds with the error
Command 'Wikitext: Get preview' resulted in an error (command 'wikitext.getPreview' not found)
This appears to also be true with the other commands in this version too.
Substituted templates, signatures and pipe tricks don't render in previews. These can be enabled by putting the pst=1
parameter in the API parse request. Sorry for opening so many issues!
1.希望增加十六进制颜色代码的对应颜色高亮渲染
2.希望增加连接的高亮
For non-public wikis (i.e.,$wgGroupPermissions['*']['read'] = false) it'd be great if you could use the current login credentials to retrieve a page for editing. Right now I believe it just fails silently.
Everything seems to be working fine when using English Wikipedia. However, when I change the host to en.wikifur.com
and attempt to pull a page, all I get is an error notification which says undefined! undefined
. It's too cryptic for me to understand, so I thought I should report it here.
Full error message:
Access to fetch at 'https://github.com/' from origin 'https://v--05jqmiibrpsovhruor6qb71uo3ga8g9dbv6hr2q5l7elh6s78j7p.vscode-cdn.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
ErrorName: TypeError; ErrorMessage: Failed to fetch.
Extension Guides - Web Extensions:
For accessing web resources, the Fetch API must be used. Accessed resources need to support Cross-Origin Resource Sharing (CORS)
The problem is caused by the browser's security policy and depends on the backend settings, and this is part of the security specification. As a part of normal web application, this extension cannot bypass this restriction in a non-destructive way.
For more details see: https://fetch.spec.whatwg.org/
Note: The error occurs when the response is received, not when it is sent. Generally, operation messages can be sent successfully.
Since v3.6.3, this error happens when pushing to any fandom.com wiki:
'Invalid value for key "name". Expected type "" but got 0'
It doesn't happen when downgrading to v3.6.2.
The commit has been bisected to 1fecc62. The tag interface added in that commit mandates the property name
of type string
.
export interface Tag {
name: string;
defined?: string;
active?: string;
}
Most of the objects in query.tags
obey this.
But some of them have name
be of type number
.
{name: 0} // query.tags[4]
{name: 1} // query.tags[26]
{name: 2} // query.tags[27]
{name: 3} // query.tags[28]
The problem seems to be one of the transform methods in convertFunctions.ts. When the name has a numeric value, the object is not cast properly or at all.
Thanks for developing this great extension!
I see the [edit] section links in the previews are quite bigger than what they are on the live sites.
Since these links are useless and don't point point anywhere, it would be good to be able to hide these. API:Parse has a handy disableeditsection
parameter. I think this parameter should always be used, but it would also be fine to make that a user preference. Thanks!
I see that categories are not shown in the previews. These can be shown by using prop=text|categorieshtml
in the API:Parse request (and then concatenating the two pieces of HTML in the response).
If I understood it correctly, the preview feature is sending the Wiki markup to Wikipedia server, retrieve the HTML, and display it in VS Code; is that right? If so, how about adding "Show source" in the context menu (or any other way)? I think it would be helpful to understand the structure.
Also, the preview shows a line with "
at the beginning no matter what the input is. Isn't it a bug?
Implement the function of quickly querying Wikibase entries in Notebook using query sentences.
ErrorName: Error; ErrorMessage: Invalid value {"main":{"*":"Unrecognized parameter: rvslots."}} for type [null,{"ref":"MWError"}];
I don't know if it's helpful, but I'm here to provide my MediaWiki project website:r6s.huijiwiki.com/api.php
In fact, in version 3.4, I will modify the content of user agent to achieve normal operation (change "mwbot" to my own user name)
When I click the Preview button, I get the error below:
command 'wikitext.getPreview' not found
VSCode version:1.62.3
Wikitext version:3.6.0
I tend to close VSC between page edits because I don't like stuff constantly running in the background if I'm not actively using it, which means nearly every time I pull a page down, I have to re-login in order to push.
To get around this, right now I'm using multi-command with a custom command set in keybindings.json:
{
"key": "ctrl+s",
"command": "extension.multiCommand.execute",
"when": "editorTextFocus && editorLangId == wikitext",
"args": {
"sequence": [
"wikitext.login",
"wikitext.writePage",
"workbench.action.closeActiveEditor"
]
}
}
Replace MWBot dependence to mwn or other modern MediaWiki bot framework in order to solve security issue and better adapt TypeScript development.
MediaWiki supports page redirects using #REDIRECT
. Could this be highlighted for completeness in the syntax file?
If Two-factor_authentication (2FA) is enabled, VS Code can't log in Wikipedia. Is there a better way to login, turn off 2FA, activate 2FA login?
The preview stopped working. Error:
ErrorName: Error; ErrorMessage: certificate has expired;
Wikitext: v3.6.1
After posting the page, update the PAGE_INFO
and other information in the source code.
First off, awesome work! I haven't tried any of the custom Wikipedia editors but, after this plugin, I really don't think I need to.
Second, the web citation command is curious, but not useful to me if it treats WaybackMachine links the same as non-archived links. (Also noting that WaybackMachine [web.archive.org] is different than the archive.org library.) Note how I handle this with regex in my snippets below. Personally, I rarely use title as reported by the web page and may never use this command over snippets... but it still might useful it on occasion if the archive stuff is worked out.
Third, a big hint on how to build more citation commands like the web one (ISBN being much desired) is the Citation bot: https://en.wikipedia.org/wiki/User:Citation_bot
Finally, here is my snippets file for anyone who might find it as useful I do (I just tested it on writing a few articles amounting to ~225 citations). I included both vertical and horizontal citation formats (vertical being the default--comment out and uncomment as you like--but I highly recommend using vertical with list-defined refs {{reflist|refs=...}}). I also included regex code in the comments of the JSON file (and below) for cleaning out all unused citation fields when you are done (do a search for the regex code [enabling the regex search option .*
and replace with nothing]).
I included most citation templates (but not all) and included what most templates indicated as the most common fields (with some normalizing of fields across templates done by myself--it's a mess on wiki). Modify the snippet fields as your work dictates. I expect these snippets to just be a starting point for many users.
Note that the real time-saver of the snippets are the archive ones that take a single valid WaybackMachine URL (web.archive.org/web/...) and parses it into url, archive-url, and archive-date for you. It takes some getting used to, tabbing through the snippet fields without falling out of snippet mode before getting to the URL, but it's not too hard either. When I biff it, I often just start a second snippet, skip to the URL, fill it, then edit the two snippets back into one with a simple delete of the middle redundant lines. I tried putting URL first in order, but that was weird.
[[ Also note the VSCode currently has trouble with shift-tabbing through the url-status choice field (drop-down). I reported this as bug with choice fields to VSCode but they closed it without even testing the example code I sent with it. So... good luck getting that one fixed. ]]
The snippet descriptions are a bit wordy because I tried to make it clear to novices that the archive.org Library (which is an archive, maybe... but its works are not "archived") and the WaybackMachine should be handled differently in citations. Again, change descriptions as you like.
Most snippets have two forms. For example, web has: citeweb
and aciteweb
. aciteweb
means ARCHIVED web citation. aciteweb
also has an alias, citeweb-wb
, in case you don't like typing acite...
(but it actually exists to help users understand things when browsing the list of snippets during autocomplete).
// Maybe write a cleaner (cleaning script) to go with it all.
// Well, don't really need a script with regex search/replace:
// To find empty parameters (search for the code between the `backticks`):
// Vertical format (strict): `^\| [a-z0-9-]+ += \n`
// Vertical format (broad) : `^ *\| *[a-z0-9-]+ *= *\n`
// Horizontal format (strict): ` \|[a-z0-9-]+=((?= \|)|(?= ?\}\}))`
// Horizontal format (broad) : ` *\| *[a-z0-9-]+ *=((?= *\|)|(?= *\}\}))`
// Strict: strictly limited to the exact formatting used by these snippets.
// Broad: broadly allows for imprecise editing and various standards.
To use, put this JSON file in your Code/User/snippets folder (wherever that is for you) and remove the TXT filename extension (added so I could upload it here).
Suppose I wanted to link to the section "Position in the week" on the "Monday" wikipedia page on the sentence "Monday is either the first or the last day of the week." I would use the syntax:
[[Monday#Position_in_the_week| Monday is either the first or the last day of the week.]]
which is working on the main Wiki site. However, if I do this in VScode viewer and use the preview, the link is not clickable. The links are clickable if you do not link to a section but merely to a page.
Please add a feature for previewing the effects of Scribunto module and template edits on other pages. This is possible in wikis using the TemplateSandbox endpoint, if that extension is installed.
You can see the necessary API query parameters at the MediaWiki API's action=parse
page. Here is an example for sandboxing a Lua module, and sandboxing a template.
It already pre-fills the name if you pulled the page from the command palette or on-site extension; would be nice to be able to skip that extra tap of enter.
The self-closing nowiki tag: <nowiki />
is permissible according to MediaWiki. In addition to the examples presented on that Help page, other usages of it include preserving leading spaces after pipes | in template and parser function calls.
{{Some template|Some parameter=<nowiki /> this value will have a space before it}}
Example of how highlighting it should work (Fandom's Wikitext editor):
What the Wikitext-VSCode-Extension currently does is treat it like a opening nowiki tag so all code after it is not highlighted until there is a closing nowiki tag.
When copying text from VSCode it be pasted as HTML formatted text in Word with black background as style of VSCode and same font and styling colors of VSCode. This happened only with (wikitext) type files on (plaintext) files text is pasted as plain text.
If you edit multiple wikis it's a bit of a hassle to need to go into the settings and change everything every time you go edit a different site. It would be much nicer if you could specify more than one in the settings json, maybe with a layout like:
{
"wikitext.hosts": {
"mediawiki.org": {
"apiPath": "/w/api.php",
"articlePath": "/wiki/",
"userName": "username",
"password": "password"
},
"community.fandom.com": {
"apiPath": "/api.php",
"articlePath": "/wiki/",
"userName": "username",
"password": "password"
}
}
}
Then when you pull a page, you could select which host before typing in the page name, and it would keep track of which host you picked so when you push, it would know which host to push to. Similarly when using the gadget directly on a wiki, it already includes the host in the vscode:// URL, so it already knows which host it should push back to.
Can we make the texts between <ref> and </ref> dimmed? Just like wikEd does
The texts are so unrecognizable right now, especially when there are a lot of references
習慣用 vs code 編輯條目,找正文看到眼睛快瞎了
I would love to see some kind of auto-update functionality for the preview window.
Right now you need to close and re-open the window every time you change something on your document. Especially when you playing with the visual style of you document it becomes a bit cumbersome.
We have an internal wiki that uses Active Directory logins via MediaWiki's LDAP Stack extension set that doesn't seem to work with this VSCode extension. Logins fail during attempts to preview.
It looks like some changes may be needed on the MediaWiki extension and the VSCode extension may have to specify pluggableauthlogin=1
for the logins to work. I think this could be added as a boolean setting in the VSCode extension settings so that users could enable it as needed. This thread about login via the API with these extensions enabled that may be helpful in addressing this issue. I applied the patch linked in the thread and got past the first issue, but the logins still fail, possibly because of the need to specify pluggableauthlogin=1
.
Enable <syntaxhighlight>
to support content in different languages.
Not sure if MediaWiki can actually do this, but seeing CSS styling in previews would be useful. An API query would be used to add styling modules (either the prop=text|headhtml
or prop=text|modules|jsconfigvars
query strings).
A toggle icon attached to collapsed container elements, to let users remove display: none
, would also be useful. This lets users check navboxes and infoboxes fully even if they're collapsed. From a UX perspective, it would be important to make such a toggle appear as part of VSC instead of a native element of the preview content.
I saw this on your todo list.
How do you plan to implement this?
mediaWiki uses https://github.com/jasonwilliams/mediawiki-support/blob/master/src/webCitation.ts you're free to take a copy of that as a start.
Calling webArchive is useful as wikipedia expects users to do this anyway, so the fact that it's automatic helps.
Curious if there was a way to have this extension have a setting to allow for http traffic rather than https. I have a couple mediawiki's that do not run on https yet and another that does not have a domain name (it is currently running straight from IP address). It would be nice if I could have it not fail in these situations due security being less than optimal.
Login, logout and edit push functions are now available (after version 3.0.0).
At the same time, I noticed that the original expansion has been sealed and removed from the market.
After pushing, the tab is still open in VSC for the page you pulled and isn't marked as saved, so when you want to close it, VSC asks if you want to save the file locally which adds just a little extra friction every time you pull a page to edit in VSC. It should be marked as saved when you push, so VSC doesn't ask you to save the page locally, or there could be an option to automatically close the tab when you push since pushing usually means you're done editing that page, though I can see the use-case where you'd want to keep it open just in case you misspelled something or needed another minor edit like that.
The default save keybind is mostly useless for me when the editor lang is wikitext - I'll never need to locally save the page if I'm pushing up to a wiki, all the edit history is saved on the wiki - So as described in #37, I'm using multi-command with a custom command in keybindings.json set to override the ctrl+s keybind when the editor lang is wikitext. However, since the tab doesn't get marked as saved after push, trying to close it with workbench.action.closeActiveEditor
in my multicommad sequence makes the confirmation popup appear.
Currently there is no posibility to edit a webpage that is behind basic authentication.
Solution to this would be to add a setting for username and password for basic authentication when performing calls to the wikipage host.
Great work bro, I'm dreaming all day and night thinking about writing an editor with wikitext rendering and preview😂, but there's still something to do next:
Maybe I didn't express these opinions or issues clearing due to my poor English😔, if further explantion needed, please reply bro.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.