1

I'm writing a VBSscript for uploading plain "raw" text into my Mediawiki, but I fail to add newlines to the raw text.

For example when I try concatenating new lines in the strings with VBS code, like so:

S = S & "Some string" & Chr(10) & "some other string"

... and upload it (via api EditPage), and then look at the raw text with a browser on the Wiki (in edit mode), then the text looks like so:

"Some string%Asome other string"

Tha is, no real line break, only the "%A" representation.

I also tried reading the text file (from disk) line for line like so, but no line breaks are inserted here either :

Function ReadEntireFile(aFile)
   Const ForReading = 1
   Dim S
   Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
   Dim theFile: Set theFile = fso.OpenTextFile(aFile, ForReading, False)

   S = ""
   Do While theFile.AtEndOfStream <> True
      S = S  & Chr(13) & Chr(10) & theFile.ReadLine
   Loop
   theFile.Close
   ReadEntireFile = S
End Function

... but I get the same kind of result, that is:

"First string part%D%Asecond string part"

As you know, if you edit the mediawiki article directly, then there's no problem entering new lines (just press "ENTER" as usual), but why do I fail to insert #13 (cr) and #10 (lf) into text uploaded via the api? I must be overlooking something.

Notice that I'm fully aware of syntaxes for Html parsing of line breaks (<br /> etc) but that's not what I'm at here, I want to insert "raw" line breaks in the "raw" source text of the Mediawiki articles.

Q: So, is there any trick for inserting newlines which I have overlooked when using mediwiki api, or is it simply not possible?

svick
  • 236,525
  • 50
  • 385
  • 514
RIL
  • 185
  • 2
  • 11
  • Maybe one of the strategies from http://stackoverflow.com/q/10375821/603855 will be of help in your case. – Ekkehard.Horner Mar 28 '15 at 06:59
  • **Solved.** I found that the script I started from didn't use proper URLEncoding. Now I tried using the inbuilt `Escape(sRawText)` (in VBScript) and then it appears that any (raw) string is good to send to Mediawiki, just like one would expect. – RIL Mar 28 '15 at 07:50

1 Answers1

0

I tried using the inbuilt VBScript function Escape(sRawText) on the string to send, and then - just like one would expect - any (raw) string is good to send to Mediawiki via API.

RIL
  • 185
  • 2
  • 11