Skip to content

Commit 607462d

Browse files
committed
Add support for <q> to quotes (") and children
1 parent 687d126 commit 607462d

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

lib/handlers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ exports.a = require('./link');
5050

5151
exports.wbr = require('./wbr');
5252

53+
exports.q = require('./q');
54+
5355
function ignore() {}
5456

5557
function children(h, node) {

lib/handlers/q.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
module.exports = q;
4+
5+
var all = require('../all');
6+
7+
var quote = '"';
8+
9+
function q(h, node) {
10+
var contents = all(h, node);
11+
var head = contents[0];
12+
var tail = contents[contents.length - 1];
13+
14+
if (head && head.type === 'text') {
15+
head.value = quote + head.value;
16+
} else {
17+
contents.unshift({type: 'text', value: quote});
18+
}
19+
20+
if (tail && tail.type === 'text') {
21+
tail.value += quote;
22+
} else {
23+
contents.push({type: 'text', value: quote});
24+
}
25+
26+
return contents;
27+
}

test/fixtures/q/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p><q>Hello</q> World.</p>
2+
<p><q>World</q></p>
3+
<p><q>Hello <em>World</em></q></p>
4+
<p><q><em>Hello</em> World</q></p>

test/fixtures/q/index.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fragment": true
3+
}

test/fixtures/q/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"Hello" World.
2+
3+
"World"
4+
5+
"Hello _World_"
6+
7+
"_Hello_ World"

0 commit comments

Comments
 (0)