Topic on Extension talk:WYSIWYG

WYSIWYG is turning relative links into text, when subpage feature of MediaWiki is used

13
Real struggle (talkcontribs)

Just installed the extension to try it out on an existing wiki.

My wiki has many links like this:

[[../SomePage|LinkText]]

When I click edit on a page with such a link it does not render them as links, it renders them as a textual representation, which in source looks like this:

[[../SomePage|LinkText]]

Even worse, when saving the page I find that it did in fact replace all the links with this text version.

WYSIWYG_EDITOR_VERSION: 1.5.6_0 [B551+18.04.2016]

CKEDITOR_VERSION: CKEditor 4.5.4 (revision d4677a3)

MediaWiki 1.25.2

Not using WikiEditor

Not using SemanticMediaWiki

Not using SemanticForms

Real struggle (talkcontribs)

was able to post today! yay

Real struggle (talkcontribs)

In case it wasn't obvious, non-relative links work fine.

[[BaseDir/SomePage|LinkText]]

will render as a link to the right page with the right link text.

Riparap (talkcontribs)

Seems that wysiwyg does not understand that.

This may be stupid question, but this kind of link is new to me :).. and it is not listed here Help:Links . Is your link pointing to wiki page or external file which is stored somewhere?

Riparap (talkcontribs)

MW1.26 shows [[../SomePage|LinkText]] as text and does not convert it to link (if edited with wikieditor)....so is this how it works in your wiki too?

I did modification which is available in branch wysiwyg_mw126_rsl458, where I removed conversion of characters [ and ] (in direction wysiwyg=>wikitext). I am not sure if it will help you because your example does not work in same way with my wiki (MW1.26) and it sounds like you had problem in other direction (when opening page and doing wikitext=>wysiwyg conversion).

If you want to test this, you have to select branch wysiwyg_mw126_rsl458 manually, because it is not default branch in github. Branch also contains updated CKeditor (vers. 4.5.8).

Real struggle (talkcontribs)

Are you sure they don't work on MW? I just played around in the MW sandbox and they seem to be supported fine - seems like the same full relative link support as is documented on the wikipedia relative link page, not sure why it's not documented on the mediawiki page, but it works fine on the sandbox (which is probably getting wiped very very quickly)

https://www.mediawiki.org/wiki/Project:Sandbox/sub01

 [[Project:Sandbox/sub01]]   [[../sub01|sub01]]
 
  [[Project:Sandbox/sub02]]   [[../sub02|sub02]]
 
  [[Project:Sandbox/sub01/sub11]] [[/sub11|sub11]]
 
  [[Project:Sandbox/sub01/sub12]] [[/sub12|sub12]]
 
  [[Project:Sandbox/sub02/sub21]] [[../sub02/sub21|sub21]]
 
  [[Project:Sandbox/sub02/sub22]] [[../sub02/sub22|sub22]]
Real struggle (talkcontribs)

Update: I've been able to make it work with some minor changes to the WM files that the visual editor is using to get HTML versions of the page.

Title::secureAndSplit()

Title::newFromText

and

CKeditorParser::replaceInternalLinks( $text ) # purely to handle case with no piped text

Riparap (talkcontribs)

So... there are two possible different problems: first one was that wysiwyg converted character strings [[ and ]] in wrong way. I am not sure anymore if my modification with these characters were right. Second problem is your relative links.

On my installation of MW1.26.2 (no extra plugins than wysiwyg) result of relative link is like in picture Relative_link.png (page has been edited with wikieditor). As soon as link text begins with two dots, my installation of mediawiki does not display it as link, it is displayed as text. After my latest modification with wysiwyg I can also edit page using wysiwyg and that line of text containing two dots can be saved without problems.

Is it so that you have enabled subpage feature in your wiki in case relative links work in your system? ... this is enabled only with some namespaces by default, see Subpage feature and Relative links. It seems like subpages are somehow stored in different way than "normal" pages in MW. If I create pages startting with "/", then I can get relative links to these pages work with MW. It looks like wysiwyg can not handle this kind of links properly and treats it as text.

I do not quite understand what you mean... are you saying that you have modified some files of mediawiki in order to make relative link work in your system or have you made some changes with files of extension wysiwyg? If you have made changes with files of wysiwyg, could you please post your changes so that I can try to learn from them and merge possible valid fix into wysiwyg extension.

To understand you better, please use shorthands "MW" if you are referring to mediawiki, "wysiwyg" if you are referring to extension wysiwyg, "wikieditor" if you referring to extension wikieditor (text based editor of mediawiki), visual editor if you are referring to mediawiki extension visual editor, which is completely different way to edit wiki pages and has nothing to do with extension "wysiwyg".

Real struggle (talkcontribs)

subpages enabled via:

LocalSettings.php

$wgNamespacesWithSubpages[NS_MAIN] = true;

As for changes, yes, I 'made it work' via changes to the MW code and a change to the WYSIWYG code. Perhaps not the best way to fix it, but a start.

change to MW Title.php

- super hacky : in secureAndSplit() these relative links throw MalformedTitleException and are caught and return false. I just edited the catch to test if the $dbkey starts with ../

if It does, then I set the mTextform to $dbkey and return true.

This is a really poor fix, but a start.

Change to WYSIWYG CKeditorParser.body.php

replaceInternalLinks( $text )

- I commented out the first $text.replace because it was changing [[../link]] to [[../link|../link]]

Riparap (talkcontribs)

Thank you... I will not modify files of MW because of this. This should be fixed with wysiwyg files only. I located the place were links are handled but I could not yet make it work properly. I will try to test this more when I have time...

Riparap (talkcontribs)

I have made modification with this in branch "wysiwyg_mw126_rsl548". Version 1.5.6_0 [B551+03.05.2016].

Robwikinow (talkcontribs)

I have a similar problem. I am new to mediawiki, just installed a clean version 1.29 and installed the latest wysiwyg version.

When I save a page with a link, then the html code for the link is shown as text in the page

Aslo the preview tabs keeps loading (and displays nothing)

Robwikinow (talkcontribs)

Apparently there is a differentce between the PUBLISH button on the top and and SAVE CHANGES on the bottom

The PUBLISH converts the links to plain text

Reply to "WYSIWYG is turning relative links into text, when subpage feature of MediaWiki is used"