Skip to content

Commit 0141a07

Browse files
committed
Code refactoring and cleanup.
1 parent 3506a0b commit 0141a07

File tree

18 files changed

+345
-320
lines changed

18 files changed

+345
-320
lines changed

index.php

Lines changed: 21 additions & 270 deletions
Original file line numberDiff line numberDiff line change
@@ -32,273 +32,24 @@
3232
}
3333

3434
Kirby::plugin(
35-
name: 'scottboms/kirby-markup',
36-
info: [
37-
'homepage' => 'https://github.com/scottboms/kirby-markup'
38-
],
39-
version: '1.1.2',
40-
extends: [
41-
'tags' => [
42-
// Abbreviation
43-
'abbr' => [
44-
'attr' => [
45-
'title',
46-
'class'
47-
],
48-
'html' => function($tag) {
49-
$html = '';
50-
// tag options
51-
$abbr = $tag->abbr;
52-
$title = $tag->title;
53-
$class = $tag->class;
54-
55-
if($title == '' && $class == '') {
56-
// if no title or class attributes
57-
$html .= '<abbr>' . $abbr . '</abbr>';
58-
} elseif($title !== '' && $class == '') {
59-
// title provided but no class
60-
$html .= '<abbr title="' . $title . '">' . $abbr . '</abbr>';
61-
} else {
62-
$html .= '<abbr title="' . $title . '" class="' . $class . '">' . $abbr . '</abbr>';
63-
}
64-
return $html;
65-
},
66-
],
67-
68-
// Citation
69-
'cite' => [
70-
'attr' => [
71-
'class'
72-
],
73-
'html' => function($tag) {
74-
$html = '';
75-
$cite = $tag->cite;
76-
$class = $tag->class;
77-
78-
if($class == '') {
79-
// if no class attributes
80-
$html .= '<cite>' . $cite . '</cite>';
81-
} else {
82-
$html .= '<cite class="' . $class . '">' . $cite . '</cite>';
83-
}
84-
return $html;
85-
}
86-
],
87-
88-
// Deletion
89-
'del' => [
90-
'attr' => [
91-
'cite',
92-
'datetime'
93-
],
94-
'html' => function($tag) {
95-
$html = '';
96-
// tag options
97-
$del = $tag->del;
98-
$cite = $tag->cite;
99-
$datetime = $tag->datetime;
100-
101-
if($cite == '' && $datetime == '') {
102-
// if no cite or datetime attributes
103-
$html .= '<del>' . $del . '</del>';
104-
} elseif($cite !== '' && $datetime == '') {
105-
// cite provided but not datetime
106-
$html .= '<del cite="' . $cite . '">' . $del . '</del>';
107-
} else {
108-
$html .= '<del cite="' . $cite . '" datetime="' . $datetime . '">' . $del . '</del>';
109-
}
110-
return $html;
111-
},
112-
],
113-
114-
// Definition
115-
'dfn' => [
116-
'attr' => [
117-
'class',
118-
'title'
119-
],
120-
'html' => function($tag) {
121-
$html = '';
122-
$dfn = $tag->dfn;
123-
$class = $tag->class;
124-
$title = $tag->title;
125-
126-
if($title == '' && $class == '') {
127-
// if no title or class attributes
128-
$html .= '<dfn>' . $dfn . '</dfn>';
129-
} elseif($title !== '' && $class == '') {
130-
// title provided but no class
131-
$html .= '<dfn title="' . $title . '">' . $dfn . '</dfn>';
132-
} else {
133-
$html .= '<dfn title="' . $title . '" class="' . $class . '">' . $dfn . '</dfn>';
134-
}
135-
return $html;
136-
}
137-
],
138-
139-
// Insert
140-
'ins' => [
141-
'attr' => [
142-
'class'
143-
],
144-
'html' => function($tag) {
145-
$html = '';
146-
$ins = $tag->ins;
147-
$class = $tag->class;
148-
149-
if($class == '') {
150-
// if no class attributes
151-
$html .= '<ins>' . $ins . '</ins>';
152-
} else {
153-
$html .= '<ins class="' . $class . '">' . $ins . '</ins>';
154-
}
155-
return $html;
156-
}
157-
],
158-
159-
// Mark
160-
'mark' => [
161-
'attr' => [
162-
'class'
163-
],
164-
'html' => function($tag) {
165-
$html = '';
166-
$mark = $tag->mark;
167-
$class = $tag->class;
168-
169-
if($class == '') {
170-
// if no class attributes
171-
$html .= '<mark>' . $mark . '</mark>';
172-
} else {
173-
$html .= '<mark class="' . $class . '">' . $mark . '</mark>';
174-
}
175-
return $html;
176-
}
177-
],
178-
179-
// Inline Quote
180-
'q' => [
181-
'attr' => [
182-
'class',
183-
'cite'
184-
],
185-
'html' => function($tag) {
186-
$html = '';
187-
$q = $tag->q;
188-
$class = $tag->class;
189-
$cite = $tag->cite;
190-
191-
if($class == '' && $cite == '') {
192-
// if no class or cite attributes
193-
$html .= '<q>' . $q . '</q>';
194-
} elseif($class !== '' && $cite == '') {
195-
// class provided but no cite
196-
$html .= '<q class="' . $class . '">' . $q . '</q>';
197-
} else {
198-
$html .= '<q class="' . $class . '" cite="' . $cite . '">' . $q . '</q>';
199-
}
200-
return $html;
201-
}
202-
],
203-
204-
// Sample
205-
'samp' => [
206-
'attr' => [
207-
'class'
208-
],
209-
'html' => function($tag) {
210-
$html = '';
211-
$samp = $tag->samp;
212-
$class = $tag->class;
213-
214-
if($class == '') {
215-
// if no class attributes
216-
$html .= '<samp>' . $samp . '</samp>';
217-
} else {
218-
$html .= '<samp class="' . $class . '">' . $samp . '</samp>';
219-
}
220-
return $html;
221-
}
222-
],
223-
224-
// Small Caps
225-
'smallcaps' => [
226-
'attr' => [
227-
'class'
228-
],
229-
'html' => function($tag) {
230-
$html = '';
231-
$smallcaps = $tag->smallcaps;
232-
$class = $tag->class;
233-
234-
if($class == '') {
235-
// if no class attributes
236-
$html .= '<span class="markup__smallcaps">' . $smallcaps . '</span>';
237-
} else {
238-
$html .= '<span class="' . $class . '">' . $smallcaps . '</span>';
239-
}
240-
return $html;
241-
}
242-
],
243-
244-
// Strikethrough
245-
's' => [
246-
'attr' => [
247-
'class'
248-
],
249-
'html' => function($tag) {
250-
$html = '';
251-
$s = $tag->s;
252-
$class = $tag->class;
253-
254-
if($class == '') {
255-
// if no class attributes
256-
$html .= '<s>' . $s . '</s>';
257-
} else {
258-
$html .= '<s class="' . $class . '">' . $s . '</s>';
259-
}
260-
return $html;
261-
}
262-
],
263-
264-
// Subscript
265-
'sub' => [
266-
'attr' => [
267-
'class'
268-
],
269-
'html' => function($tag) {
270-
$html = '';
271-
$sub = $tag->sub;
272-
$class = $tag->class;
273-
274-
if($class == '') {
275-
// if no class attributes
276-
$html .= '<sub>' . $sub . '</sub>';
277-
} else {
278-
$html .= '<sub class="' . $class . '">' . $sub . '</sub>';
279-
}
280-
return $html;
281-
}
282-
],
283-
284-
// Superscript
285-
'sup' => [
286-
'attr' => [
287-
'class'
288-
],
289-
'html' => function($tag) {
290-
$html = '';
291-
$sup = $tag->sup;
292-
$class = $tag->class;
293-
294-
if($class == '') {
295-
// if no class attributes
296-
$html .= '<sup>' . $sup . '</sup>';
297-
} else {
298-
$html .= '<sup class="' . $class . '">' . $sup . '</sup>';
299-
}
300-
return $html;
301-
}
302-
],
303-
]
304-
]);
35+
name: 'scottboms/kirby-markup',
36+
info: [
37+
'homepage' => 'https://github.com/scottboms/kirby-markup'
38+
],
39+
version: '1.1.3',
40+
extends: [
41+
'tags' => [
42+
'abbr' => require __DIR__ . '/tags/abbr.php',
43+
'cite' => require __DIR__ . '/tags/cite.php',
44+
'del' => require __DIR__ . '/tags/del.php',
45+
'dfn' => require __DIR__ . '/tags/dfn.php',
46+
'ins' => require __DIR__ . '/tags/ins.php',
47+
'mark' => require __DIR__ . '/tags/mark.php',
48+
'q' => require __DIR__ . '/tags/quote.php',
49+
'samp' => require __DIR__ . '/tags/samp.php',
50+
'smallcaps' => require __DIR__ . '/tags/smallcaps.php',
51+
's' => require __DIR__ . '/tags/strikethrough.php',
52+
'sub' => require __DIR__ . '/tags/sub.php',
53+
'sup' => require __DIR__ . '/tags/sup.php',
54+
]
55+
]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Advanced semantic markup for Textarea and Writer fields.",
44
"author": "Scott Boms <[email protected]>",
55
"type": "kirby-plugin",
6-
"version": "1.1.2",
6+
"version": "1.1.3",
77
"license": "MIT",
88
"scripts": {
99
"dev": "kirbyup serve src/index.js",

src/components/CiteDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</template>
1818

1919
<script>
20-
console.log('Citation Dialog loaded...');
20+
// console.log('Citation Dialog loaded...');
2121
2222
export default {
2323
name: "cite-dialog",

0 commit comments

Comments
 (0)