Skip to content

Commit

Permalink
Merge pull request #480 from gethinode/develop
Browse files Browse the repository at this point in the history
Add mark shortcode
  • Loading branch information
markdumay committed Aug 29, 2023
2 parents b3118ba + 158fd88 commit c83c3b7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions layouts/shortcodes/mark.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Highlights text by applying a background color. The shortcode supports the following arguments:
"color": Optional theme color of the highlight, either "primary", "secondary", "success", "danger",
"warning", "info", "light", "dark", "white" or "black". By default, the highlight uses the color of
the HTML mark function.
"class": Optional class attribute of the highlight element.
-->

{{- $error := false -}}
{{ $color := .Get "color" -}}
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" -}}
{{ if and $color (not (in $supportedColors $color)) -}}
{{ errorf "Invalid value for param 'color': %s" .Position -}}
{{ $error = true -}}
{{ end -}}

{{- $class := .Get "class" -}}

{{- if $color }}{{ $class = printf "%s text-bg-%s" $class $color }}{{ end -}}

{{- if not $error -}}
<mark{{ with $class }} class="{{ . }}"{{ end }}>{{ trim .Inner " \r\n" | .Page.RenderString -}}</mark>
{{- end -}}

0 comments on commit c83c3b7

Please sign in to comment.