Code Monkey home page Code Monkey logo

wikitext-vscode-extension's Introduction

Wikitext Markup Language Support Extension for Visual Studio Code

VSMarket: wikitext extension Open VSX: wikitext extension GitHub: wikitext extension Toolhub: wikitext extension

Build GitHub Actions CodeQL CodeFactor Status

@mastodon.social@rwfholme Patreon Donate

This Visual Studio Code Extension provides support of Wikitext Markup language. With this extension, you can more easily discover your grammatical problems through the marked and styled text. The plugin is based on MediaWiki's Wikitext standard, but the rules are somewhat stricter, which helps users write text that is easier to read and maintain.

Of course, the development of this extension is short, and there may be some errors in operation and labeling. If you find a problem, please report it to me immediately for resolution.

If you get help with this project, give this project a star or recommend it to others, thanks!😸

Enhancement Tool: Wikitext-Extension-Gadget

  • Now you can add Wikitext Extension Gadget as a user gadget on your wiki site. And you will get a button to open VSCode directly in your browser to edit the page!

    Go to the gadget's repository page to learn more.

    Wikitext Extension Gadget

Features

  • Color and style annotations of Wikitext can make it easier for users to intuitively find problems in writing grammatical formats.

    Code main page
  • Automatic matching and closing of simple parentheses reduces unnecessary double typing.

    Code video
  • The special comment syntax(<!--#region-->&<!--#endregion-->) can folds the code for easy reading.

    Code region
  • Press Ctrl + Shift + V or click the Preview icon in the title menu bar directly in the Wikitext content to get a parsed preview of Wikitext in the currently active text editor.

    Code previewer
  • Enter @[name] to get a snippet of wikitext. Such as @table, @region, @title...

    Code snippets
  • You can modify the website content by logging in directly in VSCode! Enter the settings page, search Wikitext and find the username and password items, and fill in them. Then press F1 in the text editor, select Post your page to the website!

  • Obtain the Wikitext source code directly in VSCode according to the page name without opening the web page. Press F1 and select Pull page to edit to use this function.

  • Browse the page by entering the page name. Press F1 then select View the page.

Release Notes

  • Added more syntaxes of wikitext tags.
  • Removed '<>' pairs.
  • Made summary shorter.
  • Alleviated the issue of the extension posting edits without logging in.

Usage

Usage Requirements

Please ensure that your VSCode version is higher than 1.64.0, this version requirements may change in the future.

Generally, make sure that your VSCode is always the latest version.

Development

Development Requirements

How to build this extension yourself

Firstly, clone this repository and change directory to the repository, then install VS Code Extension Manager and other packages:

npm install -g yarn vsce # VS Code Extension Manager
yarn install # Install devDependencies

Package this project and you will get a .vsix file:

vsce package --yarn # Package Extension with yarn

This is it!

Special Thanks

wikitext-vscode-extension's People

Contributors

3-e-d avatar bryghtshadow avatar dependabot[bot] avatar frederisk avatar jcdhan1 avatar lavgup avatar nixinova avatar vi-brance avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wikitext-vscode-extension's Issues

Mark as saved after push (or option to auto-close tab)

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.

Web Extension Error: `TypeError: Failed to fetch`

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.

Commands resolving to Not Found

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.

Implement checking for editing conflict

  • When posting, send out the revision ID and timestamp.
  • Try to resolve the conflict remotely or locally.
    • After the remote solution is resolved, return success directly,
    • or Open diff locally and let the editor resolve conflicts manually.
  • Post the resolved edit.

MediaWiki redirects

MediaWiki supports page redirects using #REDIRECT. Could this be highlighted for completeness in the syntax file?

Wikimedia Two-factor_authentication

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?

Cannot login to FANDOM Wiki

I have a Bot username and Bot password on my Fandom wiki account; I entered it into the extension settings like this:
Capture

but then it gives me an "invalid json error" upon executing the "Login with your account" from the command palette:
image

Categories not shown

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).

ErrorCode:ENOTFOUND| ErrorInfo:undefined

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

Multiple site support

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.

Option for autologin on push

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"
			]
	}
}

Bracket highlighting not working in v3.7.0

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

Logins to Internal Wiki

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.

Feature Request: Add in additional autoclose wiki tags

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.

Math remains dark when using dark-themed vscode

I'm currently editing a wiki page that includes some math text while using vscode in dark mode.

Say I write a piece of math:

:  <math>
1+1=2
</math>

Here's an image of how this looks in my editor together with that same math written in text above:

Screenshot 2021-01-20 at 11 21 55

Am I missing an option or is this a bug?

[Enhancement] Template styling in Preview and Preview for mobile devices needed

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:

  1. image
    The preview page shows a navbar, which uses Lua script (clearly that it's easy to rewrite in typescript or javascript) rendered on MediaWiki. (this is what #18 meaning bro) I think the styling can be enhanced like that. I thought I expressed clearly🙂...
    What English wikipedia rendered like: (default collapsed and expanded also applyed)
    image
  2. Templates like navbox won't be shown on mobile phones. But when we scratch the preview page (tab in vs code), if I'm a developer😂, I don't know whether the page should be responsive, for those templates won't appear on mobile devices.
  3. Editing an article on wikipedia is like developing a website, both display effects on desktop and mobile devices needed. Here are my two contrast opinions for you to argue: First, this plugin should be easy to use, only desktop effect is ok. Another, both effects needed.
  4. CSS preference interface is a future work, wikipedia supports personalized css. We can consider personal CSS preference interface for rendering. (Maybe then a documentation need lol)

Maybe I didn't express these opinions or issues clearing due to my poor English😔, if further explantion needed, please reply bro.

can't pull page

image

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)

like this:
extension.js
image

There are always extra `"` in the preview

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?

image

Error when pushing changes

Replication steps

  1. Configure Wikitext-VSCode-Extension for any wiki on fandom.com
  2. Log in.
  3. Pull or create a page.
  4. Make an edit.
    image
  5. Push the edit.
    image
  6. Enter an edit summary (optional).
    image
  7. Hit the enter key:
    • Expected: Edit is successfully saved.
    • Actual: Edit is not saved and there is an error.
      image

Investigation

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.

Can we make the texts between <ref> and </ref> dimmed?

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 編輯條目,找正文看到眼睛快瞎了

Cannot pull wikitext for non-Wikipedia wiki

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.

Wikipreview unable to produce working links to sections

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.

[Feature Request] Auto-update preview

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.

Credential requirement

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.

Feature Request: Optional variable for unsecure traffic.

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.

Enable PST

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!

Self-closing nowiki tags do not highlight properly.

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):
image

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.
image

Styling in previews

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.

Citation Snippets for free!

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).

wikitext.json.TXT

// 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).

Option to skip page name on push

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.

Add basic authentication to settings.

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.

Disable edit section links in preview

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.