From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search


The following discussion is marked as answered (suggested change added). If you have a new comment, add it just below the box.

The line in the pages says

Copy the following code to your common.js page.

as this can also be added to global.js, is that worth mentioning there too?  — billinghurst sDrewth 04:39, 3 November 2014 (UTC)[reply]

Done. Thanks for the suggestion. :) —Pathoschild 04:54, 03 November 2014 (UTC)

Question about regex session[edit]

@Pathoschild: Just as bats wings are both different and similar to birds wings, our it.source (and mul.source) "memoRegex" is both similar and different to your Regex editor. I browsed a little bit the code (a very hard job for my limited skill!), and I found how/where session are stored. My question: is there a tool to save permanently regex editor session data into a page code? --Alex brollo (talk) 19:24, 16 August 2015 (UTC)[reply]

Hi Alex brollo. The sessions are saved to localstorage, but soon we might add them to user preferences instead. That means they'd be saved permanently for your user account, even if you use a different browser or computer. Would that work for you? —Pathoschild 19:44, 16 August 2015 (UTC)

Using TemplateScript for a OCR checker?[edit]

At English Wikisource there is a discussion about how to check for Commons OCR errors. What scope is there to have TemplateScript or a targeted variation, have a namespace ability to look for a compiled list of common OCR errors when the page is visited/previewed/saved. Thinking that in the Page: ns that it can check a common page or problematic words, one per line, and highlight text found on that page.  — billinghurst sDrewth

Hello Billinghurst. TemplateScript already lets you register a custom script (which can fetch another page's content and interact with the current page), but it's really meant to be triggered by the user. It doesn't support running scripts automatically on save, but you can intercept the form submission directly without TemplateScript. —Pathoschild 17:49, 08 January 2016 (UTC)

New code editors[edit]

The following discussion is marked as answered (fixed by updating from the regex menu framework to TemplateScript). If you have a new comment, add it just below the box.

Doesn't seem to work in the RegEx part on the new code editor enabled namespaces, like templates, or content pages where Visual editor edit window gets messed up. KPu3uC B Poccuu (talk) 16:43, 8 January 2016 (UTC)[reply]

Hello KPu3uC B Poccuu. VisualEditor isn't supported yet, but CodeEditor should work. Can you provide an example page with CodeEditor where it doesn't work? —Pathoschild 17:06, 08 January 2016 (UTC)
Hello. I tried it on ru:Шаблон:Param. The editor becomes a strange mess of colored blocks. KPu3uC B Poccuu (talk) 17:51, 8 January 2016 (UTC)[reply]
It looks like you're not using TemplateScript; you have a custom version of the obsolete regex menu framework instead. There are also a few errors in the other scripts you're using; for example, User:KPu3uC B Poccuu/rqedit.js uses sajax_init_object (which no longer exists) and User:js/dabfixer.js calls addFuncBtn (which doesn't seem to exist). I suggest:
  1. removing any scripts you no longer use;
  2. transferring your translations from User:KPu3uC B Poccuu/RegExFramework.js to TemplateScript#Translation;
  3. replacing the regex menu framework (which is no longer supported) with TemplateScript (which has equivalent features).
Do you want me to help you do that? —Pathoschild 21:08, 08 January 2016 (UTC)
Would be really nice, the sole reason I kept both was I wasn't sure how to convert my custom replace rules to the new system. Dabfixer and rqedit aren't my scripts, the latter was simply adopted and changed a bit, BTW. KPu3uC B Poccuu (talk) 01:14, 9 January 2016 (UTC)[reply]
Wait, I do use it, it's on my global.js. KPu3uC B Poccuu (talk) 01:15, 9 January 2016 (UTC)[reply]
Hello? KPu3uC B Poccuu (talk) 01:16, 12 January 2016 (UTC)[reply]
Don't worry, I haven't forgotten you. :) I was focused on Synchbot this weekend; I'll update your scripts this week. —Pathoschild 01:23, 12 January 2016 (UTC)
If you wanna fix colored mess with the code editor, you just need to insert the RegExp tool form before $('#wpTextbox1'). KPu3uC B Poccuu (talk) 13:41, 12 January 2016 (UTC)[reply]
This was fixed by updating from the regex menu framework to TemplateScript (see discussion). —Pathoschild 21:29, 17 January 2016 (UTC)

Russian localization[edit]

See User:KPu3uC B Poccuu/global.js. You may revert that after you copy it. KPu3uC B Poccuu (talk) 11:40, 17 January 2016 (UTC)[reply]

Thanks! Your translations are added and deployed. :) —Pathoschild 15:49, 17 January 2016 (UTC)
There is untranslated menu item title ("Regex editor") and a wild "tutorial" (should be "справку" in the same quotes as in other places).
@KPu3uC B Poccuu: the menu item is translated, but TemplateScript is loaded before the translations in User:KPu3uC B Poccuu/global.js. Make sure that ru.js is imported first (since otherwise it's not available when TemplateScript renders the menu).
I'll correct the 'tutorial' translation. Can you translate the link title ("JavaScript regex tutorial") too? Should the link point to ru:Регулярные выражения instead? —Pathoschild 02:10, 20 January 2016 (UTC)
It may point to instead. I don't see such a string anywhere in the form though. KPu3uC B Poccuu (talk) 03:23, 20 January 2016 (UTC)[reply]
It's in the regexeditor.instructions string. Here's the translated string so far (just missing the title= text):

Вы можете указать любое количество шаблонов для использования. Шаблон поиска может выглядеть как «{code|text=шаблон поиска}», либо как «{code|text=/шаблон/флаги}», а шаблон замены может содержать ссылки на группы вида «{code|text=$1}» (см. {helplink|text=справку|title=JavaScript regex tutorial|url=}).

Pathoschild 03:34, 20 January 2016 (UTC)
Alright: Справка по регулярным выражениям JavaScript. KPu3uC B Poccuu (talk) 03:49, 20 January 2016 (UTC)[reply]
Done! You may need to update your browser cache to see the updated translations. —Pathoschild 04:58, 20 January 2016 (UTC)

Regex editor[edit]

Hi! I just started using TemplateScript, and have been finding the regex editor really useful. However, I am a little frustrated by a few things. I wish the editor would automatically bring up a script that I have been repeatedly using, rather than requiring me to click on the save each time. And I wonder if it would be possible to allow it to overwrite previous saves of the script, so that I don't have to save the new version of the script and then delete the previous version of the script in the saved scripts menu. That would save a few clicks. Are there any options for setting the behavior of the regex editor to make it more convenient? Erutuon (talk) 10:10, 2 February 2017 (UTC)[reply]

I realized I can just add a script that contains the regex I want to use; much simpler. Erutuon (talk) 20:25, 2 February 2017 (UTC)[reply]

Bug in script[edit]

On Wiktionary, when I use a script that adds {{subst:chars|grc|}}, it returns that template plus the character immediately before the cursor. So if I click the script when the cursor is immediately after a pipe, it returns {{subst:chars|grc|}}|. Can this be fixed? Erutuon (talk) 21:21, 2 February 2017 (UTC)[reply]

Hi Erutuon. Sorry, I didn't see this message earlier. I just released a fix for that; you may need to bypass your cache to see the changes. —Pathoschild 16:10, 23 September 2017 (UTC)[reply]
@Pathoschild: Thanks! The problem is fixed now. Erutuon (talk) 20:31, 26 September 2017 (UTC)[reply]

updating my scripts[edit]

@Pathoschild:I have been informed that my scripts, in particular EngvarB.js, is using a deprecated framework, and that I ought to migrate to this one. My problem is that I have received a lot of coding help and advice on an ongoing basis, am out of my depth in updating them. Can anyone advise me how to do this in a step by step manner? --Ohconfucius (talk) 19:17, 31 August 2017 (UTC)[reply]

Hi Ohconfucius. Sure, I can update your scripts for you. Which one do you want to start with, and how do you want me to update it (e.g. should I update the test version for you to review)? Feel free to ping me when you reply, since I don't actively monitor my watchlist anymore. —Pathoschild 15:32, 23 September 2017 (UTC)[reply]

Conflict with Wikitext highlighting[edit]

I'm trying out the new wikitext highlighting on the English Wiktionary, but I find I can't use my TemplateScript scripts anymore. I click the buttons on the sidebar and they do nothing. My other editing scripts work fine. Not sure where the problem lies, but just letting you know. Erutuon (talk) 20:24, 26 September 2017 (UTC)[reply]

The wikitext highlighting feature replaces the textbox with CodeMirror, which TemplateScript doesn't support yet. I'll look into adding CodeMirror support sometime soonish. —Pathoschild 14:29, 27 September 2017 (UTC)[reply]

Script not functioning. Can we generate a local copy?[edit]

@Pathoschild: Hi. I know that there was some discussion on github though I wasn't fully paying attention. Anyway, there is no functioning script being called. Do we have a ready workaround in the absence of the script? Can we pull a local copy at least as a temporary measure?  — billinghurst sDrewth 02:58, 1 October 2019 (UTC)[reply]

Sorry about that! I had to revamp the Toolforge structure a bit to fix some performance issues with the web tools, which left a broken symlink in the static hosting. That's fixed now. (You might need to bypass your cache to see the fix.) —Pathoschild 03:18, 01 October 2019 (UTC)[reply]

Make the regex apply to all things it matches?[edit]

Hi! I just made a template with the regex editor to remove smart quotes/apostrophes. One problem is that each click only runs the patterns once — only replacing one smart quote at a time. How can I make it do this to each match at once instead? Thanks, DemonDays64 (talk) 05:12, 22 March 2020 (UTC) (please ping on reply)[reply]

@DemonDays64: add a "g" switch after the closing "/" /your regex/g (g = global). Have a look at s:user:billinghurst/common.js for examples  — billinghurst sDrewth 11:33, 22 March 2020 (UTC)[reply]
There is a smart quote replacement there '" fwiw  — billinghurst sDrewth 11:36, 22 March 2020 (UTC)[reply]
@Billinghurst: thanks, the flag works great! Also where are the templates I save from the regex editor stored? DemonDays64 (talk) 14:06, 22 March 2020 (UTC)[reply]
@DemonDays64: If you are talking about those that you save from the interface, they are stored in your local PC browser settings. Pathoschild can tell you the intricate details, that is blackmagic to me. Those that you see in my common.js appear in the sidebar of my browser, some in all editing windows, some in editing window for a namespace.  — billinghurst sDrewth 04:57, 23 March 2020 (UTC)[reply]

Positive lookbehind syntax shows as erroneous[edit]

When using the syntax /(?<=lookbehind)regex the (? ) components show as errors in red. The syntax works without issue, though it doesn't seem to be recognised as valid.  — billinghurst sDrewth 15:25, 1 August 2021 (UTC)[reply]