Fixing the Code Format of OTN Java Articles — oracle-tech

    Forum Stats

  • 3,681,445 Users
  • 2,238,012 Discussions
  • 7,831,224 Comments

Discussions

Fixing the Code Format of OTN Java Articles

Some of our articles have code formatting issues. It's going to take us a while to fix those issues. In the meantime, you can request access to edit your article by adding a thread . I will grant you edit rights.

Here are the steps to follow to fix the code:

  • Click Edit on the right hand sidebar
  • In the html code editor, remove <pre> tags

         (Find and remove all <pre> before the code and </pre> after the code)

  • In the text editor, highlight the code to reformat
  • Click on  >>  and select SYNTAX HIGHLIGHTING
  • From the drop down menu, select Java

Screen Shot 2016-08-18 at 2.29.00 PM.png

  • You will need to manually format the code in the text editor

Comments

  • BluShadowBluShadow Moderator Posts: 40,754 Red Diamond

    The "Syntax highlighting" option can have some side-effects if people want to copy/paste the content from the community (i.e. you can end up getting the line numbers the community has attached included in the copy/paste text).

    An alternative is to use the Advanced Editor and:

    • highlight the code you want to format
    • choose the font "Courier New" from the drop down list
    • click on the ">>" icon in the editor and choose "Quote" (rather than Syntax Highlighting)

    This indents the text as a quoted section using a fixed width font, but allows the text to be copied and pasted as shown.

  • I tried that. There were a lot of html tags added as a result of choosing the font "Courier New."

  • BluShadowBluShadow Moderator Posts: 40,754 Red Diamond
    edited August 2016

    I tried that. There were a lot of html tags added as a result of choosing the font "Courier New."

    Well, most people don't look at the HTML behind the page

    As an example though, go to this thread which uses syntax highlighting in the original post...

    and try to copy/paste the code from it into notepad.  You'll see that you end up getting all the line numbers from the syntax highlighting included which would then require you to manually edit and remove all of those.

    Now take a look at this thread where my answer uses courier new font:

    or one of the articles I've created on the community e.g.

    and try to copy/paste the code from it into notepad.  Apart from some additional line feeds that get created, the code is pasted "as is" and can be used straight away.

    It's a known issue with the syntax highlighting which will hopefully get sorted when Oracle get around to providing their own in-house editor for the community.

Sign In or Register to comment.