Shortcodes

Ray Fan edited this page Aug 28, 2018 · 1 revision

When writing a post, you may need to post things like source code or youtube videos, shortcodes make this really easy.

Source code

Fanray uses SyntaxHighlighter to highlgith source code, here are the supported languages. For example, to post C# code

[code lang=cs]
paste your code here...
[/code]

The following attributes are supported

  • highlight: (comma-seperated list of numbers) - You can list the line numbers you want to be highlighted.
    [code lang=cs highlight=1,3]
    your source code line 1 and 3 will be highlighted
    [/code]
    
  • gutter: (true/false) - If false, the line numbers on the left side will be hidden. Defaults to true.
    [code lang=cs gutter=false]
    you won't see line numbers on the left
    [/code]
    
  • firstline: (number) - Use this to change what number the line numbering starts at. It defaults to 1.
    [code lang=cs firstline=87]
    the line number on the left starts at 87
    [/code]
    
  • htmlscript: (true/false) - If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as razor content. Defaults to false. Only works with certain languages. Don't use this attribute when lang is already html or xml.
    [code lang=cs htmlscript=true]
    paste your cshtml code here
    [/code]
    

YouTube videos

To post a youtube video, get the video's url, any of the two formats will do.

[youtube https://www.youtube.com/watch?v=MNor4dYXa6U] or 
[youtube https://youtu.be/MNor4dYXa6U]

To embed the video with default width and height (560 x 315)

[youtube https://www.youtube.com/watch?v=MNor4dYXa6U]

To specify the width and height explicitly

[youtube https://www.youtube.com/watch?v=MNor4dYXa6U&w=800&h=400]

To specify the width only

[youtube https://www.youtube.com/watch?v=MNor4dYXa6U&w=800]

To start at a certain point in the video, convert the time of that point from minutes and seconds to all seconds, then add that number as shown (using an example start point of 1 minute 15 seconds)

[youtube https://www.youtube.com/watch?v=MNor4dYXa6U&start=75]
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.