diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/macros/head.html | 17 | ||||
| -rw-r--r-- | templates/shortcodes/image.html | 2 | ||||
| -rw-r--r-- | templates/shortcodes/imagehover.html | 41 | ||||
| -rw-r--r-- | templates/shortcodes/img.html | 56 | ||||
| -rw-r--r-- | templates/shortcodes/imghover.html | 85 | ||||
| -rw-r--r-- | templates/shortcodes/katex.html | 2 | ||||
| -rw-r--r-- | templates/shortcodes/quote.html | 6 |
7 files changed, 114 insertions, 95 deletions
diff --git a/templates/macros/head.html b/templates/macros/head.html index 6736cd9..42d8fa0 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -203,14 +203,17 @@ {%- endif %} {%- endmacro %} - +{# https://katex.org/docs/autorender.html #} +{# https://github.com/KaTeX/KaTeX/ #} +{# https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #} {%- macro math() %} - {%- if config.extra.katex_enabled %} - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous"> - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script> - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script> - {%- if config.extra.katex_auto_render %} - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script> + {%- if config.extra.math or page.extra.math %} + <link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/katex.min.css" as="style" integrity="sha384-ZPe7yZ91iWxYumsBEOn7ieg8q/o+qh/hQpSaPow8T6BwALcXSCS6C6fSRPIAnTQs" onload="this.onload=null;this.rel='stylesheet'" crossorigin="anonymous"> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/katex.min.js" integrity="sha384-ljao5I1l+8KYFXG7LNEA7DyaFvuvSCmedUf6Y6JI7LJqiu8q5dEivP2nDdFH31V4" crossorigin="anonymous"></script> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script> + {%- if config.extra.math_auto_render or page.extra.math_auto_render %} + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.6/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script> + <script>document.addEventListener("DOMContentLoaded",function(){renderMathInElement(document.body,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1},{left:"\\[",right:"\\]",display:!0}],throwOnError:!1})});</script> {%- endif %} {%- endif %} {%- endmacro %} diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html index ea236ef..3653c8a 100644 --- a/templates/shortcodes/image.html +++ b/templates/shortcodes/image.html @@ -3,5 +3,5 @@ {% set type = source | split(pat=".") | last -%} <source srcset="{{ config.base_url | safe}}{{ page.path | safe }}{{ source | safe }}" type="{{ 'img/' ~ type }}"> {% endfor -%} - <img src="{{ fallback_path }}" alt="{{ fallback_alt }}"/> + <img src="{{ fpath }}" alt="{{ falt | default(value='Image') }}" {% if fw %}width="{{fw}}" {% endif %}{% if fh %}height="{{fh}}" {% endif %}/> </picture> diff --git a/templates/shortcodes/imagehover.html b/templates/shortcodes/imagehover.html deleted file mode 100644 index 99dd4e4..0000000 --- a/templates/shortcodes/imagehover.html +++ /dev/null @@ -1,41 +0,0 @@ -{%- set_global bg = " " %} -{%- set_global bgname = " " %} -{%- for source in sources %} - {%- set sourcename = source | split(pat=".") | first %} - {%- if loop.first %} - {%- set_global bg = source %} - {%- set_global bgname = source | split(pat=".") | first %} - {%- else %} - - <div id="{{ sourcename }}">## {{ sourcename }} </div> - <div id="{{ sourcename }}image" alt="{{ sourcename }}"> </div> - - {%- endif %} -{%- endfor %} - -{%- if w and h and p %} - {%- set padding = h / w * p %} -{%- elif w and h %} - {%- set padding = h / w * 50 %} -{%- else %} - {%- set padding = 50 %} -{%- endif %} - -<style> - {%- for source in sources %} - {%- set sourcename = source | split(pat=".") | first %} - {%- if not loop.first %} - #{{ sourcename | safe }}image { - background-image: url('{{ get_url(path="/", trailing_slash=false) }}{{ page.path | safe }}{{ bg | safe }}'); - background-size: contain; - background-repeat: no-repeat; - width: {{ p | default(value=50) }}%; - height: 0; - padding-top: {{ padding }}%; - } - #{{ sourcename | safe }}image:hover { - background-image: url('{{ get_url(path="/", trailing_slash=false) }}{{ page.path | safe }}{{ source | safe }}'); - } - {%- endif %} - {%- endfor %} -</style> diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html index d003eeb..46fb39d 100644 --- a/templates/shortcodes/img.html +++ b/templates/shortcodes/img.html @@ -1,45 +1,23 @@ -{# {{ img(path="", alt="", caption="", extended_width_pct=1.3, quality=90) }} #} +{# {{ img(src="ferris.svg" class="" alt="" w=600 h=400) }} #} -{# container_width = (pixel size, px) * (.container's max-width) #} -{% set container_width = 16 * 42 %} +{%- set dirtest = src | trim_start_matches(pat="./") %} +{%- if dirtest is containing("/") %} + {%- set reldir = true %} +{%- endif %} -{# figure_width = container_width - (figure margin_blocks) #} -{% set figure_width = container_width - (40 * 2) %} +{%- if src is starting_with("./") and reldir %} {# Relative Path #} + {%- set path = src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} + {%- set path = path ~ "/" %} -{% if path is starting_with("./") %} - {% set relative_path = page.relative_path | split(pat="/") | slice(end=-1) | join(sep="/") %} - {% set img_path = path | trim_start_matches(pat="./") %} - {% set img_path = relative_path ~ "/" ~ img_path %} -{% else %} - {% set img_path = path %} -{% endif %} +{%- elif src is starting_with("/") %} {# Root Path #} + {%- set rootpath = src | split(pat="/") | slice(end=-1) | join(sep="/") %} + {%- set path = config.base_url ~ rootpath ~ "/" %} -{% if path is not ending_with(".svg") %} +{%- else %} {# Same Directory Path #} + {%- set path = "" %} - {% set resize = true %} - {% set image_quality = 90 %} - {% if quality %} - {% set image_quality = quality %} - {% endif %} +{%- endif %} - {% if extended_width_pct %} - - {% if extended_width_pct == -1 %} - {# adjust extended width to container width #} - {% set extended_width_pct = 0.042 %} - {% endif %} - {% set _width = config.extra.images.max_width - figure_width %} - {% set extended_width = (extended_width_pct * _width + figure_width) | round | int %} - {% if extended_width > config.extra.images.max_width %} - {% set extended_width = config.extra.images.max_width %} - {% endif %} - {% set resized_image = resize_image(path=img_path, width=extended_width, op="fit_width", quality=image_quality) %} - - {% else %} - {% set resized_image = resize_image(path=img_path, width=figure_width, op="fit_width", quality=image_quality) %} - {% endif %} -{% endif %} -<figure> - <img src="{% if resize %}{{ resized_image.url }}{% else %}{{ path }}{% endif %}" {% if alt %}alt="{{alt}}"{% endif %}/> - {% if caption %}<figcaption>{{ caption | safe }}</figcaption>{% endif %} -</figure> +{%- set img = src | split(pat="/") | last %} +{%- set name = img | split(pat=".") | first %} +<img src="{{ path | safe }}{{ img | safe }}" {% if class %}class="{{class}}" {% endif %}{% if alt %}alt="{{alt}}" {% endif %}{% if w %}width="{{w}}" {% endif %}{% if h %}height="{{h}}" {% endif %}/> diff --git a/templates/shortcodes/imghover.html b/templates/shortcodes/imghover.html new file mode 100644 index 0000000..8063378 --- /dev/null +++ b/templates/shortcodes/imghover.html @@ -0,0 +1,85 @@ +{%- set_global bg = "" %} + +{%- for source in src %} + + {%- set dirtest = source | trim_start_matches(pat="./") %} + {%- if dirtest is containing("/") %} + {%- set reldir = true %} + {%- endif %} + + {%- if source is starting_with("./") and reldir %} {# Relative Path #} + {%- set pathtype = "rel-" %} + {%- set path = source | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} + {%- set path = path ~ "/" %} + + {%- elif source is starting_with("/") %} {# Root Path #} + {%- set pathtype = "root-" %} + {%- set rootpath = source | split(pat="/") | slice(end=-1) | join(sep="/") %} + {%- set path = config.base_url ~ rootpath ~ "/" %} + + {%- else %} {# Same Directory Path #} + {%- set pathtype = "same-" %} + {%- set path = "" %} + {%- endif %} + + {%- set sourcepath = source | split(pat="/") | last %} + {%- set sourcename = pathtype ~ sourcepath | split(pat=".") | first %} + + {%- if loop.first %} + {%- set_global bg = source | split(pat="/") | last %} + {%- else %} + <div id="{{ sourcename }}"><b>{{ sourcename }} on hover</b></div> + <div id="{{ sourcename }}image" alt="{{ sourcename }}"> </div> + {%- endif %} + +{%- endfor %} + +{%- if w and h and p %} + {%- set padding = h / w * p %} +{%- elif w and h %} + {%- set padding = h / w * 50 %} +{%- else %} + {%- set padding = 50 %} +{%- endif %} + +<style> + {%- for source in src %} + + {%- set dirtest = source | trim_start_matches(pat="./") %} + {%- if dirtest is containing("/") %} + {%- set reldir = true %} + {%- endif %} + + {%- if source is starting_with("./") and reldir %} {# Relative Path #} + {%- set pathtype = "rel-" %} + {%- set path = source | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} + {%- set path = path ~ "/" %} + + {%- elif source is starting_with("/") %} {# Root Path #} + {%- set pathtype = "root-" %} + {%- set rootpath = source | split(pat="/") | slice(end=-1) | join(sep="/") %} + {%- set path = config.base_url ~ rootpath ~ "/" %} + + {%- else %} {# Same Directory Path #} + {%- set pathtype = "same-" %} + {%- set path = "" %} + {%- endif %} + + {%- set sourcepath = source | split(pat="/") | last %} + {%- set sourcename = pathtype ~ sourcepath | split(pat=".") | first %} + + {%- if not loop.first %} + #{{ sourcename | safe }}image { + background-image: url('{{ path | safe }}{{ bg | safe }}'); + background-size: contain; + background-repeat: no-repeat; + width: {{ p | default(value=50) }}%; + height: 0; + padding-top: {{ padding }}%; + } + #{{ sourcename | safe }}image:hover { + background-image: url('{{ path | safe }}{{ sourcepath | safe }}'); + } + {%- endif %} + {%- endfor %} +</style> diff --git a/templates/shortcodes/katex.html b/templates/shortcodes/katex.html index cac8e97..9b9a1f7 100644 --- a/templates/shortcodes/katex.html +++ b/templates/shortcodes/katex.html @@ -1 +1 @@ -<script type="math/tex{% if block %};mode=display{% endif %}">{{body}}</script> +<script type="math/tex{% if block %};mode=display{% endif %}">{{body | safe}}</script> diff --git a/templates/shortcodes/quote.html b/templates/shortcodes/quote.html deleted file mode 100644 index 8238b71..0000000 --- a/templates/shortcodes/quote.html +++ /dev/null @@ -1,6 +0,0 @@ -<blockquote> - {{body}}<br /> - {% if author %} - -- {{ author }} - {% endif %} -</blockquote> |
