Hello. Is it possible to create a button like with simple text "Python code" and it would insert a piece of text like
<syntaxhighlight lang="Python"></syntaxhighlight>
This page is an archive. Do not edit the contents of this page. Please direct any additional comments to the current talk page. |
Hello. Is it possible to create a button like with simple text "Python code" and it would insert a piece of text like
<syntaxhighlight lang="Python"></syntaxhighlight>
It is a very useful tool. Please do not obsolete it. RIT RAJARSHI (talk) 06:29, 6 April 2020 (UTC)
I am using the CharInsert extension on a local wiki installation. However I find the information in Extension:CharInsert#Notes confusing, not very helpful.
I actually found important information for customization at other places.
Following explanations:
\\n
with double backslashes<nowiki>
tag might actually work (not sure here), however using just the dot sign .
is much more convenientGadget-charinsert-core.js
are actually used, in my case the toolbar used an older version from the cache for certain time.I believe the code in MediaWiki:Gadget-Edittools.js is broken after phab:T30856. Clicking on buttons prints the following error into browsers console:
TypeError: mw.toolbar is undefined; can't access its "insertTags" property
We fixed on fawiki with the following change: https://fa.wikipedia.org/w/index.php?title=%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C%3AGadget-Edittools.js&type=revision&diff=24787771&oldid=24786882 .
his might not be the most appropriate location for this query (I have also posted it to Mediawiki:Edittools, but is it possible to adjust preferences, skin, common.css etc to have the edittools/charinsert box ABOVE the edit window rather than below it? ElectricRay (talk) 14:44, 9 May 2018 (UTC)
I posted a code there. There is also on Commons a default gadget which does this for the Wikieditor (converts them all).
Is it a way how to exlude (or not to include) Edittools page (with CharInsert) from Forms? Since CharInsert does not work there properly, at least on MW 1.27. I mean do not include in edit mode, in view mode Forms look fine.
Hi. Please could you clarify which specific Forms you mean? I don't think you mean Extension:InputBox which is the usual meaning that I'm familiar with, on wikimedia wikis. Thanks! (direct example links almost always help.)
I mean form pages which are created with Extension:Page Forms...
I have found out that is was my fault. I've added Edittools in MediaWiki:Summary for better access durint the editing. So this updated Summary massage was shown in forms as plain text without parsing by CharInsert.
Solution: remove Summary from forms.
For what it's worth, I like it. For text editing in Wikisource it's very helpful. Thanks to those who designed and implemented it.
Previously (<=MW 1.25) we could add code that adds linebreaks on insert with
.
E.g.
<charinsert label="Foo Bar"><nowiki>Foo Bar</charinsert></nowiki>
inserts
Foo Bar
In MW 1.27.1 these are returned as �.
Hmm, does this work?
#x0A;
instead of #13;
(Note: I am not a dev. I just poked around on google a bit, and also noticed that roundtripping #13;
in parsoid resulted in #x0A;
...)
Tried it before. It's also not working, but differently:
:


does the linebreak in the links (but we want them in the inserted text):
Can't you try on mediawiki.org?
<charinsert label="Foo Bar"><nowiki>Foo Bar</charinsert></nowiki>
I assume you've tried a raw linebreak, too?
(I'm not comfortable with personally testing things on such a prominent interface element on mediawiki.org, and the CharInsert doesn't appear to be functional at Testwiki: or https://en.wikipedia.beta.wmflabs.org ... so I can't do testing there... :/ )
I'll try to find a dev to take a look...

 (newline) is much more correct than #13 (carriage return)
I cant really reproduce what you are describing. It sounds almost like you are running into doBlockLevels() (aka pre formatting when you start a line with a space). Can you paste the exact code you are using?
The syntax you are using is a bit odd. Nowiki is misnested, and you have a label attribute which isnt part of the extension...
As an aside you can test charinsert on any page during preview. You do not need to edit mediawiki ns to test.
Meanwhile was changed to https://www.mediawiki.org/w/index.php?title=Extension%3ACharInsert&type=revision&diff=2239365&oldid=2235689
This fixes it I guess. Just not when you want a working button. Add this button:
<charinsert><nowiki>{{Infobox | }}</nowiki></charinsert>
Now I need to hack my label attribute back in...
Thanks!
Try killing the space between the and the |:
<charinsert>{{Infobox | }}</charinsert>
Perhaps the extension should be changed so that charInsertHook() returns an array with first parameter the current return value and a 'markerType' => 'nowiki'
parameter.
Subject says it all.
See task T86715 Regression: No longer able to insert characters using CharInsert gadget based on extension after 1.25wmf14 roll-out.
Anxious for this to be resolved, as the work I am editing requires the gadget's use on almost every page. Thanks, Londonjackbooks (talk) 00:23, 14 January 2015 (UTC)
"The gadget needs to be made dependent on mediawiki.toolbar in the gadgets definition:
charinsert-core[ResourceLoader|hidden|rights=hidden|dependencies=mediawiki.action.edit,mediawiki.toolbar,jquery.textSelection,user]|charinsert-core.js|charinsert-core.css
Added the dependency on en.wikisource and character insertion works again. Hat-tip to TTO.
Same issue. How to make it work with MW 1.26.2 and an advanced installation ? Cheers.
What is the difference between this extension and the charinsert gadget? Do I need to install both or only one of them to get the the drop-down box like wikipedia?
To get the drop-down box, you need Extension:Gadgets, too. See instructions at Extension:CharInsert#Advanced_Installation.
I've deployed the gadget, and removed this extension, and I get all the features that I required. It seems this extension is only required if one doesn't want to deploy the gadgets extension.