Skip to content

Commit

Permalink
Fix to ignore footnotes, footnote references
Browse files Browse the repository at this point in the history
Closes GH-66.
  • Loading branch information
wooorm committed Apr 13, 2020
1 parent 7124daf commit 9b7b270
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 9 additions & 2 deletions lib/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var LIST_ITEM = 'listItem'
var PARAGRAPH = 'paragraph'
var LINK = 'link'
var LINK_REFERENCE = 'linkReference'
var FOOTNOTE = 'footnote'
var FOOTNOTE_REFERENCE = 'footnoteReference'

// Transform a list of heading objects to a markdown list.
function contents(map, tight, prefix) {
Expand Down Expand Up @@ -107,7 +109,7 @@ function insert(entry, parent, tight, prefix) {

function all(children) {
var result = []
var length = children.length
var length = children ? children.length : 0
var index = -1

while (++index < length) {
Expand All @@ -120,7 +122,12 @@ function all(children) {
function one(node) {
var copy

if (node.type === LINK || node.type === LINK_REFERENCE) {
if (
node.type === LINK ||
node.type === LINK_REFERENCE ||
node.type === FOOTNOTE ||
node.type === FOOTNOTE_REFERENCE
) {
return all(node.children)
}

Expand Down
14 changes: 2 additions & 12 deletions test/fixtures/phrasing-content/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,8 @@
"url": "#a-footnote",
"children": [
{
"type": "footnote",
"children": [
{
"type": "text",
"value": "a footnote"
}
]
"type": "text",
"value": "a footnote"
}
]
}
Expand All @@ -203,11 +198,6 @@
{
"type": "text",
"value": "footnote reference "
},
{
"type": "footnoteReference",
"identifier": "1",
"label": "1"
}
]
}
Expand Down

0 comments on commit 9b7b270

Please sign in to comment.