-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(syntax): add support for liquid_tags.include_code plugin
fix #518
- Loading branch information
Showing
7 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
documentation/content/Supported Plugins/code-snippets-liquid-tags.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
Title: Code Snippets -- Include code from file | ||
Tags: code-snippets, plugins, liquid-tags | ||
Date: 2020-02-02 20:53 | ||
comments: false | ||
Slug: code-snippets-include-code-from-file | ||
authors: Talha Mansoor | ||
Category: Supported Plugins | ||
--- | ||
|
||
Elegant supports [`liquid_tags.include_code` plugin](https://github.com/getpelican/pelican-plugins/tree/master/liquid_tags#include-code). | ||
|
||
<!-- TODO: remove this warning after https://github.com/getpelican/pelican-plugins/pull/1243 is merged --> | ||
|
||
!!! Warning "Pending Pull Request" | ||
|
||
The demo you see here is dependent on [this | ||
patch](https://github.com/getpelican/pelican-plugins/pull/1243). | ||
|
||
Until Pelican team merges the patch into plugins repository, you will have | ||
apply this patch manually to your copy of plugins. | ||
|
||
## Example 1 | ||
|
||
{% include_code square-root.py lang:python Calculate square root of 8 %} | ||
|
||
## Example 2 -- Without Filename | ||
|
||
{% include_code alias-sed.fish :hidefilename: Fish Shell alias for sed %} | ||
|
||
## Example 3 -- Without Download Link | ||
|
||
{% include_code alias-sed.fish :hidelink: Fish Shell alias for sed %} | ||
|
||
## Example 4 -- Without Filename and Download Link | ||
|
||
{% include_code alias-sed.fish :hidefilename: :hidelink: Fish Shell alias for sed %} | ||
|
||
## Example 3 -- Without Metadata | ||
|
||
{% include_code square-root.js lang:js :hideall: Compute square-root %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function sed -d 'alias sed to gsed' | ||
command gsed $argv; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// From https://gist.github.com/joelpt/3824024 | ||
// | ||
// The Babylonian Method | ||
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method | ||
// @param n - the number to compute the square root of | ||
// @param g - the best guess so far (can omit from initial call) | ||
function squirt(n, g) { | ||
if (!g) { | ||
// Take an initial guess at the square root | ||
g = n / 2.0; | ||
} | ||
var d = n / g; // Divide our guess into the number | ||
var ng = (d + g) / 2.0; // Use average of g and d as our new guess | ||
if (g == ng) { | ||
// The new guess is the same as the old guess; further guesses | ||
// can get no more accurate so we return this guess | ||
return g; | ||
} | ||
// Recursively solve for closer and closer approximations of the square root | ||
return squirt(n, ng); | ||
} | ||
|
||
console.log(squirt(42)); // 6.48074069840786 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# Python Program to calculate the square root | ||
# Note: change this value for a different result | ||
num = 8 | ||
# To take the input from the user | ||
# num = float(input('Enter a number: ')) | ||
num_sqrt = num ** 0.5 | ||
print("The square root of %0.3f is %0.3f" % (num, num_sqrt)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters