
內容簡介
此外掛會將公開 GitHub 存儲庫的內容嵌入到 WordPress 文章中。它可以擷取文件的完整內容或片段。程式碼會顯示語法突出顯示和行號。
現在支援內容快取,以提高頁面反應速度和載入速度。
語法突出顯示是由 Sunlight JS 語法突出顯示器提供的。非常感謝參與該項目的人員!
使用说明
此外掛註冊了一個 shortcode,允許將 GitHub 存儲庫內容嵌入到博客文章中。要將內容嵌入到文章中,請使用如下所示的 github shortcode:
[github userid="[目標使用者 ID]" repoid="[目標存儲庫 ID]" path="[內容的路徑]" language="[目標內容的語言]"]
github shortcode 使用的屬性:
userid – 存儲庫所有者的使用者 ID。
repoid – 包含目標內容的存儲庫的 ID。
path – 內容的完整路徑。此路徑應該從存儲庫根目錄開始,不包括領先的 /,並以目標內容的檔名結束。
language – 內容中包含的程式碼的程式語言。此資訊將傳遞給語法突出顯示器。該值必須匹配 Sunlight JS 引擎的可識別值之一。有關值列表,請參閱 Sunlight 說明文件。
startloc – 可選。要在程式碼片段中顯示的程式碼的開始行。如果省略此屬性,第一行的擷取檔將是片段中顯示的第一行程式碼。
stoploc – 可選。要顯示在程式碼片段中的最後一行程式碼(含)。如果省略此屬性,片段中顯示的最後一行內容將是擷取檔的最後一行。
範例
擷取 jQuery 項目存儲庫中的 src/support.js:
[getgit repoid="jquery" userid="jquery" path="src/support.js" language="javascript"]
取得此外掛程式碼回收類的第 39 至第 64 行:
[getgit repoid=github-wordpress-plugin userid=claycarpenter path="src/php/github_repo_content_retriever.php" language="php" startloc=39 stoploc=64]
外掛標籤
開發者團隊
原文外掛簡介
This plugin embeds the content of a public GitHub repository into your WordPress posts. It’s capable of retrieving either the full content or a snippet of a file. The code will be displayed with syntax highlighting and line numbers.
Now supports content caching for improved page responsiveness and load times.
Syntax highlighting is provided by the Sunlight JS syntax highlighter. Many thanks to those involved in that project!
Usage
This plugin registers a shortcode that allows for embedding GitHub repo content into blog posts. To embed content into your post, use the github shortcode like so:
[github userid="[target user id]" repoid="[target repo id]" path="[path to content]" language="[language of target content]"]
Attributes used by the github shortcode:
userid – The user ID of the repository owner.
repoid – The ID of the repository that contains the target content.
path – The full path to the content. This path should start at the repository root, not inclusive of the leading /, and terminate with the name of the target content’s filename.
language – The programming language of the code contained in the content. This information will be passed to the syntax highlighter. The value must match one of the recognized values for the Sunlight JS engine. For a list of values, see the Sunlight documentation.
startloc – Optional. The starting line of code to display in the code snippet. If this attribute is ommitted, the first line of retrieved file will be the first line of code displayed in the snippet.
stoploc – Optional. The final line of code (inclusive) to display in the code snippet. If this attribute is ommitted, the final line of content shown in the snippet will be the last line of the retrieved file.
Examples
Retrieve src/support.js from the jQuery project repo:
[getgit repoid=”jquery” userid=”jquery” path=”src/support.js” language=”javascript”]
Retrieve lines 39 through 64 of this plugin’s content retrieval class:
[getgit repoid=github-wordpress-plugin userid=claycarpenter path=”src/php/github_repo_content_retriever.php” language=”php” startloc=39 stoploc=64]
