Skip to content

Commit

Permalink
Fixes a few markup things in the HTML output and adds a new feature f…
Browse files Browse the repository at this point in the history
…or Small Caps.
  • Loading branch information
scottboms committed Mar 3, 2024
1 parent 11cf3f2 commit 4b0aaae
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Semantic Markup Kirbytags

A collection of kirbytags providing advanced options for semantic markup within textareas. Includes tags for: `abbr`, `cite`, `dfn`, `ins`, `mark`, `q`, `s`, `samp`, `sub`, `sup`. Each new tag includes a complementary textareaToolbar button.
A collection of kirbytags providing advanced options for semantic markup within textareas. Includes tags for: `abbr`, `cite`, `dfn`, `ins`, `mark`, `q`, `s`, `samp`, `sub`, `sup` along with a special shortcut for handling `small caps`. Each new tag includes a complementary textareaToolbar button.

## Installation

Expand All @@ -25,6 +25,7 @@ To utilize the buttons in textarea field, you need to add them explicitly to [yo
label: Content
type: textarea
buttons:
- smallcaps
- abbr
- cite
- dfn
Expand Down Expand Up @@ -75,6 +76,9 @@ All tags provide an convenience `class` attribute and the `abbr` and `dfn` tags

`(samp: Keyboard not found. Press F1 to continue. class: markup__samp)`

### [smallcaps]
`(smallcaps: porsche class: markup__sc title: Proof of Rich Spoiled Children Having Everything)`

### [sub](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub)

`C(sub: 8)H(sub: 10)N(sub: 4)O(sub: 2), also known as caffeine.`
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "scottboms/kirby-markup",
"description": "Kirby Semantic Markup Plugin",
"type": "kirby-plugin",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/scottboms/kirby-markup",
"license": "MIT",
"authors": [
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ panel.plugin("scottboms/kirby-markup", {
'q': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z"></path></svg>',
'samp': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M8,20H3c-.55,0-1-.45-1-1V5c0-.55.45-1,1-1h5v2h-4v12h4v2ZM16,18h4s0-12,0-12h-4v-2h5c.55,0,1,.45,1,1v14c0,.55-.45,1-1,1h-5v-2ZM8.5,16h5.5c1.38,0,2.5-1.12,2.5-2.5s-1.12-2.5-2.5-2.5h-4c-.28,0-.5-.22-.5-.5s.22-.5.5-.5h5.5v-2h-5.5c-1.38,0-2.5,1.12-2.5,2.5s1.12,2.5,2.5,2.5h4c.28,0,.5.22.5.5s-.22.5-.5.5h-5.5v2Z"/></svg>',
's': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z"></path></svg>',
'smallcaps': '<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M10,6.5v13h-2V6.5H2v-2h14v2h-6ZM22,10.5v-2h-10v2h4v9h2v-9h4Z"/></svg>',
'sub': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5.59567 4L10.5 9.92831L15.4043 4H18L11.7978 11.4971L18 18.9943V19H15.4091L10.5 13.0659L5.59092 19H3V18.9943L9.20216 11.4971L3 4H5.59567ZM21.8 16C21.8 15.5582 21.4418 15.2 21 15.2C20.5582 15.2 20.2 15.5582 20.2 16C20.2 16.0762 20.2107 16.15 20.2306 16.2198L19.0765 16.5496C19.0267 16.375 19 16.1906 19 16C19 14.8954 19.8954 14 21 14C22.1046 14 23 14.8954 23 16C23 16.5727 22.7593 17.0892 22.3735 17.4538L20.7441 19H23V20H19V19L21.5507 16.5803C21.7042 16.4345 21.8 16.2284 21.8 16Z"></path></svg>',
'sup': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M11 7V20H9V7H3V5H15V7H11ZM19.5507 6.5803C19.7042 6.43453 19.8 6.22845 19.8 6C19.8 5.55817 19.4418 5.2 19 5.2C18.5582 5.2 18.2 5.55817 18.2 6C18.2 6.07624 18.2107 6.14999 18.2306 6.21983L17.0765 6.54958C17.0267 6.37497 17 6.1906 17 6C17 4.89543 17.8954 4 19 4C20.1046 4 21 4.89543 21 6C21 6.57273 20.7593 7.08923 20.3735 7.45384L18.7441 9H21V10H17V9L19.5507 6.5803V6.5803Z"></path></svg>'
},
Expand Down Expand Up @@ -68,6 +69,13 @@ panel.plugin("scottboms/kirby-markup", {
this.command('toggle', '(s: ', ')');
}
},
smallcaps: {
label: 'Small Caps',
icon: 'smallcaps',
click: function() {
this.command('toggle', '(smallcaps: ', ')');
}
},
sub: {
label: 'Subscript',
icon: 'sub',
Expand Down
44 changes: 32 additions & 12 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Kirby Semantic Markup Plugin
*
* @version 1.0.0
* @version 1.0.1
* @author Scott Boms <[email protected]>
* @copyright Scott Boms <[email protected]>
* @link https://github.com/scottboms/kirby-markup
Expand All @@ -30,9 +30,9 @@
$html .= '<abbr>' . $abbr . '</abbr>';
} elseif($title !== '' && $class == '') {
// title provided but no class
$html .= '<abbr title=">' . $title . '">' . $abbr . '</abbr>';
$html .= '<abbr title="' . $title . '">' . $abbr . '</abbr>';
} else {
$html .= '<abbr title=">' . $title . '" class="' . $class . '">' . $abbr . '</abbr>';
$html .= '<abbr title="' . $title . '" class="' . $class . '">' . $abbr . '</abbr>';
}
return $html;
},
Expand Down Expand Up @@ -75,9 +75,9 @@
$html .= '<dfn>' . $dfn . '</dfn>';
} elseif($title !== '' && $class == '') {
// title provided but no class
$html .= '<dfn title=">' . $title . '">' . $dfn . '</dfn>';
$html .= '<dfn title="' . $title . '">' . $dfn . '</dfn>';
} else {
$html .= '<dfn title=">' . $title . '" class="' . $class . '">' . $dfn . '</dfn>';
$html .= '<dfn title="' . $title . '" class="' . $class . '">' . $dfn . '</dfn>';
}
return $html;
}
Expand All @@ -97,7 +97,7 @@
// if no class attributes
$html .= '<ins>' . $ins . '</ins>';
} else {
$html .= '<ins class=">' . $class . '">' . $ins . '</ins>';
$html .= '<ins class="' . $class . '">' . $ins . '</ins>';
}
return $html;
}
Expand All @@ -117,7 +117,7 @@
// if no class attributes
$html .= '<mark>' . $mark . '</mark>';
} else {
$html .= '<mark class=">' . $class . '">' . $mark . '</mark>';
$html .= '<mark class="' . $class . '">' . $mark . '</mark>';
}
return $html;
}
Expand All @@ -137,7 +137,7 @@
// if no class attributes
$html .= '<q>' . $q . '</q>';
} else {
$html .= '<q class=">' . $class . '">' . $q . '</q>';
$html .= '<q class="' . $class . '">' . $q . '</q>';
}
return $html;
}
Expand All @@ -157,7 +157,27 @@
// if no class attributes
$html .= '<samp>' . $samp . '</samp>';
} else {
$html .= '<samp class=">' . $class . '">' . $samp . '</samp>';
$html .= '<samp class="' . $class . '">' . $samp . '</samp>';
}
return $html;
}
],

// Small Caps
'smallcaps' => [
'attr' => [
'class'
],
'html' => function($tag) {
$html = '';
$smallcaps = $tag->smallcaps;
$class = $tag->class;

if($class == '') {
// if no class attributes
$html .= '<span class="markup__smallcaps">' . $smallcaps . '</span>';
} else {
$html .= '<span class="' . $class . '">' . $smallcaps . '</span>';
}
return $html;
}
Expand All @@ -177,7 +197,7 @@
// if no class attributes
$html .= '<s>' . $s . '</s>';
} else {
$html .= '<s class=">' . $class . '">' . $s . '</s>';
$html .= '<s class="' . $class . '">' . $s . '</s>';
}
return $html;
}
Expand All @@ -197,7 +217,7 @@
// if no class attributes
$html .= '<sub>' . $sub . '</sub>';
} else {
$html .= '<sub class=">' . $class . '">' . $sub . '</sub>';
$html .= '<sub class="' . $class . '">' . $sub . '</sub>';
}
return $html;
}
Expand All @@ -217,7 +237,7 @@
// if no class attributes
$html .= '<sup>' . $sup . '</sup>';
} else {
$html .= '<sup class=">' . $class . '">' . $sup . '</sup>';
$html .= '<sup class="' . $class . '">' . $sup . '</sup>';
}
return $html;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "kirby-markup",
"description": "Custom Kirbytags providing more advanced semantic markup in textareas",
"author": "Scott Boms <[email protected]>",
"version": "1.0.0",
"version": "1.0.1",
"type": "kirby-plugin",
"license": "MIT"
}

0 comments on commit 4b0aaae

Please sign in to comment.