mirror of
https://github.com/wassname/template.git
synced 2026-09-12 13:00:27 +08:00
Fix linter warnings except for /transforms
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { body } from "../helpers/layout";
|
||||
import { Template } from '../mixins/template';
|
||||
import { body } from '../helpers/layout';
|
||||
|
||||
const T = Template("d-abstract", `
|
||||
const T = Template('d-abstract', `
|
||||
<style>
|
||||
d-abstract {
|
||||
display: block;
|
||||
@@ -9,7 +9,7 @@ const T = Template("d-abstract", `
|
||||
line-height: 1.7em;
|
||||
margin-bottom: 140px;
|
||||
}
|
||||
${body("d-abstract")}
|
||||
${body('d-abstract')}
|
||||
</style>
|
||||
`, false);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { Template } from '../mixins/template';
|
||||
|
||||
const T = Template('d-acknowledgements', `
|
||||
<style>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { page } from "../helpers/layout";
|
||||
import { Template } from '../mixins/template';
|
||||
import { page } from '../helpers/layout';
|
||||
|
||||
const T = Template("d-appendix", `
|
||||
const T = Template('d-appendix', `
|
||||
<style>
|
||||
|
||||
:host {
|
||||
@@ -16,7 +16,7 @@ const T = Template("d-appendix", `
|
||||
padding-bottom: 48px;
|
||||
}
|
||||
|
||||
${page(".l-body")}
|
||||
${page('.l-body')}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class Article extends T(HTMLElement) {
|
||||
if (typeof callback === 'function') {
|
||||
document.addEventListener(functionName, callback);
|
||||
} else {
|
||||
console.error('Controller listeners need to be functions!')
|
||||
console.error('Controller listeners need to be functions!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { Mutating } from "../mixins/mutating";
|
||||
import { collectCitations } from './d-cite'
|
||||
import bibtexParse from "bibtex-parse-js";
|
||||
import { bibliography_cite } from "../helpers/citation";
|
||||
import { Template } from '../mixins/template';
|
||||
import bibtexParse from 'bibtex-parse-js';
|
||||
import { bibliography_cite } from '../helpers/citation';
|
||||
|
||||
const T = Template('d-bibliography', `
|
||||
<style>
|
||||
@@ -43,11 +41,11 @@ export function parseBibtex(bibtex) {
|
||||
// normalize tags; note entryTags is an object, not Map
|
||||
for (const tag in entry.entryTags) {
|
||||
let value = entry.entryTags[tag];
|
||||
value = value.replace(/[\t\n ]+/g, " ");
|
||||
value = value.replace(/{\\["^`\.'acu~Hvs]( )?([a-zA-Z])}/g,
|
||||
(full, x, char) => char);
|
||||
value = value.replace(/[\t\n ]+/g, ' ');
|
||||
value = value.replace(/{\\["^`.'acu~Hvs]( )?([a-zA-Z])}/g,
|
||||
(full, x, char) => char);
|
||||
value = value.replace(/{\\([a-zA-Z])}/g,
|
||||
(full, char) => char);
|
||||
(full, char) => char);
|
||||
entry.entryTags[tag] = value;
|
||||
}
|
||||
entry.entryTags.type = entry.entryType;
|
||||
@@ -60,11 +58,11 @@ export function parseBibtex(bibtex) {
|
||||
export class Bibliography extends T(HTMLElement) {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
super();
|
||||
|
||||
// set up mutation observer
|
||||
const options = {childList: true, subtree: true};
|
||||
const observer = new MutationObserver( (mutations) => {
|
||||
const options = {childList: true, characterData: true, subtree: true};
|
||||
const observer = new MutationObserver( () => {
|
||||
observer.disconnect();
|
||||
this.parseIfPossible();
|
||||
observer.observe(this, options);
|
||||
@@ -82,27 +80,10 @@ export class Bibliography extends T(HTMLElement) {
|
||||
this.notify(bibliography);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.list = this.root.querySelector('ol');
|
||||
// bibliography is initially hidden
|
||||
this.root.host.style.display = 'none';
|
||||
// this.parseIfPossible();
|
||||
// Store.subscribeTo('citations', (citations) => {
|
||||
// // ensure citations list is visible
|
||||
// this.root.host.style.display = 'initial';
|
||||
// this.list.innerHTML = '';
|
||||
// for (const key of citations) {
|
||||
// const bibliography = Store.get('bibliography');
|
||||
// const entry = bibliography.get(key);
|
||||
// // construct and append list item to show citation
|
||||
// const listItem = document.createElement('li');
|
||||
// listItem.id = key;
|
||||
// listItem.innerHTML = bibliography_cite(entry);
|
||||
// this.list.appendChild(listItem);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
notify(bibliography) {
|
||||
@@ -112,15 +93,20 @@ export class Bibliography extends T(HTMLElement) {
|
||||
}
|
||||
|
||||
set entries(newEntries) {
|
||||
this.root.host.style.display = 'initial';
|
||||
this.list.innerHTML = '';
|
||||
if (newEntries.size) {
|
||||
this.root.host.style.display = 'initial';
|
||||
this.list.innerHTML = '';
|
||||
|
||||
for (const [key, entry] of newEntries) {
|
||||
const listItem = document.createElement('li');
|
||||
listItem.id = key;
|
||||
listItem.innerHTML = bibliography_cite(entry);
|
||||
this.list.appendChild(listItem);
|
||||
for (const [key, entry] of newEntries) {
|
||||
const listItem = document.createElement('li');
|
||||
listItem.id = key;
|
||||
listItem.innerHTML = bibliography_cite(entry);
|
||||
this.list.appendChild(listItem);
|
||||
}
|
||||
} else {
|
||||
this.root.host.style.display = 'none';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renderContent() {
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { page } from "../helpers/layout";
|
||||
import { Template } from '../mixins/template';
|
||||
import { page } from '../helpers/layout';
|
||||
|
||||
const T = Template("d-byline", `
|
||||
const T = Template('d-byline', `
|
||||
<style>
|
||||
d-byline {
|
||||
box-sizing: border-box;
|
||||
@@ -14,7 +14,7 @@ const T = Template("d-byline", `
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
${page(".byline")}
|
||||
${page('.byline')}
|
||||
d-article.centered {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -117,15 +117,15 @@ export function bylineTemplate(frontMatter) {
|
||||
<div class="authors">
|
||||
${frontMatter.authors.map( author => `<div class="author">
|
||||
${author.personalURL ?
|
||||
`<a class="name" href="${author.personalURL}">${author.name}</a>`
|
||||
:
|
||||
`<div class="name">${author.name}</div>`
|
||||
}
|
||||
`<a class="name" href="${author.personalURL}">${author.name}</a>`
|
||||
:
|
||||
`<div class="name">${author.name}</div>`
|
||||
}
|
||||
${author.affiliationURL ?
|
||||
`<a class="affiliation" href="${author.affiliationURL}">${author.affiliation}</a>`
|
||||
:
|
||||
`<div class="affiliation">${author.affiliation}</div>`
|
||||
}
|
||||
`<a class="affiliation" href="${author.affiliationURL}">${author.affiliation}</a>`
|
||||
:
|
||||
`<div class="affiliation">${author.affiliation}</div>`
|
||||
}
|
||||
</div>`).join('\n')}
|
||||
</div>
|
||||
<div class="date">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { hover_cite } from "../helpers/citation";
|
||||
import { HoverBox } from "../helpers/hover-box";
|
||||
import { Template } from '../mixins/template';
|
||||
import { hover_cite } from '../helpers/citation';
|
||||
import { HoverBox } from '../helpers/hover-box';
|
||||
|
||||
const T = Template('d-cite', `
|
||||
<style>
|
||||
@@ -54,7 +54,7 @@ export class Cite extends T(HTMLElement) {
|
||||
/* Lifecycle */
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
super();
|
||||
// Cite.currentId += 1;
|
||||
// this.citeId = Cite.currentId;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export class Cite extends T(HTMLElement) {
|
||||
const numberStrings = numbers.map( index => {
|
||||
return index == -1 ? '?' : index + 1 + '';
|
||||
});
|
||||
const textContent = "[" + numberStrings.join(", ") + "]";
|
||||
const textContent = '[' + numberStrings.join(', ') + ']';
|
||||
const innerSpan = this.root.querySelector('.citation-number');
|
||||
innerSpan.textContent = textContent;
|
||||
}
|
||||
|
||||
+14
-14
@@ -1,12 +1,12 @@
|
||||
import Prism from "prismjs";
|
||||
import "prismjs/components/prism-python";
|
||||
import "prismjs/components/prism-clike";
|
||||
import css from "prismjs/themes/prism.css";
|
||||
import Prism from 'prismjs';
|
||||
import 'prismjs/components/prism-python';
|
||||
import 'prismjs/components/prism-clike';
|
||||
import css from 'prismjs/themes/prism.css';
|
||||
|
||||
import { Template } from "../mixins/template.js"
|
||||
import { Mutating } from "../mixins/mutating.js"
|
||||
import { Template } from '../mixins/template.js';
|
||||
import { Mutating } from '../mixins/mutating.js';
|
||||
|
||||
const T = Template("d-code", `
|
||||
const T = Template('d-code', `
|
||||
<style>
|
||||
|
||||
code {
|
||||
@@ -39,7 +39,7 @@ export class Code extends Mutating(T(HTMLElement)) {
|
||||
// check if language can be highlighted
|
||||
this.languageName = this.getAttribute('language');
|
||||
if (!this.languageName) {
|
||||
console.warn(`You need to provide a language attribute to your <d-code> block to let us know how to highlight your code; e.g.:\n <d-code language="python">zeros = np.zeros(shape)</d-code>.`);
|
||||
console.warn('You need to provide a language attribute to your <d-code> block to let us know how to highlight your code; e.g.:\n <d-code language="python">zeros = np.zeros(shape)</d-code>.');
|
||||
return;
|
||||
}
|
||||
const language = Prism.languages[this.languageName];
|
||||
@@ -49,18 +49,18 @@ export class Code extends Mutating(T(HTMLElement)) {
|
||||
}
|
||||
|
||||
let content = this.textContent;
|
||||
const codeTag = this.shadowRoot.querySelector("#code-container");
|
||||
const codeTag = this.shadowRoot.querySelector('#code-container');
|
||||
|
||||
if (this.hasAttribute("block")) {
|
||||
if (this.hasAttribute('block')) {
|
||||
// normalize the tab indents
|
||||
content = content.replace(/\n/, "");
|
||||
content = content.replace(/\n/, '');
|
||||
const tabs = content.match(/\s*/);
|
||||
content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
|
||||
content = content.replace(new RegExp('\n' + tabs, 'g'), '\n');
|
||||
content = content.trim();
|
||||
// wrap code block in pre tag if needed
|
||||
if (codeTag.parentNode instanceof ShadowRoot) {
|
||||
const preTag = document.createElement("pre");
|
||||
this.shadowRoot.removeChild(codeTag)
|
||||
const preTag = document.createElement('pre');
|
||||
this.shadowRoot.removeChild(codeTag);
|
||||
preTag.appendChild(codeTag);
|
||||
this.shadowRoot.appendChild(preTag);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Template } from "../mixins/template.js";
|
||||
import { HoverBox } from "../helpers/hover-box";
|
||||
import { Template } from '../mixins/template.js';
|
||||
import { HoverBox } from '../helpers/hover-box';
|
||||
// import { Store } from './store';
|
||||
|
||||
const T = Template("d-footnote", `
|
||||
const T = Template('d-footnote', `
|
||||
<style>
|
||||
|
||||
d-math[block] {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import ymlParse from "js-yaml";
|
||||
import ymlParse from 'js-yaml';
|
||||
|
||||
export class FrontMatter extends HTMLElement {
|
||||
|
||||
static get is() { return "d-front-matter"; }
|
||||
static get is() { return 'd-front-matter'; }
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const options = {childList: true, characterData: true, subtree: true};
|
||||
const observer = new MutationObserver( (mutation) => {
|
||||
const observer = new MutationObserver( () => {
|
||||
const data = this.parse();
|
||||
this.notify(data);
|
||||
});
|
||||
@@ -16,13 +16,13 @@ export class FrontMatter extends HTMLElement {
|
||||
}
|
||||
|
||||
parse(){
|
||||
const scriptTag = this.querySelector("script");
|
||||
const scriptTag = this.querySelector('script');
|
||||
if (scriptTag) {
|
||||
const yml = scriptTag.textContent;
|
||||
const data = ymlParse.safeLoad(yml);
|
||||
return data;
|
||||
} else {
|
||||
console.error('You added a frontmatter tag but did not provide a script tag with front matter data in it. Please take a look at our templates.')
|
||||
console.error('You added a frontmatter tag but did not provide a script tag with front matter data in it. Please take a look at our templates.');
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import katex from "katex";
|
||||
import { Mutating } from "../mixins/mutating.js"
|
||||
import { Template } from "../mixins/template.js"
|
||||
import katexCSS from "../../node_modules/katex/dist/katex.min.css"
|
||||
import katex from 'katex';
|
||||
import { Mutating } from '../mixins/mutating.js';
|
||||
import { Template } from '../mixins/template.js';
|
||||
import katexCSS from '../../node_modules/katex/dist/katex.min.css';
|
||||
|
||||
const T = Template("d-math", `
|
||||
const T = Template('d-math', `
|
||||
<style>
|
||||
|
||||
d-math[block] {
|
||||
@@ -20,8 +20,8 @@ ${katexCSS}
|
||||
export class DMath extends Mutating(T(HTMLElement)) {
|
||||
|
||||
renderContent() {
|
||||
const options = { displayMode: this.hasAttribute("block") };
|
||||
const container = this.root.querySelector("#katex-container");
|
||||
const options = { displayMode: this.hasAttribute('block') };
|
||||
const container = this.root.querySelector('#katex-container');
|
||||
katex.render(this.textContent, container, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { body } from "../helpers/layout";
|
||||
import { Template } from '../mixins/template';
|
||||
|
||||
const T = Template("d-references", `
|
||||
const T = Template('d-references', `
|
||||
<style>
|
||||
d-references {
|
||||
display: block;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Template } from "../mixins/template";
|
||||
import { page } from "../helpers/layout";
|
||||
import { Template } from '../mixins/template';
|
||||
import { page } from '../helpers/layout';
|
||||
|
||||
const T = Template("d-title", `
|
||||
const T = Template('d-title', `
|
||||
<style>
|
||||
|
||||
:host {
|
||||
@@ -24,7 +24,7 @@ d-byline {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
${page("::slotted(h1), ::slotted(h2)")}
|
||||
${page('::slotted(h1), ::slotted(h2)')}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Template} from "../mixins/template";
|
||||
import {Template} from '../mixins/template';
|
||||
|
||||
const T = Template("d-toc", `
|
||||
const T = Template('d-toc', `
|
||||
<style>
|
||||
d-toc {
|
||||
display: block;
|
||||
|
||||
Reference in New Issue
Block a user