Copying source code directly from VS works for me (Firefox 3.5).
However, there's no way to prevent smiley codes from being expanded (e.g., x.[i⁠⁠] being transformed into x.[i]), is there?

/edit - Well, for every problem, there's a hack: Use the invisible "Word Joiner" (U+2060 / ⁠).

By on 1/13/2010 4:38 AM ()

Hi, Kha:
I found one way to workaround the "i" becomes a smile icon, you can use "j", then it looks OK. Even "j" is not often used as "i", but other people can understand.

By on 1/13/2010 11:25 AM ()

I followed the directions, but I still get a tiny text box as an editor - no toolbars at all.

About this big:

<---------------------------------------------------------->

(Using IE 8.x)

thanks, m

By on 1/12/2010 3:45 PM ()

it seems that only IE7 works. I need to change to compat mode in IE8 and Chrome failed too.

By on 1/12/2010 4:13 PM ()

it seems that only IE7 works. I need to change to compat mode in IE8 and Chrome failed too.

Yes, I can't get IE8, 32 or 64 bit, or Google Chrome version 4.1.249.1064 to work with the rich HTML editor under Windows 7 either.

My solution, at least until this is fixed, is to set my profile so that my Content Editor is the Default TextEditor so I can edit all of the HTML codes, follow all paragraphs with a

sequence to separate them, then use the following F# program to generate the codes to be copy and pasted into the text editor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
open System.IO


printfn "This program converts text F# code as HTML for the hubFS Bulletin Board.\r\n"


printfn "Paste (right click this window) the program code you've copied to the clipboard,"


printfn "then convert by holding the Ctrl and Shift keys down while pressing the @ key:\r\n"


let mutable outputstring = "[&#0;code language=\"F#\"]"


let mutable c = System.Console.ReadKey().KeyChar


while c <> '\u0000' do


  match c with


    | '&' -> outputstring <- outputstring + "&"


    | '<' -> outputstring <- outputstring + "<"


    | '>' -> outputstring <- outputstring + ">"


    | '[&#0;' -> outputstring <- outputstring + "[&#0;&#0;"


    | '\r' ->


      System.Console.Write '\n'


      outputstring <- outputstring + "\r\n
"


    | '\n' -> ()


    | _ -> outputstring <- outputstring + string c


  if c = '\r' then


    c <- System.Console.ReadKey().KeyChar


    while c = ' ' do


      outputstring <- outputstring + " "


      c <- System.Console.ReadKey().KeyChar


  else c <- System.Console.ReadKey().KeyChar


outputstring <- outputstring + "[&#0;/code]"


printfn "The HTML formatting is as follows:\r\n"


printfn "%s\r\n" outputstring


let p = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory)


let sw = new StreamWriter(p + "\\Code.txt", false, System.Text.ASCIIEncoding.ASCII)


sw.Write(outputstring)


sw.Close()


printfn "The output has been written to a text file named \"Code.txt\" on your Desktop.\r\n"


printfn "Set your hubFS user profile options (click your name at the top of the page) to"


printfn "use the Default TestEditor as your Content Editor under Site Options.\r\n"


printfn "Then open the \"Code.txt\" file with a text editor such as Notepad"


printfn "with Formating/Wordwrap turned off, and copy-and-paste all of it"


printfn "into the hubFS forums message box for posting as a code segment.\r\n"

I used the above program to generate the code representation of the program file that I copy and pasted into here and as you see above.

@BFalkner, this takes care of the angled brackets.

@Kha, this also takes care of the square bracket "smiley" problem by writing a null character after the '['.

@Gary, I agree that this thread should be included as a "sticky" or even more preferably, written up to be included in the help FAQ's.

By on 5/11/2010 5:25 AM ()

it seems that only IE7 works. I need to change to compat mode in IE8 and Chrome failed too.

I haven't tried it in IE7. I have only gotten it to work in firefox. But, IE8 compatibility mode seems to work.

By on 1/13/2010 1:05 PM ()

is there any way to make this thread sticky ? This is almost like an FAQ.

By on 1/13/2010 2:09 PM ()

And is there a way to prevent angled brackets from being swallowed?

By on 1/12/2010 2:03 PM ()

(And is there a way to prevent angled brackets from being swallowed? )

Use the &amplt substitution, this works for me when using the plaintext editor and HTML tags.

Also use &ltpre&gt...&lt/pre&gt for code.

(Oops - this works when I view in IE8 (with or without compatibility mode). Safari was a different story - I just saw the escapes verbatim.)

By on 8/11/2010 2:16 PM ()

Modified version of the above script that automatically copies to clipboard. Doesn't work from inside VS because Console.ReadKey doesn't work there, but run it from fsi.exe or compile it into a program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#r "PresentationCore"


open System


open System.IO

[&#0;<STAThread>]


do


    let read() = System.Console.ReadKey(true)


    let writer = new System.IO.StringWriter()


    let write (x:string) = 


        writer.Write x


    printfn "Paste text and then hit Ctrl-Z"


    let mutable c = read().KeyChar


    while c <> '\026' do


      match c with


        | '&' -> write "&"


        | '<' -> write "<"


        | '>' -> write ">"


        | '[&#0;' -> write "[&#0;&#0;"


        | '\r' -> write "\r\n
"


        | '\n' -> ()


        | _ -> 


            write (string c)


      if c = '\r' then


        c <- read().KeyChar


        while c = ' ' do


          write " "


          c <- read().KeyChar


      else c <- read().KeyChar

    let output = sprintf @"

[&#0;code language=""F#""]%s[&#0;/code]

" (writer.ToString())


    printf "%s" output


    System.Windows.Clipboard.SetText output


    printf "\n\n[&#0;copied to clipboard]"

-Max

By on 9/22/2010 5:04 PM ()

Modified version of the above script that automatically copies to clipboard. Doesn't work from inside VS because Console.ReadKey doesn't work there, but run it from fsi.exe or compile it into a program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#r "PresentationCore"


open System


open System.IO

[&#0;<STAThread>]


do


    let read() = System.Console.ReadKey(true)


    let writer = new System.IO.StringWriter()


    let write (x:string) = 


        writer.Write x


    printfn "Paste text and then hit Ctrl-Z"


    let mutable c = read().KeyChar


    while c <> '\026' do


      match c with


        | '&' -> write "&"


        | '<' -> write "<"


        | '>' -> write ">"


        | '[&#0;' -> write "[&#0;&#0;"


        | '\r' -> write "\r\n
"


        | '\n' -> ()


        | _ -> 


            write (string c)


      if c = '\r' then


        c <- read().KeyChar


        while c = ' ' do


          write " "


          c <- read().KeyChar


      else c <- read().KeyChar

    let output = sprintf @"

[&#0;code language=""F#""]%s[&#0;/code]

" (writer.ToString())


    printf "%s" output


    System.Windows.Clipboard.SetText output


    printf "\n\n[&#0;copied to clipboard]"

-Max

Max, thanks for cleaning up my code! Just a quick note that one doesn't really need the #r "PresentationCore" line as there is also a Clipboard class for all versions of DotNet so that one can replace the line as follows:

1
2
3
    System.Windows.Clipboard.SetText output

with the following line:

1
2
3
    System.Windows.Forms.Clipboard.SetText output

and be compatible with more installations and more versions of the DotNet Framework.

Regards, Gordon

By on 12/22/2010 12:05 AM ()

Hello, Brianmcn:
I appreciate your post, but, I can not see the editor, when I click on the link to the screenshot, I got the error message:

XML Parsing Error: not well-formed
Location: [link:cid-701679ad17b6d310.skydrive.live.com]
Line Number 119, Column 20:for (var i = 0; i < selfPageData.items.length; i++)
-------------------^
Any idea?

By on 1/12/2010 10:44 AM ()

No, but just type that location into your browser address bar (the PostCodeToHubFS.jpg url listed in the error message).

By on 1/12/2010 11:15 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper