how to post a BAS file keeping the same layout and colors as in the compiler

Started by basiclover, Aug 25, 2021, 03:12 PM

Previous topic - Next topic

basiclover


JohnB

I don't think CODE /CODE flags is aware of the basic syntax or colour coding.  Text is seen as plain text. 
JohnB

Stephen Moss

I don't think you can without re-format it manually which could be time consuming for a lot of code.
 
I am not sure how text editors store their formatting information, if they used HTML tags than theoretically copy and past should work as the the forum should understand the HTML tags and it would probably appear correctly formatted. However, I would speculate that rather than having to recognise and convert a number of different formatting methods it simply defaults to pasting as plain text thus stripping out the formatting.
   
I am not sure on the limitation of file uploads but if it is a small section of code you could save it as a screen grab and post the image file if you really think it necessary to display formatted. But anyone who would like the formatting to make it easier to read could either download the code file (if attached) or just copy and past the posted code into whichever IDE they are using.


flosigud

To retain formatting you need to save as html. You can do that in Notepad++, I don't know about others.

JohnB

I will add a Save as HTML and CopyHTMLtoCLipboard although I have my doubts on how well CopyHTLToClipboard will work.
It works if I paste it into MS Word but when I try and paste it into the Proton Forum it does not pick up the colour formatting.
I will pursue this further.
JohnB

JohnB

I have added a new menu entry 'Files, Export To HTML' which will save the current document as an HTML file.  I have also added a keyboard shortcut Ctrl+E which will copy the selected text to the clipboard as HTML.  It will be in the next release.
JohnB

JohnB

I have just tried inserting HTML text into a topic and all I get is the raw HTML not the rendered HTML

Here is an example:

<HTML>
<BODY bgColor=#000000 LINK=#0000FF VLINK=#0000FF ALINK=#0000FF>
<PRE>
<FONT style="font-family:COURIER NEW;">
<FONT style="background-color: #000000;color:#2E8B57;font-style:italic;">;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

</FONT><FONT style="background-color: #000000;color:#FFFFFF;">    </FONT><FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;">Device</FONT><FONT style="background-color: #000000;color:#FFFFFF;"> = </FONT><FONT style="background-color: #000000;color:#0000FF;font-style:bold;">24FJ64GA002

</FONT><FONT style="background-color: #000000;color:#FFFFFF;">    </FONT><FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;">Config</FONT><FONT style="background-color: #000000;color:#FFFFFF;"> </FONT><FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;">Config2</FONT><FONT style="background-color: #000000;color:#FFFFFF;"> = FCKSM_CSDCMD, FNOSC_PRI, I2C1SEL_PRI, IESO_ON, IOL1WAY_ON, OSCIOFNC_OFF, POSCMOD_HS, SOSCSEL_SOSC, WUTSEL_LEG
    </FONT><FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;">Config</FONT><FONT style="background-color: #000000;color:#FFFFFF;"> </FONT><FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;">Config1</FONT><FONT style="background-color: #000000;color:#FFFFFF;"> = BKBUG_OFF, COE_OFF, FWDTEN_OFF, FWPSA_PR128, GCP_OFF, GWRP_OFF, ICS_PGx1, JTAGEN_ON, WDTPOST_PS32768, WINDIS_ON

</FONT><FONT style="background-color: #000000;color:#2E8B57;font-style:italic;">;**** End of Fuse Configurator Settings ****
</FONT>
</FONT>
</PRE>
</BODY>
</HTML>

I have tried pasting it into an on line HTML renderer and it works fine.  Does anyone know how to get HTML to appear rendered in the forum?
JohnB

Stephen Moss

#7
I am not sure forums are designed to work that way, I did a search and all the answer I could find suggest that it is a security thing in that if the forums processed raw HTML then unscrupulous people could use some kind of exploit or Java script code within the HTML to either screw up the forum functionality or create some kind of access to the members personal data.
That could be the reason why forums use the HTML like BBcode tags with the square brackets for formatting text instead of true HTML tags using "<" and ">".

Thus for the forum...
[size=4] this is some text[/size] = this is some text

Bold is [b] & [/b]
Italic is [i] & [/i]
Colour is [color=blue] and [/color]
Font is[font=Courier New] and [/font]
Combined style element in true HTML can be combined in one tag, i.e. <FONT style="background-color: #000000;color:#FFFFFF;font-style:bold;"> whereas in the forums they need to be nested, i.e for Red italic, size 4 text tags the tags relating to each element surround those of previous one[color=red][i][size=4]Red italic, size 4 text[/size][/i][/color]
Therefore you would probably have to write an exporter that processes the HTML tags into the appropriate BBcode tags for cut and past to keep the same formatting when posting to the forum as exists when in the IDE.   

JohnB

Thanks for the insight, I'm really not sure its worth the hassle just to keep pretty colours in the code window.
I think there are more useful things I could do.
JohnB