Skip to content

Commit da817ba

Browse files
authored
Use innerText for code
Closes GH-39. Closes GH-42.
1 parent 15d6072 commit da817ba

File tree

7 files changed

+15
-7
lines changed

7 files changed

+15
-7
lines changed

lib/handlers/code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = code
44

55
var is = require('hast-util-is-element')
66
var has = require('hast-util-has-property')
7-
var toString = require('hast-util-to-string')
7+
var toText = require('hast-util-to-text')
88
var trim = require('trim-trailing-lines')
99

1010
var prefix = 'language-'
@@ -43,5 +43,5 @@ function code(h, node) {
4343
}
4444
}
4545

46-
return h(node, 'code', {lang: lang || null, meta: null}, trim(toString(node)))
46+
return h(node, 'code', {lang: lang || null, meta: null}, trim(toText(node)))
4747
}

lib/handlers/inline-code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
module.exports = inlineCode
44

5-
var toString = require('hast-util-to-string')
5+
var toText = require('hast-util-to-text')
66

77
function inlineCode(h, node) {
8-
return h(node, 'inlineCode', toString(node))
8+
return h(node, 'inlineCode', toText(node))
99
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"dependencies": {
2626
"hast-util-has-property": "^1.0.0",
2727
"hast-util-is-element": "^1.0.0",
28-
"hast-util-to-string": "^1.0.0",
28+
"hast-util-to-text": "^1.0.0",
2929
"mdast-util-phrasing": "^1.0.0",
3030
"mdast-util-to-string": "^1.0.4",
3131
"rehype-minify-whitespace": "^2.0.3",

test/fixtures/br/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
<p>alpha<br>bravo</p>
2+
<pre>charlie<br>delta</pre>

test/fixtures/br/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
alpha··
22
bravo
3+
4+
charlie
5+
delta

test/fixtures/listing/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ hotel(); india
2424
```
2525

2626
```
27-
juliettkilo();lima
27+
juliett
28+
kilo();
29+
lima
2830
```

test/fixtures/pre/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ lima(); mike
3131
```
3232

3333
```
34-
november oscar(); papa
34+
november·
35+
oscar();
36+
papa
3537
```

0 commit comments

Comments
 (0)