Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating remark, unified etc #342

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,846 changes: 5,626 additions & 5,220 deletions package-lock.json

Large diffs are not rendered by default.

58 changes: 30 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@
"collectCoverage": true
},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/polyfill": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"axios": "^0.18.0",
"babel-jest": "^24.7.1",
"babel-loader": "^8.0.5",
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@babel/preset-env": "^7.5.4",
"axios": "^0.19.0",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
"clone": "^2.1.1",
"core-js": "^2.6.8",
"coveralls": "^3.0.3",
"core-js": "^3.1.4",
"coveralls": "^3.0.5",
"cross-env": "^5.2.0",
"dedent": "^0.7.0",
"del-cli": "^1.0.0",
"eslint": "^5.16.0",
"express": "^4.16.2",
"del-cli": "^2.0.0",
"eslint": "^6.1.0",
"express": "^4.17.1",
"html-differ": "^1.4.0",
"jest": "^24.7.1",
"jest": "^24.8.0",
"jest-environment-node-debug": "^2.0.0",
"lerna": "^3.13.2",
"mdast-util-to-hast": "3.0.2",
"parallel-webpack": "^2.3.0",
"rehype-stringify": "^4.0.0",
"remark": "^9.0.0",
"lerna": "^3.16.4",
"mdast-util-to-hast": "6.0.1",
"parallel-webpack": "^2.4.0",
"regenerator-runtime": "^0.13.3",
"rehype-stringify": "^6.0.0",
"remark": "^11.0.0",
"remark-math": "^1.0.6",
"remark-parse": "^5.0.0",
"remark-rehype": "^3.0.2",
"remark-stringify": "^5.0.0",
"remark-parse": "^7.0.0",
"remark-rehype": "^5.0.0",
"remark-stringify": "^7.0.1",
"textr": "^0.3.0",
"unified": "^7.1.0",
"unist-util-visit": "^1.3.1",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0"
"unified": "^8.3.2",
"unist-util-visit": "^1.4.1",
"webpack": "^4.38.0",
"webpack-cli": "^3.3.6"
},
"scripts": {
"pretest": "npm run lint && lerna run pretest --scope zmarkdown",
Expand All @@ -58,15 +58,15 @@
"private": true,
"name": "zmarkdown-meta",
"dependencies": {
"deepmerge": "^3.2.0",
"hast-util-sanitize": "^1.3.0",
"deepmerge": "^4.0.0",
"hast-util-sanitize": "^2.0.1",
"mdast-util-split-by-heading": "file:packages/mdast-util-split-by-heading",
"rebber": "file:packages/rebber",
"rebber-plugins": "file:packages/rebber-plugins",
"rehype-footnotes-title": "file:packages/rehype-footnotes-title",
"rehype-html-blocks": "file:packages/rehype-html-blocks",
"rehype-postfix-footnote-anchors": "file:packages/rehype-postfix-footnote-anchors",
"rehype-sanitize": "^2.0.2",
"rehype-sanitize": "^3.0.0",
"remark-abbr": "file:packages/remark-abbr",
"remark-align": "file:packages/remark-align",
"remark-captions": "file:packages/remark-captions",
Expand All @@ -93,6 +93,8 @@
"typographic-permille": "file:packages/typographic-permille",
"typographic-question-mark": "file:packages/typographic-question-mark",
"typographic-semicolon": "file:packages/typographic-semicolon",
"unist-util-inspect": "^4.1.4",
"util-inspect": "^0.1.8",
"zmarkdown": "file:packages/zmarkdown"
}
}
2 changes: 1 addition & 1 deletion packages/mdast-util-split-by-heading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
],
"license": "MIT",
"dependencies": {
"unist-util-visit": "^1.3.1"
"unist-util-visit": "^1.4.1"
}
}
15 changes: 9 additions & 6 deletions packages/rebber-plugins/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/rebber-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"license": "MIT",
"dependencies": {
"has": "^1.0.1",
"xtend": "^4.0.1"
"xtend": "^4.0.2"
},
"devDependencies": {
"rebber": "file:../rebber",
Expand Down
34 changes: 17 additions & 17 deletions packages/rebber/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/rebber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license": "MIT",
"dependencies": {
"has": "^1.0.1",
"mdast-util-definitions": "^1.2.3",
"xtend": "^4.0.1"
"mdast-util-definitions": "^1.2.4",
"xtend": "^4.0.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@ Nor is third...</p>
<li>item 1</li>
<li>item 2</li>
</ul>
<a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"Foo bar 1\\">↩</a>
<p><a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"Foo bar 1\\">↩</a></p>
</li>
<li id=\\"fn-2\\">
<blockquote>
<p>This footnote is a blockquote.</p>
</blockquote>
<a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"Foo bar 2\\">↩</a>
<p><a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"Foo bar 2\\">↩</a></p>
</li>
<li id=\\"fn-3\\">
<p>A simple oneliner.</p>
<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"Foo bar 3\\">↩</a>
<p>A simple oneliner.<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"Foo bar 3\\">↩</a></p>
</li>
<li id=\\"fn-4\\">
<p>A footnote with multiple paragraphs.</p>
<p>Paragraph two.</p>
<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"Foo bar 4\\">↩</a>
<p>Paragraph two.<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"Foo bar 4\\">↩</a></p>
</li>
<li id=\\"fn-5\\">
<p>First line of first paragraph.</p>
<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"Foo bar 5\\">↩</a>
<p>First line of first paragraph.<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"Foo bar 5\\">↩</a></p>
</li>
</ol>
</div>"
Expand All @@ -53,26 +50,23 @@ Nor is third...</p>
<li>item 1</li>
<li>item 2</li>
</ul>
<a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"Baz 1 qux?\\">↩</a>
<p><a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"Baz 1 qux?\\">↩</a></p>
</li>
<li id=\\"fn-2\\">
<blockquote>
<p>This footnote is a blockquote.</p>
</blockquote>
<a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"Baz 2 qux?\\">↩</a>
<p><a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"Baz 2 qux?\\">↩</a></p>
</li>
<li id=\\"fn-3\\">
<p>A simple oneliner.</p>
<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"Baz 3 qux?\\">↩</a>
<p>A simple oneliner.<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"Baz 3 qux?\\">↩</a></p>
</li>
<li id=\\"fn-4\\">
<p>A footnote with multiple paragraphs.</p>
<p>Paragraph two.</p>
<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"Baz 4 qux?\\">↩</a>
<p>Paragraph two.<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"Baz 4 qux?\\">↩</a></p>
</li>
<li id=\\"fn-5\\">
<p>First line of first paragraph.</p>
<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"Baz 5 qux?\\">↩</a>
<p>First line of first paragraph.<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"Baz 5 qux?\\">↩</a></p>
</li>
</ol>
</div>"
Expand All @@ -92,26 +86,23 @@ Nor is third...</p>
<li>item 1</li>
<li>item 2</li>
</ul>
<a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"1\\">↩</a>
<p><a href=\\"#fnref-1\\" class=\\"footnote-backref\\" title=\\"1\\">↩</a></p>
</li>
<li id=\\"fn-2\\">
<blockquote>
<p>This footnote is a blockquote.</p>
</blockquote>
<a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"2\\">↩</a>
<p><a href=\\"#fnref-2\\" class=\\"footnote-backref\\" title=\\"2\\">↩</a></p>
</li>
<li id=\\"fn-3\\">
<p>A simple oneliner.</p>
<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"3\\">↩</a>
<p>A simple oneliner.<a href=\\"#fnref-3\\" class=\\"footnote-backref\\" title=\\"3\\">↩</a></p>
</li>
<li id=\\"fn-4\\">
<p>A footnote with multiple paragraphs.</p>
<p>Paragraph two.</p>
<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"4\\">↩</a>
<p>Paragraph two.<a href=\\"#fnref-4\\" class=\\"footnote-backref\\" title=\\"4\\">↩</a></p>
</li>
<li id=\\"fn-5\\">
<p>First line of first paragraph.</p>
<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"5\\">↩</a>
<p>First line of first paragraph.<a href=\\"#fnref-5\\" class=\\"footnote-backref\\" title=\\"5\\">↩</a></p>
</li>
</ol>
</div>"
Expand Down
36 changes: 33 additions & 3 deletions packages/rehype-footnotes-title/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

var visit = require('unist-util-visit');

function findLastTag(node) {
var tag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'p';
if (!node.children || !node.children.length) return;
var links = node.children.filter(function (e) {
return e.tagName === tag;
});
if (!links.length) return;
return links[links.length - 1];
}

function findLastLink(node, className) {
if (!node.children || !node.children.length) return;
var links = node.children.filter(function (e) {
return e.tagName === 'a';
});
if (!links.length) return;
var aTag = links[links.length - 1];
if (!aTag.properties || !aTag.properties.className || !aTag.properties.className.includes(className)) return;
return aTag;
}

function plugin() {
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';

Expand All @@ -10,8 +31,17 @@ function plugin() {
}

function visitor(node, index, parent) {
if (node.tagName === 'a' && node.properties.className && node.properties.className.includes('footnote-backref')) {
var identifier = parent.properties.id.slice(3);
if (node.tagName === 'li' && node.properties.id) {
if (!node.children || !node.children.length) return;
var aTag = findLastLink(node, 'footnote-backref');

if (!aTag) {
var pTag = findLastTag(node, 'p');
aTag = findLastLink(pTag, 'footnote-backref');
}

if (!aTag) return;
var identifier = node.properties.id.slice(3);
var placeholderIndex = title.indexOf('$id');
var thisTitle;

Expand All @@ -22,7 +52,7 @@ function plugin() {
}

if (!thisTitle) thisTitle = identifier;
node.properties.title = thisTitle;
aTag.properties.title = thisTitle;
}
}

Expand Down
Loading